v3dv: fix image addressing calculations to account for suballocation
authorIago Toral Quiroga <itoral@igalia.com>
Fri, 8 May 2020 12:07:53 +0000 (14:07 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 13 Oct 2020 21:21:30 +0000 (21:21 +0000)
An image can be suballocated from a larger memory allocation, in which
case we get a memory offset for the start of the bound region at
vkBindImageMemory. Take that offset into account when doing image
addressing calculations.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

src/broadcom/vulkan/v3dv_image.c

index bfa5e6a..c0fc31f 100644 (file)
@@ -253,9 +253,9 @@ v3dv_layer_offset(const struct v3dv_image *image, uint32_t level, uint32_t layer
    const struct v3d_resource_slice *slice = &image->slices[level];
 
    if (image->type == VK_IMAGE_TYPE_3D)
-      return slice->offset + layer * slice->size;
+      return image->mem_offset + slice->offset + layer * slice->size;
    else
-      return slice->offset + layer * image->cube_map_stride;
+      return image->mem_offset + slice->offset + layer * image->cube_map_stride;
 }
 
 VkResult