diff --git a/Source/Core/VideoCommon/Src/PixelShaderManager.cpp b/Source/Core/VideoCommon/Src/PixelShaderManager.cpp index f298629536..deb4646a27 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderManager.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderManager.cpp @@ -31,7 +31,7 @@ static bool s_bZTextureTypeChanged; static bool s_bDepthRangeChanged; static bool s_bFogColorChanged; static bool s_bFogParamChanged; -static float lastDepthRange[4]; // 0 = far z, 1 = far - near, 2 = scale , 3 = offset +static float lastDepthRange[2]; // 0 = far z, 1 = far - near static float lastRGBAfull[2][4][4]; static float lastCustomTexScale[8][2]; static u8 s_nTexDimsChanged; @@ -54,10 +54,6 @@ void PixelShaderManager::Init() lastZBias = 0; s_texturemask = 0; memset(lastRGBAfull, 0, sizeof(lastRGBAfull)); - lastDepthRange[0]=16777216.0f; - lastDepthRange[1]=16777216.0f; - lastDepthRange[2]=16777216.0f; - lastDepthRange[3]=0.0f; Dirty(); } @@ -136,7 +132,7 @@ void PixelShaderManager::SetConstants() if (s_bZBiasChanged || s_bDepthRangeChanged) { //ERROR_LOG("pixel=%x,%x, bias=%x\n", bpmem.zcontrol.pixel_format, bpmem.ztex2.type, lastZBias); - SetPSConstant4f(C_ZBIAS+1, (lastDepthRange[0] + lastDepthRange[3]) / lastDepthRange[2], (lastDepthRange[1] + lastDepthRange[3]) / lastDepthRange[2], 0, (float)( (((int)lastZBias<<8)>>8))/16777215.0f); + SetPSConstant4f(C_ZBIAS+1, lastDepthRange[0] / 16777216.0f, lastDepthRange[1] / 16777216.0f, 0, (float)( (((int)lastZBias<<8)>>8))/16777216.0f); s_bZBiasChanged = s_bDepthRangeChanged = false; } @@ -332,18 +328,18 @@ void PixelShaderManager::SetViewport(float* viewport) void PixelShaderManager::SetZScale(float data) { - if (lastDepthRange[2] != data) + if (lastDepthRange[0] != data) { - lastDepthRange[2] = data; + lastDepthRange[0] = data; s_bDepthRangeChanged = true; } } void PixelShaderManager::SetZOffset(float data) { - if (lastDepthRange[3] != data) + if (lastDepthRange[1] != data) { - lastDepthRange[3] = data; + lastDepthRange[1] = data; s_bDepthRangeChanged = true; } } diff --git a/Source/Core/VideoCommon/Src/VertexShaderManager.cpp b/Source/Core/VideoCommon/Src/VertexShaderManager.cpp index d913d11df3..9331cac345 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderManager.cpp @@ -61,9 +61,7 @@ void VertexShaderManager::Init() Dirty(); memset(&xfregs, 0, sizeof(xfregs)); - memset(xfmem, 0, sizeof(xfmem)); - xfregs.ZScale = 16777216.0f; - xfregs.Zoffset = 0.0f; + memset(xfmem, 0, sizeof(xfmem)); ResetView(); } @@ -454,13 +452,13 @@ void VertexShaderManager::SetViewport(float* _Viewport) void VertexShaderManager::SetZScale(float data) { - xfregs.ZScale = data; + xfregs.rawViewport[5] = data; bViewportChanged = true; } void VertexShaderManager::SetZOffset(float data) { - xfregs.Zoffset = data; + xfregs.rawViewport[2] = data; bViewportChanged = true; } diff --git a/Source/Core/VideoCommon/Src/XFMemory.h b/Source/Core/VideoCommon/Src/XFMemory.h index 0e6529a4d5..c2b3aa2e36 100644 --- a/Source/Core/VideoCommon/Src/XFMemory.h +++ b/Source/Core/VideoCommon/Src/XFMemory.h @@ -227,9 +227,7 @@ struct XFRegisters TexCoordInfo texcoords[8]; bool bEnableDualTexTransform; float rawViewport[6]; - float rawProjection[7]; - float ZScale; - float Zoffset; + float rawProjection[7]; }; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index f97207bc7f..f2393042ba 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -611,8 +611,8 @@ void UpdateViewport() vp.Width = (int)ceil(abs((int)(2 * xfregs.rawViewport[0])) * MValueX); vp.Height = (int)ceil(abs((int)(2 * xfregs.rawViewport[1])) * MValueY); //new depth equation , don't know if is correct but... - vp.MinZ = (xfregs.rawViewport[5] - xfregs.rawViewport[2]+xfregs.Zoffset) / xfregs.ZScale; - vp.MaxZ = (xfregs.rawViewport[5] + xfregs.Zoffset) / xfregs.ZScale; + vp.MinZ = (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f; + vp.MaxZ = xfregs.rawViewport[5] / 16777216.0f; // This seems to happen a lot - the above calc is probably wrong. if (vp.MinZ < 0.0f) vp.MinZ = 0.0f; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index ea4e9c1ae8..41699d3fc8 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -1345,8 +1345,8 @@ void UpdateViewport() int GLWidth = (int)ceil(abs((int)(2 * xfregs.rawViewport[0])) * MValueX); int GLHeight = (int)ceil(abs((int)(2 * xfregs.rawViewport[1])) * MValueY); //new dept equation , don't know if is correct but... - double GLNear = (xfregs.rawViewport[5] - xfregs.rawViewport[2] + xfregs.Zoffset) / xfregs.ZScale; - double GLFar = (xfregs.rawViewport[5] + xfregs.Zoffset) / xfregs.ZScale; + double GLNear = (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f; + double GLFar = xfregs.rawViewport[5] / 16777216.0f; // Update the view port glViewport(GLx, GLy, GLWidth, GLHeight);