MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / initHandles

Method initHandles

Engine/source/gfx/gl/gfxGLShader.cpp:649–792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

647}
648
649void GFXGLShader::initHandles()
650{
651 // Mark all existing handles as invalid.
652 // Those that are found when parsing the descriptions will then be marked valid again.
653 for ( HandleMap::Iterator iter = mHandles.begin(); iter != mHandles.end(); ++iter )
654 (iter->value)->setValid( false );
655 mValidHandles.clear();
656
657 // Loop through all ConstantDescriptions,
658 // if they aren't in the HandleMap add them, if they are reinitialize them.
659 for ( U32 i = 0; i < mConstants.size(); i++ )
660 {
661 GFXShaderConstDesc &desc = mConstants[i];
662
663 // Index element 1 of the name to skip the '$' we inserted earier.
664 GLint loc = glGetUniformLocation(mProgram, &desc.name.c_str()[1]);
665
666 AssertFatal(loc != -1, avar("uniform %s in shader file Vert: (%s) Frag: (%s)", &desc.name.c_str()[1], mVertexFile.getFullPath().c_str(), mPixelFile.getFullPath().c_str()));
667
668 HandleMap::Iterator handle = mHandles.find(desc.name);
669 S32 sampler = -1;
670 if(desc.constType == GFXSCT_Sampler ||
671 desc.constType == GFXSCT_SamplerCube ||
672 desc.constType == GFXSCT_SamplerCubeArray ||
673 desc.constType == GFXSCT_SamplerTextureArray)
674 {
675 S32 idx = mSamplerNamesOrdered.find_next(desc.name);
676 AssertFatal(idx != -1, "");
677 sampler = idx; //assignedSamplerNum++;
678 }
679 if ( handle != mHandles.end() )
680 {
681 handle->value->reinit( desc, loc, sampler );
682 }
683 else
684 {
685 mHandles[desc.name] = new GFXGLShaderConstHandle( this, desc, loc, sampler );
686 }
687 }
688
689 // Loop through handles once more to set their offset and calculate our
690 // constBuffer size.
691
692 if ( mConstBuffer )
693 delete[] mConstBuffer;
694 mConstBufferSize = 0;
695
696 for ( HandleMap::Iterator iter = mHandles.begin(); iter != mHandles.end(); ++iter )
697 {
698 GFXGLShaderConstHandle* handle = iter->value;
699 if ( handle->isValid() )
700 {
701 mValidHandles.push_back(handle);
702 handle->mOffset = mConstBufferSize;
703 mConstBufferSize += handle->getSize();
704 }
705 }
706

Callers

nothing calls this directly

Calls 15

avarFunction · 0.85
find_nextMethod · 0.80
reinitMethod · 0.80
dMemsetFunction · 0.50
dMemcpyFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
setValidMethod · 0.45
clearMethod · 0.45
sizeMethod · 0.45
c_strMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected