From 8e550d957843b1ab897c14eba74124fc6d1d3bd3 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sat, 23 Feb 2013 23:26:58 +0800 Subject: [PATCH 1/5] Set float for glstate.depthRange.set(0.0f, 1.0f) --- GPU/GLES/StateMapping.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index 1c13ac261..8cbb92e98 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -164,11 +164,11 @@ void TransformDrawEngine::ApplyDrawState(int prim) { // Set cull if (gstate.isModeClear()) { - bool colMask = (gstate.clearmode >> 8) & 1; + bool colorMask = (gstate.clearmode >> 8) & 1; bool alphaMask = (gstate.clearmode >> 9) & 1; - bool updateZ = (gstate.clearmode >> 10) & 1; + bool depthMask = (gstate.clearmode >> 10) & 1; - glstate.colorMask.set(colMask, colMask, colMask, alphaMask); + glstate.colorMask.set(colorMask, colorMask, colorMask, alphaMask); glstate.stencilTest.enable(); glstate.stencilOp.set(GL_REPLACE, GL_REPLACE, GL_REPLACE); @@ -176,7 +176,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) { glstate.depthTest.enable(); glstate.depthFunc.set(GL_ALWAYS); - glstate.depthWrite.set(updateZ ? GL_TRUE : GL_FALSE); + glstate.depthWrite.set(depthMask ? GL_TRUE : GL_FALSE); } else { u8 cullMode = gstate.getCullMode(); bool wantCull = !gstate.isModeThrough() && prim != GE_PRIM_RECTANGLES && gstate.isCullEnabled(); @@ -202,7 +202,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) { (gstate.stenciltest >> 16) & 0xFF); // mask glstate.stencilOp.set(stencilOps[gstate.stencilop & 0x7], // stencil fail stencilOps[(gstate.stencilop >> 8) & 0x7], // depth fail - stencilOps[(gstate.stencilop >> 16) & 0x7]); + stencilOps[(gstate.stencilop >> 16) & 0x7]); // depth pass } else { glstate.stencilTest.disable(); } @@ -235,7 +235,7 @@ void TransformDrawEngine::UpdateViewportAndProjection() { if (throughmode) { // No viewport transform here. Let's experiment with using region. glstate.viewport.set((0 + regionX1) * renderWidthFactor, (0 - regionY1) * renderHeightFactor, (regionX2 - regionX1) * renderWidthFactor, (regionY2 - regionY1) * renderHeightFactor); - glstate.depthRange.set(0.0, 1.0); + glstate.depthRange.set(0.0f, 1.0f); } else { // These we can turn into a glViewport call, offset by offsetX and offsetY. Math after. float vpXa = getFloat24(gstate.viewportx1); @@ -268,8 +268,8 @@ void TransformDrawEngine::UpdateViewportAndProjection() { // Sadly, as glViewport takes integers, we will not be able to support sub pixel offsets this way. But meh. // shaderManager_->DirtyUniform(DIRTY_PROJMATRIX); - float zScale = getFloat24(gstate.viewportz1) / 65535.f; - float zOff = getFloat24(gstate.viewportz2) / 65535.f; + float zScale = getFloat24(gstate.viewportz1) / 65535.0f; + float zOff = getFloat24(gstate.viewportz2) / 65535.0f; float depthRangeMin = zOff - zScale; float depthRangeMax = zOff + zScale; glstate.depthRange.set(depthRangeMin, depthRangeMax); From cee27a9db6870a0252863f6f072db8d692b28f27 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sun, 24 Feb 2013 02:05:06 +0800 Subject: [PATCH 2/5] Group GE_CMD_CLUTFORMAT --- GPU/GLES/DisplayListInterpreter.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index 6ec35e8ba..82cafa1b3 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -623,6 +623,7 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) { case GE_CMD_CLUTADDR: case GE_CMD_CLUTADDRUPPER: case GE_CMD_LOADCLUT: + case GE_CMD_CLUTFORMAT: gstate_c.textureChanged = true; // This could be used to "dirty" textures with clut. break; @@ -631,10 +632,6 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) { case GE_CMD_TEXSHADELS: break; - case GE_CMD_CLUTFORMAT: - gstate_c.textureChanged = true; - break; - case GE_CMD_TRANSFERSRC: case GE_CMD_TRANSFERSRCW: case GE_CMD_TRANSFERDST: From b1db09b84fbedb69fee12112a32b4555c960fe29 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sun, 24 Feb 2013 02:17:16 +0800 Subject: [PATCH 3/5] Add missing glClearColor(0,0,0,1); --- GPU/GLES/Framebuffer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 12c78238d..4ed482d1c 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -384,6 +384,7 @@ void FramebufferManager::SetRenderFrameBuffer() { { glstate.depthWrite.set(GL_TRUE); glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glClearColor(0,0,0,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } #endif From 6b22266a00f4310857de9ab8e49adb054d8a9543 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sun, 24 Feb 2013 02:18:18 +0800 Subject: [PATCH 4/5] Add glstate.depthTest.disable(); --- GPU/GLES/StateMapping.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index 8cbb92e98..4590c8020 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -183,9 +183,13 @@ void TransformDrawEngine::ApplyDrawState(int prim) { glstate.cullFace.set(wantCull); glstate.cullFaceMode.set(cullingMode[cullMode]); - glstate.depthTest.set(gstate.isDepthTestEnabled()); - glstate.depthFunc.set(ztests[gstate.getDepthTestFunc()]); - glstate.depthWrite.set(gstate.isDepthWriteEnabled() ? GL_TRUE : GL_FALSE); + if (gstate.isDepthTestEnabled()) { + glstate.depthTest.enable(); + glstate.depthFunc.set(ztests[gstate.getDepthTestFunc()]); + glstate.depthWrite.set(gstate.isDepthWriteEnabled() ? GL_TRUE : GL_FALSE); + } else { + glstate.depthTest.disable(); + } // PSP color/alpha mask is per bit but we can only support per byte. // But let's do that, at least. And let's try a threshold. From 5105c6cd93131ced24ec13042d1581d9532b08f8 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sun, 24 Feb 2013 02:44:52 +0800 Subject: [PATCH 5/5] Add glstate.stencilTest.disable(); --- GPU/GLES/Framebuffer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 4ed482d1c..f4caeaf64 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -421,7 +421,8 @@ void FramebufferManager::CopyDisplayToOutput() { glstate.cullFace.disable(); glstate.depthTest.disable(); glstate.scissorTest.disable(); - + glstate.stencilTest.disable(); + fbo_bind_color_as_texture(vfb->fbo, 0); if (resized_) { @@ -451,6 +452,8 @@ void FramebufferManager::BeginFrame() { glstate.cullFace.disable(); glstate.depthTest.disable(); glstate.blend.disable(); + glstate.scissorTest.disable(); + glstate.stencilTest.disable(); DrawPixels(pspframebuf, displayFormat_, displayStride_); // TODO: restore state? }