mach icon indicating copy to clipboard operation
mach copied to clipboard

sysgpu: provide clear default values instead of WebGPU 'undefined' default values

Open silversquirl opened this issue 1 year ago • 3 comments

eg. the default value for the type field of Buffer.BindingLayout should be uniform, according to the WebGPU spec. The undefined buffer type should only be used in the default value of the buffer on BindGroupLayout.Entry, in order to show that those fields are empty.

The default values of the structs themselves should match WebGPU spec, so that if someone tries to use the defaults they get the expected behaviour instead of a confusing validation error :)

silversquirl avatar Feb 12 '24 20:02 silversquirl

For Dawn / mach-gpu, we follow Dawn's API definitions (webgpu.h and dawn.json) which have Buffer.BindingLayout.type's default value as undefined. https://github.com/hexops/dawn/blob/generated-2023-08-10.1691685418/dawn.json#L276

For sysgpu we will document the defaults better, but for Dawn / mach-gpu this is as intended

emidoots avatar Feb 16 '24 03:02 emidoots

Are Dawn's defaults not simply the zero-values? Zero-values are ofc the "default" in a C API, but a Zig API shouldn't necessarily mirror that. I'd argue it's much better to use the WebGPU spec's defaults, as those are more carefully considered and thus make more sense.

I guess that'd turn this into a feature request rather than a bug :)

silversquirl avatar Feb 18 '24 18:02 silversquirl

Are Dawn's defaults not simply the zero-values? Zero-values are ofc the "default" in a C API

yeah, that's undefined (which is an enum name assigned zero value in basically every case)

I guess that'd turn this into a feature request rather than a bug :)

I agree, I'll update the title

emidoots avatar Mar 06 '24 18:03 emidoots