From d84fd86af1a392d1aa56e5e3b27ad0300fc8a8c2 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 29 Sep 2021 18:20:46 -0500 Subject: [PATCH] ntt: Separate image and sampler handling Use nir_foreach_image_variable for images so we survive the coming refactor where they get their own mode. Reviewed-by: Caio Marcelo de Oliveira Filho Part-of: --- src/gallium/auxiliary/nir/nir_to_tgsi.c | 33 ++++++++++---------- src/gallium/auxiliary/nir/nir_to_tgsi_info.c | 7 +++-- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c index 50b55a6f14c..0bc6796aeda 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c @@ -471,8 +471,6 @@ 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 @@ -490,20 +488,6 @@ 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 (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(itype), - glsl_sampler_type_is_array(itype), 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; @@ -515,6 +499,23 @@ ntt_setup_uniforms(struct ntt_compile *c) */ } + nir_foreach_image_variable(var, c->s) { + int image_count = glsl_type_get_image_count(var->type); + 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(itype), + glsl_sampler_type_is_array(itype), 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); + } + } + c->first_ubo = ~0; unsigned ubo_sizes[PIPE_MAX_CONSTANT_BUFFERS] = {0}; diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi_info.c b/src/gallium/auxiliary/nir/nir_to_tgsi_info.c index 3bb5f1f8bae..f54c3a9aee8 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi_info.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi_info.c @@ -784,11 +784,14 @@ void nir_tgsi_scan_shader(const struct nir_shader *nir, info->indirect_files |= 1 << TGSI_FILE_OUTPUT; } - uint32_t sampler_mask = 0, image_mask = 0; + uint32_t sampler_mask = 0; nir_foreach_uniform_variable(var, nir) { uint32_t sampler_count = glsl_type_get_sampler_count(var->type); - uint32_t image_count = glsl_type_get_image_count(var->type); sampler_mask |= ((1ull << sampler_count) - 1) << var->data.binding; + } + uint32_t image_mask = 0; + nir_foreach_image_variable(var, nir) { + uint32_t image_count = glsl_type_get_image_count(var->type); image_mask |= ((1ull << image_count) - 1) << var->data.binding; } info->num_outputs = num_outputs;