Mesa (master): intel/compiler: fixup Gen12 workaround for array sizes

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Sep 21 21:24:53 UTC 2020


Module: Mesa
Branch: master
Commit: cc3bf00cc26ddb991b4036a9911299e7d122115b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cc3bf00cc26ddb991b4036a9911299e7d122115b

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Tue Sep 15 15:33:14 2020 +0300

intel/compiler: fixup Gen12 workaround for array sizes

We didn't handle the case of NULL images/textures for which we should
return 0.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Fixes: 397ff2976ba281 ("intel: Implement Gen12 workaround for array textures of size 1")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3522
Reviewed-by: Ivan Briano <ivan.briano at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6729>

---

 .../brw_nir_clamp_image_1d_2d_array_sizes.c         | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/intel/compiler/brw_nir_clamp_image_1d_2d_array_sizes.c b/src/intel/compiler/brw_nir_clamp_image_1d_2d_array_sizes.c
index bc5e5864b62..2d71d491f87 100644
--- a/src/intel/compiler/brw_nir_clamp_image_1d_2d_array_sizes.c
+++ b/src/intel/compiler/brw_nir_clamp_image_1d_2d_array_sizes.c
@@ -107,12 +107,29 @@ brw_nir_clamp_image_1d_2d_array_sizes(nir_shader *shader)
             b.cursor = nir_after_instr(instr);
 
             nir_ssa_def *components[4];
+            /* OR all the sizes for all components but the last. */
+            nir_ssa_def *or_components = nir_imm_int(&b, 0);
             for (int i = 0; i < image_size->num_components; i++) {
                if (i == (image_size->num_components - 1)) {
-                  components[i] = nir_imax(&b, nir_channel(&b, image_size, i),
-                                               nir_imm_int(&b, 1));
+                  nir_ssa_def *null_or_size[2] = {
+                     nir_imm_int(&b, 0),
+                     nir_imax(&b, nir_channel(&b, image_size, i),
+                                  nir_imm_int(&b, 1)),
+                  };
+                  nir_ssa_def *vec2_null_or_size = nir_vec(&b, null_or_size, 2);
+
+                  /* Using the ORed sizes select either the element 0 or 1
+                   * from this vec2. For NULL textures which have a size of
+                   * 0x0x0, we'll select the first element which is 0 and for
+                   * the rest MAX(depth, 1).
+                   */
+                  components[i] =
+                     nir_vector_extract(&b, vec2_null_or_size,
+                                            nir_imin(&b, or_components,
+                                                         nir_imm_int(&b, 1)));
                } else {
                   components[i] = nir_channel(&b, image_size, i);
+                  or_components = nir_ior(&b, components[i], or_components);
                }
             }
             nir_ssa_def *image_size_replacement =



More information about the mesa-commit mailing list