summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2015-04-09 15:16:17 -0400
committerRob Clark <[email protected]>2015-04-11 10:43:15 -0400
commit0b71451920e65c4dff049359cc6ebb6e9ce53773 (patch)
tree944a4383319fe20b8404cce2c79d223a18b42939 /src/gallium/auxiliary
parent96c0f9328d315d6a5a0e83f920ad27791fd91b4f (diff)
gallium/ttn: split out helper to get texture info
We'll need this as well for TXQ. Split this out first to reduce noise in the next patch. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/nir/tgsi_to_nir.c112
1 files changed, 59 insertions, 53 deletions
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index c8973036a28..7bd5532fe61 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -867,58 +867,9 @@ ttn_endloop(struct ttn_compile *c)
}
static void
-ttn_tex(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src)
+setup_texture_info(nir_tex_instr *instr, unsigned texture)
{
- nir_builder *b = &c->build;
- struct tgsi_full_instruction *tgsi_inst = &c->token->FullInstruction;
- nir_tex_instr *instr;
- nir_texop op;
- unsigned num_srcs;
-
- switch (tgsi_inst->Instruction.Opcode) {
- case TGSI_OPCODE_TEX:
- op = nir_texop_tex;
- num_srcs = 1;
- break;
- case TGSI_OPCODE_TXP:
- op = nir_texop_tex;
- num_srcs = 2;
- break;
- case TGSI_OPCODE_TXB:
- op = nir_texop_txb;
- num_srcs = 2;
- break;
- case TGSI_OPCODE_TXL:
- op = nir_texop_txl;
- num_srcs = 2;
- break;
- case TGSI_OPCODE_TXF:
- op = nir_texop_txf;
- num_srcs = 1;
- break;
- case TGSI_OPCODE_TXD:
- op = nir_texop_txd;
- num_srcs = 3;
- break;
- default:
- fprintf(stderr, "unknown TGSI tex op %d\n", tgsi_inst->Instruction.Opcode);
- abort();
- }
-
- if (tgsi_inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D ||
- tgsi_inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D_ARRAY ||
- tgsi_inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D ||
- tgsi_inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D_ARRAY ||
- tgsi_inst->Texture.Texture == TGSI_TEXTURE_SHADOWRECT ||
- tgsi_inst->Texture.Texture == TGSI_TEXTURE_SHADOWCUBE ||
- tgsi_inst->Texture.Texture == TGSI_TEXTURE_SHADOWCUBE_ARRAY) {
- num_srcs++;
- }
-
- instr = nir_tex_instr_create(b->shader, num_srcs);
- instr->op = op;
-
- switch (tgsi_inst->Texture.Texture) {
+ switch (texture) {
case TGSI_TEXTURE_1D:
instr->sampler_dim = GLSL_SAMPLER_DIM_1D;
break;
@@ -985,10 +936,65 @@ ttn_tex(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src)
instr->is_shadow = true;
break;
default:
- fprintf(stderr, "Unknown TGSI texture target %d\n",
- tgsi_inst->Texture.Texture);
+ fprintf(stderr, "Unknown TGSI texture target %d\n", texture);
abort();
}
+}
+
+static void
+ttn_tex(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src)
+{
+ nir_builder *b = &c->build;
+ struct tgsi_full_instruction *tgsi_inst = &c->token->FullInstruction;
+ nir_tex_instr *instr;
+ nir_texop op;
+ unsigned num_srcs;
+
+ switch (tgsi_inst->Instruction.Opcode) {
+ case TGSI_OPCODE_TEX:
+ op = nir_texop_tex;
+ num_srcs = 1;
+ break;
+ case TGSI_OPCODE_TXP:
+ op = nir_texop_tex;
+ num_srcs = 2;
+ break;
+ case TGSI_OPCODE_TXB:
+ op = nir_texop_txb;
+ num_srcs = 2;
+ break;
+ case TGSI_OPCODE_TXL:
+ op = nir_texop_txl;
+ num_srcs = 2;
+ break;
+ case TGSI_OPCODE_TXF:
+ op = nir_texop_txf;
+ num_srcs = 1;
+ break;
+ case TGSI_OPCODE_TXD:
+ op = nir_texop_txd;
+ num_srcs = 3;
+ break;
+
+ default:
+ fprintf(stderr, "unknown TGSI tex op %d\n", tgsi_inst->Instruction.Opcode);
+ abort();
+ }
+
+ if (tgsi_inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D ||
+ tgsi_inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D_ARRAY ||
+ tgsi_inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D ||
+ tgsi_inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D_ARRAY ||
+ tgsi_inst->Texture.Texture == TGSI_TEXTURE_SHADOWRECT ||
+ tgsi_inst->Texture.Texture == TGSI_TEXTURE_SHADOWCUBE ||
+ tgsi_inst->Texture.Texture == TGSI_TEXTURE_SHADOWCUBE_ARRAY) {
+ num_srcs++;
+ }
+
+ instr = nir_tex_instr_create(b->shader, num_srcs);
+ instr->op = op;
+
+ setup_texture_info(instr, tgsi_inst->Texture.Texture);
switch (instr->sampler_dim) {
case GLSL_SAMPLER_DIM_1D: