From 3c40aba8b6c9b3eba0c903b0e7ecdc68bef794ef Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 12 Dec 2024 13:34:08 +0100 Subject: [PATCH] panvk: fix image size for cube-arrays on bifrost We're parsing the descriptors here to read the size of the resource, but what the HW wants and imageSize() wants is not the same. So let's fix up the result for imageSize(), by dividing the result by 6. If we change the descriptor instead, we end up failing shader-image reads and writes instead. I also looked for some unused bits in the descriptor that I could use instead, but unfortunately there's only a few bits free here - not enough for our needs. Reviewed-by: Eric R. Smith Reviewed-by: Benjamin Lee Reviewed-by: Mary Guillemard Part-of: --- src/panfrost/vulkan/panvk_vX_nir_lower_descriptors.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/panfrost/vulkan/panvk_vX_nir_lower_descriptors.c b/src/panfrost/vulkan/panvk_vX_nir_lower_descriptors.c index a7a6cd893d5..525d353e3a9 100644 --- a/src/panfrost/vulkan/panvk_vX_nir_lower_descriptors.c +++ b/src/panfrost/vulkan/panvk_vX_nir_lower_descriptors.c @@ -630,6 +630,15 @@ load_img_size(nir_builder *b, nir_deref_instr *deref, enum glsl_sampler_dim dim, nir_def *tex_sz = load_resource_deref_desc( b, deref, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 18, 3, 16, ctx); +#if PAN_ARCH <= 7 + if (is_array && dim == GLSL_SAMPLER_DIM_CUBE) + tex_sz = + nir_vector_insert_imm(b, tex_sz, + nir_udiv_imm(b, nir_channel(b, tex_sz, 2), + 6), + 2); +#endif + if (is_array && dim == GLSL_SAMPLER_DIM_1D) tex_sz = nir_vec2(b, nir_channel(b, tex_sz, 0), nir_channel(b, tex_sz, 2));