From b7c037224665ac826490c142b800b11dfc4acf49 Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Fri, 8 Nov 2024 20:16:24 +0300 Subject: [PATCH] Implement reverse Z negation. --- ShaderRecomp/shader_recompiler.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ShaderRecomp/shader_recompiler.cpp b/ShaderRecomp/shader_recompiler.cpp index 7169cc0..79b537b 100644 --- a/ShaderRecomp/shader_recompiler.cpp +++ b/ShaderRecomp/shader_recompiler.cpp @@ -245,11 +245,14 @@ void ShaderRecompiler::recompile(const TextureFetchInstruction& instr, bool bicu std::string constName; const char* constNamePtr = nullptr; + bool subtractFromOne = false; auto findResult = samplers.find(instr.constIndex); if (findResult != samplers.end()) { constNamePtr = findResult->second; + subtractFromOne = strcmp(constNamePtr, "sampZBuffer") == 0 || + strcmp(constNamePtr, "g_DepthSampler") == 0; } else { @@ -273,12 +276,18 @@ void ShaderRecompiler::recompile(const TextureFetchInstruction& instr, bool bicu switch (instr.opcode) { case FetchOpcode::TextureFetch: + { + if (subtractFromOne) + out += "1.0 - "; out += "tfetch"; break; + } case FetchOpcode::GetTextureWeights: + { out += "getWeights"; break; } + } std::string_view dimension; uint32_t componentCount = 0;