Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D3D: Restore workaround for erroneous NaN optimization #11603

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Source/Core/VideoCommon/ShaderGenCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,20 @@ std::string GetDiskShaderCacheFileName(APIType api_type, const char* type, bool

void WriteIsNanHeader(ShaderCode& out, APIType api_type)
{
out.Write("#define dolphin_isnan(f) isnan(f)\n");
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,
Expand Down