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

Optional invariant on gl_FragCoord and gl_PointCoord #3520

Closed

Conversation

grovesNL
Copy link

Fixes #3518

As mentioned in #3518, from the ESSL 3.00 specification the variance of gl_FragCoord and gl_PointCoord is mentioned:

How does this rule apply to the built-in special variables.
Option 1: It should be the same as for varyings. But gl_Position is used internally by the rasterizer as
well as for gl_FragCoord so there may be cases where rasterization is required to be invariant but
gl_FragCoord is not.
Option 2: gl_FragCoord and gl_PointCoord can be qualified as invariance if and only if gl_Position and
gl_PointSize are qualified invariant, respectively.

The same language is in the ESSL 1.00 specification.

There is no resolution, but option 2 is implied by existing ESSL 1.00 tests, e.g.:

passMsg: "vertex shader with invariant gl_Position and fragment shader with variant gl_FragCoord must succeed",

However ESSL 3.00 also states:

RESOLUTION: Only allow invariant declarations on outputs.

So we have a choice to either:

  1. match ESSL 1.00 behavior and loosen that invariant declaration requirement for gl_FragCoord and gl_PointCoord only
  2. require ESSL 3.00 to be more strict than ESSL 1.00 and disallow invariant on gl_FragCoord and gl_PointCoord (this appears to be the current behavior under ANGLE but doesn't appear to be tested explicitly)

This PR chooses the first option to slightly improve compatibility between ESSL 1.00 and ESSL 3.00 if there's no strong reason to prefer one over the other. The tests in this PR currently expect ESSL 3.00 to match ESSL 1.00 behavior for invariant gl_FragCoord and invariant gl_PointCoord, which loosen the "only allow invariant declarations on outputs" rule for those two built-ins. I'd happy to update this PR to use the second option instead if that's preferred though.

@CLAassistant
Copy link

CLAassistant commented Feb 16, 2023

CLA assistant check
All committers have signed the CLA.

@grovesNL grovesNL force-pushed the webgl2-invariance-fragcoord branch from 460e1f8 to 52a9cd0 Compare February 16, 2023 18:10
@grovesNL
Copy link
Author

grovesNL commented Mar 16, 2023

#3518 was resolved to disallow invariant gl_FragCoord and invariant_glPointCoord for shaders using #version 300 es (second option I listed above)

@grovesNL grovesNL closed this Mar 16, 2023
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.

Clarify invariant gl_FragCoord for WebGL2
2 participants