struct ttn_compile {
union tgsi_full_token *token;
nir_builder build;
- struct nir_shader *s;
struct tgsi_shader_info *scan;
struct ttn_reg_info *output_regs;
nir_instr_insert_after_cf_list(b->cf_node_list, &load_const->instr);
}
-static nir_src *
+static nir_src
ttn_src_for_indirect(struct ttn_compile *c, struct tgsi_ind_register *indirect);
/* generate either a constant or indirect deref chain for accessing an
if (indirect) {
arr->deref_array_type = nir_deref_array_type_indirect;
- arr->indirect = *ttn_src_for_indirect(c, indirect);
+ arr->indirect = ttn_src_for_indirect(c, indirect);
} else {
arr->deref_array_type = nir_deref_array_type_direct;
}
case TGSI_FILE_INPUT:
case TGSI_FILE_CONSTANT: {
nir_intrinsic_instr *load;
+ nir_intrinsic_op op;
switch (file) {
case TGSI_FILE_INPUT:
- load = nir_intrinsic_instr_create(b->shader,
- indirect ?
- nir_intrinsic_load_input_indirect :
- nir_intrinsic_load_input);
+ op = indirect ? nir_intrinsic_load_input_indirect :
+ nir_intrinsic_load_input;
break;
case TGSI_FILE_CONSTANT:
- load = nir_intrinsic_instr_create(b->shader,
- indirect ?
- nir_intrinsic_load_uniform_indirect :
- nir_intrinsic_load_uniform);
+ op = indirect ? nir_intrinsic_load_uniform_indirect :
+ nir_intrinsic_load_uniform;
break;
default:
unreachable("No other load files supported");
break;
}
+ load = nir_intrinsic_instr_create(b->shader, op);
+
load->num_components = 4;
load->const_index[0] = index;
load->const_index[1] = 1;
if (indirect) {
- nir_alu_src indirect_address;
- memset(&indirect_address, 0, sizeof(indirect_address));
- indirect_address.src = nir_src_for_reg(c->addr_reg);
- for (int i = 0; i < 4; i++)
- indirect_address.swizzle[i] = indirect->Swizzle;
- load->src[0] = nir_src_for_ssa(nir_imov_alu(b, indirect_address, 1));
+ load->src[0] = ttn_src_for_indirect(c, indirect);
}
nir_ssa_dest_init(&load->instr, &load->dest, 4, NULL);
nir_instr_insert_after_cf_list(b->cf_node_list, &load->instr);
return src;
}
-static nir_src *
+static nir_src
ttn_src_for_indirect(struct ttn_compile *c, struct tgsi_ind_register *indirect)
{
nir_builder *b = &c->build;
src.src = ttn_src_for_file_and_index(c,
indirect->File,
indirect->Index, NULL);
- nir_src *result = ralloc(b->shader, nir_src);
- *result = nir_src_for_ssa(nir_imov_alu(b, src, 1));
- return result;
+ return nir_src_for_ssa(nir_imov_alu(b, src, 1));
}
static nir_alu_dest
dest.write_mask = tgsi_dst->WriteMask;
dest.saturate = false;
- if (tgsi_dst->Indirect && (tgsi_dst->File != TGSI_FILE_TEMPORARY))
- dest.dest.reg.indirect = ttn_src_for_indirect(c, &tgsi_fdst->Indirect);
+ if (tgsi_dst->Indirect && (tgsi_dst->File != TGSI_FILE_TEMPORARY)) {
+ nir_src *indirect = ralloc(c->build.shader, nir_src);
+ *indirect = ttn_src_for_indirect(c, &tgsi_fdst->Indirect);
+ dest.dest.reg.indirect = indirect;
+ }
return dest;
}