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

Method UpdateConstants

trinity/Shader/Tr2Material.cpp:316–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314}
315
316void Tr2Material::UpdateConstants( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput& input, bool hasReroutables, Tr2RenderContext& renderContext ) const
317{
318 auto& cb = input.m_constantBuffer;
319 if( cb.GetSize() )
320 {
321 if( input.m_constantBufferDirty || hasReroutables || !input.m_shaderParameters.empty() )
322 {
323 uint8_t* const mirror = reinterpret_cast<uint8_t*>( input.m_constantMirror.get() );
324 if( mirror )
325 {
326 const auto end = input.m_shaderParameters.cend();
327 for( auto it = input.m_shaderParameters.cbegin(); it != end; ++it )
328 {
329 size_t size = it->m_registerCount;
330 uint8_t* const dst = mirror + it->m_registerIndex;
331 it->m_sourceValue->CopyValueToEffect( shaderType, dst, size, renderContext );
332 }
333 for( auto& it : input.m_shaderParametersWithNotification )
334 {
335 size_t size = it.m_registerCount;
336 uint8_t* const dst = mirror + it.m_registerIndex;
337 it.m_sourceValue->CopyValueToEffect( shaderType, dst, size, renderContext );
338 }
339
340 void* cbData = nullptr;
341 if( SUCCEEDED( cb.Lock( &cbData, renderContext ) ) && cbData )
342 {
343 memcpy( cbData, mirror, cb.GetSize() );
344 cb.Unlock( renderContext );
345 }
346 }
347 input.m_constantBufferDirty = false;
348 }
349 }
350}
351
352bool Tr2Material::UpdateResourceSetDesc( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput& input, Tr2ResourceSetDescriptionAL& desc ) const
353{

Callers

nothing calls this directly

Calls 6

emptyMethod · 0.80
getMethod · 0.80
GetSizeMethod · 0.45
CopyValueToEffectMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected