From 2e7609b0840f69bfa8e6c1527ecd02e86d990312 Mon Sep 17 00:00:00 2001 From: raven02 Date: Tue, 10 Dec 2013 20:48:20 +0800 Subject: [PATCH] Cleanup ClearmodeDepthMask --- GPU/Directx9/StateMappingDX9.cpp | 2 +- GPU/GLES/StateMapping.cpp | 2 +- GPU/GPUState.h | 6 ++++-- GPU/Software/Rasterizer.cpp | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/GPU/Directx9/StateMappingDX9.cpp b/GPU/Directx9/StateMappingDX9.cpp index 20d5463b34..bd50e801f8 100644 --- a/GPU/Directx9/StateMappingDX9.cpp +++ b/GPU/Directx9/StateMappingDX9.cpp @@ -212,7 +212,7 @@ void TransformDrawEngineDX9::ApplyDrawState(int prim) { // Depth Test dxstate.depthTest.enable(); dxstate.depthFunc.set(D3DCMP_ALWAYS); - dxstate.depthWrite.set(gstate.isClearModeDepthWriteEnabled()); + dxstate.depthWrite.set(gstate.isClearModeDepthMask()); // Color Test bool colorMask = (gstate.clearmode >> 8) & 1; diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index d03f468e64..c9045c2735 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -335,7 +335,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) { // Depth Test glstate.depthTest.enable(); glstate.depthFunc.set(GL_ALWAYS); - glstate.depthWrite.set(gstate.isClearModeDepthWriteEnabled() || alwaysDepthWrite ? GL_TRUE : GL_FALSE); + glstate.depthWrite.set(gstate.isClearModeDepthMask() || alwaysDepthWrite ? GL_TRUE : GL_FALSE); // Color Test bool colorMask = gstate.isClearModeColorMask(); diff --git a/GPU/GPUState.h b/GPU/GPUState.h index 9004f51674..3473e864f7 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -213,6 +213,7 @@ struct GPUgstate float tgenMatrix[12]; float boneMatrix[12 * 8]; // Eight bone matrices. + // Framebuffer u32 getFrameBufRawAddress() const { return (fbptr & 0xFFFFFF) | ((fbwidth & 0xFF0000) << 8); } // 0x44000000 is uncached VRAM. u32 getFrameBufAddress() const { return 0x44000000 | getFrameBufRawAddress(); } @@ -229,7 +230,8 @@ struct GPUgstate // Cull bool isCullEnabled() const { return cullfaceEnable & 1; } int getCullMode() const { return cullmode & 1; } - bool isClearModeDepthWriteEnabled() const { return (clearmode&0x400) != 0; } + + // Color Mask bool isClearModeColorMask() const { return (clearmode&0x100) != 0; } bool isClearModeAlphaMask() const { return (clearmode&0x200) != 0; } bool isClearModeDepthMask() const { return (clearmode&0x400) != 0; } @@ -237,9 +239,9 @@ struct GPUgstate // Blend GEBlendSrcFactor getBlendFuncA() const { return (GEBlendSrcFactor)(blend & 0xF); } + GEBlendDstFactor getBlendFuncB() const { return (GEBlendDstFactor)((blend >> 4) & 0xF); } u32 getFixA() const { return blendfixa & 0xFFFFFF; } u32 getFixB() const { return blendfixb & 0xFFFFFF; } - GEBlendDstFactor getBlendFuncB() const { return (GEBlendDstFactor)((blend >> 4) & 0xF); } GEBlendMode getBlendEq() const { return static_cast((blend >> 8) & 0x7); } bool isAlphaBlendEnabled() const { return alphaBlendEnable & 1; } diff --git a/GPU/Software/Rasterizer.cpp b/GPU/Software/Rasterizer.cpp index 0ba65c2532..2c62aa2f53 100644 --- a/GPU/Software/Rasterizer.cpp +++ b/GPU/Software/Rasterizer.cpp @@ -1022,7 +1022,7 @@ void DrawTriangleSlice( if (gstate.isDepthTestEnabled() && gstate.isDepthWriteEnabled()) { SetPixelDepth(p.x, p.y, z); } - } else if (clearMode && gstate.isClearModeDepthWriteEnabled()) { + } else if (clearMode && gstate.isClearModeDepthMask()) { SetPixelDepth(p.x, p.y, z); } @@ -1150,7 +1150,7 @@ void DrawPixel(ScreenCoords pos, Vec3 prim_color_rgb, int prim_color_a, Vec if (gstate.isDepthTestEnabled() && gstate.isDepthWriteEnabled()) { SetPixelDepth(p.x, p.y, z); } - } else if (clearMode && gstate.isClearModeDepthWriteEnabled()) { + } else if (clearMode && gstate.isClearModeDepthMask()) { SetPixelDepth(p.x, p.y, z); }