summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/nir/tgsi_to_nir.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index 1702b41393b..985f766b201 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -58,6 +58,9 @@ struct ttn_compile {
struct ttn_reg_info *temp_regs;
nir_ssa_def **imm_defs;
+ unsigned num_samp_types;
+ nir_alu_type *samp_types;
+
nir_register *addr_reg;
/**
@@ -156,6 +159,30 @@ ttn_emit_declaration(struct ttn_compile *c)
/* 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 ||
@@ -1026,7 +1053,7 @@ ttn_tex(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src)
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:
@@ -1105,6 +1132,18 @@ ttn_tex(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src)
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 =
@@ -1710,6 +1749,9 @@ tgsi_to_nir(const void *tgsi_tokens,
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);