{
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) {
{
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");
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
};
/* 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,
.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
},
.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);
.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);
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;
};
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'))
"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,
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 = []