这是indexloc提供的服务,不要输入任何密码
Skip to content

constrain attribute alignment value to divide device alignment limits #2505

@dneto0

Description

@dneto0

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    copyeditingPure editorial stuff (copyediting, *.bs file syntax, etc.)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions