From 3384e4f768c560f604802418c6a82ab1f23b3cb9 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Fri, 3 Mar 2023 11:36:36 -0600 Subject: [PATCH] vulkan/runtime: Rename and document storage image Z range This makes it more clear that the fields specifically apply to the Z range and aren't array slices. Part-of: --- src/gallium/frontends/lavapipe/lvp_image.c | 4 ++-- src/vulkan/runtime/vk_image.c | 14 +++++++------- src/vulkan/runtime/vk_image.h | 17 +++++++++++++++-- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/gallium/frontends/lavapipe/lvp_image.c b/src/gallium/frontends/lavapipe/lvp_image.c index d87c5fd..edc4fb6 100644 --- a/src/gallium/frontends/lavapipe/lvp_image.c +++ b/src/gallium/frontends/lavapipe/lvp_image.c @@ -250,8 +250,8 @@ lvp_create_imageview(const struct lvp_image_view *iv) view.format = lvp_vk_format_to_pipe_format(iv->vk.format); if (iv->vk.view_type == VK_IMAGE_VIEW_TYPE_3D) { - view.u.tex.first_layer = iv->vk.storage.slice_offset; - view.u.tex.last_layer = view.u.tex.first_layer + iv->vk.storage.slice_count - 1; + view.u.tex.first_layer = iv->vk.storage.z_slice_offset; + view.u.tex.last_layer = view.u.tex.first_layer + iv->vk.storage.z_slice_count - 1; } else { view.u.tex.first_layer = iv->vk.base_array_layer, view.u.tex.last_layer = iv->vk.base_array_layer + iv->vk.layer_count - 1; diff --git a/src/vulkan/runtime/vk_image.c b/src/vulkan/runtime/vk_image.c index 1057340..0eb3405 100644 --- a/src/vulkan/runtime/vk_image.c +++ b/src/vulkan/runtime/vk_image.c @@ -456,8 +456,8 @@ vk_image_view_init(struct vk_device *device, /* By default storage uses the same as the image properties, but it can be * overriden with VkImageViewSlicedCreateInfoEXT. */ - image_view->storage.slice_offset = 0; - image_view->storage.slice_count = image_view->extent.depth; + image_view->storage.z_slice_offset = 0; + image_view->storage.z_slice_count = image_view->extent.depth; const VkImageViewSlicedCreateInfoEXT *sliced_info = vk_find_struct_const(pCreateInfo, IMAGE_VIEW_SLICED_CREATE_INFO_EXT); @@ -474,14 +474,14 @@ vk_image_view_init(struct vk_device *device, case VK_IMAGE_TYPE_3D: if (sliced_info) { unsigned total = image_view->extent.depth; - image_view->storage.slice_offset = sliced_info->sliceOffset; - assert(image_view->storage.slice_offset < total); + image_view->storage.z_slice_offset = sliced_info->sliceOffset; + assert(image_view->storage.z_slice_offset < total); if (sliced_info->sliceCount == VK_REMAINING_3D_SLICES_EXT) { - image_view->storage.slice_count = total - image_view->storage.slice_offset; + image_view->storage.z_slice_count = total - image_view->storage.z_slice_offset; } else { - image_view->storage.slice_count = sliced_info->sliceCount; + image_view->storage.z_slice_count = sliced_info->sliceCount; } - assert(image_view->storage.slice_offset + image_view->storage.slice_count + assert(image_view->storage.z_slice_offset + image_view->storage.z_slice_count <= image->extent.depth); } assert(image_view->base_array_layer + image_view->layer_count diff --git a/src/vulkan/runtime/vk_image.h b/src/vulkan/runtime/vk_image.h index c2b0a3a..0716a2b 100644 --- a/src/vulkan/runtime/vk_image.h +++ b/src/vulkan/runtime/vk_image.h @@ -279,9 +279,22 @@ struct vk_image_view { uint32_t base_array_layer; uint32_t layer_count; + /* VK_EXT_sliced_view_of_3d */ struct { - uint32_t slice_offset; - uint32_t slice_count; + /* VkImageViewSlicedCreateInfoEXT::sliceOffset + * + * This field will be 0 for 1D and 2D images or when no + * VkImageViewSlicedCreateInfoEXT is provided. + */ + uint32_t z_slice_offset; + + /* VkImageViewSlicedCreateInfoEXT::sliceCount + * + * This field will be 1 for 1D and 2D images and the image view depth + * (see vk_image_view::extent) when no VkImageViewSlicedCreateInfoEXT is + * provided. + */ + uint32_t z_slice_count; } storage; /* VK_EXT_image_view_min_lod */ -- 2.7.4