From 70ce8ba5a414965791805b1bf41be67d9bc00190 Mon Sep 17 00:00:00 2001 From: Rebecca Mckeever Date: Wed, 21 Dec 2022 13:01:04 -0600 Subject: [PATCH] nvk: Implement VK_EXT_image_view_min_lod Closes: https://gitlab.freedesktop.org/nouveau/mesa/-/issues/40 Signed-off-by: Rebecca Mckeever Part-of: --- src/nouveau/nil/nil_image.h | 3 +++ src/nouveau/nil/nil_image_tic.c | 6 ++++++ src/nouveau/vulkan/nvk_image_view.c | 1 + src/nouveau/vulkan/nvk_physical_device.c | 6 ++++++ 4 files changed, 16 insertions(+) diff --git a/src/nouveau/nil/nil_image.h b/src/nouveau/nil/nil_image.h index 32e906c123e..e5d18ce587d 100644 --- a/src/nouveau/nil/nil_image.h +++ b/src/nouveau/nil/nil_image.h @@ -178,6 +178,9 @@ struct nil_view { uint32_t array_len; enum pipe_swizzle swizzle[4]; + + /* VK_EXT_image_view_min_lod */ + float min_lod_clamp; }; bool nil_image_init(struct nv_device_info *dev, diff --git a/src/nouveau/nil/nil_image_tic.c b/src/nouveau/nil/nil_image_tic.c index 4eb4e986053..63b5d6a9dd9 100644 --- a/src/nouveau/nil/nil_image_tic.c +++ b/src/nouveau/nil/nil_image_tic.c @@ -370,6 +370,9 @@ nv9097_nil_image_fill_tic(const struct nil_image *image, TH_NV9097_SET_U(th, 7, MULTI_SAMPLE_COUNT, nil_to_nv9097_multi_sample_count(image->sample_layout)); + TH_NV9097_SET_UF(th, 7, MIN_LOD_CLAMP, + view->min_lod_clamp - view->base_level); + memcpy(desc_out, th, sizeof(th)); } @@ -444,6 +447,9 @@ nvb097_nil_image_fill_tic(const struct nil_image *image, TH_NVB097_SET_U(th, BL, MULTI_SAMPLE_COUNT, nil_to_nvb097_multi_sample_count(image->sample_layout)); + TH_NVB097_SET_UF(th, BL, MIN_LOD_CLAMP, + view->min_lod_clamp - view->base_level); + memcpy(desc_out, th, sizeof(th)); } diff --git a/src/nouveau/vulkan/nvk_image_view.c b/src/nouveau/vulkan/nvk_image_view.c index eb9f8010dd7..8b3bea1bd22 100644 --- a/src/nouveau/vulkan/nvk_image_view.c +++ b/src/nouveau/vulkan/nvk_image_view.c @@ -97,6 +97,7 @@ nvk_image_view_init(struct nvk_device *device, vk_swizzle_to_pipe(view->vk.swizzle.b), vk_swizzle_to_pipe(view->vk.swizzle.a), }, + .min_lod_clamp = view->vk.min_lod, }; if (nil_image.dim == NIL_IMAGE_DIM_3D && diff --git a/src/nouveau/vulkan/nvk_physical_device.c b/src/nouveau/vulkan/nvk_physical_device.c index 4cb74b057b3..e6f13981cc9 100644 --- a/src/nouveau/vulkan/nvk_physical_device.c +++ b/src/nouveau/vulkan/nvk_physical_device.c @@ -198,6 +198,11 @@ nvk_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, f->sampler2DViewOf3D = true; break; } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_VIEW_MIN_LOD_FEATURES_EXT: { + VkPhysicalDeviceImageViewMinLodFeaturesEXT *f = (void *)ext; + f->minLod = true; + break; + } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_EXT: { VkPhysicalDeviceIndexTypeUint8FeaturesEXT *f = (void *)ext; f->indexTypeUint8 = true; @@ -479,6 +484,7 @@ nvk_get_device_extensions(const struct nvk_physical_device *pdev, .EXT_extended_dynamic_state3 = true, .EXT_host_query_reset = true, .EXT_image_2d_view_of_3d = true, + .EXT_image_view_min_lod = true, .EXT_index_type_uint8 = true, .EXT_inline_uniform_block = true, .EXT_non_seamless_cube_map = true,