Skip to content

GPU Web 2025‐10‐21 WGSL

Jim Blandy edited this page Jan 10, 2026 · 2 revisions

Attendance

  • Apple
    • Mike Wyrzykowski
  • Google
    • Alan Baker
    • dan sinclair
    • David Neto
    • James Price
    • Peter McNeeley
    • Ryan Harrison
  • Mozilla
    • Jim Blandy
  • WESL
    • Lee Mighdoll
  • Connor Fitzgerald
  • Mehmet Oguz Derin

Add buffer-view proposal #5400

  • JB: Pull request to add proposal, bias to accept and then continue discussion in issues.
  • AB: A restricted way of reinterpreting buffer data/variable data in a few storage clases (storage, uniform, workgroup). Covers a few feature requests. Slices of arrays, bindless large storage buffer segmented up, in general comments about data reininterpretation. Without going all the way to data reintepretation, this is a nice easy way to get a large portion of the functionality without overwhelming implementations. At heart, opaque type taking optional param and static size needed for byte size. 2 builtin functions bufferView which says how to interpret and bufferLength (like arrayLength). Open questions:
    • If you have unrestricted ptr params, natural to pass as param. Do we want to allow matching relaxing? Larger into Smaller, Sized into unsized. Things to consider, quality of life features.
  • JB: Fundamental operation is buffer full of bytes, and buffer view, give it an offset and a type that you want at that offset and it does bounds checks and gives back pointer to the type that was asked. So, reinterpret_cast, essentially.
  • CF: Admimnstrative question, way to view rendered?
  • AB: Go into file and right click on dots, there is a view file option to show rendered.
  • CF: Looking at implementation details, one note is it sounds like for metal we would need no-alias tags on all of the results, right? Or whatever the alias tag is? Discussed during bindless discussion. User could cast char* both T and U at same time. Violates TBAA? I believe.
  • AB: At the same offset?
  • CF: Yea, take buffer at offset and zero and say it's a T and a U, because you have two objects of different types pointing at same place violates type based alias analysis. MW said this on the bindless issue is we can attach clang may alias to the result and hopefully bypasses TBAA?
  • MW: If you're casting the char* to both types then can use may_alias. If only one or the other, then should not violate the aliasing restrictions.
  • CF: Would have to be an optimization then because we can't statistically guarantee?
  • AB: Thing TBAA is per function? Can add that into the proposal
  • CF: Performance implementation question about u32 emulation. Have heard that this causes problems. Decomposing structs into a pile of u32s causes performance issues. Is this true on Vulkan?
  • AB: This is what we do in CLSPV effectively to support pointer casting we need to break down and we haven't seen big performance degradation. In D3D this is how we do buffers already. Haven't seen every driver but information should be there to combine memory accesses. Have sequential accesses and smart compiler should be able to rebuild. Or smart memory controller. I think.
  • CF: Will be non-blocking but would be good to have data. When you say untyped pointers, do you mean BDA?
  • AB: No, extension came out this year, like LLVM opaque pointers [see links below]. Pointers don’t have type info. All access chains and other instructions provide type information. Allows data reinterpretation on the fly. A clean way of doing HLSL SPIR-V templated load store in a RWByteAddress would be untyped pointers. Would access chain the right number of bytes and load a specific type. Will also say that the same transform we use in Tint is what we use for uniform buffers.
  • JB: The interesting thing about the uniform buffer restriction relaxation PR is that by the time you've done that you have everything done to lift a bunch of restrictions. If paying the price we should make sure users get benefits we're paying for.
  • JB: One concern, the bufferView function takes a u32 offset. Understand we have use cases where we upload a bunch of weights and use block of memory as array of u32s. Then turns out those values are members of a matrix that we want to cooperative multiply. So, later in the same call we produce a new view of the memory as an array of matrices which we then do cooperative matrix functions. Taking that as the starting point, one of the things I think is going on is we're going to have these u32 offsets floating around and even though we do have different interpretations at different times generally when we have a u32 at a offset we're going to know what data we expect that to point too. Sort of have offsets functioning as untyped pointers. Untyped pointers are difficult to work with. Get confused, use for wrong thing. Acknowledging we want reinterpretation, I wonder if this is not a little too untyped. A little too typeless. Granting this is a minimal proposal, wonder if we could have an alternative feature that gives flexibility that this enables but also is less error prone. That is a concern, but the right way to address is a new proposal. Lots of specifics to work out to see if a more typed approach is more bureaucratic, how much machinery, how big a lift for implementations. So many details, hard to compare the two options right now. But wanted to raise that thought.
  • AB: Worth mentioning, that you can only reinterpret from the buffer once. Can't chain reinterpretations. bufferView only takes buffer type and returns non-buffer type. The reason for the offset is folks end up writing giant struct which I don’t think serves purpose. Was middle ground. We could consider if we want to put restrictions on offset if that was a concern. It could be a const-expression and do more static check. Something you could relax, or not. We could consider it in that manor to restrict it more.
  • JB: So, that you can only do it once, not that you can only call bufferView once. You can take a buffer and create a series of views, but it's that only the buffer type allows calling bufferView so you can't derive a view from a view.
  • AB: Relies on the root variable
  • JB: Why is that a good restriction?
  • AB: Otherwise allows casting anywhere. Any pointer in any out. Level of complexity that implementations have to track. Not sure that it provides extra functionality then what this provides but tracking a lot more offsets down to the generated memory access. So, given D3D where eventually you have a load/store on a ByteAddressBuffer which needs an offset. Would have to accumulate all the buffer_views and offsets along the way to get the right offset. Seemed like an unnecessary complication to track that much info instead of just doing it once. If I want to view it another way, do that from the start.
  • JB: Why track? A view just gives a new offset into array of words
  • AB: If chain, you have to condense into a single operand in the byte address method.
  • JB: But isn't that just an offset. It's an array of u32, so just carry around the offset into the starting U32 that you can add more things too. Sounds like saying the instruction gets longer as chain gets deeper but just have a starting offset
  • AB: More stuff to track in the implementation.
  • DS: Think what Jim is saying is you don’t have extra data to track, because you fold the offset in at the point of call. So you only pass one value down
  • AB: I don’t follow. If you have multiple call sites, then you have to track multiple offset expressions coming from different call sites.
  • CF: If you pass a bufferView as an argument, you pass the offset into the function. Assuming unrestricted_pointer_parameters, it's already templated on the target so only need the offset into the target (the base offset).
  • AB: I guess it could work. Seemed unnecessary. Wanted to keep from reinterpreting any data anywhere any time. Thinking if you could call bufferView on pointer to struct in storage then don't necessarily have the same offset. Wanted to avoid having non-opaque input
  • CF: If you allow any other type you now need to make every storage buffer binding this opaque thing that you internally pass back. If it's only this opaque type then you know the buffer has to be opaque.
  • JB: Sounds like good github written discussion. Two different ways to implement and think it's hard to discuss verbally. File issues and put on the agenda.
  • JB: Resolution, accept as proposal.
  • AB: Will re-purpose original issue as feature issue and file sub-issues for what's there. Feel free to file more issues.

