Skip to content

[wgsl] Integrate the fragment_depth proposal into the spec - #6299

Open
dj2 wants to merge 6 commits into
gpuweb:mainfrom
dj2:frag_depth
Open

[wgsl] Integrate the fragment_depth proposal into the spec#6299
dj2 wants to merge 6 commits into
gpuweb:mainfrom
dj2:frag_depth

Conversation

@dj2

@dj2 dj2 commented Jun 18, 2026

Copy link
Copy Markdown
Member

Update the WGSL spec to include the fragment_depth proposal text.

Closes #5342

@dj2 dj2 self-assigned this Jun 18, 2026
@dj2 dj2 added the wgsl WebGPU Shading Language Issues label Jun 18, 2026
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Previews, as seen when this build job started (ebb7fe5):
WebGPU webgpu.idl | Explainer | Correspondence Reference
WGSL grammar.js | wgsl.lalr.txt

@beaufortfrancois beaufortfrancois left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM with nits

Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs Outdated
@dj2
dj2 requested a review from dneto0 June 18, 2026 18:25

@alan-baker alan-baker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Couple typos

Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs Outdated
@dj2
dj2 requested a review from alan-baker June 18, 2026 18:59
@dj2

dj2 commented Jun 18, 2026

Copy link
Copy Markdown
Member Author

I think the next steps are committee review of the PR and CTS tests before this can land.

Comment thread wgsl/index.bs Outdated
Comment thread wgsl/index.bs Outdated
@dj2
dj2 requested a review from dneto0 June 18, 2026 19:18

@dneto0 dneto0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@dneto0 dneto0 added this to the Milestone 2 milestone Jun 18, 2026

@mwyrzykowski mwyrzykowski left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems fine though it would be nice to understand the benefit across backends. But no need to hold up moving forwards with this

@jimblandy

Copy link
Copy Markdown
Contributor
minutes from WGSL committee meeting 2026-6-23
  • Looking for committee approval for the PR and signoff that we can land PR and CTS when CTS is written
  • DN: Dan has written the spec change, which has been reviewed by the spec editors and approved by Mike W.
  • JB: Still needs Mozilla review. I’ll get to this shortly.
  • DN: Mike asked about the benefit across backends. This allows for early culling of fragments, and therefore theoretically improves performance.
  • MW: Metal isn’t taking advantage of this potential optimization yet, but perhaps adding it to the spec will encourage them to do so.
  • DN: Would you like a note suggesting the optimization?
  • MW: That’d be nice, but not strictly required.
  • JB: I don’t think we can mark this “resolved pending review”, because it’s a larger PR. Hopefully we can close this next meeting.

@dneto0

dneto0 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Re: Mike's request for an idea of benefits.

I got a useful response from gemini by asking "what is conservative depth in graphics rendering".

Excerpting from the reply:


##Common Use Cases
You will typically see conservative depth used in advanced rendering techniques where geometry shape is faked or adjusted inside the pixel shader:

  • Raymarching & Interior Mapping: Simulating complex 3D volumes (like clouds, liquids, or deep windows on a flat wall) inside a simple bounding box.

  • Screen-Space Decals: Mapping bullet holes or posters onto uneven geometry where the depth needs slight adjustment to prevent clipping or z-fighting.

I* mpostors / Billboards: Rendering complex 3D assets (like distant trees or particles) on simple 2D cards while pushing the depth back to correctly match the shape of the real 3D asset.

  • Conservative Rasterization Matching: Used alongside conservative rasterization to make sure pixel depths align properly when calculating things like exact voxel grids or highly accurate shadow maps.

In terms of prevalence/reach:

It became an industry-wide standard alongside the release of DirectX 11 (2009) and OpenGL 4.2 (2011). If you are running hardware released in the last decade or more, it fully supports conservative depth.

It should benefit at least these GPUs:

  • NV since GTX 400
  • AMD GCN and RDNA GPUs
  • Intel Arc and Xe

@jimblandy jimblandy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm sorry, I can't approve this yet:

Comment thread wgsl/index.bs Outdated
dj2 and others added 5 commits July 9, 2026 10:59
Update the WGSL spec to include the fragment_depth proposal text.

Closes gpuweb#5342
Co-authored-by: alan-baker <alanbaker@google.com>

@jimblandy jimblandy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for sorting out the "or equal" question!

I think it's clearer to talk about "returning" the value, since that's the act that matters. The change works fine; see my suggestion below. I think it'd be better not to talk about "writing" here at all; although the reader can figure out what was intended, "writes" are a thing described in the memory model, and that is definitely not what we're doing here.

However, the "write" vs "return" question is editorial; the PR is fine to land either way.

Comment thread wgsl/index.bs
Comment thread wgsl/index.bs Outdated
Co-authored-by: Jim Blandy <jimb@red-bean.com>
@jimblandy

jimblandy commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

When we last discussed this in committee, I was the only person with remaining concerns, and they're addressed now. It's got a full list of approvals, so I think we can merge this without bringing it up in committee again.

@dj2

dj2 commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

I need to write CTS tests I believe before this can land in the spec. I think that's the only missing piece at this point.

@jimblandy jimblandy added this to WGSL Jul 13, 2026
@jimblandy jimblandy moved this to Waiting on CTS in WGSL Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wgsl WebGPU Shading Language Issues

Projects

Status: Waiting on CTS

Development

Successfully merging this pull request may close these issues.

WGSL Proposal for fragment depth (less, greater, any)

6 participants