| 517 | } |
| 518 | |
| 519 | void Tr2Material::ApplyConstantBuffers( uint32_t techniqueIndex, unsigned int passIndex, Tr2IndirectDrawBufferWriter& indirectBuffer, Tr2RenderContext& renderContext ) |
| 520 | { |
| 521 | unsigned mask = m_shader->GetShaderTypeMask( techniqueIndex ); |
| 522 | auto& passDesc = m_shader->GetEffectDescription().techniques[techniqueIndex].passes[passIndex]; |
| 523 | auto& pp = *m_parametersForPasses[techniqueIndex].passes[passIndex]; |
| 524 | for( unsigned i = 0; i != Tr2RenderContextEnum::SHADER_TYPE_COUNT && mask; ++i ) |
| 525 | { |
| 526 | auto& input = pp.m_stageInput[i]; |
| 527 | if( ( mask & ( 1 << i ) ) && indirectBuffer.HasMaterialConstants( Tr2RenderContextEnum::ShaderType( i ) ) ) |
| 528 | { |
| 529 | auto& cb = input.m_constantBuffer; |
| 530 | if( cb.GetSize() ) |
| 531 | { |
| 532 | if( input.m_constantBufferDirty || !pp.m_reroutedParameters.empty() || !input.m_shaderParameters.empty() ) |
| 533 | { |
| 534 | uint8_t* const mirror = reinterpret_cast<uint8_t*>( input.m_constantMirror.get() ); |
| 535 | if( mirror ) |
| 536 | { |
| 537 | const auto endVS = input.m_shaderParameters.cend(); |
| 538 | for( auto it = input.m_shaderParameters.cbegin(); it != endVS; ++it ) |
| 539 | { |
| 540 | size_t size = it->m_registerCount; |
| 541 | uint8_t* const dst = mirror + it->m_registerIndex; |
| 542 | it->m_sourceValue->CopyValueToEffect( Tr2RenderContextEnum::ShaderType( i ), dst, size, renderContext ); |
| 543 | } |
| 544 | for( auto& it : input.m_shaderParametersWithNotification ) |
| 545 | { |
| 546 | size_t size = it.m_registerCount; |
| 547 | uint8_t* const dst = mirror + it.m_registerIndex; |
| 548 | it.m_sourceValue->CopyValueToEffect( Tr2RenderContextEnum::ShaderType( i ), dst, size, renderContext ); |
| 549 | } |
| 550 | |
| 551 | void* cbData = nullptr; |
| 552 | if( SUCCEEDED( cb.Lock( &cbData, renderContext ) ) && cbData ) |
| 553 | { |
| 554 | memcpy( cbData, mirror, cb.GetSize() ); |
| 555 | cb.Unlock( renderContext ); |
| 556 | } |
| 557 | } |
| 558 | input.m_constantBufferDirty = false; |
| 559 | } |
| 560 | |
| 561 | indirectBuffer.SetMaterialConstants( Tr2RenderContextEnum::ShaderType( i ), cb ); |
| 562 | } |
| 563 | mask &= ~( 1 << i ); |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | void Tr2Material::ApplyMaterialDataForRtState( uint32_t techniqueIndex, const Tr2RtPipelineStateAL& rtPipelineState, Tr2RenderContext& renderContext ) const |
| 569 | { |
nothing calls this directly
no test coverage detected