freedreno/ir3: Move handle_bindless_cat6 to compiler_nir and reuse.
authorEric Anholt <eric@anholt.net>
Wed, 20 May 2020 21:00:33 +0000 (14:00 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 26 May 2020 18:17:46 +0000 (18:17 +0000)
There was an open coded version for ldc, and now we can drop that.  I
needed to do it for resinfo as well.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3501>

src/freedreno/ir3/ir3_a6xx.c
src/freedreno/ir3/ir3_compiler_nir.c
src/freedreno/ir3/ir3_context.h

index cef7a78dad54b7b90207df0fe3b99244bdac870e..9b8f154bb6451681b6bf12b3e4af942de16d17fc 100644 (file)
  * encoding compared to a4xx/a5xx.
  */
 
-static void
-handle_bindless_cat6(struct ir3_instruction *instr, nir_src rsrc)
-{
-       nir_intrinsic_instr *intrin = ir3_bindless_resource(rsrc);
-       if (!intrin)
-               return;
-
-       instr->flags |= IR3_INSTR_B;
-       instr->cat6.base = nir_intrinsic_desc_set(intrin);
-}
-
 /* src[] = { buffer_index, offset }. No const_index */
 static void
 emit_intrinsic_load_ssbo(struct ir3_context *ctx, nir_intrinsic_instr *intr,
@@ -66,7 +55,7 @@ emit_intrinsic_load_ssbo(struct ir3_context *ctx, nir_intrinsic_instr *intr,
        ldib->cat6.type = intr->dest.ssa.bit_size == 16 ? TYPE_U16 : TYPE_U32;
        ldib->barrier_class = IR3_BARRIER_BUFFER_R;
        ldib->barrier_conflict = IR3_BARRIER_BUFFER_W;
-       handle_bindless_cat6(ldib, intr->src[0]);
+       ir3_handle_bindless_cat6(ldib, intr->src[0]);
 
        ir3_split_dest(b, dst, ldib, 0, intr->num_components);
 }
@@ -93,7 +82,7 @@ emit_intrinsic_store_ssbo(struct ir3_context *ctx, nir_intrinsic_instr *intr)
        stib->cat6.type = intr->src[0].ssa->bit_size == 16 ? TYPE_U16 : TYPE_U32;
        stib->barrier_class = IR3_BARRIER_BUFFER_W;
        stib->barrier_conflict = IR3_BARRIER_BUFFER_R | IR3_BARRIER_BUFFER_W;
-       handle_bindless_cat6(stib, intr->src[1]);
+       ir3_handle_bindless_cat6(stib, intr->src[1]);
 
        array_insert(b, b->keeps, stib);
 }
@@ -197,7 +186,7 @@ emit_intrinsic_atomic_ssbo(struct ir3_context *ctx, nir_intrinsic_instr *intr)
        atomic->cat6.type = type;
        atomic->barrier_class = IR3_BARRIER_BUFFER_W;
        atomic->barrier_conflict = IR3_BARRIER_BUFFER_R | IR3_BARRIER_BUFFER_W;
-       handle_bindless_cat6(atomic, intr->src[0]);
+       ir3_handle_bindless_cat6(atomic, intr->src[0]);
 
        /* even if nothing consume the result, we can't DCE the instruction: */
        array_insert(b, b->keeps, atomic);
@@ -224,7 +213,7 @@ emit_intrinsic_load_image(struct ir3_context *ctx, nir_intrinsic_instr *intr,
        ldib->cat6.typed = true;
        ldib->barrier_class = IR3_BARRIER_IMAGE_R;
        ldib->barrier_conflict = IR3_BARRIER_IMAGE_W;
-       handle_bindless_cat6(ldib, intr->src[0]);
+       ir3_handle_bindless_cat6(ldib, intr->src[0]);
 
        ir3_split_dest(b, dst, ldib, 0, intr->num_components);
 }
@@ -252,7 +241,7 @@ emit_intrinsic_store_image(struct ir3_context *ctx, nir_intrinsic_instr *intr)
        stib->cat6.typed = true;
        stib->barrier_class = IR3_BARRIER_IMAGE_W;
        stib->barrier_conflict = IR3_BARRIER_IMAGE_R | IR3_BARRIER_IMAGE_W;
-       handle_bindless_cat6(stib, intr->src[0]);
+       ir3_handle_bindless_cat6(stib, intr->src[0]);
 
        array_insert(b, b->keeps, stib);
 }
@@ -343,7 +332,7 @@ emit_intrinsic_atomic_image(struct ir3_context *ctx, nir_intrinsic_instr *intr)
        atomic->cat6.typed = true;
        atomic->barrier_class = IR3_BARRIER_IMAGE_W;
        atomic->barrier_conflict = IR3_BARRIER_IMAGE_R | IR3_BARRIER_IMAGE_W;
-       handle_bindless_cat6(atomic, intr->src[0]);
+       ir3_handle_bindless_cat6(atomic, intr->src[0]);
 
        /* even if nothing consume the result, we can't DCE the instruction: */
        array_insert(b, b->keeps, atomic);
index 617fe1a7706e2864d2a7cfa6f2d2c1be1423b715..e12a814abd8b584faa9c81672ebd52b9523aa309 100644 (file)
 #include "ir3.h"
 #include "ir3_context.h"
 
+void
+ir3_handle_bindless_cat6(struct ir3_instruction *instr, nir_src rsrc)
+{
+       nir_intrinsic_instr *intrin = ir3_bindless_resource(rsrc);
+       if (!intrin)
+               return;
+
+       instr->flags |= IR3_INSTR_B;
+       instr->cat6.base = nir_intrinsic_desc_set(intrin);
+}
 
 static struct ir3_instruction *
 create_indirect_load(struct ir3_context *ctx, unsigned arrsz, int n,
@@ -747,12 +757,9 @@ emit_intrinsic_load_ubo_ldc(struct ir3_context *ctx, nir_intrinsic_instr *intr,
        ldc->cat6.d = nir_intrinsic_base(intr);
        ldc->cat6.type = TYPE_U32;
 
-       nir_intrinsic_instr *bindless = ir3_bindless_resource(intr->src[0]);
-       if (bindless) {
-               ldc->flags |= IR3_INSTR_B;
-               ldc->cat6.base = nir_intrinsic_desc_set(bindless);
+       ir3_handle_bindless_cat6(ldc, intr->src[0]);
+       if (ldc->flags & IR3_INSTR_B)
                ctx->so->bindless_ubo = true;
-       }
 
        ir3_split_dest(b, dst, ldc, 0, ncomp);
 }
index 659303de9e17be25548fd3b0ba5e2e4605a785d0..c977dc15285abe34b1215815ee2355073b0e72fc 100644 (file)
@@ -180,6 +180,7 @@ struct ir3_instruction * ir3_create_collect(struct ir3_context *ctx,
                struct ir3_instruction *const *arr, unsigned arrsz);
 void ir3_split_dest(struct ir3_block *block, struct ir3_instruction **dst,
                struct ir3_instruction *src, unsigned base, unsigned n);
+void ir3_handle_bindless_cat6(struct ir3_instruction *instr, nir_src rsrc);
 
 NORETURN void ir3_context_error(struct ir3_context *ctx, const char *format, ...);