From dbf16cb106195bde6f50b3efdbea5145af5b5224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 16 Aug 2022 12:50:48 +0200 Subject: [PATCH] Minor cleanup in reinterpret --- GPU/Common/ReinterpretFramebuffer.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/GPU/Common/ReinterpretFramebuffer.cpp b/GPU/Common/ReinterpretFramebuffer.cpp index bf77181fa740..b453a4d3d67b 100644 --- a/GPU/Common/ReinterpretFramebuffer.cpp +++ b/GPU/Common/ReinterpretFramebuffer.cpp @@ -150,15 +150,13 @@ void FramebufferManagerCommon::ReinterpretFramebuffer(VirtualFramebuffer *vfb, G return; } - char *vsCode = nullptr; - char *fsCode = nullptr; - if (!reinterpretVS_) { - vsCode = new char[4000]; + char *vsCode = new char[4000]; const ShaderLanguageDesc &shaderLanguageDesc = draw_->GetShaderLanguageDesc(); GenerateReinterpretVertexShader(vsCode, shaderLanguageDesc); reinterpretVS_ = draw_->CreateShaderModule(ShaderStage::Vertex, shaderLanguageDesc.shaderLanguage, (const uint8_t *)vsCode, strlen(vsCode), "reinterpret_vs"); _assert_(reinterpretVS_); + delete[] vsCode; } if (!reinterpretSampler_) { @@ -176,11 +174,12 @@ void FramebufferManagerCommon::ReinterpretFramebuffer(VirtualFramebuffer *vfb, G Draw::Pipeline *pipeline = reinterpretFromTo_[(int)oldFormat][(int)newFormat]; if (!pipeline) { - fsCode = new char[4000]; + char *fsCode = new char[4000]; const ShaderLanguageDesc &shaderLanguageDesc = draw_->GetShaderLanguageDesc(); GenerateReinterpretFragmentShader(fsCode, oldFormat, newFormat, shaderLanguageDesc); Draw::ShaderModule *reinterpretFS = draw_->CreateShaderModule(ShaderStage::Fragment, shaderLanguageDesc.shaderLanguage, (const uint8_t *)fsCode, strlen(fsCode), "reinterpret_fs"); _assert_(reinterpretFS); + delete[] fsCode; std::vector shaders; shaders.push_back(reinterpretVS_); @@ -239,6 +238,4 @@ void FramebufferManagerCommon::ReinterpretFramebuffer(VirtualFramebuffer *vfb, G // In case ReinterpretFramebuffer was called from the texture manager. draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "After reinterpret"); } - delete[] vsCode; - delete[] fsCode; }