Commit e085f3ad authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

midgard: Use actual compact writeout fields

Signed-off-by: Alyssa Rosenzweig's avatarAlyssa Rosenzweig <alyssa@rosenzweig.io>
parent b8c15bd0
......@@ -184,6 +184,33 @@ __attribute__((__packed__))
bool src2_imm : 1;
} midgard_reg_info_t;
/* Compact writeouts */
typedef enum
{
midgard_jmp_writeout_op_branch_uncond = 1,
midgard_jmp_writeout_op_branch_cond = 2,
midgard_jmp_writeout_op_writeout = 7,
} midgard_jmp_writeout_op_e;
typedef struct
__attribute__((__packed__))
{
midgard_jmp_writeout_op_e op : 3; /* == branch_uncond */
unsigned dest_tag : 4; /* tag of branch destination */
unsigned unknown : 2;
int offset : 7;
} midgard_branch_uncond_t;
typedef struct
__attribute__((__packed__))
{
midgard_jmp_writeout_op_e op : 3; /* == branch_cond */
unsigned dest_tag : 4; /* tag of branch destination */
int offset : 7;
unsigned cond : 2;
} midgard_branch_cond_t;
/*
* Load/store words
*/
......@@ -253,3 +280,7 @@ __attribute__((__packed__))
#define COMPONENT_Y 0x1
#define COMPONENT_Z 0x2
#define COMPONENT_W 0x3
/* Output writing "condition" for the branch (all one's) */
#define COND_FBWRITE 0x3
......@@ -251,15 +251,25 @@ M_ALU_VECTOR_1(synthwrite);
* no? */
static midgard_instruction
m_alu_br_compact(uint16_t val)
m_alu_br_compact_cond(midgard_jmp_writeout_op_e op, unsigned tag, signed offset, unsigned cond)
{
midgard_branch_cond_t branch = {
.op = op,
.dest_tag = tag,
.offset = offset,
.cond = cond
};
uint16_t compact;
memcpy(&compact, &branch, sizeof(branch));
midgard_instruction ins = {
.type = TAG_ALU_4,
.unused = false,
.uses_ssa = false,
.compact_branch = true,
.br_compact = val,
.br_compact = compact
};
return ins;
......@@ -805,13 +815,13 @@ midgard_compile_shader_nir(nir_shader *nir, struct util_dynarray *compiled)
allocate_registers(ctx);
/* Append fragment shader epilogue (value writeout) */
EMIT(alu_br_compact, 0xF00F);
EMIT(alu_br_compact_cond, midgard_jmp_writeout_op_writeout, TAG_ALU_4, 0, COND_FBWRITE);
/* Errata workaround -- the above write
* can sometimes fail -.- */
EMIT(fmov, 0, blank_alu_src, 0, true);
EMIT(alu_br_compact, 0xF00F);
EMIT(alu_br_compact_cond, midgard_jmp_writeout_op_writeout, TAG_ALU_4, -1, COND_FBWRITE);
break; /* TODO: Multi-block shaders */
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment