struct ttn_reg_info *temp_regs;
nir_ssa_def **imm_defs;
+ unsigned num_samp_types;
+ nir_alu_type *samp_types;
+
nir_register *addr_reg;
/**
/* Nothing to record for system values. */
} else if (file == TGSI_FILE_SAMPLER) {
/* Nothing to record for samplers. */
+ } else if (file == TGSI_FILE_SAMPLER_VIEW) {
+ struct tgsi_declaration_sampler_view *sview = &decl->SamplerView;
+ nir_alu_type type;
+
+ assert((sview->ReturnTypeX == sview->ReturnTypeY) &&
+ (sview->ReturnTypeX == sview->ReturnTypeZ) &&
+ (sview->ReturnTypeX == sview->ReturnTypeW));
+
+ switch (sview->ReturnTypeX) {
+ case TGSI_RETURN_TYPE_SINT:
+ type = nir_type_int;
+ break;
+ case TGSI_RETURN_TYPE_UINT:
+ type = nir_type_unsigned;
+ break;
+ case TGSI_RETURN_TYPE_FLOAT:
+ default:
+ type = nir_type_float;
+ break;
+ }
+
+ for (i = 0; i < array_size; i++) {
+ c->samp_types[decl->Range.First + i] = type;
+ }
} else {
nir_variable *var;
assert(file == TGSI_FILE_INPUT ||
struct tgsi_full_instruction *tgsi_inst = &c->token->FullInstruction;
nir_tex_instr *instr;
nir_texop op;
- unsigned num_srcs, samp = 1, i;
+ unsigned num_srcs, samp = 1, sview, i;
switch (tgsi_inst->Instruction.Opcode) {
case TGSI_OPCODE_TEX:
assert(tgsi_inst->Src[samp].Register.File == TGSI_FILE_SAMPLER);
instr->sampler_index = tgsi_inst->Src[samp].Register.Index;
+ /* TODO if we supported any opc's which take an explicit SVIEW
+ * src, we would use that here instead. But for the "legacy"
+ * texture opc's the SVIEW index is same as SAMP index:
+ */
+ sview = instr->sampler_index;
+
+ if (sview < c->num_samp_types) {
+ instr->dest_type = c->samp_types[sview];
+ } else {
+ instr->dest_type = nir_type_float;
+ }
+
unsigned src_number = 0;
instr->src[src_number].src =
c->imm_defs = rzalloc_array(c, nir_ssa_def *,
scan.file_max[TGSI_FILE_IMMEDIATE] + 1);
+ c->num_samp_types = scan.file_max[TGSI_FILE_SAMPLER_VIEW] + 1;
+ c->samp_types = rzalloc_array(c, nir_alu_type, c->num_samp_types);
+
c->if_stack = rzalloc_array(c, struct exec_list *,
(scan.opcode_count[TGSI_OPCODE_IF] +
scan.opcode_count[TGSI_OPCODE_UIF]) * 2);