summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-05-03 20:18:50 -0700
committerJason Ekstrand <[email protected]>2016-07-22 16:27:35 -0700
commit09135cd55a05908a68e173e37e0f5c375f341776 (patch)
treec1bc3a75d5eb1f3dec3c09f2887f3d683a393034 /src/compiler/nir
parent3c0077a6ec4c0ffd6e74e219c786d5d7f9217ce9 (diff)
nir: Add a helper for determining the type of a texture source
Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: "12.0" <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index a80f9c997c3..5a69e7858d4 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1246,6 +1246,50 @@ nir_tex_instr_is_query(nir_tex_instr *instr)
}
}
+static inline nir_alu_type
+nir_tex_instr_src_type(nir_tex_instr *instr, unsigned src)
+{
+ switch (instr->src[src].src_type) {
+ case nir_tex_src_coord:
+ switch (instr->op) {
+ case nir_texop_txf:
+ case nir_texop_txf_ms:
+ case nir_texop_txf_ms_mcs:
+ case nir_texop_samples_identical:
+ return nir_type_int;
+
+ default:
+ return nir_type_float;
+ }
+
+ case nir_tex_src_lod:
+ switch (instr->op) {
+ case nir_texop_txs:
+ case nir_texop_txf:
+ return nir_type_int;
+
+ default:
+ return nir_type_float;
+ }
+
+ case nir_tex_src_projector:
+ case nir_tex_src_comparitor:
+ case nir_tex_src_bias:
+ case nir_tex_src_ddx:
+ case nir_tex_src_ddy:
+ return nir_type_float;
+
+ case nir_tex_src_offset:
+ case nir_tex_src_ms_index:
+ case nir_tex_src_texture_offset:
+ case nir_tex_src_sampler_offset:
+ return nir_type_int;
+
+ default:
+ unreachable("Invalid texture source type");
+ }
+}
+
static inline unsigned
nir_tex_instr_src_size(nir_tex_instr *instr, unsigned src)
{