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

Method RenderUpscaling

trinity/PostProcess/Tr2PostProcessRenderer.cpp:1287–1390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1285}
1286
1287Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::RenderUpscaling(
1288 const Tr2TextureAL& source,
1289 const Tr2TextureAL& depth,
1290 const Tr2TextureAL& velocity,
1291 const Tr2TextureAL& opaqueColor,
1292 const Matrix& reprojection,
1293 Tr2GpuResourcePool& gpuResourcePool,
1294 Tr2RenderContext& renderContext,
1295 Tr2UpscalingContextAL* upscalingContext,
1296 Tr2PPDynamicExposureEffect* dynamicExposure )
1297{
1298 GPU_REGION( renderContext, "Upscaling" );
1299
1300 renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_FULLSCREEN );
1301 uint32_t w, h;
1302 upscalingContext->GetDisplayDimensions( w, h );
1303
1304 Tr2UpscalingAL::DispatchParameters dispatchParameters = {};
1305 auto dispatchRequirements = upscalingContext->GetDispatchRequirements();
1306 auto dest = gpuResourcePool.GetTempTexture( "Upscaled Output", w, h, GetUavCompatibleFormat( source.GetFormat() ), RENDER_TARGET | Tr2GpuUsage::UNORDERED_ACCESS );
1307 dispatchParameters.output = &dest.Get();
1308
1309 bool wantsExposure = dispatchRequirements & Tr2UpscalingAL::DispatchRequirements::OPTIONAL_EXPOSURE;
1310 bool canHaveExposure = dynamicExposure != nullptr;
1311 float middleValue = dynamicExposure != nullptr ? dynamicExposure->m_middleValue : 0.0f;
1312 SetupExposureConversion( wantsExposure && canHaveExposure, middleValue );
1313
1314 Tr2GpuResourcePool::Texture exposureTexture;
1315 if( wantsExposure && canHaveExposure )
1316 {
1317 GPU_REGION( renderContext, "ExposureToTexture" );
1318 TEMP_PARAM( m_dynamicExposureToTextureShader, "ExposureBuffer", GetExposureBuffer( gpuResourcePool ) );
1319 exposureTexture = gpuResourcePool.GetTempTexture( "Exposure", 1, 1, Tr2RenderContextEnum::PIXEL_FORMAT_R32_FLOAT, Tr2GpuUsage::SHADER_RESOURCE | Tr2GpuUsage::UNORDERED_ACCESS );
1320 TEMP_PARAM( m_dynamicExposureToTextureShader, "ExposureTexture", exposureTexture );
1321 Tr2Renderer::RunComputeShader( m_dynamicExposureToTextureShader, 1, 1, 1, renderContext );
1322 m_dynamicExposureToTextureShader->SetParameter( MEMOIZED_STRING( "ExposureTexture" ), Tr2TextureAL{} );
1323 dispatchParameters.exposure = &exposureTexture.Get();
1324 }
1325
1326 Tr2GpuResourcePool::Texture reactiveMask;
1327 if( dispatchRequirements & Tr2UpscalingAL::DispatchRequirements::REACTIVE )
1328 {
1329 GPU_REGION( renderContext, "ReactiveMask" );
1330 reactiveMask = gpuResourcePool.GetTempTexture( "ReactiveMask", source.GetWidth(), source.GetHeight(), Tr2RenderContextEnum::PIXEL_FORMAT_R8_UNORM, RENDER_TARGET );
1331 TEMP_PARAM( m_reactiveMaskEffect, "OpaqueOnly", opaqueColor );
1332 TEMP_PARAM( m_reactiveMaskEffect, "OpaqueAndTransparency", source );
1333 DrawInto( reactiveMask, Tr2LoadAction::DONT_CARE, m_reactiveMaskEffect, renderContext );
1334 dispatchParameters.reactive = &reactiveMask.Get();
1335 }
1336
1337 Tr2GpuResourcePool::Texture transparencyMask;
1338 if( dispatchRequirements & Tr2UpscalingAL::DispatchRequirements::TRANSPARENCY )
1339 {
1340 GPU_REGION( renderContext, "Transparency" );
1341 transparencyMask = gpuResourcePool.GetTempTexture( "TransparencyMask", source.GetWidth(), source.GetHeight(), Tr2RenderContextEnum::PIXEL_FORMAT_R8_UNORM, RENDER_TARGET );
1342 TEMP_PARAM( m_transparencyMaskEffect, "OpaqueOnly", opaqueColor );
1343 TEMP_PARAM( m_transparencyMaskEffect, "OpaqueAndTransparency", source );
1344 DrawInto( transparencyMask, Tr2LoadAction::DONT_CARE, m_transparencyMaskEffect, renderContext );

Callers

nothing calls this directly

Calls 15

GetUavCompatibleFormatFunction · 0.85
DrawIntoFunction · 0.85
GetViewTransformFunction · 0.85
GetProjectionTransformFunction · 0.85
GetAspectRatioFunction · 0.85
GetBackClipFunction · 0.85
GetFrontClipFunction · 0.85
GetFieldOfViewFunction · 0.85
GetCurrentFrameCounterFunction · 0.85
GetViewPositionFunction · 0.85
LogResultFunction · 0.85
ApplyStandardStatesMethod · 0.80

Tested by

no test coverage detected