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

Method getShader

Engine/source/materials/shaderData.cpp:187–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187GFXShader* ShaderData::getShader( const Vector<GFXShaderMacro> &macros )
188{
189 PROFILE_SCOPE( ShaderData_GetShader );
190
191 // Combine the dynamic macros with our script defined macros.
192 Vector<GFXShaderMacro> finalMacros;
193 finalMacros.merge( _getMacros() );
194 finalMacros.merge( macros );
195
196 // Convert the final macro list to a string.
197 String cacheKey;
198 GFXShaderMacro::stringize( macros, &cacheKey );
199
200 // Lookup the shader for this instance.
201 ShaderCache::Iterator iter = mShaders.find( cacheKey );
202 if ( iter != mShaders.end() )
203 return iter->value;
204
205 // Create the shader instance... if it fails then
206 // bail out and return nothing to the caller.
207 GFXShader *shader = _createShader( finalMacros );
208 if ( !shader )
209 return NULL;
210
211 _checkDefinition(shader);
212
213 // Store the shader in the cache and return it.
214 mShaders.insertUnique( cacheKey, shader );
215 return shader;
216}
217
218GFXShader* ShaderData::_createShader( const Vector<GFXShaderMacro> &macros )
219{

Callers 3

getAlignmentValueMethod · 0.45
_addPassMethod · 0.45
initMethod · 0.45

Calls 4

insertUniqueMethod · 0.80
mergeMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected