diff options
| author | Mai M <mathew1800@gmail.com> | 2021-09-08 03:59:45 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-08 03:59:45 -0400 |
| commit | 5538e90ebf52645bf7389ad6b3e487b6d9e1b82b (patch) | |
| tree | 8745fba2ca0705b0abb12750e0b8e29c5e9de2dd /Source/Core/VideoCommon/ShaderGenCommon.cpp | |
| parent | 282fda1530545ad49c11a6093476be44785b4d14 (diff) | |
| parent | 52c82733f6ba606de5d877c25b95828b73e668bd (diff) | |
Merge pull request #10090 from Pokechu22/d3d-isnan-replacement
Use custom isnan implementation to avoid HLSL optimizer issues
Diffstat (limited to 'Source/Core/VideoCommon/ShaderGenCommon.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/ShaderGenCommon.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/ShaderGenCommon.cpp b/Source/Core/VideoCommon/ShaderGenCommon.cpp index 53cf3edf61..c5cd3ef30d 100644 --- a/Source/Core/VideoCommon/ShaderGenCommon.cpp +++ b/Source/Core/VideoCommon/ShaderGenCommon.cpp @@ -87,6 +87,24 @@ std::string GetDiskShaderCacheFileName(APIType api_type, const char* type, bool return filename; } +void WriteIsNanHeader(ShaderCode& out, APIType api_type) +{ + if (api_type == APIType::D3D) + { + out.Write("bool dolphin_isnan(float f) {{\n" + " // Workaround for the HLSL compiler deciding that isnan can never be true and\n" + " // optimising away the call, even though the value can actually be NaN\n" + " // Just look for the bit pattern that indicates NaN instead\n" + " return (asint(f) & 0x7FFFFFFF) > 0x7F800000;\n" + "}}\n\n"); + // If isfinite is needed, (asint(f) & 0x7F800000) != 0x7F800000 can be used + } + else + { + out.Write("#define dolphin_isnan(f) isnan(f)\n"); + } +} + static void DefineOutputMember(ShaderCode& object, APIType api_type, std::string_view qualifier, std::string_view type, std::string_view name, int var_index, std::string_view semantic = {}, int semantic_index = -1) |
