vk/image: Add a vk_image_buffer_range() helper
vk_image_buffer_range() returns the buffer range needed for an image <-> buffer copy, which will help us initialize storage buffer descriptors. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29333>
This commit is contained in:

committed by
Marge Bot

parent
f8b2f967b4
commit
6ff9b8c36b
@@ -224,6 +224,25 @@ struct vk_image_buffer_layout {
|
||||
uint64_t image_stride_B;
|
||||
};
|
||||
|
||||
static inline VkDeviceSize
|
||||
vk_image_buffer_range(const struct vk_image *image,
|
||||
const struct vk_image_buffer_layout *buf_layout,
|
||||
const VkExtent3D *elem_extent,
|
||||
const VkImageSubresourceLayers *subres)
|
||||
{
|
||||
uint32_t depth_or_layer_count =
|
||||
MAX2(elem_extent->depth, vk_image_subresource_layer_count(image, subres));
|
||||
|
||||
/* Depth, layer_count and height must be at least one, and we rely on that
|
||||
* for the rest of the buffer range calculation. */
|
||||
assert(depth_or_layer_count > 0);
|
||||
assert(elem_extent->height > 0);
|
||||
|
||||
return (VkDeviceSize)buf_layout->image_stride_B * (depth_or_layer_count - 1) +
|
||||
(VkDeviceSize)buf_layout->row_stride_B * (elem_extent->height - 1) +
|
||||
(VkDeviceSize)buf_layout->element_size_B * elem_extent->width;
|
||||
}
|
||||
|
||||
struct vk_image_buffer_layout
|
||||
vk_image_buffer_copy_layout(const struct vk_image *image,
|
||||
const VkBufferImageCopy2* region);
|
||||
|
Reference in New Issue
Block a user