Wgpu: Dynamic offsets on Nvidia require alignment

Created on 8 May 2019  路  4Comments  路  Source: gfx-rs/wgpu

On certain Nvidia cards, using buffer offsets that aren't multiples of 256 creates problems and gives this error:

2019-05-07 22:04:45 ERROR [gfx_backend_vulkan] [Validation]  [ VUID-vkCmdBindDescriptorSets-pDynamicOffsets-01971 ] Object: VK_NULL_HANDLE (Type = 2) | vkCmdBindDescriptorSets(): pDynamicOffsets[0] is 64 but must be a multiple of device limit minUniformBufferOffsetAlignment 0x100. The Vulkan spec states: Each element of pDynamicOffsets which corresponds to a descriptor binding with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC must be a multiple of VkPhysicalDeviceLimits::minUniformBufferOffsetAlignment (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkCmdBindDescriptorSets-pDynamicOffsets-01971)

I'm not sure what the right solution is, we can:

  1. Do nothing - it's for the user to know how to align things correctly, we just have to expose the offset alignment variable.
  2. Pad the buffer items for the user, eg. if it's a list of mat4 (64 bytes), we'd have to pad each item with 192 bytes somehow, and pass that to the device. We'd also have to map offsets passed to wgpu to device offsets.

Thoughts?

bug

All 4 comments

Thank you for filing the issue!
The current status of WebGPU API requirements is that any offsets into buffers should be 256-aligned, but this isn't yet set in stone (i.e. there are concerns...).
While the working group is figuring this out, we should at least check the user-provided offsets against the actual adapter limits, like we do for the non-dynamic bind groups.

Hmm I see - I guess this number 256 should be exposed by wgpu somewhere in the API so that users can ensure their offsets are aligned?

Yes, we need to have it exposed as a public constant. Want to help with this PR? :)

We also need to validate the dynamic offsets against that alignment. We currently validate all the other offsets correctly, but not the dynamic ones.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lordnoriyuki picture lordnoriyuki  路  21Comments

kvark picture kvark  路  15Comments

Aeledfyr picture Aeledfyr  路  23Comments

simast picture simast  路  15Comments

MarekLg picture MarekLg  路  39Comments