Open kanerogers opened 1 year ago
Some updates on this one:
Some notes (for my reference, or for anyone who wants to pick this up should I get hit by a bus):
I am reasonably confident that a 1:1 mapping can be made between a WGPU bind group and an argument buffer. That is, the four kinds of resources defined in the WSGL spec (Uniform Buffers, Storage Buffers, Texture resources and Sampler resources) are all legal members of argument buffers, per section 2.13 of the MSL spec:
Argument buffers extend the basic buffer types to include pointers (buffers), textures, texture buffers, and samplers.
With this in mind, I believe it makes more sense to preserve the structure of a bind group on both the wgpu and naga side to more easily populate (on the naga side) and encode (on the wgpu side) the relevant argument buffer.
Some considerations:
MSL 2
(i.e. iOS 11.0+
macOS 10.13+
); the WebGPU spec is ok with this and so is Firefox but this might still impact naga/wgpu users@kanerogers The "Without argument buffers" example in the top comment seems mangled - is that valid MSL?
@kanerogers The "Without argument buffers" example in the top comment seems mangled - is that valid MSL?
Ah, good pick up! 😅
No, it's not valid MSL. This was just a rough sketch I wrote, mostly for myself, when I was first looking into the project.
Background
This is a companion to the wgpu issue https://github.com/gfx-rs/wgpu/issues/3334
Using argument buffers would simplify the Metal shaders emitted by naga. Instead of having to pass each binding to the shader function as an argument, each binding group can be bundled into a struct which can then be used throughout the shader. For example:
Input wgsl
Without argument buffers
With argument buffers