From bb18fa4cd9a167e37384ebfcd3ad8db085356325 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 23 Sep 2015 23:57:59 -0700 Subject: [PATCH 1/3] Allow framebufs to get smaller in expected size. This doesn't change the buffer size, but it does change the recorded size, which effects how we calculate things about them. --- GPU/Common/FramebufferCommon.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/GPU/Common/FramebufferCommon.cpp b/GPU/Common/FramebufferCommon.cpp index 3f034ad294..6958f9aa34 100644 --- a/GPU/Common/FramebufferCommon.cpp +++ b/GPU/Common/FramebufferCommon.cpp @@ -330,6 +330,10 @@ VirtualFramebuffer *FramebufferManagerCommon::DoSetRenderFrameBuffer(const Frame needsRecreate = needsRecreate || vfb->newHeight > vfb->bufferHeight || vfb->newHeight * 2 < vfb->bufferHeight; if (needsRecreate) { ResizeFramebufFBO(vfb, vfb->width, vfb->height, true); + } else { + // Even though we won't resize it, let's at least change the size params. + vfb->width = drawing_width; + vfb->height = drawing_height; } } } else { From 400b8886e64044c446c87348f09dba6d233534c5 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 23 Sep 2015 23:59:13 -0700 Subject: [PATCH 2/3] Use the framebuf->height for offset calculation. This way if we shrunk the framebuffer, it'll still work. --- GPU/Common/SoftwareTransformCommon.cpp | 4 ++-- GPU/Common/TextureCacheCommon.cpp | 13 +++++++++++++ GPU/Common/TextureCacheCommon.h | 4 ++++ GPU/Directx9/TextureCacheDX9.h | 2 -- GPU/GLES/TextureCache.h | 2 -- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index cdbd78cf34..69e4d4e311 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -450,8 +450,8 @@ void SoftwareTransform( // Okay, so we're texturing from outside the framebuffer, but inside the texture height. // Breath of Fire 3 does this to access a render surface at an offset. const u32 bpp = fbman->GetTargetFormat() == GE_FORMAT_8888 ? 4 : 2; - const u32 fb_size = bpp * fbman->GetTargetStride() * gstate_c.curTextureHeight; - const u32 prevH = gstate_c.curTextureHeight; + const u32 prevH = texCache->AttachedDrawingHeight(); + const u32 fb_size = bpp * fbman->GetTargetStride() * prevH; const u32 prevYOffset = gstate_c.curTextureYOffset; if (texCache->SetOffsetTexture(fb_size)) { const float oldWidthFactor = widthFactor; diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index d6098933c6..3056b8eee5 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -16,6 +16,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "Core/Config.h" +#include "GPU/Common/FramebufferCommon.h" #include "GPU/Common/GPUStateUtils.h" #include "GPU/Common/TextureCacheCommon.h" #include "GPU/GPUState.h" @@ -29,6 +30,18 @@ bool TextureCacheCommon::SetOffsetTexture(u32 offset) { return false; } +int TextureCacheCommon::AttachedDrawingHeight() { + if (nextTexture_) { + if (nextTexture_->framebuffer) { + return nextTexture_->framebuffer->height; + } + u16 dim = nextTexture_->dim; + const u8 dimY = dim >> 8; + return 1 << dimY; + } + return 0; +} + void TextureCacheCommon::GetSamplingParams(int &minFilt, int &magFilt, bool &sClamp, bool &tClamp, float &lodBias, u8 maxLevel) { minFilt = gstate.texfilter & 0x7; magFilt = (gstate.texfilter>>8) & 1; diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index 6a4df93991..7ebba4f2b8 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -34,6 +34,8 @@ public: virtual bool SetOffsetTexture(u32 offset); + int AttachedDrawingHeight(); + // Wow this is starting to grow big. Soon need to start looking at resizing it. // Must stay a POD. struct TexCacheEntry { @@ -113,6 +115,8 @@ public: protected: void GetSamplingParams(int &minFilt, int &magFilt, bool &sClamp, bool &tClamp, float &lodBias, u8 maxLevel); + + TexCacheEntry *nextTexture_; }; inline bool TextureCacheCommon::TexCacheEntry::Matches(u16 dim2, u8 format2, u8 maxLevel2) { diff --git a/GPU/Directx9/TextureCacheDX9.h b/GPU/Directx9/TextureCacheDX9.h index 964695a629..a6e7e26802 100644 --- a/GPU/Directx9/TextureCacheDX9.h +++ b/GPU/Directx9/TextureCacheDX9.h @@ -151,8 +151,6 @@ private: bool clutAlphaLinear_; u16 clutAlphaLinearColor_; - TexCacheEntry *nextTexture_; - LPDIRECT3DTEXTURE9 lastBoundTexture; float maxAnisotropyLevel; diff --git a/GPU/GLES/TextureCache.h b/GPU/GLES/TextureCache.h index ab0321bdee..8936c0bc7f 100644 --- a/GPU/GLES/TextureCache.h +++ b/GPU/GLES/TextureCache.h @@ -153,8 +153,6 @@ private: bool clutAlphaLinear_; u16 clutAlphaLinearColor_; - TexCacheEntry *nextTexture_; - u32 lastBoundTexture; float maxAnisotropyLevel; From e98a31ef77d19535bec135e9abfc232a9d9700b6 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 24 Sep 2015 00:00:02 -0700 Subject: [PATCH 3/3] Cleanup some indentation. --- Windows/MainWindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 6d3358dd57..484a6c1b63 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -685,8 +685,8 @@ namespace MainWindow } break; - case WM_ERASEBKGND: - // This window is always covered by DisplayWindow. No reason to erase. + case WM_ERASEBKGND: + // This window is always covered by DisplayWindow. No reason to erase. return 1; case WM_MOVE: