diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index 69b20b5c2..94752b814 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -588,12 +588,14 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) } break; - case GE_CMD_MINZ: - DEBUG_LOG(G3D, "DL MinZ: %i", data); + case GE_CMD_MINZ: + gstate_c.zMin = getFloat24(data) / 65535.f; + DEBUG_LOG(G3D, "DL MinZ: %i", gstate_c.zMin); break; - case GE_CMD_MAXZ: - DEBUG_LOG(G3D, "DL MaxZ: %i", data); + case GE_CMD_MAXZ: + gstate_c.zMax = getFloat24(data) / 65535.f; + DEBUG_LOG(G3D, "DL MaxZ: %i", gstate_c.zMax); break; case GE_CMD_FRAMEBUFPTR: @@ -850,12 +852,18 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) case GE_CMD_VIEWPORTX1: case GE_CMD_VIEWPORTY1: - case GE_CMD_VIEWPORTZ1: case GE_CMD_VIEWPORTX2: case GE_CMD_VIEWPORTY2: - case GE_CMD_VIEWPORTZ2: DEBUG_LOG(G3D,"DL Viewport param %i: %f", cmd-GE_CMD_VIEWPORTX1, getFloat24(data)); break; + case GE_CMD_VIEWPORTZ1: + gstate_c.zScale = getFloat24(data) / 65535.f; + DEBUG_LOG(G3D,"DL Z scale: %f", gstate_c.zScale); + break; + case GE_CMD_VIEWPORTZ2: + gstate_c.zOff = getFloat24(data) / 65535.f; + DEBUG_LOG(G3D,"DL Z pos: %f", gstate_c.zOff); + break; case GE_CMD_LIGHTENABLE0: case GE_CMD_LIGHTENABLE1: case GE_CMD_LIGHTENABLE2: diff --git a/GPU/GLES/TransformPipeline.cpp b/GPU/GLES/TransformPipeline.cpp index 109f76575..9eeb8d25e 100644 --- a/GPU/GLES/TransformPipeline.cpp +++ b/GPU/GLES/TransformPipeline.cpp @@ -557,6 +557,8 @@ void TransformAndDrawPrim(void *verts, void *inds, int prim, int vertexCount, Li glstate.depthFunc.set(ztests[depthTestFunc]); } + glstate.depthRange.set(gstate_c.zOff - gstate_c.zScale, gstate_c.zOff + gstate_c.zScale); + glEnableVertexAttribArray(program->a_position); if (useTexCoord && program->a_texcoord != -1) glEnableVertexAttribArray(program->a_texcoord); if (program->a_color0 != -1) glEnableVertexAttribArray(program->a_color0); diff --git a/GPU/GPUState.h b/GPU/GPUState.h index 058d3887b..4314a641f 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -260,8 +260,9 @@ struct GPUStateCache bool textureChanged; - float uScale,vScale; - float uOff,vOff; + float uScale,vScale,zScale; + float uOff,vOff,zOff; + float zMin, zMax; float lightpos[4][3]; float lightdir[4][3]; float lightatt[4][3];