From 2ec4c53ef94901bd7d1623047c52dcdb98a9764f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 20 May 2020 14:00:33 -0700 Subject: [PATCH] freedreno/ir3: Move handle_bindless_cat6 to compiler_nir and reuse. 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: --- src/freedreno/ir3/ir3_a6xx.c | 23 ++++++----------------- src/freedreno/ir3/ir3_compiler_nir.c | 17 ++++++++++++----- src/freedreno/ir3/ir3_context.h | 1 + 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/freedreno/ir3/ir3_a6xx.c b/src/freedreno/ir3/ir3_a6xx.c index cef7a78dad5..9b8f154bb64 100644 --- a/src/freedreno/ir3/ir3_a6xx.c +++ b/src/freedreno/ir3/ir3_a6xx.c @@ -37,17 +37,6 @@ * 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); diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index 617fe1a7706..e12a814abd8 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -39,6 +39,16 @@ #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); } diff --git a/src/freedreno/ir3/ir3_context.h b/src/freedreno/ir3/ir3_context.h index 659303de9e1..c977dc15285 100644 --- a/src/freedreno/ir3/ir3_context.h +++ b/src/freedreno/ir3/ir3_context.h @@ -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, ...); -- 2.30.2