From c8fe0b2690207f0302a21fb53ca1c982fb3d7d68 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 26 Jul 2015 22:54:18 +0200 Subject: [PATCH] Minor simplification, buildfixes --- Core/HW/MediaEngine.cpp | 1 + GPU/Common/TextureDecoderNEON.cpp | 2 + GPU/Directx9/FramebufferDX9.cpp | 68 ++++++++++++++++--------------- GPU/GLES/Framebuffer.cpp | 24 ++++++----- 4 files changed, 51 insertions(+), 44 deletions(-) diff --git a/Core/HW/MediaEngine.cpp b/Core/HW/MediaEngine.cpp index 4fa2704689..4d43585244 100644 --- a/Core/HW/MediaEngine.cpp +++ b/Core/HW/MediaEngine.cpp @@ -21,6 +21,7 @@ #include "Core/MemMap.h" #include "Core/MIPS/MIPS.h" #include "Core/Reporting.h" +#include "GPU/GPUState.h" // Used by TextureDecoder.h when templates get instanced #include "GPU/Common/TextureDecoder.h" #include "GPU/GPUInterface.h" #include "Core/HW/SimpleAudioDec.h" diff --git a/GPU/Common/TextureDecoderNEON.cpp b/GPU/Common/TextureDecoderNEON.cpp index d63cdc0d5b..ea276d6309 100644 --- a/GPU/Common/TextureDecoderNEON.cpp +++ b/GPU/Common/TextureDecoderNEON.cpp @@ -16,6 +16,8 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include + +#include "GPU/GPUState.h" #include "GPU/Common/TextureDecoder.h" #if !defined(ARM) && !defined(ARM64) diff --git a/GPU/Directx9/FramebufferDX9.cpp b/GPU/Directx9/FramebufferDX9.cpp index b49ea0e04c..ac2fc0cd9f 100644 --- a/GPU/Directx9/FramebufferDX9.cpp +++ b/GPU/Directx9/FramebufferDX9.cpp @@ -522,50 +522,52 @@ namespace DX9 { return; } + // Let's only do this if not clearing depth. + if (gstate.isModeClear() && gstate.isClearModeDepthMask()) { + return; + } + if (src->z_address == dst->z_address && src->z_stride != 0 && dst->z_stride != 0 && src->renderWidth == dst->renderWidth && src->renderHeight == dst->renderHeight) { - // Let's only do this if not clearing. - if (!gstate.isModeClear() || !gstate.isClearModeDepthMask()) { - // Doesn't work. Use a shader maybe? - /*fbo_unbind(); + // Doesn't work. Use a shader maybe? + /*fbo_unbind(); - LPDIRECT3DTEXTURE9 srcTex = fbo_get_depth_texture(src->fbo); - LPDIRECT3DTEXTURE9 dstTex = fbo_get_depth_texture(dst->fbo); + LPDIRECT3DTEXTURE9 srcTex = fbo_get_depth_texture(src->fbo); + LPDIRECT3DTEXTURE9 dstTex = fbo_get_depth_texture(dst->fbo); - if (srcTex && dstTex) { - D3DSURFACE_DESC srcDesc; - srcTex->GetLevelDesc(0, &srcDesc); - D3DSURFACE_DESC dstDesc; - dstTex->GetLevelDesc(0, &dstDesc); + if (srcTex && dstTex) { + D3DSURFACE_DESC srcDesc; + srcTex->GetLevelDesc(0, &srcDesc); + D3DSURFACE_DESC dstDesc; + dstTex->GetLevelDesc(0, &dstDesc); - D3DLOCKED_RECT srcLock; - D3DLOCKED_RECT dstLock; - HRESULT srcLockRes = srcTex->LockRect(0, &srcLock, nullptr, D3DLOCK_READONLY); - HRESULT dstLockRes = dstTex->LockRect(0, &dstLock, nullptr, 0); - if (SUCCEEDED(srcLockRes) && SUCCEEDED(dstLockRes)) { - int pitch = std::min(srcLock.Pitch, dstLock.Pitch); - u32 h = std::min(srcDesc.Height, dstDesc.Height); - const u8 *srcp = (const u8 *)srcLock.pBits; - u8 *dstp = (u8 *)dstLock.pBits; - for (u32 y = 0; y < h; ++y) { - memcpy(dstp, srcp, pitch); - dstp += dstLock.Pitch; - srcp += srcLock.Pitch; - } - } - if (SUCCEEDED(srcLockRes)) { - srcTex->UnlockRect(0); - } - if (SUCCEEDED(dstLockRes)) { - dstTex->UnlockRect(0); + D3DLOCKED_RECT srcLock; + D3DLOCKED_RECT dstLock; + HRESULT srcLockRes = srcTex->LockRect(0, &srcLock, nullptr, D3DLOCK_READONLY); + HRESULT dstLockRes = dstTex->LockRect(0, &dstLock, nullptr, 0); + if (SUCCEEDED(srcLockRes) && SUCCEEDED(dstLockRes)) { + int pitch = std::min(srcLock.Pitch, dstLock.Pitch); + u32 h = std::min(srcDesc.Height, dstDesc.Height); + const u8 *srcp = (const u8 *)srcLock.pBits; + u8 *dstp = (u8 *)dstLock.pBits; + for (u32 y = 0; y < h; ++y) { + memcpy(dstp, srcp, pitch); + dstp += dstLock.Pitch; + srcp += srcLock.Pitch; } } - - RebindFramebuffer();*/ + if (SUCCEEDED(srcLockRes)) { + srcTex->UnlockRect(0); + } + if (SUCCEEDED(dstLockRes)) { + dstTex->UnlockRect(0); + } } + + RebindFramebuffer();*/ } } diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 1dd10ed02b..14f9341e52 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -831,6 +831,10 @@ void FramebufferManager::BlitFramebufferDepth(VirtualFramebuffer *src, VirtualFr return; } + if (gstate.isModeClear() && gstate.isClearModeDepthMask()) { + return; + } + if (src->z_address == dst->z_address && src->z_stride != 0 && dst->z_stride != 0 && src->renderWidth == dst->renderWidth && @@ -844,21 +848,19 @@ void FramebufferManager::BlitFramebufferDepth(VirtualFramebuffer *src, VirtualFr bool useNV = !gl_extensions.GLES3; #endif - // Let's only do this if not clearing. - if (!gstate.isModeClear() || !gstate.isClearModeDepthMask()) { - fbo_bind_for_read(src->fbo); - glDisable(GL_SCISSOR_TEST); + // Let's only do this if not clearing depth. + fbo_bind_for_read(src->fbo); + glDisable(GL_SCISSOR_TEST); #if defined(USING_GLES2) && defined(ANDROID) // We only support this extension on Android, it's not even available on PC. - if (useNV) { - glBlitFramebufferNV(0, 0, src->renderWidth, src->renderHeight, 0, 0, dst->renderWidth, dst->renderHeight, GL_DEPTH_BUFFER_BIT, GL_NEAREST); - } else + if (useNV) { + glBlitFramebufferNV(0, 0, src->renderWidth, src->renderHeight, 0, 0, dst->renderWidth, dst->renderHeight, GL_DEPTH_BUFFER_BIT, GL_NEAREST); + } else #endif // defined(USING_GLES2) && defined(ANDROID) - glBlitFramebuffer(0, 0, src->renderWidth, src->renderHeight, 0, 0, dst->renderWidth, dst->renderHeight, GL_DEPTH_BUFFER_BIT, GL_NEAREST); - // If we set dst->depthUpdated here, our optimization above would be pointless. + glBlitFramebuffer(0, 0, src->renderWidth, src->renderHeight, 0, 0, dst->renderWidth, dst->renderHeight, GL_DEPTH_BUFFER_BIT, GL_NEAREST); + // If we set dst->depthUpdated here, our optimization above would be pointless. - glstate.scissorTest.restore(); - } + glstate.scissorTest.restore(); } } }