anv: ensure max_plane_count is at least 1

This simplifies a bunch of checks throughout the driver.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30539>
This commit is contained in:
Lionel Landwerlin
2024-07-30 21:08:40 +03:00
committed by Marge Bot
parent 4f093b2e2b
commit 343e569ab7
2 changed files with 5 additions and 9 deletions

View File

@@ -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) {

View File

@@ -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