Mesa (main): intel/compiler: Lower cube image sizes using nir_lower_image()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 21 18:53:15 UTC 2021


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

Author: Jordan Justen <jordan.l.justen at intel.com>
Date:   Wed Feb  3 10:52:04 2021 -0800

intel/compiler: Lower cube image sizes using nir_lower_image()

Reworks:
 * Re-merge early/late passes using Jason's nir image deref patches
 * Create and use a common nir_lower_image() pass. (s-b Jason)
 * Remove cube array size handling in image load/store lowering

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9466>

---

 src/intel/compiler/brw_nir_lower_storage_image.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/intel/compiler/brw_nir_lower_storage_image.c b/src/intel/compiler/brw_nir_lower_storage_image.c
index 682ae13dedb..7eeaee79c7a 100644
--- a/src/intel/compiler/brw_nir_lower_storage_image.c
+++ b/src/intel/compiler/brw_nir_lower_storage_image.c
@@ -655,15 +655,10 @@ lower_image_size_instr(nir_builder *b,
 
    nir_ssa_def *comps[4] = { NULL, NULL, NULL, NULL };
 
-   enum glsl_sampler_dim dim = glsl_get_sampler_dim(deref->type);
+   assert(nir_intrinsic_image_dim(intrin) != GLSL_SAMPLER_DIM_CUBE);
    unsigned coord_comps = glsl_get_sampler_coordinate_components(deref->type);
-   for (unsigned c = 0; c < coord_comps; c++) {
-      if (c == 2 && dim == GLSL_SAMPLER_DIM_CUBE) {
-         comps[2] = nir_idiv(b, nir_channel(b, size, 2), nir_imm_int(b, 6));
-      } else {
-         comps[c] = nir_channel(b, size, c);
-      }
-   }
+   for (unsigned c = 0; c < coord_comps; c++)
+      comps[c] = nir_channel(b, size, c);
 
    for (unsigned c = coord_comps; c < intrin->dest.ssa.num_components; ++c)
       comps[c] = nir_imm_int(b, 1);
@@ -681,6 +676,11 @@ brw_nir_lower_storage_image(nir_shader *shader,
 {
    bool progress = false;
 
+   const nir_lower_image_options image_options = {
+      .lower_cube_size = true,
+   };
+   progress |= nir_lower_image(shader, &image_options);
+
    nir_foreach_function(function, shader) {
       if (function->impl == NULL)
          continue;



More information about the mesa-commit mailing list