diff --git a/GPU/Common/GPUStateUtils.cpp b/GPU/Common/GPUStateUtils.cpp index c49a7ea8fd..d624d4eb08 100644 --- a/GPU/Common/GPUStateUtils.cpp +++ b/GPU/Common/GPUStateUtils.cpp @@ -504,6 +504,10 @@ float ToScaledDepth(u16 z) { return z * (1.0f / depthSliceFactor) * (1.0f / 65535.0f) + (0.5f / depthSliceFactor); } +float FromScaledDepth(float z) { + return (z - (0.5f / depthSliceFactor)) * depthSliceFactor * 65535.0f; +} + float ToScaledDepthFromInteger(float z) { return z * (1.0f / depthSliceFactor) * (1.0f / 65535.0f) + (0.5f / depthSliceFactor); } diff --git a/GPU/Common/GPUStateUtils.h b/GPU/Common/GPUStateUtils.h index dffb2e4bc3..210573164b 100644 --- a/GPU/Common/GPUStateUtils.h +++ b/GPU/Common/GPUStateUtils.h @@ -67,6 +67,7 @@ struct ViewportAndScissor { }; void ConvertViewportAndScissor(bool useBufferedRendering, float renderWidth, float renderHeight, int bufferWidth, int bufferHeight, ViewportAndScissor &out); float ToScaledDepth(u16 z); +float FromScaledDepth(float z); // These are common to all modern APIs and can be easily converted with a lookup table. enum class BlendFactor : uint8_t { diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index 836e9f4b21..d8bf28efd6 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -33,6 +33,7 @@ #include "Windows/main.h" #include "GPU/GPUInterface.h" #include "GPU/Common/GPUDebugInterface.h" +#include "GPU/Common/GPUStateUtils.h" #include "GPU/GPUState.h" #include "GPU/Debugger/Breakpoints.h" #include "GPU/Debugger/Stepping.h" @@ -398,7 +399,7 @@ void CGEDebugger::DescribePixel(u32 pix, GPUDebugBufferFormat fmt, int x, int y, case GPU_DBG_FORMAT_24BIT_8X: // These are only ever going to be depth values, so let's also show scaled to 16 bit. - _snwprintf(desc, 256, L"%d,%d: %d / %f / %f", x, y, pix & 0x00FFFFFF, (pix & 0x00FFFFFF) * (1.0f / 16777215.0f), (pix & 0x00FFFFFF) * (65535.0f / 16777215.0f)); + _snwprintf(desc, 256, L"%d,%d: %d / %f / %f", x, y, pix & 0x00FFFFFF, (pix & 0x00FFFFFF) * (1.0f / 16777215.0f), FromScaledDepth((pix & 0x00FFFFFF) * (1.0f / 16777215.0f))); break; case GPU_DBG_FORMAT_24X_8BIT: @@ -406,7 +407,7 @@ void CGEDebugger::DescribePixel(u32 pix, GPUDebugBufferFormat fmt, int x, int y, break; case GPU_DBG_FORMAT_FLOAT: - _snwprintf(desc, 256, L"%d,%d: %f / %f", x, y, *(float *)&pix, *(float *)&pix * 65535.0f); + _snwprintf(desc, 256, L"%d,%d: %f / %f", x, y, *(float *)&pix, FromScaledDepth(*(float *)&pix)); break; default: