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

UberShaderPixel: always set tevcoord, even if the stage has no texture #9833

Merged
merged 1 commit into from Jun 23, 2021

Conversation

Pokechu22
Copy link
Contributor

This fixes NES game graphics when UberShaders are in use.

For performance reasons, ubershaders are supposed to skip some of the indirect texture logic when the indirect functionality isn't enabled, since an indirect configuration that's all zeros does nothing. However, prior to e1d45e9 (part of #9651), that wasn't actually done and it was only skipped when the indirect functionality referred to an indirect stage index that was greater than the number of enabled ones (despite there being a comment claiming it also could be disabled when set to zero).

Super Mario Bros. has 3 TEV stages and 2 indirect stages enabled, and uses indirect logic in TEV stage 1 (the indirect logic for TEV stages 0 and 2 are set to 0). TEV stage 0 doesn't have any texture enabled, but TEV stage 1 uses its texture coordinates for add-to-previous coordinate functionality. Since the more detailed indirect texture logic for stage 0 was now being skipped, the else if (texture_enabled) code was hit, and and since there was no texture, tevcoord.xy was never updated (and thus tevcoord was (0, 0, 0)). This meant that stage 1 used the wrong texture coordinates since it the values from the previous stage were wrong. (This is based on object 1 in the nes-vc test case (dff)).

I'm guessing the texture_enabled check was added because on first glance, it looks like tevcoord is only used when the texture is enabled on that stage (immediately below), and then that assumption being violated by add-to-previous was never noticed because the tevind != 0u previously always succeeded.

This texture_enabled issue existed since ubershaders were first implemented, but it only became visible when skipping indirect stages where the value is 0 was fixed.

This fixes NES game graphics when UberShaders are in use.
@dolphin-emu-bot
Copy link
Contributor

FifoCI detected that this change impacts graphical rendering. Here are the behavior differences detected by the system:

  • nes-vc on uberogl-lin-radeon: diff

automated-fifoci-reporter

@leoetlino leoetlino merged commit a632a6a into dolphin-emu:master Jun 23, 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