From ca5a00a70cabf7c77ba0c18bc3760dd21afc91c2 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 5 Nov 2020 12:10:42 +0100 Subject: [PATCH] pan/bi: Extract LD_VAR sample field from ins->load_vary.interp_mode So we can extend bi_emit_ld_vary() to support centroid and sample modes. Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_print_common.c | 4 ++-- src/panfrost/bifrost/bifrost.h | 7 ++++--- src/panfrost/bifrost/bifrost_compile.c | 4 ++-- src/panfrost/bifrost/gen_pack.py | 4 +++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/panfrost/bifrost/bi_print_common.c b/src/panfrost/bifrost/bi_print_common.c index e0f8b3f8425..0bd8f0f9812 100644 --- a/src/panfrost/bifrost/bi_print_common.c +++ b/src/panfrost/bifrost/bi_print_common.c @@ -91,9 +91,9 @@ const char * bi_interp_mode_name(enum bifrost_interp_mode mode) { switch (mode) { - case BIFROST_INTERP_PER_FRAG: return ".per_frag"; + case BIFROST_INTERP_CENTER: return ".center"; case BIFROST_INTERP_CENTROID: return ".centroid"; - case BIFROST_INTERP_DEFAULT: return ""; + case BIFROST_INTERP_SAMPLE: return ".sample"; case BIFROST_INTERP_EXPLICIT: return ".explicit"; default: return ".unknown"; } diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index 6d03a582b94..a0d7d7fbc73 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -221,10 +221,11 @@ enum bifrost_minmax_mode { }; enum bifrost_interp_mode { - BIFROST_INTERP_PER_FRAG = 0x0, + BIFROST_INTERP_CENTER = 0x0, BIFROST_INTERP_CENTROID = 0x1, - BIFROST_INTERP_DEFAULT = 0x2, - BIFROST_INTERP_EXPLICIT = 0x3 + BIFROST_INTERP_SAMPLE = 0x2, + BIFROST_INTERP_EXPLICIT = 0x3, + BIFROST_INTERP_NONE = 0x4, }; /* Fixed location for gl_FragCoord.zw */ diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 68ca813e893..aae3a1a500c 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -148,7 +148,7 @@ static void bi_emit_ld_vary(bi_context *ctx, nir_intrinsic_instr *instr) { bi_instruction ins = bi_load(BI_LOAD_VAR, instr); - ins.load_vary.interp_mode = BIFROST_INTERP_DEFAULT; /* TODO */ + ins.load_vary.interp_mode = BIFROST_INTERP_CENTER; /* TODO */ ins.load_vary.reuse = false; /* TODO */ ins.load_vary.flat = instr->intrinsic != nir_intrinsic_load_interpolated_input; ins.dest_type = nir_type_float | nir_dest_bit_size(instr->dest); @@ -500,7 +500,7 @@ bi_emit_ld_frag_coord(bi_context *ctx, nir_intrinsic_instr *instr) bi_instruction load = { .type = BI_LOAD_VAR, .load_vary = { - .interp_mode = BIFROST_INTERP_DEFAULT, + .interp_mode = BIFROST_INTERP_CENTER, .reuse = false, .flat = true }, diff --git a/src/panfrost/bifrost/gen_pack.py b/src/panfrost/bifrost/gen_pack.py index 1121de7a3b3..d9d31fd57d5 100644 --- a/src/panfrost/bifrost/gen_pack.py +++ b/src/panfrost/bifrost/gen_pack.py @@ -281,6 +281,9 @@ modifier_map = { "z": lambda a,b,c,d: '(ins->src[0] != 0)', "stencil": lambda a,b,c,d: '(ins->src[1] != 0)', + # For +LD_VAR, infer sample from load_vary.interp_mode + "sample": lambda a,b,c,d: 'ins->load_vary.interp_mode', + # We don't support these in the IR yet (TODO) "saturate": lambda a,b,c,d: '0', # clamp to min/max int "mask": lambda a,b,c,d: '0', # clz(~0) = ~0 @@ -296,7 +299,6 @@ modifier_map = { "func": lambda a,b,c,d: '0', # pow special case thing "h": lambda a,b,c,d: '0', # VN_ASST1.f16 "l": lambda a,b,c,d: '0', # VN_ASST1.f16 - "sample": lambda a,b,c,d: '0', # LD_VAR center "function": lambda a,b,c,d: '3', # LD_VAR_FLAT none "preserve_null": lambda a,b,c,d: '0', # SEG_ADD none "bytes2": lambda a,b,c,d: '0', # NIR shifts are in bits