Mesa (main): freedreno/ir3: Only lower cube image sizes once.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 18 00:34:06 UTC 2021


Module: Mesa
Branch: main
Commit: 513920ba827e64c95ddb684da6ec285786cf0853
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=513920ba827e64c95ddb684da6ec285786cf0853

Author: Emma Anholt <emma at anholt.net>
Date:   Tue Aug 17 13:40:57 2021 -0700

freedreno/ir3: Only lower cube image sizes once.

shader variants can cause ir3_nir_finalize() to run more than once, which
would make us keep dividing the size by 6.

Fixes: a48fc88571f9 ("freedreno/a6xx: Apply the cube image size lowering to GL, too.")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12258>

---

 src/freedreno/ir3/ir3_nir.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c
index 670750e5986..fdc38b95e8f 100644
--- a/src/freedreno/ir3/ir3_nir.c
+++ b/src/freedreno/ir3/ir3_nir.c
@@ -352,11 +352,6 @@ ir3_finalize_nir(struct ir3_compiler *compiler, nir_shader *s)
       .lower_tg4_offsets = true,
    };
 
-   nir_lower_image_options lower_image_opts = {
-      .lower_cube_size = true,
-   };
-   NIR_PASS_V(s, nir_lower_image, &lower_image_opts);
-
    if (compiler->gen >= 4) {
       /* a4xx seems to have *no* sam.p */
       tex_options.lower_txp = ~0; /* lower all txp */
@@ -477,6 +472,11 @@ ir3_nir_lower_subgroup_id_cs(nir_shader *shader)
                                         lower_subgroup_id, NULL);
 }
 
+static const nir_lower_idiv_options idiv_options = {
+   .imprecise_32bit_lowering = true,
+   .allow_fp16 = true,
+};
+
 /**
  * Late passes that need to be done after pscreen->finalize_nir()
  */
@@ -525,10 +525,16 @@ ir3_nir_post_finalize(struct ir3_compiler *compiler, nir_shader *s)
    }
 
    /* we cannot ensure that ir3_finalize_nir() is only called once, so
-    * we also need to do trig workarounds here:
+    * we also need to do any run-once workarounds here:
     */
    OPT_V(s, ir3_nir_apply_trig_workarounds);
 
+   nir_lower_image_options lower_image_opts = {
+      .lower_cube_size = true,
+   };
+   NIR_PASS_V(s, nir_lower_image, &lower_image_opts);
+   NIR_PASS_V(s, nir_lower_idiv, &idiv_options); /* idiv generated by cube lowering */
+
    ir3_optimize_loop(compiler, s);
 }
 



More information about the mesa-commit mailing list