[Mesa-dev] [PATCH 1/2] tgsi: add texture-type info to texture instructions
Rob Clark
robdclark at gmail.com
Thu Jun 4 08:50:22 PDT 2015
From: Rob Clark <robclark at freedesktop.org>
Signed-off-by: Rob Clark <robclark at freedesktop.org>
---
src/gallium/auxiliary/tgsi/tgsi_ureg.c | 7 +++++--
src/gallium/auxiliary/tgsi/tgsi_ureg.h | 22 +++++++++++++++-------
src/gallium/include/pipe/p_shader_tokens.h | 7 ++++++-
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 19 +++++++++++++++++++
src/mesa/state_tracker/st_mesa_to_tgsi.c | 1 +
5 files changed, 46 insertions(+), 10 deletions(-)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 7a8bf54..cd0bf71 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1072,7 +1072,8 @@ ureg_fixup_label(struct ureg_program *ureg,
void
ureg_emit_texture(struct ureg_program *ureg,
unsigned extended_token,
- unsigned target, unsigned num_offsets)
+ unsigned target, unsigned num_offsets,
+ unsigned texture_type)
{
union tgsi_any_token *out, *insn;
@@ -1084,6 +1085,7 @@ ureg_emit_texture(struct ureg_program *ureg,
out[0].value = 0;
out[0].insn_texture.Texture = target;
out[0].insn_texture.NumOffsets = num_offsets;
+ out[0].insn_texture.TextureType = texture_type;
}
void
@@ -1169,6 +1171,7 @@ ureg_tex_insn(struct ureg_program *ureg,
unsigned target,
const struct tgsi_texture_offset *texoffsets,
unsigned nr_offset,
+ unsigned tex_type,
const struct ureg_src *src,
unsigned nr_src )
{
@@ -1205,7 +1208,7 @@ ureg_tex_insn(struct ureg_program *ureg,
nr_dst,
nr_src);
- ureg_emit_texture( ureg, insn.extended_token, target, nr_offset );
+ ureg_emit_texture( ureg, insn.extended_token, target, nr_offset, tex_type );
for (i = 0; i < nr_offset; i++)
ureg_emit_texture_offset( ureg, &texoffsets[i]);
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index c3f4012..7ceacd9 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -495,6 +495,7 @@ ureg_tex_insn(struct ureg_program *ureg,
unsigned target,
const struct tgsi_texture_offset *texoffsets,
unsigned nr_offset,
+ unsigned tex_type,
const struct ureg_src *src,
unsigned nr_src );
@@ -537,7 +538,8 @@ ureg_emit_label(struct ureg_program *ureg,
void
ureg_emit_texture(struct ureg_program *ureg,
unsigned insn_token,
- unsigned target, unsigned num_offsets);
+ unsigned target, unsigned num_offsets,
+ unsigned texture_type);
void
ureg_emit_texture_offset(struct ureg_program *ureg,
@@ -738,7 +740,8 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
dst.PredSwizzleW, \
1, \
2); \
- ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \
+ ureg_emit_texture(ureg, insn.extended_token, target, 0, \
+ TGSI_TEXTURE_TYPE_FLOAT); \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
@@ -767,7 +770,8 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
dst.PredSwizzleW, \
1, \
2); \
- ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \
+ ureg_emit_texture(ureg, insn.extended_token, target, 0, \
+ TGSI_TEXTURE_TYPE_FLOAT); \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
@@ -826,7 +830,8 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
dst.PredSwizzleW, \
1, \
3); \
- ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \
+ ureg_emit_texture(ureg, insn.extended_token, target, 0, \
+ TGSI_TEXTURE_TYPE_FLOAT); \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
@@ -858,7 +863,8 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
dst.PredSwizzleW, \
1, \
4); \
- ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \
+ ureg_emit_texture(ureg, insn.extended_token, target, 0, \
+ TGSI_TEXTURE_TYPE_FLOAT); \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
@@ -891,7 +897,8 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
dst.PredSwizzleW, \
1, \
4); \
- ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \
+ ureg_emit_texture(ureg, insn.extended_token, target, 0, \
+ TGSI_TEXTURE_TYPE_FLOAT); \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
@@ -991,7 +998,8 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
dst.PredSwizzleW, \
1, \
5); \
- ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \
+ ureg_emit_texture(ureg, insn.extended_token, target, 0, \
+ TGSI_TEXTURE_TYPE_FLOAT); \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index 953bdf6..b2fc9a0 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -613,11 +613,16 @@ struct tgsi_instruction_label
#define TGSI_TEXTURE_UNKNOWN 18
#define TGSI_TEXTURE_COUNT 19
+#define TGSI_TEXTURE_TYPE_FLOAT 0
+#define TGSI_TEXTURE_TYPE_INT 1
+#define TGSI_TEXTURE_TYPE_UNSIGNED 2
+
struct tgsi_instruction_texture
{
unsigned Texture : 8; /* TGSI_TEXTURE_ */
unsigned NumOffsets : 4;
- unsigned Padding : 20;
+ unsigned TextureType : 2; /* TGSI_TEXTURE_TYPE_ */
+ unsigned Padding : 18;
};
/* for texture offsets in GLSL and DirectX.
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index f0f2a77..fb6ecfd 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -233,6 +233,7 @@ public:
st_src_reg sampler; /**< sampler register */
int sampler_array_size; /**< 1-based size of sampler array, 1 if not array */
int tex_target; /**< One of TEXTURE_*_INDEX */
+ glsl_base_type tex_type;
GLboolean tex_shadow;
st_src_reg tex_offsets[MAX_GLSL_TEXTURE_OFFSET];
@@ -3246,6 +3247,8 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
assert(!"Should not get here.");
}
+ inst->tex_type = ir->type->base_type;
+
this->result = result_src;
}
@@ -4768,6 +4771,7 @@ compile_tgsi_instruction(struct st_translate *t,
unsigned num_dst;
unsigned num_src;
unsigned tex_target;
+ unsigned tex_type;
num_dst = num_inst_dst_regs(inst->op);
num_src = num_inst_src_regs(inst->op);
@@ -4781,6 +4785,20 @@ compile_tgsi_instruction(struct st_translate *t,
for (i = 0; i < num_src; i++)
src[i] = translate_src(t, &inst->src[i]);
+ switch (inst->tex_type) {
+ case GLSL_TYPE_FLOAT:
+ tex_type = TGSI_TEXTURE_TYPE_FLOAT;
+ break;
+ case GLSL_TYPE_INT:
+ tex_type = TGSI_TEXTURE_TYPE_INT;
+ break;
+ case GLSL_TYPE_UINT:
+ tex_type = TGSI_TEXTURE_TYPE_UNSIGNED;
+ break;
+ default:
+ unreachable("not reached");
+ }
+
switch(inst->op) {
case TGSI_OPCODE_BGNLOOP:
case TGSI_OPCODE_CAL:
@@ -4824,6 +4842,7 @@ compile_tgsi_instruction(struct st_translate *t,
dst, num_dst,
tex_target,
texoffsets, inst->tex_offset_num_offset,
+ tex_type,
src, num_src);
return;
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 98d525c..49bdbf9 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -707,6 +707,7 @@ compile_instruction(
st_translate_texture_target( inst->TexSrcTarget,
inst->TexShadow ),
NULL, 0,
+ TGSI_TEXTURE_TYPE_FLOAT,
src, num_src );
return;
--
2.4.2
More information about the mesa-dev
mailing list