From 6ed1bdfee4b3566e9246563f6cc0914400547f63 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 6 Oct 2020 10:31:04 -0400 Subject: [PATCH] pan/bi: Use canonical texture op names in IR Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/bi_pack.c | 20 ++++++++++---------- src/panfrost/bifrost/bi_print.c | 21 +++++---------------- src/panfrost/bifrost/bi_print.h | 1 - src/panfrost/bifrost/bi_schedule.c | 4 +++- src/panfrost/bifrost/bi_tables.c | 4 +++- src/panfrost/bifrost/bifrost_compile.c | 5 ++--- src/panfrost/bifrost/compiler.h | 11 +++-------- src/panfrost/bifrost/test/bi_interpret.c | 4 +++- 8 files changed, 29 insertions(+), 41 deletions(-) diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 86217f4..eb4683b 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -853,17 +853,17 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, bi_registers *regs, gl_shader_s case BI_SELECT: assert(nir_alu_type_get_type_size(bundle.add->src_types[0]) == 16); return pan_pack_add_mkvec_v2i16(clause, bundle.add, regs); - case BI_TEX: - if (bundle.add->op.texture == BI_TEX_COMPACT) { - assert(f16 || f32); + case BI_TEXC: + case BI_TEXC_DUAL: + unreachable("Packing todo"); + case BI_TEXS: + assert(f16 || f32); - if (f16) - return pan_pack_add_texs_2d_f16(clause, bundle.add, regs); - else - return pan_pack_add_texs_2d_f32(clause, bundle.add, regs); - } else - unreachable("Unknown tex type"); - case BI_ROUND: + if (f16) + return pan_pack_add_texs_2d_f16(clause, bundle.add, regs); + else + return pan_pack_add_texs_2d_f32(clause, bundle.add, regs); +case BI_ROUND: unreachable("Packing todo"); default: unreachable("Cannot encode class as ADD"); diff --git a/src/panfrost/bifrost/bi_print.c b/src/panfrost/bifrost/bi_print.c index 527f506..e801f77 100644 --- a/src/panfrost/bifrost/bi_print.c +++ b/src/panfrost/bifrost/bi_print.c @@ -69,7 +69,9 @@ bi_class_name(enum bi_class cl) case BI_STORE_VAR: return "store_var"; case BI_SPECIAL: return "special"; case BI_TABLE: return "table"; - case BI_TEX: return "tex"; + case BI_TEXS: return "texs"; + case BI_TEXC: return "texc"; + case BI_TEXC_DUAL: return "texc_dual"; case BI_ROUND: return "round"; case BI_IMUL: return "imul"; default: return "unknown_class"; @@ -205,17 +207,6 @@ bi_frexp_op_name(enum bi_frexp_op op) } } -const char * -bi_tex_op_name(enum bi_tex_op op) -{ - switch (op) { - case BI_TEX_NORMAL: return "normal"; - case BI_TEX_COMPACT: return "compact"; - case BI_TEX_DUAL: return "dual"; - default: return "invalid"; - } -} - static void bi_print_load_vary(struct bi_load_vary *load, FILE *fp) { @@ -280,9 +271,7 @@ bi_print_instruction(bi_instruction *ins, FILE *fp) bi_print_load_vary(&ins->load_vary, fp); else if (ins->type == BI_BLEND) fprintf(fp, ".loc%u", ins->blend_location); - else if (ins->type == BI_TEX) { - fprintf(fp, ".%s", bi_tex_op_name(ins->op.texture)); - } else if (ins->type == BI_BITWISE) + else if (ins->type == BI_BITWISE) fprintf(fp, ".%cshift", ins->bitwise.rshift ? 'r' : 'l'); if (bi_class_props[ins->type] & BI_CONDITIONAL) @@ -336,7 +325,7 @@ bi_print_instruction(bi_instruction *ins, FILE *fp) } else { fprintf(fp, "-> void"); } - } else if (ins->type == BI_TEX) { + } else if (ins->type == BI_TEXS) { bi_print_texture(&ins->texture, fp); } diff --git a/src/panfrost/bifrost/bi_print.h b/src/panfrost/bifrost/bi_print.h index d0af7a9..e5a60ee 100644 --- a/src/panfrost/bifrost/bi_print.h +++ b/src/panfrost/bifrost/bi_print.h @@ -42,7 +42,6 @@ const char * bi_special_op_name(enum bi_special_op op); const char * bi_table_op_name(enum bi_table_op op); const char * bi_reduce_op_name(enum bi_reduce_op op); const char * bi_frexp_op_name(enum bi_frexp_op op); -const char * bi_tex_op_name(enum bi_tex_op op); void bi_print_instruction(bi_instruction *ins, FILE *fp); void bi_print_slots(bi_registers *regs, FILE *fp); diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c index 32d1e1d..3e615f0 100644 --- a/src/panfrost/bifrost/bi_schedule.c +++ b/src/panfrost/bifrost/bi_schedule.c @@ -62,7 +62,9 @@ bi_message_type_for_ins(bi_instruction *ins) case BI_LOAD_VAR_ADDRESS: return BIFROST_MESSAGE_ATTRIBUTE; - case BI_TEX: + case BI_TEXS: + case BI_TEXC: + case BI_TEXC_DUAL: return BIFROST_MESSAGE_TEX; case BI_LOAD: diff --git a/src/panfrost/bifrost/bi_tables.c b/src/panfrost/bifrost/bi_tables.c index 0891a27..634d687 100644 --- a/src/panfrost/bifrost/bi_tables.c +++ b/src/panfrost/bifrost/bi_tables.c @@ -54,7 +54,9 @@ unsigned bi_class_props[BI_NUM_CLASSES] = { [BI_SPECIAL] = BI_SCHED_ADD | BI_SCHED_SLOW, [BI_TABLE] = BI_SCHED_ADD, [BI_SELECT] = BI_SCHED_ALL | BI_SWIZZLABLE, - [BI_TEX] = BI_SCHED_HI_LATENCY | BI_SCHED_ADD | BI_VECTOR | BI_DATA_REG_DEST, + [BI_TEXS] = BI_SCHED_HI_LATENCY | BI_SCHED_ADD | BI_VECTOR | BI_DATA_REG_DEST, + [BI_TEXC] = BI_SCHED_HI_LATENCY | BI_SCHED_ADD | BI_VECTOR | BI_DATA_REG_DEST, + [BI_TEXC_DUAL] = BI_SCHED_HI_LATENCY | BI_SCHED_ADD | BI_VECTOR | BI_DATA_REG_DEST, [BI_ROUND] = BI_ROUNDMODE | BI_SCHED_ALL, [BI_IMUL] = BI_SCHED_FMA, }; diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 2de2e7f..a029e9a 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -951,15 +951,14 @@ emit_alu(bi_context *ctx, nir_alu_instr *instr) bi_emit(ctx, alu); } -/* TEX_COMPACT instructions assume normal 2D f32 operation but are more +/* TEXS instructions assume normal 2D f32 operation but are more * space-efficient and with simpler RA/scheduling requirements*/ static void emit_tex_compact(bi_context *ctx, nir_tex_instr *instr) { bi_instruction tex = { - .type = BI_TEX, - .op = { .texture = BI_TEX_COMPACT }, + .type = BI_TEXS, .texture = { .texture_index = instr->texture_index, .sampler_index = instr->sampler_index, diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 6b81d85..43978db 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -74,7 +74,9 @@ enum bi_class { BI_STORE_VAR, BI_SPECIAL, /* _FAST on supported GPUs */ BI_TABLE, - BI_TEX, + BI_TEXS, + BI_TEXC, + BI_TEXC_DUAL, BI_ROUND, BI_IMUL, BI_NUM_CLASSES @@ -231,12 +233,6 @@ enum bi_special_op { BI_SPECIAL_IABS, }; -enum bi_tex_op { - BI_TEX_NORMAL, - BI_TEX_COMPACT, - BI_TEX_DUAL -}; - struct bi_bitwise { bool dest_invert; bool src1_invert; @@ -320,7 +316,6 @@ typedef struct { enum bi_reduce_op reduce; enum bi_table_op table; enum bi_frexp_op frexp; - enum bi_tex_op texture; enum bi_imath_op imath; enum bi_imul_op imul; diff --git a/src/panfrost/bifrost/test/bi_interpret.c b/src/panfrost/bifrost/test/bi_interpret.c index 90d779d..bc2aa32 100644 --- a/src/panfrost/bifrost/test/bi_interpret.c +++ b/src/panfrost/bifrost/test/bi_interpret.c @@ -666,7 +666,9 @@ bit_step(struct bit_state *s, bi_instruction *ins, bool FMA) case BI_LOAD: case BI_STORE: case BI_STORE_VAR: - case BI_TEX: + case BI_TEXS: + case BI_TEXC: + case BI_TEXC_DUAL: unreachable("Unsupported I/O in interpreter"); default: -- 2.7.4