diff --git a/GPU/Common/FramebufferCommon.cpp b/GPU/Common/FramebufferCommon.cpp index 1a6576bf70..28bc2413b2 100644 --- a/GPU/Common/FramebufferCommon.cpp +++ b/GPU/Common/FramebufferCommon.cpp @@ -20,6 +20,7 @@ #include "Core/Config.h" #include "Core/CoreParameter.h" #include "Core/Reporting.h" +#include "Core/ELF/ParamSFO.h" #include "Core/System.h" #include "GPU/Common/FramebufferCommon.h" #include "GPU/GPUInterface.h" @@ -41,6 +42,21 @@ FramebufferManagerCommon::FramebufferManagerCommon() : FramebufferManagerCommon::~FramebufferManagerCommon() { } +void FramebufferManagerCommon::Init() { + + const std::string gameId = g_paramSFO.GetValueString("DISC_ID"); + // This applies a hack to Dangan Ronpa, its demo, and its sequel. + // The game draws solid colors to a small framebuffer, and then reads this directly in VRAM. + // We force this framebuffer to 1x and force download it automatically. + hackForce04154000Download_ = gameId == "NPJH50631" || gameId == "NPJH50372" || gameId == "NPJH90164" || gameId == "NPJH50515"; + + // And an initial clear. We don't clear per frame as the games are supposed to handle that + // by themselves. + ClearBuffer(); + + BeginFrame(); +} + void FramebufferManagerCommon::BeginFrame() { DecimateFBOs(); currentRenderVfb_ = 0; @@ -664,7 +680,7 @@ bool FramebufferManagerCommon::NotifyBlockTransferBefore(u32 dstBasePtr, int dst if (srcHeight <= 0 || srcY + srcHeight > srcBuffer->bufferHeight) { WARN_LOG_ONCE(btdheight, G3D, "Block transfer download %08x -> %08x skipped, %d+%d is taller than %d", srcBasePtr, dstBasePtr, srcY, srcHeight, srcBuffer->bufferHeight); } else { - ReadFramebufferToMemory(srcBuffer, true, srcX * srcXFactor, srcY, srcWidth * srcXFactor, srcHeight); + ReadFramebufferToMemory(srcBuffer, true, static_cast(srcX * srcXFactor), srcY, static_cast(srcWidth * srcXFactor), srcHeight); } } return false; // Let the bit copy happen @@ -708,7 +724,7 @@ void FramebufferManagerCommon::NotifyBlockTransferAfter(u32 dstBasePtr, int dstS const u8 *srcBase = Memory::GetPointerUnchecked(srcBasePtr) + (srcX + srcY * srcStride) * bpp; int dstBpp = dstBuffer->format == GE_FORMAT_8888 ? 4 : 2; float dstXFactor = (float)bpp / dstBpp; - DrawPixels(dstBuffer, dstX * dstXFactor, dstY, srcBase, dstBuffer->format, srcStride * dstXFactor, dstWidth * dstXFactor, dstHeight); + DrawPixels(dstBuffer, static_cast(dstX * dstXFactor), dstY, srcBase, dstBuffer->format, static_cast(srcStride * dstXFactor), static_cast(dstWidth * dstXFactor), dstHeight); SetColorUpdated(dstBuffer); RebindFramebuffer(); } diff --git a/GPU/Common/FramebufferCommon.h b/GPU/Common/FramebufferCommon.h index 10be753152..b71ca1c807 100644 --- a/GPU/Common/FramebufferCommon.h +++ b/GPU/Common/FramebufferCommon.h @@ -94,6 +94,7 @@ public: FramebufferManagerCommon(); virtual ~FramebufferManagerCommon(); + virtual void Init(); void BeginFrame(); void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format); diff --git a/GPU/Directx9/FramebufferDX9.cpp b/GPU/Directx9/FramebufferDX9.cpp index f83b4229b5..55372e2ad0 100644 --- a/GPU/Directx9/FramebufferDX9.cpp +++ b/GPU/Directx9/FramebufferDX9.cpp @@ -126,9 +126,6 @@ namespace DX9 { convBuf(0), gameUsesSequentialCopies_(false) { - // And an initial clear. We don't clear per frame as the games are supposed to handle that - // by themselves. - ClearBuffer(); // TODO: Check / use D3DCAPS2_DYNAMICTEXTURES? int usage = 0; D3DPOOL pool = D3DPOOL_MANAGED; @@ -141,7 +138,6 @@ namespace DX9 { drawPixelsTex_ = nullptr; ERROR_LOG(G3D, "Failed to create drawpixels texture"); } - BeginFrame(); } FramebufferManagerDX9::~FramebufferManagerDX9() { diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index 26c0176541..ef4cc74711 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -396,6 +396,7 @@ DIRECTX9_GPU::DIRECTX9_GPU() transformDraw_.SetShaderManager(shaderManager_); transformDraw_.SetTextureCache(&textureCache_); transformDraw_.SetFramebufferManager(&framebufferManager_); + framebufferManager_.Init(); framebufferManager_.SetTextureCache(&textureCache_); framebufferManager_.SetShaderManager(shaderManager_); framebufferManager_.SetTransformDrawEngine(&transformDraw_); diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 7cd8c078f3..eaceb665a4 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -30,7 +30,6 @@ #include "Core/Config.h" #include "Core/System.h" #include "Core/Reporting.h" -#include "Core/ELF/ParamSFO.h" #include "Core/HLE/sceDisplay.h" #include "GPU/ge_constants.h" #include "GPU/GPUState.h" @@ -353,20 +352,9 @@ FramebufferManager::FramebufferManager() : } void FramebufferManager::Init() { + FramebufferManagerCommon::Init(); CompileDraw2DProgram(); - - const std::string gameId = g_paramSFO.GetValueString("DISC_ID"); - // This applies a hack to Dangan Ronpa, its demo, and its sequel. - // The game draws solid colors to a small framebuffer, and then reads this directly in VRAM. - // We force this framebuffer to 1x and force download it automatically. - hackForce04154000Download_ = gameId == "NPJH50631" || gameId == "NPJH50372" || gameId == "NPJH90164" || gameId == "NPJH50515"; - - // And an initial clear. We don't clear per frame as the games are supposed to handle that - // by themselves. - ClearBuffer(); - SetLineWidth(); - BeginFrame(); } FramebufferManager::~FramebufferManager() { diff --git a/GPU/GLES/Framebuffer.h b/GPU/GLES/Framebuffer.h index 1e2a22afa0..ec17e246bc 100644 --- a/GPU/GLES/Framebuffer.h +++ b/GPU/GLES/Framebuffer.h @@ -83,7 +83,7 @@ public: void DestroyAllFBOs(); - void Init(); + virtual void Init() override; void EndFrame(); void Resized(); void DeviceLost();