From 23f78193295a78d398107b0349f436ada28abe3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 15 Nov 2017 20:44:25 +0100 Subject: [PATCH] Unify RebindFramebuffer, mostly. --- GPU/Common/FramebufferCommon.cpp | 10 ++++++++++ GPU/Common/FramebufferCommon.h | 2 +- GPU/D3D11/FramebufferManagerD3D11.cpp | 2 -- GPU/Directx9/FramebufferDX9.cpp | 9 --------- GPU/Directx9/FramebufferDX9.h | 2 -- GPU/GLES/FramebufferManagerGLES.cpp | 7 +------ GPU/GLES/FramebufferManagerGLES.h | 1 - GPU/Vulkan/FramebufferVulkan.cpp | 10 ---------- GPU/Vulkan/FramebufferVulkan.h | 1 - 9 files changed, 12 insertions(+), 32 deletions(-) diff --git a/GPU/Common/FramebufferCommon.cpp b/GPU/Common/FramebufferCommon.cpp index 73f0550b95..66d01f0e84 100644 --- a/GPU/Common/FramebufferCommon.cpp +++ b/GPU/Common/FramebufferCommon.cpp @@ -2103,6 +2103,16 @@ void FramebufferManagerCommon::DownloadFramebufferForClut(u32 fb_address, u32 lo } } +void FramebufferManagerCommon::RebindFramebuffer() { + if (currentRenderVfb_ && currentRenderVfb_->fbo) { + draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP }); + } else { + // Should this even happen? + draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::KEEP, Draw::RPAction::KEEP }); + } + gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE); +} + std::vector FramebufferManagerCommon::GetFramebufferList() { std::vector list; diff --git a/GPU/Common/FramebufferCommon.h b/GPU/Common/FramebufferCommon.h index 0b1a4125aa..926f3211c3 100644 --- a/GPU/Common/FramebufferCommon.h +++ b/GPU/Common/FramebufferCommon.h @@ -214,7 +214,7 @@ public: return vfb; } } - virtual void RebindFramebuffer() = 0; + virtual void RebindFramebuffer(); std::vector GetFramebufferList(); void CopyDisplayToOutput(); diff --git a/GPU/D3D11/FramebufferManagerD3D11.cpp b/GPU/D3D11/FramebufferManagerD3D11.cpp index 095d659856..5a532d9d9b 100644 --- a/GPU/D3D11/FramebufferManagerD3D11.cpp +++ b/GPU/D3D11/FramebufferManagerD3D11.cpp @@ -459,8 +459,6 @@ void FramebufferManagerD3D11::BindPostShader(const PostShaderUniforms &uniforms) context_->Unmap(postConstants_, 0); context_->VSSetConstantBuffers(0, 1, &postConstants_); // Probably not necessary context_->PSSetConstantBuffers(0, 1, &postConstants_); - - gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE); } void FramebufferManagerD3D11::RebindFramebuffer() { diff --git a/GPU/Directx9/FramebufferDX9.cpp b/GPU/Directx9/FramebufferDX9.cpp index af12aa999a..22466f1620 100644 --- a/GPU/Directx9/FramebufferDX9.cpp +++ b/GPU/Directx9/FramebufferDX9.cpp @@ -304,15 +304,6 @@ static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = { } } - void FramebufferManagerDX9::RebindFramebuffer() { - if (currentRenderVfb_ && currentRenderVfb_->fbo) { - draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP }); - } else { - // Should this even happen? - draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::KEEP, Draw::RPAction::KEEP }); - } - } - void FramebufferManagerDX9::Bind2DShader() { device_->SetVertexDeclaration(pFramebufferVertexDecl); device_->SetPixelShader(pFramebufferPixelShader); diff --git a/GPU/Directx9/FramebufferDX9.h b/GPU/Directx9/FramebufferDX9.h index 544438ed39..dd1b3bd2ca 100644 --- a/GPU/Directx9/FramebufferDX9.h +++ b/GPU/Directx9/FramebufferDX9.h @@ -66,8 +66,6 @@ public: bool GetStencilbuffer(u32 fb_address, int fb_stride, GPUDebugBuffer &buffer) override; bool GetOutputFramebuffer(GPUDebugBuffer &buffer) override; - virtual void RebindFramebuffer() override; - LPDIRECT3DSURFACE9 GetOffscreenSurface(LPDIRECT3DSURFACE9 similarSurface, VirtualFramebuffer *vfb); LPDIRECT3DSURFACE9 GetOffscreenSurface(D3DFORMAT fmt, u32 w, u32 h); diff --git a/GPU/GLES/FramebufferManagerGLES.cpp b/GPU/GLES/FramebufferManagerGLES.cpp index 1ec5a83c95..e62cc79463 100644 --- a/GPU/GLES/FramebufferManagerGLES.cpp +++ b/GPU/GLES/FramebufferManagerGLES.cpp @@ -438,12 +438,7 @@ void FramebufferManagerGLES::DrawActiveTexture(float x, float y, float w, float } void FramebufferManagerGLES::RebindFramebuffer() { - if (currentRenderVfb_ && currentRenderVfb_->fbo) { - draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP }); - } else { - // Should this even happen? - draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::KEEP, Draw::RPAction::KEEP }); - } + FramebufferManagerCommon::RebindFramebuffer(); if (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) glstate.viewport.restore(); } diff --git a/GPU/GLES/FramebufferManagerGLES.h b/GPU/GLES/FramebufferManagerGLES.h index f867f833d6..03b279c54c 100644 --- a/GPU/GLES/FramebufferManagerGLES.h +++ b/GPU/GLES/FramebufferManagerGLES.h @@ -81,7 +81,6 @@ public: bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) override; bool GetOutputFramebuffer(GPUDebugBuffer &buffer) override; - virtual void RebindFramebuffer() override; protected: diff --git a/GPU/Vulkan/FramebufferVulkan.cpp b/GPU/Vulkan/FramebufferVulkan.cpp index 402ae9ba2d..1c1a5d2507 100644 --- a/GPU/Vulkan/FramebufferVulkan.cpp +++ b/GPU/Vulkan/FramebufferVulkan.cpp @@ -367,16 +367,6 @@ void FramebufferManagerVulkan::BindPostShader(const PostShaderUniforms &uniforms gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE); } -void FramebufferManagerVulkan::RebindFramebuffer() { - if (currentRenderVfb_ && currentRenderVfb_->fbo) { - draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP }); - } else { - // Should this even happen? - draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::KEEP, Draw::RPAction::KEEP }); - } - gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE); -} - int FramebufferManagerVulkan::GetLineWidth() { if (g_Config.iInternalResolution == 0) { return std::max(1, (int)(renderWidth_ / 480)); diff --git a/GPU/Vulkan/FramebufferVulkan.h b/GPU/Vulkan/FramebufferVulkan.h index 49538dfa99..10d739642c 100644 --- a/GPU/Vulkan/FramebufferVulkan.h +++ b/GPU/Vulkan/FramebufferVulkan.h @@ -78,7 +78,6 @@ public: bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) override; - virtual void RebindFramebuffer() override; VkImageView BindFramebufferAsColorTexture(int stage, VirtualFramebuffer *framebuffer, int flags); // If within a render pass, this will just issue a regular clear. If beginning a new render pass,