From a0992cce757b4493da3266bd0835ec749c3216f8 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Mon, 6 Feb 2017 12:02:30 +0100 Subject: [PATCH] Unify DestroyFramebuf() --- GPU/Common/FramebufferCommon.cpp | 23 +++++++++++++ GPU/Common/FramebufferCommon.h | 5 ++- GPU/Directx9/FramebufferDX9.cpp | 45 +++++++++---------------- GPU/Directx9/FramebufferDX9.h | 7 ++-- GPU/Directx9/StencilBufferDX9.cpp | 2 +- GPU/GLES/FramebufferManagerGLES.cpp | 52 ++++++++++------------------- GPU/GLES/FramebufferManagerGLES.h | 7 ++-- GPU/GLES/StencilBufferGLES.cpp | 2 +- GPU/Vulkan/FramebufferVulkan.cpp | 43 ++++++++---------------- GPU/Vulkan/FramebufferVulkan.h | 7 ++-- 10 files changed, 82 insertions(+), 111 deletions(-) diff --git a/GPU/Common/FramebufferCommon.cpp b/GPU/Common/FramebufferCommon.cpp index 88ebcbac98..767589d5e8 100644 --- a/GPU/Common/FramebufferCommon.cpp +++ b/GPU/Common/FramebufferCommon.cpp @@ -18,6 +18,8 @@ #include #include +#include "ext/native/thin3d/thin3d.h" + #include "i18n/i18n.h" #include "Common/Common.h" #include "Core/Config.h" @@ -27,6 +29,7 @@ #include "Core/ELF/ParamSFO.h" #include "Core/System.h" #include "GPU/Common/FramebufferCommon.h" +#include "GPU/Common/TextureCacheCommon.h" #include "GPU/GPUInterface.h" #include "GPU/GPUState.h" @@ -476,6 +479,26 @@ VirtualFramebuffer *FramebufferManagerCommon::DoSetRenderFrameBuffer(const Frame return vfb; } +void FramebufferManagerCommon::DestroyFramebuf(VirtualFramebuffer *v) { + textureCache_->NotifyFramebuffer(v->fb_address, v, NOTIFY_FB_DESTROYED); + if (v->fbo) { + delete v->fbo; + v->fbo = nullptr; + } + + // Wipe some pointers + if (currentRenderVfb_ == v) + currentRenderVfb_ = 0; + if (displayFramebuf_ == v) + displayFramebuf_ = 0; + if (prevDisplayFramebuf_ == v) + prevDisplayFramebuf_ = 0; + if (prevPrevDisplayFramebuf_ == v) + prevPrevDisplayFramebuf_ = 0; + + delete v; +} + void FramebufferManagerCommon::NotifyVideoUpload(u32 addr, int size, int width, GEBufferFormat fmt) { // Note: UpdateFromMemory() is still called later. // This is a special case where we have extra information prior to the invalidation. diff --git a/GPU/Common/FramebufferCommon.h b/GPU/Common/FramebufferCommon.h index f54b070e95..dc3d367071 100644 --- a/GPU/Common/FramebufferCommon.h +++ b/GPU/Common/FramebufferCommon.h @@ -137,6 +137,8 @@ namespace Draw { class DrawContext; } +class TextureCacheCommon; + class FramebufferManagerCommon { public: FramebufferManagerCommon(Draw::DrawContext *draw); @@ -145,6 +147,7 @@ public: virtual void Init(); void BeginFrame(); void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format); + void DestroyFramebuf(VirtualFramebuffer *v); VirtualFramebuffer *DoSetRenderFrameBuffer(const FramebufferHeuristicParams ¶ms, u32 skipDrawReason); VirtualFramebuffer *SetRenderFrameBuffer(bool framebufChanged, int skipDrawReason) { @@ -252,7 +255,6 @@ protected: u32 FramebufferByteSize(const VirtualFramebuffer *vfb) const; static bool MaskedEqual(u32 addr1, u32 addr2); - virtual void DestroyFramebuf(VirtualFramebuffer *vfb) = 0; virtual void ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force = false, bool skipCopy = false) = 0; virtual void NotifyRenderFramebufferCreated(VirtualFramebuffer *vfb) = 0; virtual void NotifyRenderFramebufferSwitched(VirtualFramebuffer *prevVfb, VirtualFramebuffer *vfb, bool isClearingDepth) = 0; @@ -282,6 +284,7 @@ protected: } Draw::DrawContext *draw_; + TextureCacheCommon *textureCache_; u32 displayFramebufPtr_; u32 displayStride_; diff --git a/GPU/Directx9/FramebufferDX9.cpp b/GPU/Directx9/FramebufferDX9.cpp index 756f269307..d2ab11a6b1 100644 --- a/GPU/Directx9/FramebufferDX9.cpp +++ b/GPU/Directx9/FramebufferDX9.cpp @@ -178,6 +178,11 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float } } + void FramebufferManagerDX9::SetTextureCache(TextureCacheDX9 *tc) { + textureCacheDX9_ = tc; + textureCache_ = tc; + } + void FramebufferManagerDX9::MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) { u8 *convBuf = NULL; D3DLOCKED_RECT rect; @@ -274,7 +279,7 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float MakePixelTexture(srcPixels, srcPixelFormat, srcStride, width, height); DisableState(); DrawActiveTexture(drawPixelsTex_, dstX, dstY, width, height, vfb->bufferWidth, vfb->bufferHeight, 0.0f, 0.0f, 1.0f, 1.0f, ROTATION_LOCKED_HORIZONTAL); - textureCache_->ForgetLastTexture(); + textureCacheDX9_->ForgetLastTexture(); dxstate.viewport.restore(); } @@ -346,26 +351,6 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float } } - void FramebufferManagerDX9::DestroyFramebuf(VirtualFramebuffer *v) { - textureCache_->NotifyFramebuffer(v->fb_address, v, NOTIFY_FB_DESTROYED); - if (v->fbo) { - delete v->fbo; - v->fbo = nullptr; - } - - // Wipe some pointers - if (currentRenderVfb_ == v) - currentRenderVfb_ = 0; - if (displayFramebuf_ == v) - displayFramebuf_ = 0; - if (prevDisplayFramebuf_ == v) - prevDisplayFramebuf_ = 0; - if (prevPrevDisplayFramebuf_ == v) - prevPrevDisplayFramebuf_ = 0; - - delete v; - } - void FramebufferManagerDX9::RebindFramebuffer() { if (currentRenderVfb_ && currentRenderVfb_->fbo) { draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo); @@ -417,7 +402,7 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float } } - textureCache_->ForgetLastTexture(); + textureCacheDX9_->ForgetLastTexture(); draw_->BindBackbufferAsRenderTarget(); if (!useBufferedRendering_) { @@ -476,7 +461,7 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float } else { DownloadFramebufferOnSwitch(prevVfb); } - textureCache_->ForgetLastTexture(); + textureCacheDX9_->ForgetLastTexture(); if (useBufferedRendering_) { if (vfb->fbo) { @@ -488,7 +473,7 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float } else { if (vfb->fbo) { // wtf? This should only happen very briefly when toggling bBufferedRendering - textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_DESTROYED); + textureCacheDX9_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_DESTROYED); delete vfb->fbo; vfb->fbo = nullptr; } @@ -501,7 +486,7 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float gstate_c.skipDrawReason |= SKIPDRAW_NON_DISPLAYED_FB; } } - textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_UPDATED); + textureCacheDX9_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_UPDATED); // Copy depth pixel value from the read framebuffer to the draw framebuffer if (prevVfb && !g_Config.bDisableSlowFramebufEffects) { @@ -529,7 +514,7 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float void FramebufferManagerDX9::NotifyRenderFramebufferUpdated(VirtualFramebuffer *vfb, bool vfbFormatChanged) { if (vfbFormatChanged) { - textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_UPDATED); + textureCacheDX9_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_UPDATED); if (vfb->drawnFormat != vfb->format) { ReformatFramebufferFrom(vfb, vfb->drawnFormat); } @@ -681,7 +666,7 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float return it->second.fbo; } - textureCache_->ForgetLastTexture(); + textureCacheDX9_->ForgetLastTexture(); Draw::Framebuffer *fbo = draw_->CreateFramebuffer({ w, h, 1, 1, false, depth }); if (!fbo) return fbo; @@ -713,7 +698,7 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float return it->second.surface; } - textureCache_->ForgetLastTexture(); + textureCacheDX9_->ForgetLastTexture(); LPDIRECT3DSURFACE9 offscreen = nullptr; HRESULT hr = pD3Ddevice->CreateOffscreenPlainSurface(w, h, fmt, D3DPOOL_SYSTEMMEM, &offscreen, NULL); if (FAILED(hr) || !offscreen) { @@ -963,7 +948,7 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float PackFramebufferDirectx9_(nvfb, x, y, w, h); - textureCache_->ForgetLastTexture(); + textureCacheDX9_->ForgetLastTexture(); RebindFramebuffer(); } } @@ -997,7 +982,7 @@ static void DXSetViewport(float x, float y, float w, float h, float minZ, float PackFramebufferDirectx9_(nvfb, x, y, w, h); - textureCache_->ForgetLastTexture(); + textureCacheDX9_->ForgetLastTexture(); RebindFramebuffer(); } } diff --git a/GPU/Directx9/FramebufferDX9.h b/GPU/Directx9/FramebufferDX9.h index 392fc1b2d7..cb7c6b9307 100644 --- a/GPU/Directx9/FramebufferDX9.h +++ b/GPU/Directx9/FramebufferDX9.h @@ -45,9 +45,7 @@ public: FramebufferManagerDX9(Draw::DrawContext *draw); ~FramebufferManagerDX9(); - void SetTextureCache(TextureCacheDX9 *tc) { - textureCache_ = tc; - } + void SetTextureCache(TextureCacheDX9 *tc); void SetShaderManager(ShaderManagerDX9 *sm) { shaderManager_ = sm; } @@ -79,7 +77,6 @@ public: virtual bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) override; - void DestroyFramebuf(VirtualFramebuffer *vfb) override; void ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force = false, bool skipCopy = false) override; bool GetCurrentFramebuffer(GPUDebugBuffer &buffer, GPUDebugFramebufferType type, int maxRes); @@ -137,7 +134,7 @@ private: LPDIRECT3DVERTEXSHADER9 stencilUploadVS_; bool stencilUploadFailed_; - TextureCacheDX9 *textureCache_; + TextureCacheDX9 *textureCacheDX9_; ShaderManagerDX9 *shaderManager_; DrawEngineDX9 *drawEngine_; diff --git a/GPU/Directx9/StencilBufferDX9.cpp b/GPU/Directx9/StencilBufferDX9.cpp index da3f669197..5c51fde4b9 100644 --- a/GPU/Directx9/StencilBufferDX9.cpp +++ b/GPU/Directx9/StencilBufferDX9.cpp @@ -256,7 +256,7 @@ bool FramebufferManagerDX9::NotifyStencilUpload(u32 addr, int size, bool skipZer pD3Ddevice->SetTexture(0, drawPixelsTex_); shaderManager_->DirtyLastShader(); - textureCache_->ForgetLastTexture(); + textureCacheDX9_->ForgetLastTexture(); for (int i = 1; i < values; i += i) { if (!(usedBits & i)) { diff --git a/GPU/GLES/FramebufferManagerGLES.cpp b/GPU/GLES/FramebufferManagerGLES.cpp index 056c1bfc95..804c552bd4 100644 --- a/GPU/GLES/FramebufferManagerGLES.cpp +++ b/GPU/GLES/FramebufferManagerGLES.cpp @@ -247,7 +247,7 @@ FramebufferManagerGLES::FramebufferManagerGLES(Draw::DrawContext *draw) : timeLoc_(-1), pixelDeltaLoc_(-1), deltaLoc_(-1), - textureCache_(nullptr), + textureCacheGL_(nullptr), shaderManager_(nullptr), resized_(false), pixelBufObj_(nullptr), @@ -263,6 +263,11 @@ void FramebufferManagerGLES::Init() { SetLineWidth(); } +void FramebufferManagerGLES::SetTextureCache(TextureCacheGLES *tc) { + textureCacheGL_ = tc; + textureCache_ = tc; +} + FramebufferManagerGLES::~FramebufferManagerGLES() { if (drawPixelsTex_) glDeleteTextures(1, &drawPixelsTex_); @@ -287,7 +292,7 @@ void FramebufferManagerGLES::MakePixelTexture(const u8 *srcPixels, GEBufferForma } if (!drawPixelsTex_) { - drawPixelsTex_ = textureCache_->AllocTextureName(); + drawPixelsTex_ = textureCacheGL_->AllocTextureName(); drawPixelsTexW_ = width; drawPixelsTexH_ = height; @@ -377,7 +382,7 @@ void FramebufferManagerGLES::DrawPixels(VirtualFramebuffer *vfb, int dstX, int d DisableState(); DrawActiveTexture(0, dstX, dstY, width, height, vfb->bufferWidth, vfb->bufferHeight, 0.0f, v0, 1.0f, v1, nullptr, ROTATION_LOCKED_HORIZONTAL); - textureCache_->ForgetLastTexture(); + textureCacheGL_->ForgetLastTexture(); } void FramebufferManagerGLES::DrawFramebufferToOutput(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) { @@ -529,26 +534,6 @@ void FramebufferManagerGLES::DrawActiveTexture(GLuint texture, float x, float y, glsl_unbind(); } -void FramebufferManagerGLES::DestroyFramebuf(VirtualFramebuffer *v) { - textureCache_->NotifyFramebuffer(v->fb_address, v, NOTIFY_FB_DESTROYED); - if (v->fbo) { - delete v->fbo; - v->fbo = nullptr; - } - - // Wipe some pointers - if (currentRenderVfb_ == v) - currentRenderVfb_ = 0; - if (displayFramebuf_ == v) - displayFramebuf_ = 0; - if (prevDisplayFramebuf_ == v) - prevDisplayFramebuf_ = 0; - if (prevPrevDisplayFramebuf_ == v) - prevPrevDisplayFramebuf_ = 0; - - delete v; -} - void FramebufferManagerGLES::RebindFramebuffer() { if (currentRenderVfb_ && currentRenderVfb_->fbo) { draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo); @@ -602,7 +587,7 @@ void FramebufferManagerGLES::ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u } } - textureCache_->ForgetLastTexture(); + textureCacheGL_->ForgetLastTexture(); draw_->BindBackbufferAsRenderTarget(); if (!useBufferedRendering_) { @@ -641,10 +626,9 @@ void FramebufferManagerGLES::NotifyRenderFramebufferCreated(VirtualFramebuffer * gstate_c.skipDrawReason |= SKIPDRAW_NON_DISPLAYED_FB; } - textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_CREATED); + textureCacheGL_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_CREATED); // Some AMD drivers crash if we don't clear the buffer first? - glDisable(GL_DITHER); // why? ClearBuffer(); // ugly... @@ -659,7 +643,7 @@ void FramebufferManagerGLES::NotifyRenderFramebufferSwitched(VirtualFramebuffer } else { DownloadFramebufferOnSwitch(prevVfb); } - textureCache_->ForgetLastTexture(); + textureCacheGL_->ForgetLastTexture(); if (useBufferedRendering_) { if (vfb->fbo) { @@ -671,7 +655,7 @@ void FramebufferManagerGLES::NotifyRenderFramebufferSwitched(VirtualFramebuffer } else { if (vfb->fbo) { // wtf? This should only happen very briefly when toggling bBufferedRendering - textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_DESTROYED); + textureCacheGL_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_DESTROYED); delete vfb->fbo; vfb->fbo = nullptr; } @@ -684,7 +668,7 @@ void FramebufferManagerGLES::NotifyRenderFramebufferSwitched(VirtualFramebuffer gstate_c.skipDrawReason |= SKIPDRAW_NON_DISPLAYED_FB; } } - textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_UPDATED); + textureCacheGL_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_UPDATED); if (gl_extensions.IsGLES) { // Some tiled mobile GPUs benefit IMMENSELY from clearing an FBO before rendering @@ -718,7 +702,7 @@ void FramebufferManagerGLES::NotifyRenderFramebufferSwitched(VirtualFramebuffer void FramebufferManagerGLES::NotifyRenderFramebufferUpdated(VirtualFramebuffer *vfb, bool vfbFormatChanged) { if (vfbFormatChanged) { - textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_UPDATED); + textureCacheGL_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_UPDATED); if (vfb->drawnFormat != vfb->format) { ReformatFramebufferFrom(vfb, vfb->drawnFormat); } @@ -801,7 +785,7 @@ Draw::Framebuffer *FramebufferManagerGLES::GetTempFBO(u16 w, u16 h, Draw::FBColo return it->second.fbo; } - textureCache_->ForgetLastTexture(); + textureCacheGL_->ForgetLastTexture(); Draw::Framebuffer *fbo = draw_->CreateFramebuffer({ w, h, 1, 1, false, depth }); if (!fbo) return fbo; @@ -1148,7 +1132,7 @@ void FramebufferManagerGLES::ReadFramebufferToMemory(VirtualFramebuffer *vfb, bo } } - textureCache_->ForgetLastTexture(); + textureCacheGL_->ForgetLastTexture(); RebindFramebuffer(); } } @@ -1186,7 +1170,7 @@ void FramebufferManagerGLES::DownloadFramebufferForClut(u32 fb_address, u32 load PackFramebufferSync_(nvfb, x, y, w, h); - textureCache_->ForgetLastTexture(); + textureCacheGL_->ForgetLastTexture(); RebindFramebuffer(); } } @@ -1318,7 +1302,7 @@ void FramebufferManagerGLES::BlitFramebuffer(VirtualFramebuffer *dst, int dstX, float srcH = src->bufferHeight; DrawActiveTexture(0, dstX1, dstY1, w * dstXFactor, h, dst->bufferWidth, dst->bufferHeight, srcX1 / srcW, srcY1 / srcH, srcX2 / srcW, srcY2 / srcH, draw2dprogram_, ROTATION_LOCKED_HORIZONTAL); glBindTexture(GL_TEXTURE_2D, 0); - textureCache_->ForgetLastTexture(); + textureCacheGL_->ForgetLastTexture(); glstate.viewport.restore(); glstate.blend.restore(); glstate.cullFace.restore(); diff --git a/GPU/GLES/FramebufferManagerGLES.h b/GPU/GLES/FramebufferManagerGLES.h index 3f24be3f64..6a62cc383d 100644 --- a/GPU/GLES/FramebufferManagerGLES.h +++ b/GPU/GLES/FramebufferManagerGLES.h @@ -65,9 +65,7 @@ public: FramebufferManagerGLES(Draw::DrawContext *draw); ~FramebufferManagerGLES(); - void SetTextureCache(TextureCacheGLES *tc) { - textureCache_ = tc; - } + void SetTextureCache(TextureCacheGLES *tc); void SetShaderManager(ShaderManagerGLES *sm) { shaderManager_ = sm; } @@ -105,7 +103,6 @@ public: bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) override; - void DestroyFramebuf(VirtualFramebuffer *vfb) override; void ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force = false, bool skipCopy = false) override; bool GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat format, GPUDebugBuffer &buffer, int maxRes); @@ -164,7 +161,7 @@ private: int pixelDeltaLoc_; int deltaLoc_; - TextureCacheGLES *textureCache_; + TextureCacheGLES *textureCacheGL_; ShaderManagerGLES *shaderManager_; DrawEngineGLES *drawEngine_; diff --git a/GPU/GLES/StencilBufferGLES.cpp b/GPU/GLES/StencilBufferGLES.cpp index 1a959e267c..ca34125476 100644 --- a/GPU/GLES/StencilBufferGLES.cpp +++ b/GPU/GLES/StencilBufferGLES.cpp @@ -190,7 +190,7 @@ bool FramebufferManagerGLES::NotifyStencilUpload(u32 addr, int size, bool skipZe glViewport(0, 0, w, h); MakePixelTexture(src, dstBuffer->format, dstBuffer->fb_stride, dstBuffer->bufferWidth, dstBuffer->bufferHeight); - textureCache_->ForgetLastTexture(); + textureCacheGL_->ForgetLastTexture(); glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); diff --git a/GPU/Vulkan/FramebufferVulkan.cpp b/GPU/Vulkan/FramebufferVulkan.cpp index ae6a427f0f..b70cde757b 100644 --- a/GPU/Vulkan/FramebufferVulkan.cpp +++ b/GPU/Vulkan/FramebufferVulkan.cpp @@ -86,7 +86,7 @@ FramebufferManagerVulkan::FramebufferManagerVulkan(Draw::DrawContext *draw, Vulk drawPixelsTexFormat_(GE_FORMAT_INVALID), convBuf_(nullptr), convBufSize_(0), - textureCache_(nullptr), + textureCacheVulkan_(nullptr), shaderManager_(nullptr), resized_(false), pixelBufObj_(nullptr), @@ -106,6 +106,11 @@ FramebufferManagerVulkan::~FramebufferManagerVulkan() { DestroyDeviceObjects(); } +void FramebufferManagerVulkan::SetTextureCache(TextureCacheVulkan *tc) { + textureCacheVulkan_ = tc; + textureCache_ = tc; +} + void FramebufferManagerVulkan::InitDeviceObjects() { // Create a bunch of render pass objects, for normal rendering with a depth buffer, // with and without pre-clearing of both depth/stencil and color, so 4 combos. @@ -416,7 +421,7 @@ void FramebufferManagerVulkan::DrawPixels(VirtualFramebuffer *vfb, int dstX, int VulkanTexture *pixelTex = MakePixelTexture(srcPixels, srcPixelFormat, srcStride, width, height); DrawTexture(pixelTex, dstX, dstY, width, height, vfb->bufferWidth, vfb->bufferHeight, 0.0f, 0.0f, 1.0f, 1.0f, pipelineBasicTex_, ROTATION_LOCKED_HORIZONTAL); - textureCache_->ForgetLastTexture(); + textureCacheVulkan_->ForgetLastTexture(); } void FramebufferManagerVulkan::DrawFramebufferToOutput(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) { @@ -536,26 +541,6 @@ void FramebufferManagerVulkan::DrawTexture(VulkanTexture *texture, float x, floa vkCmdDraw(cmd, 4, 1, 0, 0); } -void FramebufferManagerVulkan::DestroyFramebuf(VirtualFramebuffer *v) { - textureCache_->NotifyFramebuffer(v->fb_address, v, NOTIFY_FB_DESTROYED); - if (v->fbo) { - delete v->fbo; - v->fbo = 0; - } - - // Wipe some pointers - if (currentRenderVfb_ == v) - currentRenderVfb_ = 0; - if (displayFramebuf_ == v) - displayFramebuf_ = 0; - if (prevDisplayFramebuf_ == v) - prevDisplayFramebuf_ = 0; - if (prevPrevDisplayFramebuf_ == v) - prevPrevDisplayFramebuf_ = 0; - - delete v; -} - void FramebufferManagerVulkan::RebindFramebuffer() { // Switch command buffer? } @@ -645,7 +630,7 @@ void FramebufferManagerVulkan::NotifyRenderFramebufferCreated(VirtualFramebuffer gstate_c.skipDrawReason |= SKIPDRAW_NON_DISPLAYED_FB; } - textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_CREATED); + textureCacheVulkan_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_CREATED); // ugly... if ((gstate_c.curRTWidth != vfb->width || gstate_c.curRTHeight != vfb->height) && shaderManager_) { gstate_c.Dirty(DIRTY_PROJMATRIX); @@ -658,7 +643,7 @@ void FramebufferManagerVulkan::NotifyRenderFramebufferSwitched(VirtualFramebuffe } else { DownloadFramebufferOnSwitch(prevVfb); } - textureCache_->ForgetLastTexture(); + textureCacheVulkan_->ForgetLastTexture(); if (useBufferedRendering_) { if (vfb->fbo) { @@ -667,7 +652,7 @@ void FramebufferManagerVulkan::NotifyRenderFramebufferSwitched(VirtualFramebuffe } else { if (vfb->fbo) { // wtf? This should only happen very briefly when toggling bBufferedRendering - textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_DESTROYED); + textureCacheVulkan_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_DESTROYED); delete vfb->fbo; vfb->fbo = nullptr; } @@ -679,7 +664,7 @@ void FramebufferManagerVulkan::NotifyRenderFramebufferSwitched(VirtualFramebuffe gstate_c.skipDrawReason |= SKIPDRAW_NON_DISPLAYED_FB; } } - textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_UPDATED); + textureCacheVulkan_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_UPDATED); // Copy depth pixel value from the read framebuffer to the draw framebuffer if (prevVfb && !g_Config.bDisableSlowFramebufEffects) { @@ -703,7 +688,7 @@ void FramebufferManagerVulkan::NotifyRenderFramebufferSwitched(VirtualFramebuffe void FramebufferManagerVulkan::NotifyRenderFramebufferUpdated(VirtualFramebuffer *vfb, bool vfbFormatChanged) { if (vfbFormatChanged) { - textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_UPDATED); + textureCacheVulkan_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_UPDATED); if (vfb->drawnFormat != vfb->format) { ReformatFramebufferFrom(vfb, vfb->drawnFormat); } @@ -1075,7 +1060,7 @@ void FramebufferManagerVulkan::ReadFramebufferToMemory(VirtualFramebuffer *vfb, PackFramebufferSync_(nvfb, x, y, w, h); } - textureCache_->ForgetLastTexture(); + textureCacheVulkan_->ForgetLastTexture(); RebindFramebuffer(); } } @@ -1110,7 +1095,7 @@ void FramebufferManagerVulkan::DownloadFramebufferForClut(u32 fb_address, u32 lo PackFramebufferSync_(nvfb, x, y, w, h); - textureCache_->ForgetLastTexture(); + textureCacheVulkan_->ForgetLastTexture(); RebindFramebuffer(); } } diff --git a/GPU/Vulkan/FramebufferVulkan.h b/GPU/Vulkan/FramebufferVulkan.h index 5ef6bccb54..18734b1429 100644 --- a/GPU/Vulkan/FramebufferVulkan.h +++ b/GPU/Vulkan/FramebufferVulkan.h @@ -78,9 +78,7 @@ public: FramebufferManagerVulkan(Draw::DrawContext *draw, VulkanContext *vulkan); ~FramebufferManagerVulkan(); - void SetTextureCache(TextureCacheVulkan *tc) { - textureCache_ = tc; - } + void SetTextureCache(TextureCacheVulkan *tc); void SetShaderManager(ShaderManagerVulkan *sm) { shaderManager_ = sm; } @@ -122,7 +120,6 @@ public: bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) override; - void DestroyFramebuf(VirtualFramebuffer *vfb) override; void ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force = false, bool skipCopy = false) override; bool GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat format, GPUDebugBuffer &buffer); @@ -193,7 +190,7 @@ private: u8 *convBuf_; u32 convBufSize_; - TextureCacheVulkan *textureCache_; + TextureCacheVulkan *textureCacheVulkan_; ShaderManagerVulkan *shaderManager_; DrawEngineVulkan *drawEngine_;