Merge pull request #11603 from Dentomologist/fix_d3d_nan_regression

D3D: Restore workaround for erroneous NaN optimization
This commit is contained in:
OatmealDome 2023-02-26 02:00:25 -05:00 committed by GitHub
commit c0d0a04b8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -99,9 +99,22 @@ std::string GetDiskShaderCacheFileName(APIType api_type, const char* type, bool
}
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 (floatBitsToInt(f) & 0x7FFFFFFF) > 0x7F800000;\n"
"}}\n\n");
// If isfinite is needed, (floatBitsToInt(f) & 0x7F800000) != 0x7F800000 can be used
}
else
{
out.Write("#define dolphin_isnan(f) isnan(f)\n");
}
}
void WriteBitfieldExtractHeader(ShaderCode& out, APIType api_type,
const ShaderHostConfig& host_config)