From fee4e991fe9b905edeb31f3bc5cf1fef32e9e5f1 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Mon, 16 Nov 2020 16:57:07 +0100 Subject: [PATCH] pan/bi: Stop extracting the immediate attribute index from src0 Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_pack.c | 8 ++++-- src/panfrost/bifrost/bi_print.c | 2 +- src/panfrost/bifrost/bifrost_compile.c | 36 ++++++++++++++++---------- src/panfrost/bifrost/compiler.h | 6 +++++ src/panfrost/bifrost/gen_pack.py | 4 +-- 5 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index e84f0743bfb..31d80b12717 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -863,7 +863,9 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, bi_registers *regs, gl_shader_s pan_pack_add_isub_s32(clause, bundle.add, regs); } case BI_LOAD_ATTR: - return pan_pack_add_ld_attr_imm(clause, bundle.add, regs); + return bundle.add->attribute.immediate ? + pan_pack_add_ld_attr_imm(clause, bundle.add, regs) : + pan_pack_add_ld_attr(clause, bundle.add, regs); case BI_LOAD: case BI_LOAD_UNIFORM: assert(u32 || s32 || f32); @@ -877,7 +879,9 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, bi_registers *regs, gl_shader_s case BI_LOAD_VAR: return bi_pack_add_ld_var(clause, bundle.add, regs); case BI_LOAD_VAR_ADDRESS: - return pan_pack_add_lea_attr_imm(clause, bundle.add, regs); + return bundle.add->attribute.immediate ? + pan_pack_add_lea_attr_imm(clause, bundle.add, regs) : + pan_pack_add_lea_attr(clause, bundle.add, regs); case BI_LOAD_TILE: return pan_pack_add_ld_tile(clause, bundle.add, regs); case BI_MINMAX: diff --git a/src/panfrost/bifrost/bi_print.c b/src/panfrost/bifrost/bi_print.c index fb8e11ba1e3..0ab8a68a48f 100644 --- a/src/panfrost/bifrost/bi_print.c +++ b/src/panfrost/bifrost/bi_print.c @@ -262,7 +262,7 @@ bi_print_load_vary(struct bi_load_vary *load, FILE *fp) case BIFROST_UPDATE_STORE: fprintf(fp, ".store"); break; case BIFROST_UPDATE_RETRIEVE: fprintf(fp, ".retrieve"); break; case BIFROST_UPDATE_CONDITIONAL: fprintf(fp, ".conditional"); break; - case BIFROST_UPDATE_CLOBBER: fprintf(fp, ".conditional"); break; + case BIFROST_UPDATE_CLOBBER: fprintf(fp, ".clobber"); break; default: unreachable("Invalid update mode"); } } diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index ea0c3ab6158..cec7c36303f 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -76,14 +76,11 @@ emit_jump(bi_context *ctx, nir_jump_instr *instr) } static bi_instruction -bi_load(enum bi_class T, nir_intrinsic_instr *instr) +bi_load(enum bi_class T, nir_intrinsic_instr *instr, unsigned offset_idx) { bi_instruction load = { .type = T, .vector_channels = instr->num_components, - .src = { BIR_INDEX_CONSTANT }, - .src_types = { nir_type_uint32 }, - .constant = { .u64 = nir_intrinsic_base(instr) }, }; const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic]; @@ -96,10 +93,14 @@ bi_load(enum bi_class T, nir_intrinsic_instr *instr) nir_src *offset = nir_get_io_offset_src(instr); - if (nir_src_is_const(*offset)) - load.constant.u64 += nir_src_as_uint(*offset); - else - load.src[0] = pan_src_index(offset); + load.src_types[offset_idx] = nir_type_uint32; + if (nir_src_is_const(*offset)) { + load.src[offset_idx] = BIR_INDEX_CONSTANT | 0; + load.constant.u64 = nir_src_as_uint(*offset) + + nir_intrinsic_base(instr); + } else { + load.src[offset_idx] = pan_src_index(offset); + } return load; } @@ -397,14 +398,21 @@ bi_emit_frag_out(bi_context *ctx, nir_intrinsic_instr *instr) static bi_instruction bi_load_with_r61(enum bi_class T, nir_intrinsic_instr *instr) { - bi_instruction ld = bi_load(T, instr); - ld.src[1] = BIR_INDEX_REGISTER | 61; /* TODO: RA */ - ld.src[2] = BIR_INDEX_REGISTER | 62; + bi_instruction ld = bi_load(T, instr, 2); + ld.src[0] = BIR_INDEX_REGISTER | 61; /* TODO: RA */ + ld.src[1] = BIR_INDEX_REGISTER | 62; + ld.src_types[0] = nir_type_uint32; ld.src_types[1] = nir_type_uint32; - ld.src_types[2] = nir_type_uint32; ld.format = instr->intrinsic == nir_intrinsic_store_output ? - nir_intrinsic_src_type(instr) : - nir_intrinsic_dest_type(instr); + nir_intrinsic_src_type(instr) : + nir_intrinsic_dest_type(instr); + + /* Promote to immediate instruction if we can */ + if (ld.src[0] & BIR_INDEX_CONSTANT && ld.constant.u64 < 16) { + ld.attribute.immediate = true; + ld.attribute.index = ld.constant.u64; + } + return ld; } diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index d2a021c71e1..8219b2c2e0e 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -308,6 +308,11 @@ struct bi_special { enum bi_subgroup_sz subgroup_sz; }; +struct bi_attribute { + unsigned index; + bool immediate; +}; + typedef struct { struct list_head link; /* Must be first */ enum bi_class type; @@ -405,6 +410,7 @@ typedef struct { struct bi_bitwise bitwise; struct bi_texture texture; struct bi_special special; + struct bi_attribute attribute; }; } bi_instruction; diff --git a/src/panfrost/bifrost/gen_pack.py b/src/panfrost/bifrost/gen_pack.py index d633747dae0..84485ff2c04 100644 --- a/src/panfrost/bifrost/gen_pack.py +++ b/src/panfrost/bifrost/gen_pack.py @@ -391,7 +391,7 @@ def pack_derived(pos, exprs, imm_map, body, pack_exprs): # lookup the value in the IR, performing adjustments as needed IMMEDIATE_TABLE = { - 'attribute_index': 'bi_get_immediate(ins, 0)', + 'attribute_index': 'ins->attribute.index', 'varying_index': 'ins->texture.varying_index', 'index': 'ins->load_vary.index', 'texture_index': 'ins->texture.texture_index', @@ -452,8 +452,6 @@ def pack_variant(opname, states): if staging in ["r", "rw"]: offset += 1 - offset += len(set(["attribute_index"]) & set([x[0] for x in states[0][1].get("immediates", [])])) - pack_sources(states[0][1].get("srcs", []), common_body, pack_exprs, offset) modifiers_handled = []