UberShaderPixel: always set tevcoord, even if the stage has no texture #9833
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
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.xywas never updated (and thustevcoordwas(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_enabledcheck was added because on first glance, it looks liketevcoordis 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 thetevind != 0upreviously always succeeded.This
texture_enabledissue existed since ubershaders were first implemented, but it only became visible when skipping indirect stages where the value is 0 was fixed.