file == TGSI_FILE_OUTPUT ||
file == TGSI_FILE_CONSTANT);
+ /* nothing to do for UBOs: */
+ if ((file == TGSI_FILE_CONSTANT) && decl->Declaration.Dimension)
+ return;
+
var = rzalloc(b->shader, nir_variable);
var->data.driver_location = decl->Range.First;
static nir_src
ttn_src_for_file_and_index(struct ttn_compile *c, unsigned file, unsigned index,
- struct tgsi_ind_register *indirect)
+ struct tgsi_ind_register *indirect,
+ struct tgsi_dimension *dim,
+ struct tgsi_ind_register *dimind)
{
nir_builder *b = &c->build;
nir_src src;
assert(!indirect);
src.reg.reg = c->temp_regs[index].reg;
}
+ assert(!dim);
break;
case TGSI_FILE_ADDRESS:
src.reg.reg = c->addr_reg;
+ assert(!dim);
break;
case TGSI_FILE_IMMEDIATE:
src = nir_src_for_ssa(c->imm_defs[index]);
assert(!indirect);
+ assert(!dim);
break;
case TGSI_FILE_SYSTEM_VALUE: {
nir_intrinsic_op op;
unsigned ncomp = 1;
+ assert(!indirect);
+ assert(!dim);
+
switch (c->scan->system_value_semantic_name[index]) {
case TGSI_SEMANTIC_VERTEXID_NOBASE:
op = nir_intrinsic_load_vertex_id_zero_base;
case TGSI_FILE_CONSTANT: {
nir_intrinsic_instr *load;
nir_intrinsic_op op;
+ unsigned srcn = 0;
switch (file) {
case TGSI_FILE_INPUT:
op = indirect ? nir_intrinsic_load_input_indirect :
nir_intrinsic_load_input;
+ assert(!dim);
break;
case TGSI_FILE_CONSTANT:
- op = indirect ? nir_intrinsic_load_uniform_indirect :
- nir_intrinsic_load_uniform;
+ if (dim) {
+ op = indirect ? nir_intrinsic_load_ubo_indirect :
+ nir_intrinsic_load_ubo;
+ /* convert index from vec4 to byte: */
+ index *= 16;
+ } else {
+ op = indirect ? nir_intrinsic_load_uniform_indirect :
+ nir_intrinsic_load_uniform;
+ }
break;
default:
unreachable("No other load files supported");
load->num_components = 4;
load->const_index[0] = index;
load->const_index[1] = 1;
+ if (dim) {
+ if (dimind) {
+ load->src[srcn] =
+ ttn_src_for_file_and_index(c, dimind->File, dimind->Index,
+ NULL, NULL, NULL);
+ } else {
+ /* UBOs start at index 1 in TGSI: */
+ load->src[srcn] =
+ nir_src_for_ssa(nir_imm_int(b, dim->Index - 1));
+ }
+ srcn++;
+ }
if (indirect) {
- load->src[0] = ttn_src_for_indirect(c, indirect);
+ load->src[srcn] = ttn_src_for_indirect(c, indirect);
+ if (dim) {
+ assert(load->src[srcn].is_ssa);
+ /* we also need to covert vec4 to byte here too: */
+ load->src[srcn] =
+ nir_src_for_ssa(nir_ishl(b, load->src[srcn].ssa,
+ nir_imm_int(b, 4)));
+ }
+ srcn++;
}
nir_ssa_dest_init(&load->instr, &load->dest, 4, NULL);
nir_instr_insert_after_cf_list(b->cf_node_list, &load->instr);
src.swizzle[i] = indirect->Swizzle;
src.src = ttn_src_for_file_and_index(c,
indirect->File,
- indirect->Index, NULL);
+ indirect->Index,
+ NULL, NULL, NULL);
return nir_src_for_ssa(nir_imov_alu(b, src, 1));
}
assert(!tgsi_src->Indirect);
return NULL;
} else {
+ struct tgsi_ind_register *ind = NULL;
+ struct tgsi_dimension *dim = NULL;
+ struct tgsi_ind_register *dimind = NULL;
+ if (tgsi_src->Indirect)
+ ind = &tgsi_fsrc->Indirect;
+ if (tgsi_src->Dimension) {
+ dim = &tgsi_fsrc->Dimension;
+ if (dim->Indirect)
+ dimind = &tgsi_fsrc->DimIndirect;
+ }
src.src = ttn_src_for_file_and_index(c,
tgsi_src->File,
tgsi_src->Index,
- (tgsi_src->Indirect ?
- &tgsi_fsrc->Indirect : NULL));
+ ind, dim, dimind);
}
src.swizzle[0] = tgsi_src->SwizzleX;
src.src = ttn_src_for_file_and_index(c,
tex_offset->File,
tex_offset->Index,
- NULL);
+ NULL, NULL, NULL);
src.swizzle[0] = tex_offset->SwizzleX;
src.swizzle[1] = tex_offset->SwizzleY;
c->scan = &scan;
s->num_inputs = scan.file_max[TGSI_FILE_INPUT] + 1;
- s->num_uniforms = scan.file_max[TGSI_FILE_CONSTANT] + 1;
+ s->num_uniforms = scan.const_file_max[0] + 1;
s->num_outputs = scan.file_max[TGSI_FILE_OUTPUT] + 1;
c->output_regs = rzalloc_array(c, struct ttn_reg_info,