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

glsl-out: invariant gl_FragCoord might not be allowed under WebGL2 #4481

Open
grovesNL opened this issue Feb 15, 2023 · 5 comments · Fixed by gfx-rs/naga#2254
Open

glsl-out: invariant gl_FragCoord might not be allowed under WebGL2 #4481

grovesNL opened this issue Feb 15, 2023 · 5 comments · Fixed by gfx-rs/naga#2254
Labels
area: naga back-end Outputs of naga shader conversion lang: GLSL OpenGL Shading Language naga Shader Translator type: bug Something isn't working

Comments

@grovesNL
Copy link
Collaborator

glsl-out emits invariant gl_FragCoord because of invariant position (e.g., for wgsl-in this might look like @invariant @builtin(position) position), but this doesn't compile under WebGL2/ANGLE.

I opened KhronosGroup/WebGL#3518 to try to clarify the intended behavior because this seems to be allowed for WebGL1.

We might want to consider skipping invariant for gl_FragCoord for now until the intended WebGL2 behavior is clarified.

@grovesNL grovesNL added kind: bug area: naga back-end Outputs of naga shader conversion lang: GLSL OpenGL Shading Language labels Feb 15, 2023
@teoxoy
Copy link
Member

teoxoy commented Feb 16, 2023

Hmm, so it sounds like the GLSL ES 3.0 spec is ambiguous here.

@grovesNL
Copy link
Collaborator Author

Right, the GLSL ES 3.00 spec mentions that outputs cannot have invariant (ES 1 doesn't have this restriction)

RESOLUTION: Only allow invariant declarations on outputs.

but later mentions gl_FragCoord specifically when talking about built-ins

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.

which implies that the variance for gl_FragCoord could actually vary (pardon the pun!)

@teoxoy
Copy link
Member

teoxoy commented Feb 16, 2023

Reopening to track the spec disambiguation.

@teoxoy teoxoy reopened this Feb 16, 2023
Wumpf referenced this issue in rerun-io/rerun Mar 9, 2023
* outline example setup

* new outline mask phase, outline renderer skeleton

* outline processor setup

* basic mesh mask drawing

* outline mask has now its own depth buffer

* add outline mask to meshinstance, unused so far

* scaffolding for jumpflooding in outlines

* potentially working jumpflooding init shader

* basically working jumpflooding, hardcoded red outlines for the moment

* wip

* rebase fixup

* renames

* A lot better anti-aliasing handlign and documentation thereof

* don't render meshes that don't participate in outlines during outline phase

* configurable mesh outlines. demonstrate internal outlines in example

* outline configurability, blend both outline a and b

* Fix crash in write belt

* use texture sampler for jumpflooding to fix buggy outline point at top left

* simplify shader a bit by using pixel coordinates all the way
as opposed to texel coordinates

* use inf() to mark-up invalid positions

* outline documentation

* fix thickness/radius confusion

* cleanup code in outlines.rs

* fix typos

* Fix documentation in outlines.rs

* fix release mode compilation issue

* Workaround for WebGL shader issue
See
https://github.com/gfx-rs/naga/issues/2252

* Provide non-msaa version of outline renderer for WebGL compatibility

* hackish pause/unpause to simplify visualizing everything that goes on in there

* pr feedback, fix demo timing

* bump ci?

---------

Co-authored-by: Clement Rey <cr.rey.clement@gmail.com>
@grovesNL
Copy link
Collaborator Author

KhronosGroup/WebGL#3518 confirmed that invariant gl_FragCoord is not allowed

@grovesNL
Copy link
Collaborator Author

Actually should probably leave this open so we can remove the note

@grovesNL grovesNL reopened this Mar 16, 2023
@cwfitzgerald cwfitzgerald added the naga Shader Translator label Oct 25, 2023
@cwfitzgerald cwfitzgerald transferred this issue from gfx-rs/naga Oct 25, 2023
@cwfitzgerald cwfitzgerald added type: bug Something isn't working and removed kind: bug labels Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga back-end Outputs of naga shader conversion lang: GLSL OpenGL Shading Language naga Shader Translator type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants