This adds support for GDS ops to sb backend.
This seems to work for atomics and tess factor writes.
Acked-By: Roland Scheidegger <sroland@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
AF_CC_LE = (5U << AF_CC_SHIFT),
};
-/* flags for FETCH instructions (TEX/VTX) */
+/* flags for FETCH instructions (TEX/VTX/GDS) */
enum fetch_op_flags
{
FF_GDS = (1<<0),
SQ_ALU,
SQ_TEX,
SQ_VTX,
+ SQ_GDS,
SQ_NUM
};
unsigned mega_fetch:1;
unsigned src2_gpr:7; /* for GDS */
+ unsigned alloc_consume:1;
+ unsigned uav_id:4;
+ unsigned uav_index_mode:2;
+ unsigned bcast_first_req:1;
+
void set_op(unsigned op) { this->op = op; op_ptr = r600_isa_fetch(op); }
};
int build_fetch_clause(cf_node *n);
int build_fetch_tex(fetch_node *n);
int build_fetch_vtx(fetch_node *n);
+ int build_fetch_gds(fetch_node *n);
};
} // namespace r600_sb
I != E; ++I) {
fetch_node *f = static_cast<fetch_node*>(*I);
- if (f->bc.op_ptr->flags & FF_VTX)
+ if (f->bc.op_ptr->flags & FF_GDS)
+ build_fetch_gds(f);
+ else if (f->bc.op_ptr->flags & FF_VTX)
build_fetch_vtx(f);
else
build_fetch_tex(f);
return 0;
}
+int bc_builder::build_fetch_gds(fetch_node *n) {
+ const bc_fetch &bc = n->bc;
+ const fetch_op_info *fop = bc.op_ptr;
+ unsigned gds_op = (ctx.fetch_opcode(bc.op) >> 8) & 0x3f;
+ unsigned mem_op = 4;
+ assert(fop->flags && FF_GDS);
+
+ if (bc.op == FETCH_OP_TF_WRITE) {
+ mem_op = 5;
+ gds_op = 0;
+ }
+
+ bb << MEM_GDS_WORD0_EGCM()
+ .MEM_INST(2)
+ .MEM_OP(mem_op)
+ .SRC_GPR(bc.src_gpr)
+ .SRC_SEL_X(bc.src_sel[0])
+ .SRC_SEL_Y(bc.src_sel[1])
+ .SRC_SEL_Z(bc.src_sel[2]);
+
+ bb << MEM_GDS_WORD1_EGCM()
+ .DST_GPR(bc.dst_gpr)
+ .DST_REL_MODE(bc.dst_rel)
+ .GDS_OP(gds_op)
+ .SRC_GPR(bc.src2_gpr)
+ .UAV_INDEX_MODE(bc.uav_index_mode)
+ .UAV_ID(bc.uav_id)
+ .ALLOC_CONSUME(bc.alloc_consume)
+ .BCAST_FIRST_REQ(bc.bcast_first_req);
+
+ bb << MEM_GDS_WORD2_EGCM()
+ .DST_SEL_X(bc.dst_sel[0])
+ .DST_SEL_Y(bc.dst_sel[1])
+ .DST_SEL_Z(bc.dst_sel[2])
+ .DST_SEL_W(bc.dst_sel[3]);
+
+ bb << 0;
+ return 0;
+}
+
int bc_builder::build_fetch_vtx(fetch_node* n) {
const bc_fetch &bc = n->bc;
const fetch_op_info *fop = bc.op_ptr;
unsigned gds_op;
if (mem_op == 4) {
gds_op = (dw1 >> 9) & 0x1f;
- fetch_opcode = FETCH_OP_GDS_ADD + gds_op;
+ if ((dw1 >> 9) & 0x20)
+ fetch_opcode = FETCH_OP_GDS_ADD_RET + gds_op;
+ else
+ fetch_opcode = FETCH_OP_GDS_ADD + gds_op;
} else if (mem_op == 5)
fetch_opcode = FETCH_OP_TF_WRITE;
bc.set_op(fetch_opcode);
tmp = w1.get_DST_REL_MODE();
bc.dst_rel_global = (tmp == 2);
bc.src2_gpr = w1.get_SRC_GPR();
+ bc.alloc_consume = w1.get_ALLOC_CONSUME();
+ bc.uav_id = w1.get_UAV_ID();
+ bc.uav_index_mode = w1.get_UAV_INDEX_MODE();
+ bc.bcast_first_req = w1.get_BCAST_FIRST_REQ();
MEM_GDS_WORD2_EGCM w2(dw2);
bc.dst_sel[0] = w2.get_DST_SEL_X();
sb_ostringstream s;
static const char * fetch_type[] = {"VERTEX", "INSTANCE", ""};
unsigned gds = n.bc.op_ptr->flags & FF_GDS;
+ bool gds_has_ret = gds && n.bc.op >= FETCH_OP_GDS_ADD_RET &&
+ n.bc.op <= FETCH_OP_GDS_USHORT_READ_RET;
+ bool show_dst = !gds || (gds && gds_has_ret);
s << n.bc.op_ptr->name;
fill_to(s, 20);
- if (!gds) {
+ if (show_dst) {
s << "R";
print_sel(s, n.bc.dst_gpr, n.bc.dst_rel, INDEX_LOOP, 0);
s << ".";
s << ", RID:" << n.bc.resource_id;
if (gds) {
-
+ s << " UAV:" << n.bc.uav_id;
+ if (n.bc.uav_index_mode)
+ s << " UAV:SQ_CF_INDEX_" << (n.bc.uav_index_mode - V_SQ_CF_INDEX_0);
+ if (n.bc.bcast_first_req)
+ s << " BFQ";
+ if (n.bc.alloc_consume)
+ s << " AC";
} else if (vtx) {
s << " " << fetch_type[n.bc.fetch_type];
if (!ctx.is_cayman() && n.bc.mega_fetch_count)
if (flags & FF_VTX) {
src_count = 1;
+ } else if (flags & FF_GDS) {
+ src_count = 2;
} else if (flags & FF_USEGRAD) {
emit_set_grad(f);
} else if (flags & FF_USE_TEXTURE_OFFSETS) {
for (unsigned i = 0; i < 4; ++i)
f->bc.dst_sel[i] = dst_swz[i];
+ if ((flags & FF_GDS) && reg == -1) {
+ f->bc.dst_sel[0] = SEL_MASK;
+ f->bc.dst_gpr = 0;
+ return ;
+ }
assert(reg >= 0);
if (reg >= 0)
int r;
unsigned i = cf->bc.addr << 1, cnt = cf->bc.count + 1;
- cf->subtype = NST_TEX_CLAUSE;
+ if (cf->bc.op_ptr->flags && FF_GDS)
+ cf->subtype = NST_GDS_CLAUSE;
+ else
+ cf->subtype = NST_TEX_CLAUSE;
while (cnt--) {
fetch_node *n = sh->create_fetch();
unsigned flags = n->bc.op_ptr->flags;
unsigned vtx = flags & FF_VTX;
- unsigned num_src = vtx ? ctx.vtx_src_num : 4;
+ unsigned gds = flags & FF_GDS;
+ unsigned num_src = gds ? 2 : vtx ? ctx.vtx_src_num : 4;
n->dst.resize(4);
+ if (gds) {
+ n->flags |= NF_DONT_HOIST | NF_DONT_MOVE | NF_DONT_KILL;
+ }
if (flags & (FF_SETGRAD | FF_USEGRAD | FF_GETGRAD)) {
sh->uses_gradients = true;
}
case NST_ALU_CLAUSE:
case NST_TEX_CLAUSE:
case NST_VTX_CLAUSE:
+ case NST_GDS_CLAUSE:
dump_op(*n, static_cast<cf_node*>(n)->bc.op_ptr->name);
break;
case NST_ALU_PACKED_INST:
if (sq != SQ_CF) {
if (!clause || sampler_indexing) {
- clause = sh.create_clause(sq == SQ_ALU ?
- NST_ALU_CLAUSE :
- sq == SQ_TEX ? NST_TEX_CLAUSE :
- NST_VTX_CLAUSE);
+ node_subtype nst;
+ switch (sq) {
+ case SQ_ALU:
+ nst = NST_ALU_CLAUSE;
+ break;
+ case SQ_TEX:
+ nst = NST_TEX_CLAUSE;
+ break;
+ case SQ_GDS:
+ nst = NST_GDS_CLAUSE;
+ break;
+ default:
+ nst = NST_VTX_CLAUSE;
+ break;
+ }
+ clause = sh.create_clause(nst);
bb->push_front(clause);
}
} else {
NST_FETCH_INST,
NST_TEX_CLAUSE,
NST_VTX_CLAUSE,
+ NST_GDS_CLAUSE,
NST_BB,
bool is_alu_clause() { return subtype == NST_ALU_CLAUSE; }
bool is_fetch_clause() {
- return subtype == NST_TEX_CLAUSE || subtype == NST_VTX_CLAUSE;
+ return subtype == NST_TEX_CLAUSE || subtype == NST_VTX_CLAUSE || subtype == NST_GDS_CLAUSE;
}
bool is_copy() { return subtype == NST_COPY; }
if (n->is_container())
run_on(static_cast<container_node*>(n));
else {
-
+ if (n->is_fetch_inst() && (n->fetch_op_flags() & FF_GDS)) {
+ fetch_node *f = static_cast<fetch_node*>(n);
+ bool has_dst = false;
+
+ for(vvec::iterator I = f->dst.begin(), E = f->dst.end(); I != E; ++I) {
+ value *v = *I;
+ if (v)
+ has_dst = true;
+ }
+ if (!has_dst)
+ if (f->bc.op >= FETCH_OP_GDS_ADD_RET && f->bc.op <= FETCH_OP_GDS_USHORT_READ_RET)
+ f->bc.set_op(f->bc.op - FETCH_OP_GDS_ADD_RET + FETCH_OP_GDS_ADD);
+ }
if (n->is_alu_inst()) {
alu_node *a = static_cast<alu_node*>(n);
no_src_swizzle |= n->is_fetch_op(FETCH_OP_VFETCH) ||
n->is_fetch_op(FETCH_OP_SEMFETCH);
+ no_src_swizzle |= n->is_fetch_inst() && (n->fetch_op_flags() & FF_GDS);
+
if (!n->src.empty() && !call_fs) {
// we may have more than one source vector -
case NST_ALU_CLAUSE: n->bc.set_op(CF_OP_ALU); break;
case NST_TEX_CLAUSE: n->bc.set_op(CF_OP_TEX); break;
case NST_VTX_CLAUSE: n->bc.set_op(CF_OP_VTX); break;
+ case NST_GDS_CLAUSE: n->bc.set_op(CF_OP_GDS); break;
default: assert(!"invalid clause type"); break;
}
fetch_node *f = static_cast<fetch_node*>(n);
if (ctx.is_r600() && (f->bc.op_ptr->flags & FF_VTX))
return SQ_VTX;
+ if (f->bc.op_ptr->flags & FF_GDS)
+ return SQ_GDS;
return SQ_TEX;
}
case NST_CF_INST: