From c1db77105612ee21ec87aa390a8cbcc0da9bf2cf Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 1 Nov 2015 00:50:17 +0100 Subject: [PATCH] Fix non-through rectangles --- GPU/Common/SoftwareTransformCommon.cpp | 6 +++++- GPU/GLES/ShaderManager.cpp | 2 +- GPU/GLES/StateMapping.cpp | 4 +--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index 0e78a9a95f..05372d1d3d 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -463,11 +463,15 @@ void SoftwareTransform( numTrans = vertexCount; drawIndexed = true; } else { + bool useBufferedRendering = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE; + if (useBufferedRendering) + ySign = -ySign; + float flippedMatrix[16]; if (!throughmode) { memcpy(&flippedMatrix, gstate.projMatrix, 16 * sizeof(float)); - const bool invertedY = gstate_c.vpHeight < 0; + const bool invertedY = useBufferedRendering ? (gstate_c.vpHeight > 0) : (gstate_c.vpHeight < 0); if (invertedY) { flippedMatrix[5] = -flippedMatrix[5]; flippedMatrix[13] = -flippedMatrix[13]; diff --git a/GPU/GLES/ShaderManager.cpp b/GPU/GLES/ShaderManager.cpp index 191d31f8df..291d005446 100644 --- a/GPU/GLES/ShaderManager.cpp +++ b/GPU/GLES/ShaderManager.cpp @@ -419,7 +419,7 @@ void LinkedShader::UpdateUniforms(u32 vertType) { if (invertedX) { flippedMatrix[0] = -flippedMatrix[0]; flippedMatrix[12] = -flippedMatrix[12]; - } + }\ // In Phantasy Star Portable 2, depth range sometimes goes negative and is clamped by glDepthRange to 0, // causing graphics clipping glitch (issue #1788). This hack modifies the projection matrix to work around it. diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index e92ebd598b..57e2867707 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -793,9 +793,6 @@ void TransformDrawEngine::ApplyDrawState(int prim) { float offsetY = gstate.getOffsetY(); if (throughmode) { - // If the buffer is too large, offset the viewport to the top. - renderY += renderHeight - framebufferManager_->GetTargetHeight() * renderHeightFactor; - // No viewport transform here. Let's experiment with using region. if (useBufferedRendering) { // No flip needed @@ -805,6 +802,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) { (regionX2 - regionX1) * renderWidthFactor, (regionY2 - regionY1) * renderHeightFactor); } else { + renderY += renderHeight - framebufferManager_->GetTargetHeight() * renderHeightFactor; glstate.viewport.set( renderX + displayOffsetX + (0 + regionX1) * renderWidthFactor, renderY + displayOffsetY + (0 - regionY1) * renderHeightFactor,