Mesa (staging/20.3): st/mesa: fix pbo upload/download for arrays of textures with only 1 layer

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jan 25 18:50:20 UTC 2021


Module: Mesa
Branch: staging/20.3
Commit: a098a704a41e98a3b5e694d8801820fc795567c6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a098a704a41e98a3b5e694d8801820fc795567c6

Author: Andrii Simiklit <andrii.simiklit at globallogic.com>
Date:   Mon Jan 18 14:42:05 2021 +0200

st/mesa: fix pbo upload/download for arrays of textures with only 1 layer

Having only one layer we can put 0 as third texture coordinate

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4115
Fixes: 36097fc7 ("st/pbo: fix pbo uploads without PIPE_CAP_TGSI_VS_LAYER_VIEWPORT and skip gs")
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Signed-off-by: Andrii Simiklit <andrii.simiklit at globallogic.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8576>
(cherry picked from commit e87b59f68779a7c838f35323fd9f4dddf146381d)

---

 .pick_status.json               |  2 +-
 src/mesa/state_tracker/st_pbo.c | 25 +++++++++++++++----------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index f1d7648732c..500fd3e2e25 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -94,7 +94,7 @@
         "description": "st/mesa: fix pbo upload/download for arrays of textures with only 1 layer",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "36097fc7ef70471ecfecd428f990233276e9c45b"
     },
diff --git a/src/mesa/state_tracker/st_pbo.c b/src/mesa/state_tracker/st_pbo.c
index 65a1ce8862a..b03921c1be6 100644
--- a/src/mesa/state_tracker/st_pbo.c
+++ b/src/mesa/state_tracker/st_pbo.c
@@ -431,16 +431,21 @@ create_fs(struct st_context *st, bool download,
    nir_ssa_def *coord = nir_load_var(&b, fragcoord);
 
    nir_ssa_def *layer = NULL;
-   if (st->pbo.layers && need_layer && (!download || target == PIPE_TEXTURE_1D_ARRAY ||
-                                                     target == PIPE_TEXTURE_2D_ARRAY ||
-                                                     target == PIPE_TEXTURE_3D ||
-                                                     target == PIPE_TEXTURE_CUBE ||
-                                                     target == PIPE_TEXTURE_CUBE_ARRAY)) {
-      nir_variable *var = nir_variable_create(b.shader, nir_var_shader_in,
-                                              glsl_int_type(), "gl_Layer");
-      var->data.location = VARYING_SLOT_LAYER;
-      var->data.interpolation = INTERP_MODE_FLAT;
-      layer = nir_load_var(&b, var);
+   if (st->pbo.layers && (!download || target == PIPE_TEXTURE_1D_ARRAY ||
+                                       target == PIPE_TEXTURE_2D_ARRAY ||
+                                       target == PIPE_TEXTURE_3D ||
+                                       target == PIPE_TEXTURE_CUBE ||
+                                       target == PIPE_TEXTURE_CUBE_ARRAY)) {
+      if (need_layer) {
+         nir_variable *var = nir_variable_create(b.shader, nir_var_shader_in,
+                                                glsl_int_type(), "gl_Layer");
+         var->data.location = VARYING_SLOT_LAYER;
+         var->data.interpolation = INTERP_MODE_FLAT;
+         layer = nir_load_var(&b, var);
+      }
+      else {
+         layer = zero;
+      }
    }
 
    /* offset_pos = param.xy + f2i(coord.xy) */



More information about the mesa-commit mailing list