nak/lower_tex: Re-order arguments to put can_speculate at the end

Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36396>
diff --git a/src/nouveau/compiler/nak_nir_lower_tex.c b/src/nouveau/compiler/nak_nir_lower_tex.c
index 31a2edd..24973d0 100644
--- a/src/nouveau/compiler/nak_nir_lower_tex.c
+++ b/src/nouveau/compiler/nak_nir_lower_tex.c
@@ -43,8 +43,8 @@
 }
 
 static nir_def *
-build_txq(nir_builder *b, nir_texop op, bool can_speculate, nir_def *img_h,
-          nir_def *lod_idx, const struct nak_compiler *nak)
+build_txq(nir_builder *b, nir_texop op, nir_def *img_h, nir_def *lod_idx,
+          bool can_speculate, const struct nak_compiler *nak)
 {
    uint32_t texture_index = 0;
    enum nak_nir_tex_ref_type ref_type = NAK_NIR_TEX_REF_TYPE_BINDLESS;
@@ -95,23 +95,23 @@
 }
 
 static nir_def *
-build_txq_levels(nir_builder *b, bool can_speculate, nir_def *img_h,
+build_txq_levels(nir_builder *b, nir_def *img_h, bool can_speculate,
                  const struct nak_compiler *nak)
 {
-   nir_def *res = build_txq(b, nir_texop_hdr_dim_nv, can_speculate, img_h,
-                            nir_imm_int(b, 0), nak);
+   nir_def *res = build_txq(b, nir_texop_hdr_dim_nv, img_h, nir_imm_int(b, 0),
+                            can_speculate, nak);
    return nir_channel(b, res, 3);
 }
 
 static nir_def *
-build_img_is_null(nir_builder *b, bool can_speculate, nir_def *img_h,
+build_img_is_null(nir_builder *b, nir_def *img_h, bool can_speculate,
                   const struct nak_compiler *nak)
 {
    /* Prior to Volta, we don't have real NULL descriptors but we can figure
     * out if it's null based on the number of levels returned by
     * txq.dimension.
     */
-   return nir_ieq_imm(b, build_txq_levels(b, can_speculate, img_h, nak), 0);
+   return nir_ieq_imm(b, build_txq_levels(b, img_h, can_speculate, nak), 0);
 }
 
 static enum glsl_sampler_dim
@@ -414,8 +414,9 @@
       nir_def *res = nir_vec2(b, abs, rel);
 
       if (!has_null_descriptors(nak)) {
-         res = nir_bcsel(b, build_img_is_null(b, tex->can_speculate, tex_h, nak),
-                         nir_imm_int(b, 0), res);
+         nir_def *img_is_null =
+            build_img_is_null(b, tex_h, tex->can_speculate, nak);
+         res = nir_bcsel(b, img_is_null, nir_imm_int(b, 0), res);
       }
 
       nir_def_rewrite_uses_after(&tex->def, res, res->parent_instr);
@@ -425,22 +426,22 @@
 }
 
 static nir_def *
-build_txq_samples_raw(nir_builder *b, bool can_speculate, nir_def *img_h,
+build_txq_samples_raw(nir_builder *b, nir_def *img_h, bool can_speculate,
                       const struct nak_compiler *nak)
 {
-   nir_def *res = build_txq(b, nir_texop_tex_type_nv, can_speculate, img_h,
-                            NULL, nak);
+   nir_def *res = build_txq(b, nir_texop_tex_type_nv, img_h, NULL,
+                            can_speculate, nak);
    return nir_channel(b, res, 2);
 }
 
 static nir_def *
-build_txq_samples(nir_builder *b, bool can_speculate, nir_def *img_h,
+build_txq_samples(nir_builder *b, nir_def *img_h, bool can_speculate,
                   const struct nak_compiler *nak)
 {
-   nir_def *res = build_txq_samples_raw(b, can_speculate, img_h, nak);
+   nir_def *res = build_txq_samples_raw(b, img_h, can_speculate, nak);
 
    if (!has_null_descriptors(nak)) {
-      res = nir_bcsel(b, build_img_is_null(b, can_speculate, img_h, nak),
+      res = nir_bcsel(b, build_img_is_null(b, img_h, can_speculate, nak),
                       nir_imm_int(b, 0), res);
    }
 
@@ -448,19 +449,19 @@
 }
 
 static nir_def *
-build_txq_size(nir_builder *b, unsigned num_components, bool can_speculate,
-               nir_def *img_h, nir_def *lod,
+build_txq_size(nir_builder *b, unsigned num_components,
+               nir_def *img_h, nir_def *lod, bool can_speculate,
                const struct nak_compiler *nak)
 {
    if (lod == NULL)
       lod = nir_imm_int(b, 0);
 
-   nir_def *res = build_txq(b, nir_texop_hdr_dim_nv, can_speculate, img_h,
-                            lod, nak);
+   nir_def *res = build_txq(b, nir_texop_hdr_dim_nv, img_h, lod,
+                            can_speculate, nak);
    res = nir_trim_vector(b, res, num_components);
 
    if (!has_null_descriptors(nak)) {
-      res = nir_bcsel(b, build_img_is_null(b, can_speculate, img_h, nak),
+      res = nir_bcsel(b, build_img_is_null(b, img_h, can_speculate, nak),
                       nir_imm_int(b, 0), res);
    }
 
@@ -488,14 +489,14 @@
    nir_def *res;
    switch (tex->op) {
    case nir_texop_txs:
-      res = build_txq_size(b, tex->def.num_components, tex->can_speculate,
-                           tex_h, lod, nak);
+      res = build_txq_size(b, tex->def.num_components, tex_h, lod,
+                           tex->can_speculate, nak);
       break;
    case nir_texop_query_levels:
-      res = build_txq_levels(b, tex->can_speculate, tex_h, nak);
+      res = build_txq_levels(b, tex_h, tex->can_speculate, nak);
       break;
    case nir_texop_texture_samples:
-      res = build_txq_samples(b, tex->can_speculate, tex_h, nak);
+      res = build_txq_samples(b, tex_h, tex->can_speculate, nak);
       break;
    default:
       unreachable("Invalid texture query op");
@@ -708,7 +709,7 @@
    nir_def *w = nir_channel(b, intrin->src[1].ssa, 3);
    nir_def *s = intrin->src[2].ssa;
 
-   nir_def *samples = build_txq_samples_raw(b, can_speculate, img_h, nak);
+   nir_def *samples = build_txq_samples_raw(b, img_h, can_speculate, nak);
 
    nir_def *px_size_sa_log2 = build_px_size_sa_log2(b, samples);
    nir_def *px_w_log2 = nir_channel(b, px_size_sa_log2, 0);
@@ -719,8 +720,8 @@
     * txq.sampler_pos gives us the sample coordinates as a signed 4.12 fixed
     * point with x in the bottom 16 bits and y in the top 16 bits.
     */
-   nir_def *spos_sf = build_txq(b, nir_texop_sample_pos_nv, can_speculate,
-                                img_h, s, nak);
+   nir_def *spos_sf = build_txq(b, nir_texop_sample_pos_nv, img_h, s,
+                                can_speculate, nak);
    spos_sf = nir_trim_vector(b, spos_sf, 2);
 
    /* Fortunately, the samples are laid out in the supersampled image the same
@@ -766,8 +767,8 @@
 
    switch (intrin->intrinsic) {
    case nir_intrinsic_bindless_image_size:
-      res = build_txq_size(b, intrin->def.num_components, can_speculate, img_h,
-                           intrin->src[1].ssa /* lod */, nak);
+      res = build_txq_size(b, intrin->def.num_components, img_h,
+                           intrin->src[1].ssa /* lod */, can_speculate, nak);
 
       if (nir_intrinsic_image_dim(intrin) == GLSL_SAMPLER_DIM_MS) {
          /* When NIL sets up the MSAA image descriptor, it uses a width and
@@ -776,13 +777,13 @@
           * they're given.  This means we need to divide back out the pixel
           * size in order to get the size in pixels.
           */
-         nir_def *samples = build_txq_samples_raw(b, can_speculate, img_h, nak);
+         nir_def *samples = build_txq_samples_raw(b, img_h, can_speculate, nak);
          nir_def *px_size_sa_log2 = build_px_size_sa_log2(b, samples);
          res = nir_ushr(b, res, px_size_sa_log2);
       }
       break;
    case nir_intrinsic_bindless_image_samples:
-      res = build_txq_samples(b, can_speculate, img_h, nak);
+      res = build_txq_samples(b, img_h, can_speculate, nak);
       break;
    default:
       unreachable("Invalid image query op");