Remove old RT1_FloatRGB and RT2_FloatRGB in favor pooled render targets

This commit is contained in:
Wojciech Figat
2022-12-12 14:58:16 +01:00
parent 48b88af88a
commit ee019510ca
4 changed files with 17 additions and 29 deletions

View File

@@ -20,8 +20,6 @@ RenderBuffers::RenderBuffers(const SpawnParams& params)
CREATE_TEXTURE(GBuffer1);
CREATE_TEXTURE(GBuffer2);
CREATE_TEXTURE(GBuffer3);
CREATE_TEXTURE(RT1_FloatRGB);
CREATE_TEXTURE(RT2_FloatRGB);
#undef CREATE_TEXTURE
}
@@ -125,19 +123,7 @@ bool RenderBuffers::GetUseAlpha() const
void RenderBuffers::SetUseAlpha(bool value)
{
if (_useAlpha != value)
{
_useAlpha = value;
// Reallocate buffers
if (_width != 0)
{
auto desc = GPUTextureDescription::New2D(_width, _height, GetOutputFormat(), GPUTextureFlags::ShaderResource | GPUTextureFlags::RenderTarget);
desc.DefaultClearColor = Color::Transparent;
RT1_FloatRGB->Init(desc);
RT2_FloatRGB->Init(desc);
}
}
_useAlpha = value;
}
const RenderBuffers::CustomBuffer* RenderBuffers::FindCustomBuffer(const StringView& name) const
@@ -197,12 +183,6 @@ bool RenderBuffers::Init(int32 width, int32 height)
desc.DefaultClearColor = Color::Transparent;
result |= GBuffer3->Init(desc);
// Helper HDR buffers
desc.Format = GetOutputFormat();
desc.DefaultClearColor = Color::Transparent;
result |= RT1_FloatRGB->Init(desc);
result |= RT2_FloatRGB->Init(desc);
// Cache data
_width = width;
_height = height;

View File

@@ -54,9 +54,6 @@ public:
GPUTexture* GBuffer[4];
};
GPUTexture* RT1_FloatRGB;
GPUTexture* RT2_FloatRGB;
// Helper target for the eye adaptation
float LastEyeAdaptationTime = 0.0f;
GPUTexture* LuminanceMap = nullptr;

View File

@@ -1126,7 +1126,8 @@ void GlobalSurfaceAtlasPass::RenderDebug(RenderContext& renderContext, GPUContex
Float2 outputSizeThird = outputSize * 0.333f;
Float2 outputSizeTwoThird = outputSize * 0.666f;
GPUTexture* tempBuffer = renderContext.Buffers->RT2_FloatRGB;
auto tempBuffer = RenderTargetPool::Get(output->GetDescription());
RENDER_TARGET_POOL_SET_NAME(tempBuffer, "GlobalSurfaceAtlas.TempBuffer");
context->Clear(tempBuffer->View(), Color::Black);
context->SetRenderTarget(tempBuffer->View());

View File

@@ -388,7 +388,7 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
auto outputFormat = renderContext.Buffers->GetOutputFormat();
auto tempDesc = GPUTextureDescription::New2D(renderContext.Buffers->GetWidth(), renderContext.Buffers->GetHeight(), outputFormat);
auto lightBuffer = RenderTargetPool::Get(tempDesc);
RENDER_TARGET_POOL_SET_NAME(lightBuffer, "Lighting");
RENDER_TARGET_POOL_SET_NAME(lightBuffer, "LightBuffer");
#if USE_EDITOR
if (renderContext.View.Mode == ViewMode::QuadOverdraw)
@@ -471,7 +471,8 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
if (renderContext.View.Mode == ViewMode::LightBuffer)
{
auto colorGradingLUT = ColorGradingPass::Instance()->RenderLUT(renderContext);
GPUTexture* tempBuffer = renderContext.Buffers->RT2_FloatRGB;
auto tempBuffer = RenderTargetPool::Get(tempDesc);
RENDER_TARGET_POOL_SET_NAME(tempBuffer, "TempBuffer");
EyeAdaptationPass::Instance()->Render(renderContext, lightBuffer);
PostProcessingPass::Instance()->Render(renderContext, lightBuffer, tempBuffer, colorGradingLUT);
RenderTargetPool::Release(colorGradingLUT);
@@ -480,6 +481,7 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
context->SetRenderTarget(task->GetOutputView());
context->SetViewportAndScissors(task->GetOutputViewport());
context->Draw(tempBuffer);
RenderTargetPool::Release(tempBuffer);
return;
}
@@ -519,8 +521,8 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
}
// Run forward pass
GPUTexture* frameBuffer = renderContext.Buffers->RT1_FloatRGB;
GPUTexture* tempBuffer = renderContext.Buffers->RT2_FloatRGB;
auto frameBuffer = RenderTargetPool::Get(tempDesc);
RENDER_TARGET_POOL_SET_NAME(frameBuffer, "FrameBuffer");
ForwardPass::Instance()->Render(renderContext, lightBuffer, frameBuffer);
// Cleanup
@@ -535,10 +537,13 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
context->SetRenderTarget(task->GetOutputView());
context->SetViewportAndScissors(task->GetOutputViewport());
context->Draw(frameBuffer);
RenderTargetPool::Release(frameBuffer);
return;
}
// Material and Custom PostFx
auto tempBuffer = RenderTargetPool::Get(tempDesc);
RENDER_TARGET_POOL_SET_NAME(tempBuffer, "TempBuffer");
renderContext.List->RunMaterialPostFxPass(context, renderContext, MaterialPostFxLocation::BeforePostProcessingPass, frameBuffer, tempBuffer);
renderContext.List->RunCustomPostFxPass(context, renderContext, PostProcessEffectLocation::BeforePostProcessingPass, frameBuffer, tempBuffer);
@@ -588,6 +593,8 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
context->SetRenderTarget(task->GetOutputView());
context->SetViewportAndScissors(task->GetOutputViewport());
MotionBlurPass::Instance()->RenderDebug(renderContext, frameBuffer->View());
RenderTargetPool::Release(tempBuffer);
RenderTargetPool::Release(frameBuffer);
return;
}
@@ -623,4 +630,7 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
MultiScaler::Instance()->Upscale(context, task->GetOutputViewport(), frameBuffer, task->GetOutputView());
}
}
RenderTargetPool::Release(tempBuffer);
RenderTargetPool::Release(frameBuffer);
}