diff --git a/ShaderRecomp/dxc_compiler.cpp b/ShaderRecomp/dxc_compiler.cpp index 4259f8e..ec2265a 100644 --- a/ShaderRecomp/dxc_compiler.cpp +++ b/ShaderRecomp/dxc_compiler.cpp @@ -23,6 +23,7 @@ IDxcBlob* DxcCompiler::compile(const std::string& shaderSource, bool isPixelShad args[argCount++] = isPixelShader ? L"-T ps_6_0" : L"-T vs_6_0"; args[argCount++] = L"-HV 2021"; args[argCount++] = L"-all-resources-bound"; + args[argCount++] = L"-ffinite-math-only"; if (compileSpirv) { diff --git a/ShaderRecomp/shader_common.hlsli b/ShaderRecomp/shader_common.hlsli index 4210d6d..2329fb7 100644 --- a/ShaderRecomp/shader_common.hlsli +++ b/ShaderRecomp/shader_common.hlsli @@ -20,6 +20,7 @@ struct PushConstants #define g_SwappedTexcoords vk::RawBufferLoad(g_PushConstants.SharedConstants + 268) #define g_InputLayoutFlags vk::RawBufferLoad(g_PushConstants.SharedConstants + 272) #define g_EnableGIBicubicFiltering vk::RawBufferLoad(g_PushConstants.SharedConstants + 276) +#define g_ReverseZ vk::RawBufferLoad(g_PushConstants.SharedConstants + 280) #else @@ -29,7 +30,8 @@ struct PushConstants uint g_Booleans : packoffset(c16.z); \ uint g_SwappedTexcoords : packoffset(c16.w); \ uint g_InputLayoutFlags : packoffset(c17.x); \ - bool g_EnableGIBicubicFiltering : packoffset(c17.y) + bool g_EnableGIBicubicFiltering : packoffset(c17.y); \ + bool g_ReverseZ : packoffset(c17.z) #endif diff --git a/ShaderRecomp/shader_recompiler.cpp b/ShaderRecomp/shader_recompiler.cpp index 79b537b..7fbd2df 100644 --- a/ShaderRecomp/shader_recompiler.cpp +++ b/ShaderRecomp/shader_recompiler.cpp @@ -245,14 +245,11 @@ 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 { @@ -277,8 +274,6 @@ void ShaderRecompiler::recompile(const TextureFetchInstruction& instr, bool bicu { case FetchOpcode::TextureFetch: { - if (subtractFromOne) - out += "1.0 - "; out += "tfetch"; break; } @@ -1703,6 +1698,10 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData, const std::string_vi indent(); out += '}'; } + else + { + out += "[flatten] if (g_ReverseZ) oPos.z = oPos.w - oPos.z;"; + } if (simpleControlFlow) {