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

Method UpdateLightBuffer

trinity/Tr2LightManager.cpp:380–399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378}
379
380ALResult Tr2LightManager::UpdateLightBuffer( Tr2RenderContext& renderContext )
381{
382 if( m_lightBuffer->GetGpuBuffer( 0 )->GetDesc().count < uint32_t( m_lightData.size() ) )
383 {
384 CR_RETURN_HR( m_lightBuffer->Create(
385 std::max( m_lightBuffer->GetGpuBuffer( 0 )->GetDesc().count + 1024, uint32_t( m_lightData.size() ) ),
386 sizeof( PerLightData ),
387 Tr2GpuBuffer::CPU_WRITABLE ) );
388 m_lightBuffer->SetName( "Light buffer" );
389 }
390
391 auto lightCount = std::min( m_lightBuffer->GetGpuBuffer( 0 )->GetDesc().count, uint32_t( m_lightData.size() ) );
392
393 Vector4* data;
394 CR_RETURN_HR( m_lightBuffer->GetGpuBuffer( 0 )->MapForWriting( data, renderContext ) );
395 memcpy( data, m_lightData.data(), lightCount * sizeof( PerLightData ) );
396 CCP_STATS_ADD( lightsGathered, m_lightData.size() );
397 m_lightBuffer->GetGpuBuffer( 0 )->UnmapForWriting( renderContext );
398 return S_OK;
399}
400
401ALResult Tr2LightManager::DoUpdateLists( const Tr2TextureAL& depthMap, Tr2RenderContext& renderContext )
402{

Callers

nothing calls this directly

Calls 6

sizeMethod · 0.80
GetGpuBufferMethod · 0.45
CreateMethod · 0.45
SetNameMethod · 0.45
MapForWritingMethod · 0.45
UnmapForWritingMethod · 0.45

Tested by

no test coverage detected