MCPcopy Create free account
hub / github.com/carbonengine/trinity / ApplyMaterialDataForPass

Method ApplyMaterialDataForPass

trinity/Shader/Tr2Material.cpp:209–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209void Tr2Material::ApplyMaterialDataForPass( uint32_t techniqueIndex, unsigned int passIndex, Tr2RenderContext& renderContext ) const
210{
211 if( !m_shader )
212 {
213 return;
214 }
215 unsigned mask = m_shader->GetShaderTypeMask( techniqueIndex );
216 auto& pp = *m_parametersForPasses[techniqueIndex].passes[passIndex];
217 bool descChanged = pp.m_resourceSetDirty;
218 for( unsigned i = 0; i != Tr2RenderContextEnum::SHADER_TYPE_COUNT && mask; ++i )
219 {
220 if( mask & ( 1 << i ) )
221 {
222 descChanged |= ApplyShaderInputs( techniqueIndex, passIndex, Tr2RenderContextEnum::ShaderType( i ), renderContext );
223 mask &= ~( 1 << i );
224 }
225 }
226
227 if( descChanged || !pp.m_resourceSet.IsValid() )
228 {
229 USE_MAIN_THREAD_RENDER_CONTEXT();
230
231 CCP_STATS_INC( effectResourceSetCreated );
232
233 auto sp = renderContext.m_esm.GetShaderProgram( m_shader->GetEffect().techniques[techniqueIndex].passes[passIndex].shaderProgram );
234 if( !sp )
235 {
236 return;
237 }
238 pp.m_resourceSet.Create( pp.m_resourceSetDesc, *sp, renderContext );
239 pp.m_resourceSetHash = pp.m_resourceSetDesc.ComputeHash();
240 pp.m_resourceSetDirty = false;
241
242 m_resourceSetHash = 0;
243
244 for( auto& technique : m_parametersForPasses )
245 {
246 for( auto& params : technique.passes )
247 {
248 m_resourceSetHash = CcpHashFNV1( &params->m_resourceSetHash, sizeof( params->m_resourceSetHash ), m_resourceSetHash );
249 }
250 }
251 }
252
253 renderContext.SetResourceSet( pp.m_resourceSet );
254}
255
256void Tr2Material::ApplyMaterialDataForPassWithOverride( uint32_t techniqueIndex, unsigned int passIndex, uint32_t overrideProgram, Tr2RenderContext& renderContext ) const
257{

Callers 11

DrawHelperMethod · 0.80
PickMethod · 0.80
EndRenderMethod · 0.80
RenderMethod · 0.80
RenderBatchesInOrderMethod · 0.80
RenderBatchGroupMethod · 0.80
RenderGdprBatchesMethod · 0.80
RunComputeShaderMethod · 0.80
TransformMeshesMethod · 0.80

Calls 8

ShaderTypeEnum · 0.85
GetShaderTypeMaskMethod · 0.80
GetShaderProgramMethod · 0.80
ComputeHashMethod · 0.80
IsValidMethod · 0.45
GetEffectMethod · 0.45
CreateMethod · 0.45
SetResourceSetMethod · 0.45

Tested by

no test coverage detected