pan/bi: Stop passing special varying names through src0
authorBoris Brezillon <boris.brezillon@collabora.com>
Mon, 16 Nov 2020 10:46:26 +0000 (11:46 +0100)
committerBoris Brezillon <boris.brezillon@collabora.com>
Tue, 17 Nov 2020 07:41:05 +0000 (08:41 +0100)
It's just clearer to have dedicated fields encoding the fact that the
LD_VAR should be SPECIAL, and another field storing the special var id.

With this change, the source index know matches the ISA.xml definition.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7636>

src/panfrost/bifrost/bi_pack.c
src/panfrost/bifrost/bi_print.c
src/panfrost/bifrost/bi_schedule.c
src/panfrost/bifrost/bifrost.h
src/panfrost/bifrost/bifrost_compile.c
src/panfrost/bifrost/compiler.h
src/panfrost/bifrost/gen_pack.py

index 15be31b..06289b8 100644 (file)
@@ -715,7 +715,7 @@ bi_pack_add_ld_var(bi_clause *clause, bi_instruction *ins, bi_registers *regs)
 {
         bool imm = ins->src[0] & BIR_INDEX_CONSTANT;
 
-        if (imm && bi_get_immediate(ins, 0) >= 20)
+        if (ins->load_vary.special)
                 return pan_pack_add_ld_var_special(clause, ins, regs);
 
         if (ins->load_vary.flat) {
index c546bd6..413a541 100644 (file)
@@ -240,6 +240,15 @@ bi_print_load_vary(struct bi_load_vary *load, FILE *fp)
 {
         fprintf(fp, "%s", bi_interp_mode_name(load->interp_mode));
 
+        if (load->special) {
+                switch (load->var_id) {
+                case BIFROST_SPECIAL_VAR_POINT: fprintf(fp, ".point"); break;
+                case BIFROST_SPECIAL_VAR_FRAGZ: fprintf(fp, ".fragz"); break;
+                case BIFROST_SPECIAL_VAR_FRAGW: fprintf(fp, ".fragw"); break;
+                default: unreachable("Invalid varying ID");
+                }
+        }
+
         if (load->reuse)
                 fprintf(fp, ".reuse");
 
index e6b8711..c231555 100644 (file)
 static bool
 bi_is_fragz(bi_instruction *ins)
 {
-        if (!(ins->src[0] & BIR_INDEX_CONSTANT))
-                return false;
-
-        return (ins->constant.u32 == BIFROST_FRAGZ);
+        return ins->load_vary.special &&
+               ins->load_vary.var_id == BIFROST_SPECIAL_VAR_FRAGZ;
 }
 
 static enum bifrost_message_type
index 64ded49..8ffd52b 100644 (file)
@@ -236,8 +236,11 @@ enum bifrost_update_mode {
 };
 
 /* Fixed location for gl_FragCoord.zw */
-#define BIFROST_FRAGZ (23)
-#define BIFROST_FRAGW (22)
+enum bifrost_special_var_id {
+        BIFROST_SPECIAL_VAR_POINT = 0,
+        BIFROST_SPECIAL_VAR_FRAGW = 2,
+        BIFROST_SPECIAL_VAR_FRAGZ = 3,
+};
 
 enum branch_bit_size {
         BR_SIZE_32 = 0,
index 32429b0..6fe57ab 100644 (file)
@@ -568,6 +568,10 @@ bi_emit_ld_frag_coord(bi_context *ctx, nir_intrinsic_instr *instr)
                         .load_vary = {
                                 .interp_mode = BIFROST_INTERP_CENTER,
                                 .update_mode = BIFROST_UPDATE_CLOBBER,
+                                .var_id = (i == 0) ?
+                                          BIFROST_SPECIAL_VAR_FRAGZ :
+                                          BIFROST_SPECIAL_VAR_FRAGW,
+                                .special = true,
                                 .reuse = false,
                                 .flat = true
                         },
@@ -575,14 +579,8 @@ bi_emit_ld_frag_coord(bi_context *ctx, nir_intrinsic_instr *instr)
                         .dest_type = nir_type_float32,
                         .format = nir_type_float32,
                         .dest = bi_make_temp(ctx),
-                        .src = {
-                                BIR_INDEX_CONSTANT,
-                                BIR_INDEX_PASS | BIFROST_SRC_FAU_LO
-                        },
-                        .src_types = { nir_type_uint32, nir_type_uint32 },
-                        .constant = {
-                                .u32 = (i == 0) ? BIFROST_FRAGZ : BIFROST_FRAGW
-                        }
+                        .src[0] = BIR_INDEX_PASS | BIFROST_SRC_FAU_LO,
+                        .src_types[0] = nir_type_uint32,
                 };
 
                 bi_emit(ctx, load);
@@ -727,19 +725,15 @@ bi_emit_point_coord(bi_context *ctx, nir_intrinsic_instr *instr)
                 .type = BI_LOAD_VAR,
                 .load_vary = {
                         .update_mode = BIFROST_UPDATE_CLOBBER,
+                        .var_id = BIFROST_SPECIAL_VAR_POINT,
+                        .special = true,
                 },
                 .vector_channels = 2,
                 .dest = pan_dest_index(&instr->dest),
                 .dest_type = nir_type_float32,
                 .format = nir_type_float32,
-                .src = {
-                        BIR_INDEX_CONSTANT,
-                        BIR_INDEX_ZERO,
-                },
-                .src_types = {
-                        nir_type_uint32,
-                },
-                .constant.u64 = 20,
+                .src[0] = BIR_INDEX_ZERO,
+                .src_types[0] = nir_type_uint32,
         };
 
         bi_emit(ctx, ins);
index 1eb3149..21ade30 100644 (file)
@@ -135,6 +135,8 @@ extern unsigned bi_class_props[BI_NUM_CLASSES];
 struct bi_load_vary {
         enum bifrost_interp_mode interp_mode;
         enum bifrost_update_mode update_mode;
+        enum bifrost_special_var_id var_id;
+        bool special;
         bool reuse;
         bool flat;
 };
index 93ee420..b754173 100644 (file)
@@ -153,12 +153,6 @@ def pack_extend(mod, opts, body, pack_exprs):
         body.append('assert({}_small);'.format(mod))
         return '{}_signed ? 1 : 0'.format(mod)
 
-# Packs special varying loads. Our BIFROST_FRAGZ etc defines match the hw in
-# the bottom two bits (TODO drop upper bits)
-def pack_varying_name(mod, opts, body, pack_exprs):
-    assert(opts[0] == 'point' and opts[2] == 'frag_w' and opts[3] == 'frag_z')
-    return 'ins->constant.u64 & 0x3'
-
 def pack_not_src1(mod, opts, body, pack_exprs):
     return 'ins->bitwise.src1_invert ? {} : {}'.format(opts.index('not'), opts.index('none'))
 
@@ -259,7 +253,7 @@ modifier_map = {
         "clamp": pack_clamp,
         "round": pack_round,
         "cmpf": pack_cmpf,
-        "varying_name": pack_varying_name,
+        "varying_name": lambda a,b,c,d: 'ins->load_vary.var_id',
         "not1": pack_not_src1,
         "not_result": pack_not_result,
         "register_format": pack_register_format,
@@ -460,9 +454,6 @@ def pack_variant(opname, states):
 
     offset += len(set(["attribute_index", "varying_index", "index"]) & set([x[0] for x in states[0][1].get("immediates", [])]))
 
-    if opname == '+LD_VAR_SPECIAL':
-        offset += 1
-
     pack_sources(states[0][1].get("srcs", []), common_body, pack_exprs, offset)
 
     modifiers_handled = []