Specify immediate data API and WGSL <immediate> address space - #5423
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for immediate data in WebGPU pipelines, allowing small amounts of data to be passed directly to shaders without requiring buffer bindings. This is useful for frequently changing small data like transformation matrices.
- Introduces
maxImmediateSizelimit (64 bytes) for immediate data ranges - Adds
immediateSizeparameter to pipeline layouts and validation for immediate data usage - Implements
setImmediateData()method for setting immediate data in encoders
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Previews, as seen when this build job started (f2fc3f3): |
minutes from API committee meeting 2025-10-29
|
alan-baker
left a comment
There was a problem hiding this comment.
Copying my other requests from #5424
There ought to be either a language feature or enable extension as part of this specification.
Additionally, there need to be some updates to the Resource Interface and Resource Layout Compatibility sections in the Entry Points chapter.
dneto0
left a comment
There was a problem hiding this comment.
I agree with other review comments. Once those are resolved I'm happy with this landing.
Would prefer not using an enable extension since this is supported or can be easily emulated by all core devices (and compat too I think). I.e., WGSL language extension would be my preference. |
|
I can't make the meeting today but this is 👍 from Apple's side. Metal doesn't have the concept of immediates and there was some discussion about this taking up a buffer slot. If the UA is using argument buffers then it would not, since a slot is already needed for dynamic data and you can reuse / share the same slot for immediates. Basically any transient data (dynamic offsets, immediates, other constants) can be passed in a single call to set[Vertex/Fragment]Bytes. But we are also fine with this taking up a slot. This allows UAs to not have to migrate to ABs for everything for their Metal backends. I suppose its a tradeoff but either way is 👍 from Apple's side given our AB implementation is not really impacted either way. |
minutes from WGSL committee meeting 2025-11-4
|
@amaiorano is implementing this speculatively in Dawn, we are going with |
That works, but I'd also be ok with just |
|
@jimblandy Would you mind to do a final review for this? |
|
@jimblandy would you mind to take a look again on this spec PR? |
|
hi, @jimblandy , will you take a look? |
|
I'd like to give this one more look over, but I can't get to it until tomorrow (Thursday). |
|
Hi, @jimblandy any chance to give this PR a look? |
|
Hi, @jimblandy any chance to give this PR a look? |
jimblandy
left a comment
There was a problem hiding this comment.
Aside from the editorial comment I left above, this looks great. Thank you, @shaoboyan091 !
|
Thanks all for your reviewing. I'll address all remain comments and land this. |
- Remove extra space in [[immediate_slots_set]] dfn name - Move pipeline layout/size lookups inside the validusage block to match the pattern in Validate encoder bind groups, so the null check on pipeline appears before its layout is dereferenced
|
I'll land this if no objections :) |
This PR adds missing the `setImmediates` method as described in gpuweb/gpuweb#5423
GPU Web WG 2026-05-06 Atlantic-time
|
Landing the immediate data API specification into the WebGPU spec. Ref to proposal: immediate-data.md.