From 343e569ab7890a16c33c8645f1627c972214bfcc Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Tue, 30 Jul 2024 21:08:40 +0300 Subject: [PATCH] anv: ensure max_plane_count is at least 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This simplifies a bunch of checks throughout the driver. Signed-off-by: Lionel Landwerlin Reviewed-by: Tapani Pälli Part-of: --- src/intel/vulkan/anv_descriptor_set.c | 12 ++++-------- src/intel/vulkan/anv_nir_apply_pipeline_layout.c | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c index dd41aea8344..fda64485af0 100644 --- a/src/intel/vulkan/anv_descriptor_set.c +++ b/src/intel/vulkan/anv_descriptor_set.c @@ -781,11 +781,11 @@ VkResult anv_CreateDescriptorSetLayout( buffer_view_count += binding->descriptorCount; } + set_layout->binding[b].max_plane_count = 1; switch (binding->descriptorType) { case VK_DESCRIPTOR_TYPE_SAMPLER: case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: case VK_DESCRIPTOR_TYPE_MUTABLE_EXT: - set_layout->binding[b].max_plane_count = 1; if (binding->pImmutableSamplers) { set_layout->binding[b].immutable_samplers = samplers; samplers += binding->descriptorCount; @@ -801,10 +801,6 @@ VkResult anv_CreateDescriptorSetLayout( } break; - case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: - set_layout->binding[b].max_plane_count = 1; - break; - default: break; } @@ -841,10 +837,10 @@ VkResult anv_CreateDescriptorSetLayout( * that common and likely won't be in the middle of big arrays. */ set_layout->binding[b].descriptor_surface_stride = - MAX2(set_layout->binding[b].max_plane_count, 1) * + set_layout->binding[b].max_plane_count * set_layout->binding[b].descriptor_data_surface_size; set_layout->binding[b].descriptor_sampler_stride = - MAX2(set_layout->binding[b].max_plane_count, 1) * + set_layout->binding[b].max_plane_count * set_layout->binding[b].descriptor_data_sampler_size; if (binding->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) { @@ -2223,7 +2219,7 @@ anv_descriptor_set_write_image_view(struct anv_device *device, */ assert(bind_layout->max_plane_count <= ARRAY_SIZE(desc_data)); memcpy(desc_surface_map, desc_data, - MAX2(1, bind_layout->max_plane_count) * sizeof(desc_data[0])); + bind_layout->max_plane_count * sizeof(desc_data[0])); } if (data & ANV_DESCRIPTOR_INDIRECT_STORAGE_IMAGE) { diff --git a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c index 877e0a4fc75..a4c554bd7bf 100644 --- a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c +++ b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c @@ -99,7 +99,7 @@ bti_multiplier(const struct apply_pipeline_layout_state *state, const struct anv_descriptor_set_binding_layout *bind_layout = &set_layout->binding[binding]; - return bind_layout->max_plane_count == 0 ? 1 : bind_layout->max_plane_count; + return bind_layout->max_plane_count; } static nir_address_format