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

Fix invariant propagation #2427

Closed
wants to merge 3 commits into from

Conversation

mabaro
Copy link
Contributor

@mabaro mabaro commented Dec 11, 2024

GLSL/SPIRV output seems to work fine (i.e., no problems/glitches detected when using invariant), thus only for MSL output invariant position dependencies are forced into temporaries.

@CLAassistant
Copy link

CLAassistant commented Dec 11, 2024

CLA assistant check
All committers have signed the CLA.

@mabaro
Copy link
Contributor Author

mabaro commented Dec 11, 2024

@HansKristian-Work These bits were missing from my previous pull request in order to make it work for MSL

if (expression_is_forwarded(expr.self) && !expression_suppresses_usage_tracking(expr.self) &&
forced_invariant_temporaries.count(expr.self) == 0)
if( ( forced_invariant_temporaries.count( expr.self ) == 0 ) &&
( backend.force_invariant_temporaries || ( expression_is_forwarded( expr.self ) && !expression_suppresses_usage_tracking( expr.self ) ) ) )
Copy link
Contributor

@HansKristian-Work HansKristian-Work Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what the real difference is here? The only difference I can see is that the previous code has an escape hatch for expression_suppresses_usage_tracking.

Is the fix here that for MSL, we should ignore that? Technically I suppose the suppression could be considered code variance, so I can accept that resolution, but I need to understand what you're trying to fix here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without these forced_invariant_temporaries the invariant propagation (i.e., forcing temporaries) stops before reaching the end of the dependency chain.
The intent of this option is to force the whole dependency chain into temporaries, only for MSL.
GLSL/SPIRV output (i.e, android) has not shown this kind of problems so far, thus I'd leave that codepath unchanged unless you think that would also make sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does #2428 resolve the issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrt #2428:
On a first check on a single shader abusing CompilerGLSL::flags_to_qualifiers_glsl() to output INV tag it propagates nicely until the beginning of main().
Full rebuild seems good as well, no glitches.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming.

@HansKristian-Work
Copy link
Contributor

Please make sure to sign the CLA, otherwise I cannot merge anything.

HansKristian-Work added a commit that referenced this pull request Dec 11, 2024
@HansKristian-Work
Copy link
Contributor

Merged as part of #2428.

@mabaro mabaro deleted the fix_invariant_propagation branch December 11, 2024 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants