Mesa (main): nir_to_tgsi: Add support for declaring image arrays.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Oct 6 04:34:01 UTC 2021
Module: Mesa
Branch: main
Commit: 80c007a4dd5d8853ab6b1759ee591c046233e90f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=80c007a4dd5d8853ab6b1759ee591c046233e90f
Author: Emma Anholt <emma at anholt.net>
Date: Thu Sep 9 09:18:03 2021 -0700
nir_to_tgsi: Add support for declaring image arrays.
Required for virgl.
Acked-by: Gert Wollny <gert.wollny at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12800>
---
src/gallium/auxiliary/nir/nir_to_tgsi.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 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);
-
- 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);
+ 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;
More information about the mesa-commit
mailing list