Fix GL pixel shader debug failure with gl_FrontFacing#3855
Closed
fengT-T wants to merge 1 commit into
Closed
Conversation
Remove the global #define gl_FrontFacing macro that changed its type from bool to uint, causing compile errors in user shader code when gl_FrontFacing was used in ternary/if conditions. Instead, use explicit bool-to-uint conversion at the single assignment site where it's needed (isFrontFace for SSBO output). The inputs.gl_FrontFacing capture already works via the GL reflection's correct bool type — no conversion needed there.
Owner
|
This doesn't make sense to me, can you please explain in more detail exactly what's going wrong? you briefly say "But it's global" about the macro but that's not how macros work, and the input fetcher shader is entirely generated and does not include user shader code. How is that macro affecting any other shaders? |
Author
Owner
|
If you are making the change semi-blind and you don't understand how the code works I think it's best that you file an issue with a bug report, and include a full and reproducible test case. Then I can investigate and ensure the correct fix is made. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.Suggestion cannot be applied right now. Please check back later.


Description
Pixel shader debug fails on any fragment shader that uses
gl_FrontFacingin acondition, like:
Turns out CreateInputFetcher() injects a macro:
which was meant to convert the built-in bool to uint for the SSBO output.
But it's global, so it also changes every use of gl_FrontFacing in the user's
own shader code. The ternary above becomes:
GLSL needs a bool condition there, not uint, so the replacement shader fails
to compile.
Fix
Two lines:
isFrontFace = gl_FrontFacing ? 1u : 0u;
The inputs.gl_FrontFacing assignment is generated from GL reflection data
which already gets the type right — no conversion needed there.
Tested on
AMD RX 9070, RadeonSI driver, Linux, OpenGL 3.3 core.