From ae2e8c5c7c7065fd956bd6f01423b05b79d02660 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 9 Sep 2014 22:09:41 -0700 Subject: [PATCH] d3d: Migrate a few more things into common code. --- GPU/Common/FramebufferCommon.cpp | 23 +++++++++++++++++++++++ GPU/Common/FramebufferCommon.h | 7 +++++++ GPU/Directx9/FramebufferDX9.cpp | 24 ------------------------ GPU/Directx9/FramebufferDX9.h | 6 ------ GPU/GLES/Framebuffer.cpp | 24 ------------------------ GPU/GLES/Framebuffer.h | 8 -------- 6 files changed, 30 insertions(+), 62 deletions(-) diff --git a/GPU/Common/FramebufferCommon.cpp b/GPU/Common/FramebufferCommon.cpp index c2a8baee9..0d1661356 100644 --- a/GPU/Common/FramebufferCommon.cpp +++ b/GPU/Common/FramebufferCommon.cpp @@ -41,6 +41,29 @@ void FramebufferManagerCommon::SetDisplayFramebuffer(u32 framebuf, u32 stride, G displayFormat_ = format; } +VirtualFramebuffer *FramebufferManagerCommon::GetVFBAt(u32 addr) { + VirtualFramebuffer *match = NULL; + for (size_t i = 0; i < vfbs_.size(); ++i) { + VirtualFramebuffer *v = vfbs_[i]; + if (MaskedEqual(v->fb_address, addr)) { + // Could check w too but whatever + if (match == NULL || match->last_frame_render < v->last_frame_render) { + match = v; + } + } + } + if (match != NULL) { + return match; + } + + DEBUG_LOG(SCEGE, "Finding no FBO matching address %08x", addr); + return 0; +} + +bool FramebufferManagerCommon::MaskedEqual(u32 addr1, u32 addr2) { + return (addr1 & 0x03FFFFFF) == (addr2 & 0x03FFFFFF); +} + // Heuristics to figure out the size of FBO to create. void FramebufferManagerCommon::EstimateDrawingSize(int &drawing_width, int &drawing_height) { static const int MAX_FRAMEBUF_HEIGHT = 512; diff --git a/GPU/Common/FramebufferCommon.h b/GPU/Common/FramebufferCommon.h index bc9d46bd2..11b23203c 100644 --- a/GPU/Common/FramebufferCommon.h +++ b/GPU/Common/FramebufferCommon.h @@ -138,6 +138,12 @@ public: return true; } + // TODO: Break out into some form of FBO manager + VirtualFramebuffer *GetVFBAt(u32 addr); + VirtualFramebuffer *GetDisplayVFB() { + return GetVFBAt(displayFramebufPtr_); + } + int GetRenderWidth() const { return currentRenderVfb_ ? currentRenderVfb_->renderWidth : 480; } int GetRenderHeight() const { return currentRenderVfb_ ? currentRenderVfb_->renderHeight : 272; } int GetTargetWidth() const { return currentRenderVfb_ ? currentRenderVfb_->width : 480; } @@ -149,6 +155,7 @@ public: protected: void EstimateDrawingSize(int &drawing_width, int &drawing_height); + static bool MaskedEqual(u32 addr1, u32 addr2); void SetColorUpdated(VirtualFramebuffer *dstBuffer) { dstBuffer->memoryUpdated = false; diff --git a/GPU/Directx9/FramebufferDX9.cpp b/GPU/Directx9/FramebufferDX9.cpp index 6f9814691..6b819c692 100644 --- a/GPU/Directx9/FramebufferDX9.cpp +++ b/GPU/Directx9/FramebufferDX9.cpp @@ -41,10 +41,6 @@ namespace DX9 { FBO_OLD_AGE = 5, }; - static bool MaskedEqual(u32 addr1, u32 addr2) { - return (addr1 & 0x03FFFFFF) == (addr2 & 0x03FFFFFF); - } - inline u16 RGBA8888toRGB565(u32 px) { return ((px >> 3) & 0x001F) | ((px >> 5) & 0x07E0) | ((px >> 8) & 0xF800); } @@ -294,26 +290,6 @@ namespace DX9 { pD3Ddevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coord, 5 * sizeof(float)); } - - VirtualFramebuffer *FramebufferManagerDX9::GetVFBAt(u32 addr) { - VirtualFramebuffer *match = NULL; - for (size_t i = 0; i < vfbs_.size(); ++i) { - VirtualFramebuffer *v = vfbs_[i]; - if (MaskedEqual(v->fb_address, addr) && v->format == displayFormat_ && v->width >= 480) { - // Could check w too but whatever - if (match == NULL || match->last_frame_render < v->last_frame_render) { - match = v; - } - } - } - if (match != NULL) { - return match; - } - - DEBUG_LOG(SCEGE, "Finding no FBO matching address %08x", addr); - return 0; - } - void FramebufferManagerDX9::DestroyFramebuf(VirtualFramebuffer *v) { textureCache_->NotifyFramebuffer(v->fb_address, v, NOTIFY_FB_DESTROYED); if (v->fbo) { diff --git a/GPU/Directx9/FramebufferDX9.h b/GPU/Directx9/FramebufferDX9.h index b65f9f6f5..985bcc8c0 100644 --- a/GPU/Directx9/FramebufferDX9.h +++ b/GPU/Directx9/FramebufferDX9.h @@ -72,12 +72,6 @@ public: void ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync = true); - // TODO: Break out into some form of FBO manager - VirtualFramebuffer *GetVFBAt(u32 addr); - VirtualFramebuffer *GetDisplayVFB() { - return GetVFBAt(displayFramebufPtr_); - } - std::vector GetFramebufferList(); void NotifyFramebufferCopy(u32 src, u32 dest, int size); diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 9604769a4..f7eb8797d 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -102,10 +102,6 @@ enum { FBO_OLD_AGE = 5, }; -bool FramebufferManager::MaskedEqual(u32 addr1, u32 addr2) { - return (addr1 & 0x03FFFFFF) == (addr2 & 0x03FFFFFF); -} - inline u16 RGBA8888toRGB565(u32 px) { return ((px >> 3) & 0x001F) | ((px >> 5) & 0x07E0) | ((px >> 8) & 0xF800); } @@ -640,26 +636,6 @@ void FramebufferManager::DrawActiveTexture(GLuint texture, float x, float y, flo glsl_unbind(); } - -VirtualFramebuffer *FramebufferManager::GetVFBAt(u32 addr) { - VirtualFramebuffer *match = NULL; - for (size_t i = 0; i < vfbs_.size(); ++i) { - VirtualFramebuffer *v = vfbs_[i]; - if (MaskedEqual(v->fb_address, addr)) { - // Could check w too but whatever - if (match == NULL || match->last_frame_render < v->last_frame_render) { - match = v; - } - } - } - if (match != NULL) { - return match; - } - - DEBUG_LOG(SCEGE, "Finding no FBO matching address %08x", addr); - return 0; -} - void FramebufferManager::DestroyFramebuf(VirtualFramebuffer *v) { textureCache_->NotifyFramebuffer(v->fb_address, v, NOTIFY_FB_DESTROYED); if (v->fbo) { diff --git a/GPU/GLES/Framebuffer.h b/GPU/GLES/Framebuffer.h index 54744c9df..0984f22fd 100644 --- a/GPU/GLES/Framebuffer.h +++ b/GPU/GLES/Framebuffer.h @@ -110,12 +110,6 @@ public: // Reads a rectangular subregion of a framebuffer to the right position in its backing memory. void ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync, int x, int y, int w, int h); - // TODO: Break out into some form of FBO manager - VirtualFramebuffer *GetVFBAt(u32 addr); - VirtualFramebuffer *GetDisplayVFB() { - return GetVFBAt(displayFramebufPtr_); - } - std::vector GetFramebufferList(); bool NotifyFramebufferCopy(u32 src, u32 dest, int size, bool isMemset = false); @@ -147,8 +141,6 @@ private: void SetNumExtraFBOs(int num); - static bool MaskedEqual(u32 addr1, u32 addr2); - inline bool ShouldDownloadFramebuffer(const VirtualFramebuffer *vfb) const; inline bool ShouldDownloadUsingCPU(const VirtualFramebuffer *vfb) const;