From 90f2d06697b78fa5a0285e689829cc1a38c2299b Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 25 May 2014 10:18:14 +0200 Subject: [PATCH] Add setting to enable/disable GPU block transfer --- Core/Config.cpp | 2 ++ Core/Config.h | 1 + GPU/GLES/Framebuffer.cpp | 24 ++++++++++++++++++------ UI/GameSettingsScreen.cpp | 2 +- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 17a6dca9fb..ecf0f7cf48 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -396,6 +396,8 @@ static ConfigSetting graphicsSettings[] = { ReportedConfigSetting("SplineBezierQuality", &g_Config.iSplineBezierQuality, 2), ReportedConfigSetting("PostShader", &g_Config.sPostShaderName, "Off"), + ReportedConfigSetting("BlockTransferGPU", &g_Config.bBlockTransferGPU, false), + ConfigSetting(false), }; diff --git a/Core/Config.h b/Core/Config.h index 55ec5ea43b..fb2e14962c 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -143,6 +143,7 @@ public: bool bAlwaysDepthWrite; bool bTimerHack; bool bAlphaMaskHack; + bool bBlockTransferGPU; int iSplineBezierQuality; // 0 = low , 1 = Intermediate , 2 = High std::string sPostShaderName; // Off for off. diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 2558b70078..382813509b 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -1796,14 +1796,20 @@ void FramebufferManager::NotifyFramebufferCopy(u32 src, u32 dst, int size) { WARN_LOG_ONCE(dstnotsrccpy, G3D, "Inter-buffer memcpy %08x -> %08x", src, dst); // Just do the blit! // TODO: Possibly take bpp into account somehow if games are doing really crazy things? - // BlitFramebuffer_(dstBuffer, 0, 0, srcBuffer, 0, 0, srcBuffer->width, srcBuffer->height); + // if (g_Config.bBlockTransferGPU) { + // BlitFramebuffer_(dstBuffer, 0, 0, srcBuffer, 0, 0, srcBuffer->width, srcBuffer->height); + // } } } else if (dstBuffer) { WARN_LOG_REPORT_ONCE(btucpy, G3D, "Memcpy fbo upload (not supported) %08x -> %08x", src, dst); // Here we should just draw the pixels into the buffer. + // if (g_Config.bBlockTransferGPU) { + // } } else if (srcBuffer && g_Config.iRenderingMode == FB_BUFFERED_MODE) { WARN_LOG_ONCE(btdcpy, G3D, "Memcpy fbo download %08x -> %08x", src, dst); - // ReadFramebufferToMemory(srcBuffer, true, 0, 0, srcBuffer->width, srcBuffer->height); + // if (g_Config.bBlockTransferGPU) { + // ReadFramebufferToMemory(srcBuffer, true, 0, 0, srcBuffer->width, srcBuffer->height); + // } } } @@ -1851,18 +1857,24 @@ bool FramebufferManager::NotifyBlockTransfer(u32 dstBasePtr, int dstStride, int WARN_LOG_ONCE(dstnotsrc, G3D, "Inter-buffer block transfer %08x -> %08x", srcBasePtr, dstBasePtr); // Just do the blit! // TODO: Possibly take bpp into account somehow if games are doing really crazy things? - BlitFramebuffer_(dstBuffer, dstX, dstY, srcBuffer, srcX, srcY, width, height); + if (g_Config.bBlockTransferGPU) { + BlitFramebuffer_(dstBuffer, dstX, dstY, srcBuffer, srcX, srcY, width, height); + } } return true; // No need to actually do the memory copy behind, probably. } else if (dstBuffer) { WARN_LOG_REPORT_ONCE(btu, G3D, "Block transfer upload (not supported) %08x -> %08x", srcBasePtr, dstBasePtr); - u8 *srcBase = Memory::GetPointerUnchecked(srcBasePtr) + (srcX + srcY * srcStride) * bpp; - DrawPixels(dstBuffer, dstX, dstY, srcBase, dstBuffer->format, srcStride * bpp, width, height); + if (g_Config.bBlockTransferGPU) { + u8 *srcBase = Memory::GetPointerUnchecked(srcBasePtr) + (srcX + srcY * srcStride) * bpp; + DrawPixels(dstBuffer, dstX, dstY, srcBase, dstBuffer->format, srcStride * bpp, width, height); + } // Here we should just draw the pixels into the buffer. return false; } else if (srcBuffer && g_Config.iRenderingMode == FB_BUFFERED_MODE) { WARN_LOG_ONCE(btd, G3D, "Block transfer download %08x -> %08x", srcBasePtr, dstBasePtr); - ReadFramebufferToMemory(srcBuffer, true, srcX, srcY, width, height); + if (g_Config.bBlockTransferGPU) { + ReadFramebufferToMemory(srcBuffer, true, srcX, srcY, width, height); + } return false; // Let the bit copy happen } else { return false; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 1cafa3a02d..f295c21d88 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -99,7 +99,7 @@ void GameSettingsScreen::CreateViews() { static const char *renderingMode[] = { "Non-Buffered Rendering", "Buffered Rendering", "Read Framebuffers To Memory (CPU)", "Read Framebuffers To Memory (GPU)"}; PopupMultiChoice *rm = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iRenderingMode, gs->T("Mode"), renderingMode, 0, ARRAY_SIZE(renderingMode), gs, screenManager())); rm->OnChoice.Handle(this, &GameSettingsScreen::OnRenderingMode); - + graphicsSettings->Add(new CheckBox(&g_Config.bBlockTransferGPU, gs->T("Simulate Block Transfer", "Simulate Block Transfer (unfinished)"))); graphicsSettings->Add(new ItemHeader(gs->T("Frame Rate Control"))); static const char *frameSkip[] = {"Off", "1", "2", "3", "4", "5", "6", "7", "8"};