From 80c007a4dd5d8853ab6b1759ee591c046233e90f Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Thu, 9 Sep 2021 09:18:03 -0700 Subject: [PATCH] nir_to_tgsi: Add support for declaring image arrays. Required for virgl. Acked-by: Gert Wollny Part-of: --- src/gallium/auxiliary/nir/nir_to_tgsi.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c index b22d99b38cb..99882e510d1 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c @@ -442,6 +442,8 @@ static void ntt_setup_uniforms(struct ntt_compile *c) { nir_foreach_uniform_variable(var, c->s) { + int image_count = glsl_type_get_image_count(var->type); + if (glsl_type_is_sampler(glsl_without_array(var->type))) { /* Don't use this size for the check for samplers -- arrays of structs * containing samplers should be ignored, and just the separate lowered @@ -459,17 +461,20 @@ ntt_setup_uniforms(struct ntt_compile *c) target, ret_type, ret_type, ret_type, ret_type); ureg_DECL_sampler(c->ureg, var->data.binding + i); } - } else if (glsl_type_is_image(var->type)) { + } else if (image_count) { + const struct glsl_type *itype = glsl_without_array(var->type); enum tgsi_texture_type tex_type = - tgsi_texture_type_from_sampler_dim(glsl_get_sampler_dim(var->type), - glsl_sampler_type_is_array(var->type), false); + tgsi_texture_type_from_sampler_dim(glsl_get_sampler_dim(itype), + glsl_sampler_type_is_array(itype), false); - c->images[var->data.binding] = ureg_DECL_image(c->ureg, - var->data.binding, - tex_type, - var->data.image.format, - !(var->data.access & ACCESS_NON_WRITEABLE), - false); + for (int i = 0; i < image_count; i++) { + c->images[var->data.binding] = ureg_DECL_image(c->ureg, + var->data.binding + i, + tex_type, + var->data.image.format, + !(var->data.access & ACCESS_NON_WRITEABLE), + false); + } } else if (glsl_contains_atomic(var->type)) { uint32_t offset = var->data.offset / 4; uint32_t size = glsl_atomic_size(var->type) / 4;