Repository navigation
GPU Web 2025‐09‐30 WGSL
🪑 Chair: JB
⌨️🙏 Scribes: DS
🗺 Location: Google Meet
⌚ Time: Tuesday 8-9pm Paris, 2-3pm Toronto, 11am-noon Americas/Los_Angeles
WIP, the list of all the people invited to the meeting. In bold, the people that have been seen in the meeting:
- Apple
- Mike Wyrzykowski
- Google
- Alan Baker
- Antonio Maiorano
- dan sinclair
- David Neto
- James Price
- Peter McNeeley
- Ryan Harrison
- Microsoft
- Rafael Cintron
- Mozilla
- Jim Blandy
- WESL
- Lee Mighdoll
- Stefan Brandmair (Stefnotch)
- Connor Fitzgerald
- Kelsey Gilbert
- Mehmet Oguz Derin
Handling of NaNs with Clamp (max/min) #5192
- JB: been proposed to have a full IEEE754 compliance feature but doesn't seem something were super interested in yet, so can't wait for that to happen before proper spec of behaviour. Had pr 5197 which deleted specific min/max language and clamp about how nans behave. Means the definition falls back on spec broad language about float handling. We have a paragraph that says implementations may assume overflow infinity /nan are not present during shader execution, so allowed to return indeterminate value. I think that gives liberty to use the spir-v fmin/fmax/fclamp as it returns one of their operands. The WGSL language is looser then that. We also have nan is never ==, < or > any other value. Such comparison returns false. The definition of fmin/fmax says if this is less then that, return this, otherwise return that one. It wasn' clear if that prose language was a reference to the nan comparison thing or if it was covered by the broader implementations may assume paragraph. Think we do have, even with the removals in 5197, have an ambiguity in spec where it isnt' clear if min/max returns something specific or does whatever they want. Feel that graphics devs dont' care about nan handling, they want something fast. So want WGSL to be loose enough to allow specs to do the fastest thing that isn't UB. Want to make clear that an implementation can use the underlying platform functions.
- MW: +1. Don't think we should have that much nan language in spec. Spec says fast math is allowed, so hard to prove that something proveably is nan under ieee rules but may not be treated as such under shader execution time.
- JB: This almost seems editorial. Just need to clarify that fmin/fmax/fclamp are governed by the if it's a nan do what you want rule.
- PM: Only question, do we want the ability to sanitize values. Understand we want everything to be fast, but do we want the capacity to sanitize a nan on the gpu.
- JB: What does sanitize mean
- PM: Any arbitrary value, and if it's a nan you want to clamp to 0-1. So, sanitize it. In the original question. Tint switched from nclamp to fclamp. To the performant ones not the nan ones. But sanitize is a useful utility
- DN: That's not where we are now.
- PM: Yea, this is a future milestone question.
- DN: I think this issue is it would be nice if we could have a function that did a specific well defined thing that is tighter then the spec to allow a nan to return the other one. Feature we do not have and are not enforcing. It would be nice to have at a future date when we have more nan stuff. Also interested that there is an ambiguity that is confusing in the spec and want to fix that.
- JB: So, resolution is editors draft PR to clarify min/max/clamp and in a future date allow sanitization because the new language does not provide that
- DN: Yea, and it will require implementations to do things they don't do now. They may need to turn a knob to enforce
- JB: So, throw this to the editors and file a separate issue for sanitization?
- DN: Vulkan separates a feature for inf, nan and sized 0 as a single feature and this would fit that bundle. If we have an issue for that then would lump there. We'll create an issue and lump together.
- AB: The first attempt in Vulkan of that feature is broken, there is a newer better version
- DN: FloatControls2
- AB: Yes, the original didn't work on enough instructions.
- JB: A beautiful issue with a nice proposal that is nicely written that explores the platform support nicely and lays everything out. I think we're quite a ways along in the process. Did want to confirm with the committee that we want to take the vec2<u32> approach. It looks as if every platform that has 64-bit atomic support also has 64-bit integer support. Would be a more direct representation if we had 64-bit integers and then allow that as an atomic type. Understand that's a bigger change and adding a whole lot of work for this feature but it is a little odd so wanted to make sure that the committee thought that was OK.
- AB: Do you want it to just be the atomics?
- JB: Think it would be cleaner with 64-bit integers and then atomics
- PM: Would be nice to get feature in so we can see usage before doing 64-bit integers. This is very limited with max/min, no readback, no value. Not sure when we'll get a full suite of 64-bit atomics, don't think Apple supports this. So this is a specialized thing. So should it be more generic over time, not sure. This lets us do nanite. THe fact it's uvec2, they're probably going to use as 2 components not a single number
- JB: TO be clear, MOzilla do not object. Just want folks to be cognizant.
- CF: Do we know if all 64-bit atomic platforms support 64-bit integers in shaders?
- JB: Looked to be the case.
- DS: This form, vec2u doesn’t interfere with a “real” 64-bit atomic, if we get that in the future.
- DN: Having return vs not having return would be weird if we had a real one that returned the max vs this one which is just set max.
- PM: Can bikeshed the feature/function name
storeMax,mutateMax - CF: Yea, might consider renaming it.
- JB: Yea when it works on the 2
uintswhat is the max between the two. So, next step is to have a detailed discussion about proposal text. Folks give a read over, and next week we can go through any comments and then merge? - DN: As proposal or PR?
- PM: Was thinking land proposal, then edit proposal, then prototype. Then if we like result we can push for spec.
- JB: Proposal looks mature, so we could just take it?
- DN: Internally we'd like a proposal landed somewhere.
- JB: Mozilla is fine merging this as a proposal. Mature as others we've taken.
- MW: No concerns from Apple side.
- JB: Resolve to take as a proposal.
Reintroduce source maps #4844
- JB: The original issue of 4808 has a nice explanation of why we removed the original and suggests instead we should define an official comment syntax for referring to source maps in WGSL. Got lots of activity in issue in the last 30 minutes. Looks pretty detailed. Given this is active on github would it make sense to continue on github and set aside for htis week or valuable to talk about live? I haven't read all the github and feel like I should be on top of it before discussing
- CF: Is there a brief summary as to why they were removed in the first place.
- JB: Problem was that the property specified was a source map. So to present the module to WebGPU at all, if it succeeded or failed, you had to fetch the resource to make it available at all. In practice you want folks to write synchronous code to create shader modules and not require the extra fetch operation. In the 99% case you don't want the source map anyway so it's a waste to do the fetch which you don't need. So, the core of the concern was to make sure the source map was fetched async post-facto when you wanted to present an error or needed by tooling. Only at that point do you do the fetch. Gregg also pointed to the JS precedent (and the src map spec itself) which provides a means for JS/CSS/<something else> to incorporate a comment which points to a srcmap url. If you want to put it in a comment here is how you do it. Then provides rules (where things get funny), specifies multiple methods for extracting srcmap urls from src text. With a parser that treats strings/comments differently, or could be a regex which just grabs the last thing looking like a url. So the srcmap spec recognizes the ambiguity and lays out a defined procedure for deciding which url to get out of the ting. Then it says if there are multiple ways that yield a result then they must yield the same result (must be un-ambiguous srcmap url). That's what Gregg would like us to do. One advantage is it allows lazy loading, also it means that if hte text you got, the actual WGSL being presented to WGSL which was derived from one thing which was in turn generated from a transpilation step then allow comments in the src files makes that kind of thing work transparently. Tooling in browser says the WGSL has a srcmap link and fetches something else, and if that is a wgsl doc and that can have a srcmap and it cascades the loading. Since we know folks do generate shaders from deep pipelines then it seems like a good thing to support. The srcmap spec language is groose. We could do something better then that. I think that's where things stand. Had an idea but it doesn't support nested loading scenario.
- LM: For WESL we're using a hack that sort of does srcmaps on the outside but ends up being awkward user experience at best. Not portable, in one implementation and works in chrome/ff but not safair. Different library would have a different solution and will be messy until it's a bit more integrated.
- CF: The reason i'm interested so that as long as i have a literal srcmap that i can stuff in the wgsl such that the browser can read it, it's not a resource on the server, it's a data string, some way to get it in such that the browser can read it that's fine.
- JB: Folks usually use data urls to stuff real src maps in.
- KG: The thing that always worried me about url maps is the embeddability and programmatic generation aspect. The combinatorial issues that come up. While you can use data or blob url it does require generating those when you issue the shader for compilation and you can't do it on unwind when you need to as a lazy thing. Jumps out as a concern that yo'd want to do it more lazy
- JB: THere was a proposal to have createShaderModule take a function which would produce the source map.
- LM: One more bit of motivation, as we look at more advanced features and transpilation it becomes more and more important. We're trying ot stay close but that's going to break when we do fancier stuff.
- JB: Think we should aim, generally, that if someone is using WESL to generate shaders then they should be able to get errors in console and in devtools that shows the written WESL. Our mission is to provide the simplest infrastructure to make that happen. Think we're agreed on the end effect we want.
Cooperative matrix #4195
- JB: Alan provided a detailed presentation at the F2F and there is a link to a detailed design doc. (subgroup_matrix.md file in dawn features). That includes a section at teh end called proposal which talks about WGSL stuff and defines an extension (chromium_experimental_subgroup_matrix). This seems like the intended audience is internal google which talks about chromium. Thing I want to talk about is the next steps. David posted comment in March on status update. Looks like a lot of progress. How would we update for the present.
- AB: Thought was to do a chromium proposal and clean up to do a WGSL proposal with what we expect the HLSL changes to be or do we make
subgroup_ida language feature or an enable. HLSL will get it in a future version but we could emulate now if we wanted. Not sure if it's a good idea. Every platform has the ability to have that builtin already. Would look like the chromium one minus thechromium_experimentalnaming. Can bikeshed the names. If folks are happy we can do an enable, or an enable and a separate language extension if we want to have the builtin. - JB: The builtin is valuable for a lot of reasons
- AB: Agreed
- JB: Seems like it would make sense to break
subgroup_idout to a proposal which would be an extension because it isn't available everywhere - AB: Depends how you would do it. You could emulate it with an atomic; might provide a different value from what a real subgroup_id feature would give. If you update your system and get a new D3D that supported it natively then the resulting value might change. We haven’t come to consensus internally on this. If you’re willing to allow that wobblineness then you can make it a language feature and pretend it’s available on all hardware.
- JB: That's polyfilled on systems which don't support natively
- AB: Which is just Windows.
- CF: So this would be a workgroup atomic?
- AB: Yea it would have to be.
- RC: If we did emulate on D3D windows your answer didn't give me a lot of hope the emulation would give the same result as the real implementation. That's my hesitation.
- AB: That's my hesitation as well because you're using the atomic. Can't guarantee the order the id is generated in. No the most satisfying but was floated as an idea by the HLSL idea at the f2f.
- CF: If this is emulatable by an atomic, couldn’t a user emulate it as well if they really needed to, and were willing to take that compromise (of using a workgroup atomic).
- AB: that's effectively how the cts tests work. We create a value in place of this value. THe difference is if we emulate you get the real value if available and emulated on one platform
- JB: Making the user do the emulation means it's ore controlled for them .They can choose what implementation they get and decide to choose to transition. Means implementations only provide it when they offer the real platform feature. This feels like even if we offer subgroup_id as a device conditional feature it is still valuable. It's still going to be useful and that people can wrap in something and provide portability.
- DS: Would that require some kind of @if or if constexpr. You’d need two separate shaders, or “don’t compile this part” conditional on the feature.
- JP: in terms of user emulation, they are already doing it and they're doing it incorrectly. Not doing atomics, assuming linear layout and it mostly works until it doesn't. If we want to push emulation to them then requires education on devices that don't do this as they expected. So advantage of us doing it is giving something we know will work.
- CF: Generally quite against emulation particularly in cases where it's hardware information and it just doesn't exist. Generally of the opinion we should expose our constraints directly and not try to paper over too much. Sympathetic to users doing this wrong. Emulation is a cost that every user using this would have to bear and wouldn't know they were bearing.
- RC: Asked Jesse about emulation and said yes it would give you an id but he said the values you get out may not relate to the other values you get. The native wave index would probably correlate to sb_group_id. Emulated doesn't necessarily correlate. We'll give an id but not not relate. Depends on shader author assumptions on how it relates to there things.
- JB: Right so you could emulate it but clarifies you will get different results
- RC: Just that it may not be correlated when a native would.
- PM: In emulation we need to use local storage which may add complexity as we don't use local storage for anything else that I'm aware of.
- JB: Might effect limits as we're consuming space
- PM: at least one u32
- AB: The Naga implementation limits to 1d workgroups. The case where it does work out to emulate well. If you have a linear you probably only assign one way. Gets complicated with 2 and 3 as hardware does everything. If you stay in the linear box things work out. Once you get into upper dimensions then hardware could do things differently depending on how you access memory. IDs could be set to help with memory collessing.
- JB: Lots of interesting discussion even if we break subgroup_id out. So, next steps, split subgroup_id to own proposal which seems limited and we can maybe just take as a PR.
- AB: The way we do experimental in chrome for metal uses a feature which really didn't extend in metal 4. One is going to have broader implementation then the other. Not sure if MW has feedback from metal. Seems like going forward metal uses different objects so how forward looking do we want to be for this feature. We were planning on pushing out with simdgroup matrix. newer stuff is the performance primitives and tensor objects.
- MW: Can look into that. Anything with metal4 won't work on intel macs.
- AB: So, 2 proposals. 1 for subgroup_matrix and one for subgroup_id and we can talk about the enable vs language feature for subgroup_id and subgroup_matrix assumes subgroup_id
- DN: We'll write up PRs for proposals to discuss and then prospectively land them after agree on direction.
- JB: SGTM
-
JimB: In the F2F discussion, we indicated interest in pursuing these topics next. However, we have an existing Milestone 2 with 27 WGSL issues. There is some overlap. JimB’s suggestions:
- Prioritize the F2F list, making it our new Milestone 2.
- Declare Milestone 1 complete, and add the three remaining Milestone 1 WGSL issues to Milestone 2:
- Put off the old Milestone 2 issues to a new Milestone 3.
- Individual issues of interest can certainly be promoted to M2. But if an issue has no enthusiastic advocate, and it’s not a spec fix, then I’d say it doesn’t belong in M2.
- The current “Milestone 3+” becomes “Milestone 4+”.
-
DavidN: Sounds good to me!
-
JB: Aim is to focus committee on impactful, exciting and bugs. We have M2 which has some overlap with f2f priorities and I think we want to retire M1 as done and move to M2. Then mutate M2 to be the F2F results. Anything else can be added if folks want to discuss. Issues folks don't bring to mind don't show up in agenda for group. Then chip things off. Make a M4+ milestone and make non-immediate things as M3. Sketched out with Corentin and he's thinking along the same lines. Seems to be alignment between the two meetings. Thoughts
-
DN: SGTM. The issue that sometimes comes up, if there is a bug in the spec that I think should be looked at I'll prop into M2 because others are closed
-
JB: Yes.