Language feature for relaxing uniform address space layout #5347

  • JB: As of last week, generally in favour of this. Left another week for wording. What I saw looked fine to merge. DN and AB are the editors of WGSL so maybe good to have a second editor stamp before we merge but as a committee member, no concerns just editorial quibbles.
  • DN: Comment on PR, does uniform_buffer_standard_layout need hardware support? It does not require hardware support because we can do translation to turn them into a vec4<u32>
  • MW: Followup, why are we adding this as a new language feature whereas if the UA didnt' support you'd get a compilation failure
  • JB: Had same question, we generally provide at the API level we announce what WGSL language features we support so folks can present the right shader without compilation errors. We dont' standardize errors so no portable way to see why shader failed. But unrestricted_pointer extension, if you have it give one sharder, if don't, give another. Only lifting restrictions but still want to announce it.
  • MW: Do we risk creating too much fragmentation by providing too many language features? If i'm making a website how do I reliably fall back to what the UA supports?
  • JB: That's a concern, if UAs are slow at implementing language features then we'll have a problem. Hope is UAs will be fast so divergence is small in practice and get advantages of saying what we support
  • AB: When we added this language feature vs extension we were looking into the future where if there is a language feature someone isn't going to implement it doesn't land. Everyone Will implement them is the plan. There is always the web transient issue of things rolling out makes differences but don't want to make it too hard/unspecified
  • DN: Need a way to condition the conformance tests for the before/after cases.
  • JB: Suggest once DN or an editor other than AB has a chance to look at it we merge.

[subgroup-id] is there an acceptable polyfill on D3D? #5367

  • AB: talked about this and some interesting examples that made us all sway in the direction of just polyfilling. We think there is an acceptable one and that's the best decision. Wrote 2 examples. Seen drivers that re-compile based on UBO. If recompiling could get different subgroup sizes so things seem already unreliable. Strong signal that it's ok to be variance here. Other one was in the end we thought it would be reasonable if the drive changed behavior and so no way to tell if a browser update or driver update. Don't need to agree on the polyfill, it's opaque. So make it available everywhere.
  • JB: Mozilla concern was moving to platform from polyfill would make testing difficult but if the platform ids are also ill-behaved then we aren't doing worse. That concern is addressed, not friendly, but addressed. As aside, maybe implementations make a preference for developers to control to perturb those parameters so testing finds the issue.
  • AB: Something a fuzzer might do.
  • JB: Nice that this makes it a language extension which is great.
  • AB: We would recommend that platform builtins are used. Don't need to require it, but if it's there, use it.
  • JB: Resolved, there is an acceptable polyfill and thus subgroup_id can be a language extension.

[subgroup-id] uniformity of subgroup-id #5368

  • AB: This is the last open issue on the feature. The question of uniformity analysis. Talked and were thinking for uniformity that nothing at the subgroup level is a security concern for being non-uniform. So, the value of the diagnostic is linting / portability stuff. If it's too conservative to match hardware then will turn off anyway, so leaning to wards adding a new scope to the analysis. Works like workgroup scope that catches worst issues for subgroup. Then if you have that existing subgroup stuff could use it as subgroup method returns are subgroup uniform. This ends up being the largest part of the feature. In a way it's tied to subgroup_id and makes sense to split into it's own. Then have subgroup_uniformity as a language feature. It's very small change to add the builtins vs describe all the uniformity changes. Want to split and do the builtins separate. They will interact, but also interact with old stuff and subgroup matrix and just make this it's own language feature as we'll be changing the behaviour of programs becoming more lax and will be changing existing subgroup programs.
  • JB: Like that split as well. Wonder what uniformity we should ascribe to subgroup_id in the absence of subgroup_uniformity.
  • AB: Think it would be non-uniform if you only have workgroup_uniformity.
  • JB: So wouldn't worry about phasing the two so let them vary independently.
  • AB: Yea. We'll probably implement at the same time, but not sure when others will get ot it and see real value in getting builtins out before uniformity. Gating seems unnecessary. The spec for uniformity will take a lot longer to write as well compared to builtins.
  • JB: Next step, separate proposal or PR for subgroup uniformity.
  • AB: If folks are ok with the fuzzy treat it like workgroup when subgroup style then we can go to PR. Will be hard to describe in proposal all the links.
  • JB: Very spec language driven
  • AB: So, split this into separate language feature, with own PR and land independently.
  • JB: So, subgroup_id proposal will be amended to be workgroup_uniform. Then we'll address subgroup_uniformity in a separate PR/proposal.
  • AB: Yes, and I think that's the only outstanding issue. So, we could either wait or see some spec text for buitins as a language feature if we want
  • JB: Think we're ready for PR for the builtin.
  • AB: We'll start working on CTs as well.
  • JB: Fantastic.
  • AB: Policy question, do we wait for CTS or land independently? Can do either. We'll built internally and CTS at the same time. Do we want spec to wait for CTS?
  • JB: Why wait?
  • AB: To make sure there are no gotchas
  • JB: Oh, to see if it can be implemented / used. Lots of intelligence from CTS authors. Given landing in spec has perpetual impact, in that light, maybe draft PR but seen it observed to work in practice once before we specify it.
  • AB: Makes sense to me.

Allow lets of textures and samplers #5389

  • AB: Simple one, quality of life/nice to have. Will write CTS. Lower danger. Allows it as a transient value. Think the spec text is ready to go. We can wait for CTS, will just be validation tests really.
  • JB: Comment from MW on issue and raises some good points.
    • MW: “It would be good that if we have at some point an official 'v2' WGSL version that all of these features are rolled-up in the v2 version and no longer reported to avoid this list from becoming increasingly long.”
  • JB: We are accumulating a bunch of language feature and would be nice to have some kind of way to say you don't need to worry about them anymore and they're just spec now.
  • AB: At risk of sounding strange, could have a language feature that implies other language features.
  • JP: Currently PR is scoped/named for textures/samples. Do we want other handle types like for bindless the bindless array or other handle types in the future?
  • AB: Not sure how to phrase that in the spec. I guess if they're coming later they can assume the language feature and add theemselves to the last? Maybe doesn't work, if they're an enable it's fine? Any type?
  • JP: Any handle type? It's the name, should be lets of handles instead of lets of texture/samplers? Then a future handle type could decide if it allows that
  • AB: So, any type instantiated in the handle address space, or anything that is opaque.
  • JP: Remembering where handle is used, was thinking address space
  • AB: That seems Ok, would be easy to change spec text to. Seems pretty restrictive, so seems safe. Going back to bufferView didn't want a let of buffer. If it's just opaque then answer is different.
  • DN: Should remember when we spec the bindless or arrays of textures to allow in lets. Kind of assume that we would allow from the get-go.
  • DS: For resource_binding don't think you'd want it, but maybe for binding_array?
  • JP: Let is just alias, so it all folds away anywhere. No technical reason why we couldn't. More a question of what users would want to do.
  • AB: Agree mostly. Thinking about buffer_view. A let of a buffer doesn't mean anything and you can't load it. You just couldn't use it anywhere. If you can't use it, why? it could be done. Doesn't make a difference to me. So, could write any type there I suppose. Feel like redesigning on the fly. If we want to go in this direction should wait and decide where we want to go.
  • DN: To confirm, did this fall out of bindless use cases?
  • AB: Yes. Also had other WESL requests where people wanted to be able to assign with conditional assignments.
  • JB: WESL wanted to return
  • AB: Yea didn't want to go that far yet. We couldn't do it in a meaningful way in the spec at the moment. But this seems nice for users. When we get to arrays of things will be nice to have.
  • DS: Seems in general this is the right thing, just with name being lets-of-handle. Gives us the flexibility we want.
  • JB: The default of the name should be inclusion.
  • AB: Do you want to phrased as anything in handle in to let or change feature name?
  • DS: I would just change the feature name and as we add things we can include them as it makes sense.
  • JB: Sounds like there is still some open questions to be worked out. Pretty detailed. General idea of introducing this relaxation has consensus. Need way to say what is covered by this generalization. Let folks think about it and come back in a later meeting.

Clone this wiki locally