-
Notifications
You must be signed in to change notification settings - Fork 329
Description
When creating a GPUBindGroup, validation requires a buffer binding's offset to divide the device alignments:
- for uniform, resource.offset is a multiple of limits.minUniformBufferOffsetAlignment.
- for storage or read-only-storage: resource.offset is a multiple of limits.minStorageBufferOffsetAlignment.
There is an extra constraint not quite captured anywhere:
- the alignment requirement of the store type an associated WGSL buffer variable must divide the bindgroup's offset (and also base address).
To keep things simple we propose the simple constraint:
- The alignment of the store type for a uniform buffer must divide limits.minUniformBufferOffsetAlignment.
- The alignment of the store type for a storage (or read-only-storage) buffer must divide limits.minStorageBufferOffsetAlignment.
Those two limits are device-wide, so the constraint can be checked early: at shader creation time or at pipeline creation time. I'm not too fussy about which of the two, because both are off the critical path.
Thanks @kainino0x for the suggested simple constraint.
Note: Indirectly, this might constrain the magnitude of the align
and size
attributes in WGSL.
Note: Currently WebGPU says picking a "better" (smaller) alignment requirement always relaxes constraints. This would no longer be true, so that language would have to be adjusted.