Currently, the way device crops are handled in the vulkan runtime assumes that the offset provided is aligned. However, this may not be the case if the minStorageBufferOffsetAlignment is larger than the size of the scalar value representing a channel.
To avoid alignment constraints and support arbitrary crops, we can add an index offset parameter in CodeGen_Vulkan which is passed for all storage buffers and used for all read/write calls.
In the runtime, the shader binding interface will need to provide this index offset to the UBO parameter buffer for all storage buffers.
Finally, for buffer_copy, the byte offsets for src & dst will need to be modified to take the index offset into account. Fortunately, it appears there isn't an alignment restriction on vkCmdBufferCopy so only the offsets will need to get adjusted.
Currently, the way device crops are handled in the vulkan runtime assumes that the offset provided is aligned. However, this may not be the case if the
minStorageBufferOffsetAlignmentis larger than the size of the scalar value representing a channel.To avoid alignment constraints and support arbitrary crops, we can add an index offset parameter in CodeGen_Vulkan which is passed for all storage buffers and used for all read/write calls.
In the runtime, the shader binding interface will need to provide this index offset to the UBO parameter buffer for all storage buffers.
Finally, for
buffer_copy, the byte offsets for src & dst will need to be modified to take the index offset into account. Fortunately, it appears there isn't an alignment restriction onvkCmdBufferCopyso only the offsets will need to get adjusted.