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

Method DoUpdateLists

trinity/Tr2LightManager.cpp:401–440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

399}
400
401ALResult Tr2LightManager::DoUpdateLists( const Tr2TextureAL& depthMap, Tr2RenderContext& renderContext )
402{
403 if( !m_lightBuffer->IsValid() || !m_indexBuffer->IsValid() || !m_indexBufferCounter->IsValid() )
404 {
405 return E_INVALIDCALL;
406 }
407
408 CR_RETURN_HR( UpdateLightBuffer( renderContext ) );
409
410 PerFrameData perFrameData;
411 perFrameData.projInverse = Transpose( Tr2Renderer::GetInverseProjectionTransform() );
412 perFrameData.viewInverse = Transpose( Tr2Renderer::GetInverseViewTransform() );
413 perFrameData.cameraPos = Tr2Renderer::GetViewPosition();
414 perFrameData.width = uint32_t( renderContext.m_esm.GetRenderTargetWidth() );
415 perFrameData.height = uint32_t( renderContext.m_esm.GetRenderTargetHeight() );
416 perFrameData.tilesX = ( perFrameData.width + ( TILE_WIDTH - 1 ) ) / TILE_WIDTH;
417 perFrameData.tilesY = ( perFrameData.height + ( TILE_HEIGHT - 1 ) ) / TILE_HEIGHT;
418 perFrameData.lightCount = std::min( m_lightBuffer->GetGpuBuffer( 0 )->GetDesc().count, uint32_t( m_lightData.size() ) );
419 perFrameData.indexBufferSize = INDEX_BUFFER_SIZE;
420
421
422 m_effect->SetParameter( BlueSharedString( "DepthMap" ), depthMap );
423 ON_BLOCK_EXIT( [&] { m_effect->SetParameter( BlueSharedString( "DepthMap" ), Tr2TextureAL() ); } );
424
425 if( !FillAndSetConstants( m_perFrameData, perFrameData, Tr2RenderContextEnum::COMPUTE_SHADER, Tr2Renderer::GetPerFramePSStartRegister(), renderContext ) )
426 {
427 return E_FAIL;
428 }
429
430 if( !Tr2Renderer::RunComputeShader( m_effect, BlueSharedString( "Clear" ), 1, 1, 1, renderContext ) )
431 {
432 return E_FAIL;
433 }
434
435 if( !Tr2Renderer::RunComputeShader( m_effect, perFrameData.tilesX, perFrameData.tilesY, 1, renderContext ) )
436 {
437 return E_FAIL;
438 }
439 return S_OK;
440}
441
442void Tr2LightManager::CreateShadowMapAtlas( uint32_t numShadowCastingLights, const std::vector<LightScreenSizeTuple>& lightTuples )
443{

Callers

nothing calls this directly

Calls 10

TransposeFunction · 0.85
GetViewPositionFunction · 0.85
GetRenderTargetWidthMethod · 0.80
GetRenderTargetHeightMethod · 0.80
sizeMethod · 0.80
Tr2TextureALClass · 0.70
FillAndSetConstantsFunction · 0.70
IsValidMethod · 0.45
GetGpuBufferMethod · 0.45
SetParameterMethod · 0.45

Tested by

no test coverage detected