Mesa (main): nir_to_tgsi: Fix image declarations.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jul 16 21:54:17 UTC 2021
Module: Mesa
Branch: main
Commit: 8c36022e0d5c00f6b4c18b67e87c5be2874152cf
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8c36022e0d5c00f6b4c18b67e87c5be2874152cf
Author: Emma Anholt <emma at anholt.net>
Date: Mon Jan 11 16:21:20 2021 -0800
nir_to_tgsi: Fix image declarations.
We failed to translate the target type, which virgl needs for translation.
Also the read_only flag is for consts, shader inputs, and uniforms. The
access flag gives you the readonly qualifier.
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11916>
---
src/gallium/auxiliary/nir/nir_to_tgsi.c | 50 ++++++++++++++++++---------------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c
index fbeadd935bc..38d2db77a49 100644
--- a/src/gallium/auxiliary/nir/nir_to_tgsi.c
+++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c
@@ -384,6 +384,27 @@ ntt_setup_inputs(struct ntt_compile *c)
}
}
+static enum tgsi_texture_type
+tgsi_target_from_sampler_dim(enum glsl_sampler_dim dim, bool is_array)
+{
+ switch (dim) {
+ case GLSL_SAMPLER_DIM_1D:
+ return is_array ? TGSI_TEXTURE_1D_ARRAY : TGSI_TEXTURE_1D;
+ case GLSL_SAMPLER_DIM_2D:
+ return is_array ? TGSI_TEXTURE_2D_ARRAY : TGSI_TEXTURE_2D;
+ case GLSL_SAMPLER_DIM_3D:
+ return TGSI_TEXTURE_3D;
+ case GLSL_SAMPLER_DIM_CUBE:
+ return is_array ? TGSI_TEXTURE_CUBE_ARRAY : TGSI_TEXTURE_CUBE;
+ case GLSL_SAMPLER_DIM_RECT:
+ return TGSI_TEXTURE_RECT;
+ case GLSL_SAMPLER_DIM_BUF:
+ return TGSI_TEXTURE_BUFFER;
+ default:
+ unreachable("unknown sampler dim");
+ }
+}
+
static void
ntt_setup_uniforms(struct ntt_compile *c)
{
@@ -392,11 +413,15 @@ ntt_setup_uniforms(struct ntt_compile *c)
nir_foreach_uniform_variable(var, c->s) {
if (glsl_type_is_image(var->type)) {
+ enum tgsi_texture_type tex_type =
+ tgsi_target_from_sampler_dim(glsl_get_sampler_dim(var->type),
+ glsl_sampler_type_is_array(var->type));
+
c->images[var->data.binding] = ureg_DECL_image(c->ureg,
var->data.binding,
- TGSI_TEXTURE_2D,
+ tex_type,
var->data.image.format,
- !var->data.read_only,
+ !(var->data.access & ACCESS_NON_WRITEABLE),
false);
} else {
unsigned size;
@@ -1381,27 +1406,6 @@ ntt_emit_mem(struct ntt_compile *c, nir_intrinsic_instr *instr,
0 /* format: unused */);
}
-static enum tgsi_texture_type
-tgsi_target_from_sampler_dim(enum glsl_sampler_dim dim, bool is_array)
-{
- switch (dim) {
- case GLSL_SAMPLER_DIM_1D:
- return is_array ? TGSI_TEXTURE_1D_ARRAY : TGSI_TEXTURE_1D;
- case GLSL_SAMPLER_DIM_2D:
- return is_array ? TGSI_TEXTURE_2D_ARRAY : TGSI_TEXTURE_2D;
- case GLSL_SAMPLER_DIM_3D:
- return TGSI_TEXTURE_3D;
- case GLSL_SAMPLER_DIM_CUBE:
- return is_array ? TGSI_TEXTURE_CUBE_ARRAY : TGSI_TEXTURE_CUBE;
- case GLSL_SAMPLER_DIM_RECT:
- return TGSI_TEXTURE_RECT;
- case GLSL_SAMPLER_DIM_BUF:
- return TGSI_TEXTURE_BUFFER;
- default:
- unreachable("unknown sampler dim");
- }
-}
-
static void
ntt_emit_image_load_store(struct ntt_compile *c, nir_intrinsic_instr *instr)
{
More information about the mesa-commit
mailing list