-
Notifications
You must be signed in to change notification settings - Fork 345
Description
The WebGPU spec allows creating a buffer of some size, say 16 bytes, and then binding it as a vertex buffer at offset=16, size=0. The spec currently requires offset to be a multiple of 4, and offset + size to be less than or equal to the buffer size.
Binding at an offset equal to the buffer size is invalid in Vulkan, and you'll get a validation error like:
Warning: Validation Error: [ VUID-vkCmdBindVertexBuffers-pOffsets-00626 ] Object 0: handle = 0x32030000003203, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0x4080ede | vkCmdBindVertexBuffers() offset (0x4) is beyond the end of the buffer. The Vulkan spec states: All elements of pOffsets must be less than the size of the corresponding element in pBuffers (https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VUID-vkCmdBindVertexBuffers-pOffsets-00626)
Should we disallow zero-sized vertex buffer bindings? Related to #686 where we decided to disallow zero-sized bindings in bind groups. Alternatively, we could allow zero-sized bindings, but only require the offset argument to be less than the buffer size.
The same decision here should apply for setIndexBuffer as well. Vulkan:
VUID-vkCmdBindIndexBuffer-offset-00431
offset must be less than the size of buffer