diff --git a/Source/Engine/Graphics/RenderBuffers.cpp b/Source/Engine/Graphics/RenderBuffers.cpp index 345b666cf..f46da5f60 100644 --- a/Source/Engine/Graphics/RenderBuffers.cpp +++ b/Source/Engine/Graphics/RenderBuffers.cpp @@ -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; diff --git a/Source/Engine/Graphics/RenderBuffers.h b/Source/Engine/Graphics/RenderBuffers.h index d5f56119d..ed38d078e 100644 --- a/Source/Engine/Graphics/RenderBuffers.h +++ b/Source/Engine/Graphics/RenderBuffers.h @@ -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; diff --git a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp index 68c9878e5..d4760ba4e 100644 --- a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp +++ b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp @@ -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()); diff --git a/Source/Engine/Renderer/Renderer.cpp b/Source/Engine/Renderer/Renderer.cpp index 34c32479e..1eb2c3a10 100644 --- a/Source/Engine/Renderer/Renderer.cpp +++ b/Source/Engine/Renderer/Renderer.cpp @@ -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); }