| 314 | } |
| 315 | |
| 316 | void 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 | |
| 352 | bool Tr2Material::UpdateResourceSetDesc( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput& input, Tr2ResourceSetDescriptionAL& desc ) const |
| 353 | { |