You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that the dynamic-buffers example is giving validation errors:
pDynamicOffsets[0] is 0x4 which when added to the buffer descriptor's range (0xc) is greater then the size of the buffer (0xc) in descriptorSet #0 binding #0 descriptor[0]. The Vulkan spec states: For each dynamic uniform or storage buffer binding in pDescriptorSets, the sum of the effective offset, as defined above, and the range of the binding must be less than or equal to the size of the buffer (https://vulkan.lunarg.com/doc/view/1.2.182.0/linux/1.2-extensions/vkspec.html#VUID-vkCmdBindDescriptorSets-pDescriptorSets-01979)
pDynamicOffsets[0] is 0x8 which when added to the buffer descriptor's range (0xc) is greater then the size of the buffer (0xc) in descriptorSet #0 binding #0 descriptor[0]. The Vulkan spec states: For each dynamic uniform or storage buffer binding in pDescriptorSets, the sum of the effective offset, as defined above, and the range of the binding must be less than or equal to the size of the buffer (https://vulkan.lunarg.com/doc/view/1.2.182.0/linux/1.2-extensions/vkspec.html#VUID-vkCmdBindDescriptorSets-pDescriptorSets-01979)
So I went to investigate, and found the root of the problem. When you attach a buffer to a descriptor set, Vulkan needs you to specify an offset and a range of the buffer to use. Vulkano fills these values in automatically based on the buffer type used. In the example, the buffer is filled with 12 bytes of data, so the offset is 0 and the range is 12.
When the descriptor set is then bound with dynamic offsets, the dynamic offsets get added to the offset of the buffer, but this also moves the end point of the range. So in the example, when you have a dynamic offset of 4, you end up with a buffer slice ranging from 4 to 16, and that includes 4 bytes off the end of the buffer! Nothing bad happens here because the shader only reads a single uint (4 bytes) from the buffer, but it still produces a validation error.
What really should be happening here is that the range should be 4 when the buffer is attached to the descriptor set. Then you have three valid "windows" to feed to the shader: 0-4, 4-8 and 8-12. Unfortunately, Vulkano doesn't let you do this safely at present. You can make a BufferSlice that contains only the first 4 bytes, but then Vulkano is no longer able to tell that the full buffer is 12 bytes long, and can therefore not validate the dynamic offsets properly. I don't believe it does this anyway, but it certainly should.
@Arc-blroth as the person who originally added support for dynamic offsets, do you have any ideas?
The text was updated successfully, but these errors were encountered:
I noticed that the dynamic-buffers example is giving validation errors:
So I went to investigate, and found the root of the problem. When you attach a buffer to a descriptor set, Vulkan needs you to specify an offset and a range of the buffer to use. Vulkano fills these values in automatically based on the buffer type used. In the example, the buffer is filled with 12 bytes of data, so the offset is 0 and the range is 12.
When the descriptor set is then bound with dynamic offsets, the dynamic offsets get added to the offset of the buffer, but this also moves the end point of the range. So in the example, when you have a dynamic offset of 4, you end up with a buffer slice ranging from 4 to 16, and that includes 4 bytes off the end of the buffer! Nothing bad happens here because the shader only reads a single
uint
(4 bytes) from the buffer, but it still produces a validation error.What really should be happening here is that the range should be 4 when the buffer is attached to the descriptor set. Then you have three valid "windows" to feed to the shader: 0-4, 4-8 and 8-12. Unfortunately, Vulkano doesn't let you do this safely at present. You can make a
BufferSlice
that contains only the first 4 bytes, but then Vulkano is no longer able to tell that the full buffer is 12 bytes long, and can therefore not validate the dynamic offsets properly. I don't believe it does this anyway, but it certainly should.@Arc-blroth as the person who originally added support for dynamic offsets, do you have any ideas?
The text was updated successfully, but these errors were encountered: