-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
PixelShaderGen: Manually wrap negative indirect texture coordinates #3509
Conversation
@JMC47 is this a candidate for 5.0? |
It fixes an undefined behavior bug, but it may lead to unknown regressions ... |
default: | ||
return 0; | ||
} | ||
|
||
return (coord < 0) ? (size - (std::abs(coord) % size)) : (std::abs(coord) % size); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@delroth imo yes, as it brings D3D/OpenGL even on a few graphical bugs. It also makes it a lot easier for me to cleanup the wiki on those two bugs. |
Those two diffs look good to me tho. Did you try writing a HW-Test yet? |
As all of our guesses which returns negative values didn't fix those two fifologs, I think this is the only possible way for the hardware. LGTM when the coding style issues are fixed. |
case ITW_16: | ||
return (coord % (16 << 7)); | ||
return (coord & ((16 << 7)) - 1); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
…ates (x % y) is not defined in GLSL when sign(x) != sign(y). This also has the added benefit of behaving the same as sampler wrapping modes, in regards to negative inputs.
This probably isn't important to merge due to the bug being graphical, but at the same time it'd make F-Zero GX's updated wiki page a lot cleaner if we were able to outright remove the bug instead of noting it for another release cycle. I know that's stupid; but in TFN, that was one of the issues we advertised as fixing |
PixelShaderGen: Manually wrap negative indirect texture coordinates
(x % y) is not defined in GLSL when sign(x) != sign(y).
This also has the added benefit of behaving the same as sampler wrapping modes, in regards to negative inputs.
This was causing raindrops to render incorrectly in F-Zero GX with OGL on windows/intel and mesa/llvmpipe, as well as D3D, due to the previous implementation invoking UB when the coordinates were negative. (see GLSL spec re % operator, D3D seems to take the sign from the LHS)
Marked WIP because we're not sure if this actually matches hardware behavior in regards to how negative coordinates are handled.