diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 3b4f709de8..96c457ae1e 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -1739,7 +1739,6 @@ void GPUCommon::Execute_BoneMtxNum(u32 op, u32 diff) { const int end = 12 * 8 - (op & 0x7F); int i = 0; - // TODO: Validate what should happen when explicitly setting num to 96 or higher. bool fastLoad = !debugRecording_ && end > 0; if (currentList->pc < currentList->stall && currentList->pc + end * 4 >= currentList->stall) { fastLoad = false; diff --git a/GPU/Vulkan/FragmentShaderGeneratorVulkan.cpp b/GPU/Vulkan/FragmentShaderGeneratorVulkan.cpp index 10faeb23f4..bc0dc0f633 100644 --- a/GPU/Vulkan/FragmentShaderGeneratorVulkan.cpp +++ b/GPU/Vulkan/FragmentShaderGeneratorVulkan.cpp @@ -456,8 +456,20 @@ bool GenerateVulkanGLSLFragmentShader(const FShaderID &id, char *buffer) { } if (gstate_c.Supports(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT)) { + const double scale = DepthSliceFactor() * 65535.0; + WRITE(p, " highp float z = gl_FragCoord.z;\n"); - WRITE(p, " z = (1.0/65535.0) * floor(z * 65535.0);\n"); + if (gstate_c.Supports(GPU_SUPPORTS_ACCURATE_DEPTH)) { + // We center the depth with an offset, but only its fraction matters. + // When (DepthSliceFactor() - 1) is odd, it will be 0.5, otherwise 0. + if (((int)(DepthSliceFactor() - 1.0f) & 1) == 1) { + WRITE(p, " z = (floor((z * %f) - (1.0 / 2.0)) + (1.0 / 2.0)) * (1.0 / %f);\n", scale, scale); + } else { + WRITE(p, " z = floor(z * %f) * (1.0 / %f);\n", scale, scale); + } + } else { + WRITE(p, " z = (1.0/65535.0) * floor(z * 65535.0);\n"); + } WRITE(p, " gl_FragDepth = z;\n"); } diff --git a/headless/Headless.cpp b/headless/Headless.cpp index e18e326710..661211d1d0 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -373,6 +373,7 @@ int main(int argc, const char* argv[]) g_Config.bVertexDecoderJit = true; g_Config.bBlockTransferGPU = true; g_Config.iSplineBezierQuality = 2; + g_Config.bHighQualityDepth = true; #ifdef _WIN32 InitSysDirectories();