Mesa (master): pan/bi: Stop passing special varying names through src0
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Nov 17 08:24:50 UTC 2020
Module: Mesa
Branch: master
Commit: d86973d92a9021c2bb1e0b8088cce7db3b1ae5be
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d86973d92a9021c2bb1e0b8088cce7db3b1ae5be
Author: Boris Brezillon <boris.brezillon at collabora.com>
Date: Mon Nov 16 11:46:26 2020 +0100
pan/bi: Stop passing special varying names through src0
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 at collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7636>
---
src/panfrost/bifrost/bi_pack.c | 2 +-
src/panfrost/bifrost/bi_print.c | 9 +++++++++
src/panfrost/bifrost/bi_schedule.c | 6 ++----
src/panfrost/bifrost/bifrost.h | 7 +++++--
src/panfrost/bifrost/bifrost_compile.c | 26 ++++++++++----------------
src/panfrost/bifrost/compiler.h | 2 ++
src/panfrost/bifrost/gen_pack.py | 11 +----------
7 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c
index 15be31bdf26..06289b897f5 100644
--- a/src/panfrost/bifrost/bi_pack.c
+++ b/src/panfrost/bifrost/bi_pack.c
@@ -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) {
diff --git a/src/panfrost/bifrost/bi_print.c b/src/panfrost/bifrost/bi_print.c
index c546bd6af7f..413a54116fc 100644
--- a/src/panfrost/bifrost/bi_print.c
+++ b/src/panfrost/bifrost/bi_print.c
@@ -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");
diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c
index e6b8711e64b..c2315555b5d 100644
--- a/src/panfrost/bifrost/bi_schedule.c
+++ b/src/panfrost/bifrost/bi_schedule.c
@@ -31,10 +31,8 @@
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
diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h
index 64ded49c7a1..8ffd52b7fc9 100644
--- a/src/panfrost/bifrost/bifrost.h
+++ b/src/panfrost/bifrost/bifrost.h
@@ -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,
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index 32429b0ae26..6fe57ab8d04 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -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);
diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h
index 1eb3149efe6..21ade30d282 100644
--- a/src/panfrost/bifrost/compiler.h
+++ b/src/panfrost/bifrost/compiler.h
@@ -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;
};
diff --git a/src/panfrost/bifrost/gen_pack.py b/src/panfrost/bifrost/gen_pack.py
index 93ee42020ac..b7541733157 100644
--- a/src/panfrost/bifrost/gen_pack.py
+++ b/src/panfrost/bifrost/gen_pack.py
@@ -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 = []
More information about the mesa-commit
mailing list