GL_ARB_draw_indirect DONE (i965, nvc0, radeonsi, llvmpipe, softpipe)
GL_ARB_gpu_shader5 DONE (i965, nvc0)
- 'precise' qualifier DONE
- - Dynamically uniform sampler array indices DONE ()
- - Dynamically uniform UBO array indices DONE ()
+ - Dynamically uniform sampler array indices DONE (r600)
+ - Dynamically uniform UBO array indices DONE (r600)
- Implicit signed -> unsigned conversions DONE
- Fused multiply-add DONE ()
- Packing/bitfield/conversion functions DONE (r600)
/* prepend ALU_EXTENDED if we need more than 2 kcache sets */
if (cf->eg_alu_extended) {
bc->bytecode[id++] =
- S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE0(V_SQ_CF_INDEX_NONE) |
- S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE1(V_SQ_CF_INDEX_NONE) |
- S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE2(V_SQ_CF_INDEX_NONE) |
- S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE3(V_SQ_CF_INDEX_NONE) |
+ S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE0(cf->kcache[0].index_mode) |
+ S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE1(cf->kcache[1].index_mode) |
+ S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE2(cf->kcache[2].index_mode) |
+ S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE3(cf->kcache[3].index_mode) |
S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK2(cf->kcache[2].bank) |
S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK3(cf->kcache[3].bank) |
S_SQ_CF_ALU_WORD0_EXT_KCACHE_MODE2(cf->kcache[2].mode);
output->comp_mask = G_SQ_CF_ALLOC_EXPORT_WORD1_BUF_COMP_MASK(word1);
}
#endif
+
+int egcm_load_index_reg(struct r600_bytecode *bc, unsigned id, bool inside_alu_clause)
+{
+ struct r600_bytecode_alu alu;
+ int r;
+ unsigned type;
+
+ assert(id < 2);
+ assert(bc->chip_class >= EVERGREEN);
+
+ if (bc->index_loaded[id])
+ return 0;
+
+ memset(&alu, 0, sizeof(alu));
+ alu.op = ALU_OP1_MOVA_INT;
+ alu.src[0].sel = bc->index_reg[id];
+ alu.src[0].chan = 0;
+ alu.last = 1;
+ r = r600_bytecode_add_alu(bc, &alu);
+ if (r)
+ return r;
+
+ bc->ar_loaded = 0; /* clobbered */
+
+ memset(&alu, 0, sizeof(alu));
+ alu.op = id == 0 ? ALU_OP0_SET_CF_IDX0 : ALU_OP0_SET_CF_IDX1;
+ alu.last = 1;
+ r = r600_bytecode_add_alu(bc, &alu);
+ if (r)
+ return r;
+
+ /* Must split ALU group as index only applies to following group */
+ if (inside_alu_clause) {
+ type = bc->cf_last->op;
+ if ((r = r600_bytecode_add_cf(bc))) {
+ return r;
+ }
+ bc->cf_last->op = type;
+ }
+
+ bc->index_loaded[id] = 1;
+
+ return 0;
+}
have_rel = 1;
}
+ if (alu->op == ALU_OP0_SET_CF_IDX0 ||
+ alu->op == ALU_OP0_SET_CF_IDX1)
+ return 0; /* data hazard with MOVA */
+
/* Let's check source gprs */
num_src = r600_bytecode_get_num_operands(bc, alu);
for (src = 0; src < num_src; ++src) {
/* we'll keep kcache sets sorted by bank & addr */
static int r600_bytecode_alloc_kcache_line(struct r600_bytecode *bc,
struct r600_bytecode_kcache *kcache,
- unsigned bank, unsigned line)
+ unsigned bank, unsigned line, unsigned index_mode)
{
int i, kcache_banks = bc->chip_class >= EVERGREEN ? 4 : 2;
kcache[i].mode = V_SQ_CF_KCACHE_LOCK_1;
kcache[i].bank = bank;
kcache[i].addr = line;
+ kcache[i].index_mode = index_mode;
return 0;
}
kcache[i].mode = V_SQ_CF_KCACHE_LOCK_1;
kcache[i].bank = bank;
kcache[i].addr = line;
+ kcache[i].index_mode = index_mode;
return 0;
}
}
int i, r;
for (i = 0; i < 3; i++) {
- unsigned bank, line, sel = alu->src[i].sel;
+ unsigned bank, line, sel = alu->src[i].sel, index_mode;
if (sel < 512)
continue;
bank = alu->src[i].kc_bank;
line = (sel-512)>>4;
+ index_mode = alu->src[i].kc_rel ? 1 : 0; // V_SQ_CF_INDEX_0 / V_SQ_CF_INDEX_NONE
- if ((r = r600_bytecode_alloc_kcache_line(bc, kcache, bank, line)))
+ if ((r = r600_bytecode_alloc_kcache_line(bc, kcache, bank, line, index_mode)))
return r;
}
return 0;
memcpy(bc->cf_last->kcache, kcache, 4 * sizeof(struct r600_bytecode_kcache));
}
- /* if we actually used more than 2 kcache sets - use ALU_EXTENDED on eg+ */
- if (kcache[2].mode != V_SQ_CF_KCACHE_NOP) {
+ /* if we actually used more than 2 kcache sets, or have relative indexing - use ALU_EXTENDED on eg+ */
+ if (kcache[2].mode != V_SQ_CF_KCACHE_NOP ||
+ kcache[0].index_mode || kcache[1].index_mode || kcache[2].index_mode || kcache[3].index_mode) {
if (bc->chip_class < EVERGREEN)
return -ENOMEM;
bc->cf_last->eg_alu_extended = 1;
}
bc->cf_last->op = type;
+ /* Load index register if required */
+ if (bc->chip_class >= EVERGREEN) {
+ for (i = 0; i < 3; i++)
+ if (nalu->src[i].kc_bank && nalu->src[i].kc_rel)
+ egcm_load_index_reg(bc, 0, true);
+ }
+
/* Check AR usage and load it if required */
for (i = 0; i < 3; i++)
if (nalu->src[i].rel && !bc->ar_loaded)
return -ENOMEM;
memcpy(nvtx, vtx, sizeof(struct r600_bytecode_vtx));
+ /* Load index register if required */
+ if (bc->chip_class >= EVERGREEN) {
+ if (vtx->buffer_index_mode)
+ egcm_load_index_reg(bc, 0, false);
+ }
+
/* cf can contains only alu or only vtx or only tex */
if (bc->cf_last == NULL ||
last_inst_was_not_vtx_fetch(bc) ||
return -ENOMEM;
memcpy(ntex, tex, sizeof(struct r600_bytecode_tex));
+ /* Load index register if required */
+ if (bc->chip_class >= EVERGREEN) {
+ if (tex->sampler_index_mode || tex->resource_index_mode)
+ egcm_load_index_reg(bc, 1, false);
+ }
+
/* we can't fetch data und use it as texture lookup address in the same TEX clause */
if (bc->cf_last != NULL &&
bc->cf_last->op == CF_OP_TEX) {
S_SQ_VTX_WORD1_GPR_DST_GPR(vtx->dst_gpr);
bc->bytecode[id] = S_SQ_VTX_WORD2_OFFSET(vtx->offset)|
S_SQ_VTX_WORD2_ENDIAN_SWAP(vtx->endian);
+ if (bc->chip_class >= EVERGREEN)
+ bc->bytecode[id] |= ((vtx->buffer_index_mode & 0x3) << 21); // S_SQ_VTX_WORD2_BIM(vtx->buffer_index_mode);
if (bc->chip_class < CAYMAN)
bc->bytecode[id] |= S_SQ_VTX_WORD2_MEGA_FETCH(1);
id++;
/* common to all 3 families */
static int r600_bytecode_tex_build(struct r600_bytecode *bc, struct r600_bytecode_tex *tex, unsigned id)
{
- bc->bytecode[id++] = S_SQ_TEX_WORD0_TEX_INST(
+ bc->bytecode[id] = S_SQ_TEX_WORD0_TEX_INST(
r600_isa_fetch_opcode(bc->isa->hw_class, tex->op)) |
EG_S_SQ_TEX_WORD0_INST_MOD(tex->inst_mod) |
S_SQ_TEX_WORD0_RESOURCE_ID(tex->resource_id) |
S_SQ_TEX_WORD0_SRC_GPR(tex->src_gpr) |
S_SQ_TEX_WORD0_SRC_REL(tex->src_rel);
+ if (bc->chip_class >= EVERGREEN)
+ bc->bytecode[id] |= ((tex->sampler_index_mode & 0x3) << 27) | // S_SQ_TEX_WORD0_SIM(tex->sampler_index_mode);
+ ((tex->resource_index_mode & 0x3) << 25); // S_SQ_TEX_WORD0_RIM(tex->resource_index_mode)
+ id++;
bc->bytecode[id++] = S_SQ_TEX_WORD1_DST_GPR(tex->dst_gpr) |
S_SQ_TEX_WORD1_DST_REL(tex->dst_rel) |
S_SQ_TEX_WORD1_DST_SEL_X(tex->dst_sel_x) |
void r600_bytecode_disasm(struct r600_bytecode *bc)
{
+ const char *index_mode[] = {"CF_INDEX_NONE", "CF_INDEX_0", "CF_INDEX_1"};
static int index = 0;
struct r600_bytecode_cf *cf = NULL;
struct r600_bytecode_alu *alu = NULL;
if (cf->kcache[i].mode) {
int c_start = (cf->kcache[i].addr << 4);
int c_end = c_start + (cf->kcache[i].mode << 4);
- fprintf(stderr, "KC%d[CB%d:%d-%d] ",
- i, cf->kcache[i].bank, c_start, c_end);
+ fprintf(stderr, "KC%d[CB%d:%d-%d%s%s] ",
+ i, cf->kcache[i].bank, c_start, c_end,
+ cf->kcache[i].index_mode ? " " : "",
+ cf->kcache[i].index_mode ? index_mode[cf->kcache[i].index_mode] : "");
}
}
fprintf(stderr, "\n");
o += fprintf(stderr, ", RID:%d", tex->resource_id);
o += fprintf(stderr, ", SID:%d ", tex->sampler_id);
+ if (tex->sampler_index_mode)
+ fprintf(stderr, "SQ_%s ", index_mode[tex->sampler_index_mode]);
+
if (tex->lod_bias)
fprintf(stderr, "LB:%d ", tex->lod_bias);
if (bc->chip_class < CAYMAN && vtx->mega_fetch_count)
fprintf(stderr, "MFC:%d ", vtx->mega_fetch_count);
+ if (bc->chip_class >= EVERGREEN && vtx->buffer_index_mode)
+ fprintf(stderr, "SQ_%s ", index_mode[vtx->buffer_index_mode]);
+
fprintf(stderr, "UCF:%d ", vtx->use_const_fields);
fprintf(stderr, "FMT(DTA:%d ", vtx->data_format);
fprintf(stderr, "NUM:%d ", vtx->num_format_all);
unsigned abs;
unsigned rel;
unsigned kc_bank;
+ unsigned kc_rel;
uint32_t value;
};
unsigned src_sel_y;
unsigned src_sel_z;
unsigned src_sel_w;
+ /* indexed samplers/resources only on evergreen/cayman */
+ unsigned sampler_index_mode;
+ unsigned resource_index_mode;
};
struct r600_bytecode_vtx {
unsigned srf_mode_all;
unsigned offset;
unsigned endian;
+ unsigned buffer_index_mode;
};
struct r600_bytecode_output {
unsigned bank;
unsigned mode;
unsigned addr;
+ unsigned index_mode;
};
struct r600_bytecode_cf {
unsigned ar_chan;
unsigned ar_handling;
unsigned r6xx_nop_after_rel_dst;
+ bool index_loaded[2];
+ unsigned index_reg[2]; /* indexing register CF_INDEX_[01] */
unsigned debug_id;
struct r600_isa* isa;
};
/* eg_asm.c */
int eg_bytecode_cf_build(struct r600_bytecode *bc, struct r600_bytecode_cf *cf);
+int egcm_load_index_reg(struct r600_bytecode *bc, unsigned id, bool inside_alu_clause);
/* r600_asm.c */
void r600_bytecode_init(struct r600_bytecode *bc,
/* disable SB for geom shaders - it can't handle the CF_EMIT instructions */
use_sb &= (shader->shader.processor_type != TGSI_PROCESSOR_GEOMETRY);
+ /* disable SB for shaders using CF_INDEX_0/1 (sampler/ubo array indexing) as it doesn't handle those currently */
+ use_sb &= !shader->shader.uses_index_registers;
/* Check if the bytecode has already been built. When using the llvm
* backend, r600_shader_from_tgsi() will take care of building the
unsigned abs;
unsigned rel;
unsigned kc_bank;
+ boolean kc_rel; /* true if cache bank is indexed */
uint32_t value[4];
};
static int tgsi_endloop(struct r600_shader_ctx *ctx);
static int tgsi_loop_brk_cont(struct r600_shader_ctx *ctx);
static int tgsi_fetch_rel_const(struct r600_shader_ctx *ctx,
- unsigned int cb_idx, unsigned int offset, unsigned ar_chan,
+ unsigned int cb_idx, unsigned cb_rel, unsigned int offset, unsigned ar_chan,
unsigned int dst_reg);
static void r600_bytecode_src(struct r600_bytecode_alu_src *bc_src,
const struct r600_shader_src *shader_src,
if (tgsi_src->Register.File == TGSI_FILE_CONSTANT) {
if (tgsi_src->Register.Dimension) {
r600_src->kc_bank = tgsi_src->Dimension.Index;
+ if (tgsi_src->Dimension.Indirect) {
+ r600_src->kc_rel = 1;
+ }
}
}
}
static int tgsi_fetch_rel_const(struct r600_shader_ctx *ctx,
- unsigned int cb_idx, unsigned int offset, unsigned ar_chan,
+ unsigned int cb_idx, unsigned cb_rel, unsigned int offset, unsigned ar_chan,
unsigned int dst_reg)
{
struct r600_bytecode_vtx vtx;
vtx.num_format_all = 2; /* NUM_FORMAT_SCALED */
vtx.format_comp_all = 1; /* FORMAT_COMP_SIGNED */
vtx.endian = r600_endian_swap(32);
+ vtx.buffer_index_mode = cb_rel; // cb_rel ? V_SQ_CF_INDEX_0 : V_SQ_CF_INDEX_NONE;
if ((r = r600_bytecode_add_vtx(ctx->bc, &vtx)))
return r;
continue;
}
+ if (ctx->src[i].kc_rel)
+ ctx->shader->uses_index_registers = true;
+
if (ctx->src[i].rel) {
int chan = inst->Src[i].Indirect.Swizzle;
int treg = r600_get_temp(ctx);
- if ((r = tgsi_fetch_rel_const(ctx, ctx->src[i].kc_bank, ctx->src[i].sel - 512, chan, treg)))
+ if ((r = tgsi_fetch_rel_const(ctx, ctx->src[i].kc_bank, ctx->src[i].kc_rel, ctx->src[i].sel - 512, chan, treg)))
return r;
ctx->src[i].kc_bank = 0;
+ ctx->src[i].kc_rel = 0;
ctx->src[i].sel = treg;
ctx->src[i].rel = 0;
j--;
alu.src[0].chan = k;
alu.src[0].rel = ctx->src[i].rel;
alu.src[0].kc_bank = ctx->src[i].kc_bank;
+ alu.src[0].kc_rel = ctx->src[i].kc_rel;
alu.dst.sel = treg;
alu.dst.chan = k;
alu.dst.write = 1;
ctx.gs_out_ring_offset = 0;
ctx.gs_next_vertex = 0;
+ shader->uses_index_registers = false;
ctx.face_gpr = -1;
ctx.fixed_pt_position_gpr = -1;
ctx.fragcoord_input = -1;
if (ctx.type == TGSI_PROCESSOR_GEOMETRY) {
ctx.gs_export_gpr_treg = ctx.bc->ar_reg + 1;
ctx.temp_reg = ctx.bc->ar_reg + 2;
- } else
+ ctx.bc->index_reg[0] = ctx.bc->ar_reg + 3;
+ ctx.bc->index_reg[1] = ctx.bc->ar_reg + 4;
+ } else {
ctx.temp_reg = ctx.bc->ar_reg + 1;
+ ctx.bc->index_reg[0] = ctx.bc->ar_reg + 2;
+ ctx.bc->index_reg[1] = ctx.bc->ar_reg + 3;
+ }
if (indirect_gprs) {
shader->max_arrays = 0;
bc_src->rel = shader_src->rel;
bc_src->value = shader_src->value[bc_src->chan];
bc_src->kc_bank = shader_src->kc_bank;
+ bc_src->kc_rel = shader_src->kc_rel;
}
static void r600_bytecode_src_set_abs(struct r600_bytecode_alu_src *bc_src)
unsigned sampler_src_reg = inst->Instruction.Opcode == TGSI_OPCODE_TXQ_LZ ? 0 : 1;
int8_t offset_x = 0, offset_y = 0, offset_z = 0;
boolean has_txq_cube_array_z = false;
+ unsigned sampler_index_mode;
if (inst->Instruction.Opcode == TGSI_OPCODE_TXQ &&
((inst->Texture.Texture == TGSI_TEXTURE_CUBE_ARRAY ||
/* TGSI moves the sampler to src reg 3 for TXD */
sampler_src_reg = 3;
+ sampler_index_mode = inst->Src[sampler_src_reg].Indirect.Index == 2 ? 2 : 0; // CF_INDEX_1 : CF_INDEX_NONE
+
for (i = 1; i < 3; i++) {
/* set gradients h/v */
memset(&tex, 0, sizeof(struct r600_bytecode_tex));
tex.op = (i == 1) ? FETCH_OP_SET_GRADIENTS_H :
FETCH_OP_SET_GRADIENTS_V;
tex.sampler_id = tgsi_tex_get_src_gpr(ctx, sampler_src_reg);
+ tex.sampler_index_mode = sampler_index_mode;
tex.resource_id = tex.sampler_id + R600_MAX_CONST_BUFFERS;
+ tex.resource_index_mode = sampler_index_mode;
if (tgsi_tex_src_requires_loading(ctx, i)) {
tex.src_gpr = r600_get_temp(ctx);
src_gpr = ctx->temp_reg;
}
+ sampler_index_mode = inst->Src[sampler_src_reg].Indirect.Index == 2 ? 2 : 0; // CF_INDEX_1 : CF_INDEX_NONE
+ if (sampler_index_mode)
+ ctx->shader->uses_index_registers = true;
+
if ((inst->Texture.Texture == TGSI_TEXTURE_CUBE ||
inst->Texture.Texture == TGSI_TEXTURE_CUBE_ARRAY ||
inst->Texture.Texture == TGSI_TEXTURE_SHADOWCUBE ||
tex.op = FETCH_OP_LD;
tex.inst_mod = 1; /* to indicate this is ldfptr */
tex.sampler_id = tgsi_tex_get_src_gpr(ctx, sampler_src_reg);
+ tex.sampler_index_mode = sampler_index_mode;
tex.resource_id = tex.sampler_id + R600_MAX_CONST_BUFFERS;
+ tex.resource_index_mode = sampler_index_mode;
tex.src_gpr = src_gpr;
tex.dst_gpr = temp;
tex.dst_sel_x = 7; /* mask out these components */
memset(&tex, 0, sizeof(struct r600_bytecode_tex));
tex.op = FETCH_OP_SET_TEXTURE_OFFSETS;
tex.sampler_id = tgsi_tex_get_src_gpr(ctx, sampler_src_reg);
+ tex.sampler_index_mode = sampler_index_mode;
tex.resource_id = tex.sampler_id + R600_MAX_CONST_BUFFERS;
+ tex.resource_index_mode = sampler_index_mode;
tex.src_gpr = ctx->file_offset[inst->TexOffsets[0].File] + inst->TexOffsets[0].Index;
tex.src_sel_x = inst->TexOffsets[0].SwizzleX;
tex.op = opcode;
tex.sampler_id = tgsi_tex_get_src_gpr(ctx, sampler_src_reg);
+ tex.sampler_index_mode = sampler_index_mode;
tex.resource_id = tex.sampler_id + R600_MAX_CONST_BUFFERS;
+ tex.resource_index_mode = sampler_index_mode;
tex.src_gpr = src_gpr;
tex.dst_gpr = ctx->file_offset[inst->Dst[0].Register.File] + inst->Dst[0].Register.Index;
struct r600_bytecode_alu alu;
int r;
int i, lasti = tgsi_last_instruction(inst->Dst[0].Register.WriteMask);
+ unsigned reg = inst->Dst[0].Register.Index > 0 ? ctx->bc->index_reg[inst->Dst[0].Register.Index - 1] : ctx->bc->ar_reg;
+ assert(inst->Dst[0].Register.Index < 3);
memset(&alu, 0, sizeof(struct r600_bytecode_alu));
switch (inst->Instruction.Opcode) {
continue;
r600_bytecode_src(&alu.src[0], &ctx->src[0], i);
alu.last = i == lasti;
- alu.dst.sel = ctx->bc->ar_reg;
+ alu.dst.sel = reg;
alu.dst.chan = i;
alu.dst.write = 1;
r = r600_bytecode_add_alu(ctx->bc, &alu);
return r;
}
- ctx->bc->ar_loaded = 0;
+ if (inst->Dst[0].Register.Index > 0)
+ ctx->bc->index_loaded[inst->Dst[0].Register.Index - 1] = 0;
+ else
+ ctx->bc->ar_loaded = 0;
+
return 0;
}
static int tgsi_r600_arl(struct r600_shader_ctx *ctx)
boolean has_txq_cube_array_z_comp;
boolean uses_tex_buffers;
boolean gs_prim_id_input;
+ /* Temporarily workaround SB not handling CF_INDEX_[01] index registers */
+ boolean uses_index_registers;
/* geometry shader properties */
unsigned gs_input_prim;
s << " @" << (n.bc.addr << 1);
if (n.bc.op_ptr->flags & CF_ALU) {
+ static const char *index_mode[] = {"", " CF_INDEX_0", " CF_INDEX_1"};
for (int k = 0; k < 4; ++k) {
bc_kcache &kc = n.bc.kc[k];
if (kc.mode) {
s << " KC" << k << "[CB" << kc.bank << ":" <<
(kc.addr << 4) << "-" <<
- (((kc.addr + kc.mode) << 4) - 1) << "]";
+ (((kc.addr + kc.mode) << 4) - 1) << index_mode[kc.index_mode] << "]";
}
}
}
s << " MFC:" << n.bc.mega_fetch_count;
if (n.bc.fetch_whole_quad)
s << " FWQ";
+ if (ctx.is_egcm() && n.bc.resource_index_mode)
+ s << " RIM:SQ_CF_INDEX_" << n.bc.resource_index_mode;
+ if (ctx.is_egcm() && n.bc.resource_index_mode)
+ s << " SID:SQ_CF_INDEX_" << n.bc.sampler_index_mode;
+
s << " UCF:" << n.bc.use_const_fields
<< " FMT(DTA:" << n.bc.data_format
<< " NUM:" << n.bc.num_format_all
typedef sb_map<node*, unsigned> uc_map;
// resource trackers for scheduler
+// rp = read port
+// uc = use count
typedef sb_set<unsigned> kc_lines;