-
-
Notifications
You must be signed in to change notification settings - Fork 251
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
nv2a: Make multiplication by 0 match HW behavior. #1045
nv2a: Make multiplication by 0 match HW behavior. #1045
Conversation
Thanks for checking, I would've been very surprised if this fixed the issue in Halo 2, it should really only affect calculations that end up dealing with multiplication of exceptional values (Inf/NaN/etc..) which did not appear to be the case when I briefly looked at #55. |
This fixes the menu issues in american chopper 1 and 2 |
hw/xbox/nv2a/vsh.c
Outdated
// Unfortunately mix() falls victim to the same handling of exceptional | ||
// (inf/NaN) handling as a multiply, so per-component comparisons are used | ||
// to guarantee HW behavior (anything * 0 must == 0). | ||
" vec4 zero_components = abs(sign(src0) * sign(src1));\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there an abs()
here if the only value checked for is 0.0
- is negative zero a case to cater for as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the intent was to cover the potential for a -0, in practice I believe sign
would only return 0.0 so this is probably unnecessarily conservative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A genuine question
Fixes xemu-project#1008 The nv2a returns 0 for anything multiplied by zero, including exceptional values such as Inf and NaN. Desktop GPUs do not enforce this, leading to conditions where NaNs wipe out calculations and lead to erroneous behavior. [Test](https://github.com/abaire/nxdk_vsh_tests/blob/main/src/tests/americasarmyshader.cpp) [HW Results](https://github.com/abaire/nxdk_vsh_tests_golden_results/wiki/Results-AmericasArmyShader)
a342e47
to
c6883ff
Compare
This also affects #1044 using this pr fixes the issue |
This comment was marked as spam.
This comment was marked as spam.
Also seems to fix Breakdown lighting issues https://www.youtube.com/watch?v=LQ5y4sdaA5s |
This comment was marked as spam.
This comment was marked as spam.
this is still incomplete yet since it works only at 1x resolution scale, and we don't know if there might be edge cases where graphics might change behavior like it happened before with a previous "version" of this PR. There's no need to rush if we have to grant stability. |
Fixes #1008
Fixes #1044
The nv2a returns 0 for anything multiplied by zero, including exceptional
values such as Inf and NaN. Desktop GPUs do not enforce this, leading to
conditions where NaNs wipe out calculations and lead to erroneous behavior.
Test
HW Results