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

Use custom isnan implementation to avoid HLSL optimizer issues #10090

Merged
merged 1 commit into from Sep 8, 2021

Conversation

Pokechu22
Copy link
Contributor

This adjusts the NaN replacement logic introduced in #9928 to work around the HLSL compiler optimizing away calls to isnan, which caused that functionality to not work with ubershaders on D3D11 and D3D12 (it did work with specialized shaders, despite a warning being logged for both; that warning is also now gone). Note that the D3DCOMPILE_IEEE_STRICTNESS flag did not solve this issue, despite the warning suggesting that it might.

Suggested by @kayru and @jamiehayes.

Pokechu22 referenced this pull request in Pokechu22/dolphin Sep 8, 2021
This adjusts the NaN replacement introduced in dolphin-emu#9928 to work around the HLSL compiler optimizing away calls to isnan, which caused that functionality to not work with ubershaders on D3D11 and D3D12 (it did work with specialized shaders, despite a warning being logged for both; that warning is also now gone).  Note that the `D3DCOMPILE_IEEE_STRICTNESS` flag did not solve this issue, despite the warning suggesting that it might.

Suggested by @kayru and @jamiehayes.
@Pokechu22
Copy link
Contributor Author

jamiehayes mentioned here:

Just to be pedantic, this check will also return true for +/-INF, which may or may not be what you want. If you want separate checks for NaN and INF, may I suggest the following:

bool dolphin_isnan(float f) { return (asint(f) & 0x7FFFFFFF) > 0x7F800000; }
bool dolphin_isfinite(float f) { return (asint(f) & 0x7F800000) != 0x7F800000; }

I'll replace dolphin_isnan with that.

@Pokechu22 Pokechu22 changed the title Use custom isnan implementation to avoid HLSL compiler issues Use custom isnan implementation to avoid HLSL optimizer issues Sep 8, 2021
This adjusts the NaN replacement logic introduced in dolphin-emu#9928 to work around the HLSL compiler optimizing away calls to isnan, which caused that functionality to not work with ubershaders on D3D11 and D3D12 (it did work with specialized shaders, despite a warning being logged for both; that warning is also now gone).  Note that the `D3DCOMPILE_IEEE_STRICTNESS` flag did not solve this issue, despite the warning suggesting that it might.

Suggested by @kayru and @jamiehayes.
@lioncash lioncash merged commit 5538e90 into dolphin-emu:master Sep 8, 2021
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants