<div dir="auto"><div>Hi Samuel,<div dir="auto"><br></div><div dir="auto">A comment below.</div><br><div class="gmail_extra"><br><div class="gmail_quote">Den 17 maj 2017 11:18 fm skrev "Samuel Pitoiset" <<a href="mailto:samuel.pitoiset@gmail.com">samuel.pitoiset@gmail.com</a>>:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">RadeonSI needs to do a special lowering for Gather4 with integer<br>
formats, but with bindless samplers we just can't access the index.<br>
<br>
Instead, store the return type in the instruction like the target.<br>
<br>
Signed-off-by: Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com">samuel.pitoiset@gmail.com</a>><br>
---<br>
src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.c | 7 +++++--<br>
src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.h | 11 ++++++++---<br>
src/gallium/include/pipe/p_<wbr>shader_tokens.h | 2 ++<br>
src/mesa/state_tracker/st_<wbr>atifs_to_tgsi.c | 2 +-<br>
src/mesa/state_tracker/st_<wbr>glsl_to_tgsi.cpp | 17 ++---------------<br>
src/mesa/state_tracker/st_<wbr>mesa_to_tgsi.c | 21 +++++++++++++++++++++<br>
src/mesa/state_tracker/st_<wbr>mesa_to_tgsi.h | 4 ++++<br>
7 files changed, 43 insertions(+), 21 deletions(-)<br>
<br>
diff --git a/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.c b/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.c<br>
index 9eb00d0919..1cdb95cc95 100644<br>
--- a/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.c<br>
+++ b/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.c<br>
@@ -1289,7 +1289,7 @@ ureg_fixup_label(struct ureg_program *ureg,<br>
void<br>
ureg_emit_texture(struct ureg_program *ureg,<br>
unsigned extended_token,<br>
- unsigned target, unsigned num_offsets)<br>
+ unsigned target, unsigned return_type, unsigned num_offsets)<br>
{<br>
union tgsi_any_token *out, *insn;<br>
<br>
@@ -1300,6 +1300,7 @@ ureg_emit_texture(struct ureg_program *ureg,<br>
<br>
out[0].value = 0;<br>
out[0].insn_texture.Texture = target;<br>
+ out[0].insn_texture.ReturnType = return_type;<br>
out[0].insn_texture.NumOffsets = num_offsets;<br>
}<br>
<br>
@@ -1386,6 +1387,7 @@ ureg_tex_insn(struct ureg_program *ureg,<br>
const struct ureg_dst *dst,<br>
unsigned nr_dst,<br>
unsigned target,<br>
+ unsigned return_type,<br>
const struct tgsi_texture_offset *texoffsets,<br>
unsigned nr_offset,<br>
const struct ureg_src *src,<br>
@@ -1407,7 +1409,8 @@ ureg_tex_insn(struct ureg_program *ureg,<br>
nr_dst,<br>
nr_src);<br>
<br>
- ureg_emit_texture( ureg, insn.extended_token, target, nr_offset );<br>
+ ureg_emit_texture( ureg, insn.extended_token, target, return_type,<br>
+ nr_offset );<br>
<br>
for (i = 0; i < nr_offset; i++)<br>
ureg_emit_texture_offset( ureg, &texoffsets[i]);<br>
diff --git a/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.h b/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.h<br>
index 6d2f5c0e99..54f95ba565 100644<br>
--- a/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.h<br>
+++ b/src/gallium/auxiliary/tgsi/<wbr>tgsi_ureg.h<br>
@@ -555,6 +555,7 @@ ureg_tex_insn(struct ureg_program *ureg,<br>
const struct ureg_dst *dst,<br>
unsigned nr_dst,<br>
unsigned target,<br>
+ unsigned return_type,<br>
const struct tgsi_texture_offset *texoffsets,<br>
unsigned nr_offset,<br>
const struct ureg_src *src,<br>
@@ -596,7 +597,7 @@ ureg_emit_label(struct ureg_program *ureg,<br>
void<br>
ureg_emit_texture(struct ureg_program *ureg,<br>
unsigned insn_token,<br>
- unsigned target, unsigned num_offsets);<br>
+ unsigned target, unsigned return_type, unsigned num_offsets);<br>
<br>
void<br>
ureg_emit_texture_offset(<wbr>struct ureg_program *ureg,<br>
@@ -748,6 +749,7 @@ static inline void ureg_##op( struct ureg_program *ureg, \<br>
struct ureg_src src1 ) \<br>
{ \<br>
unsigned opcode = TGSI_OPCODE_##op; \<br>
+ unsigned return_type = TGSI_RETURN_TYPE_UNKNOWN; \<br>
struct ureg_emit_insn_result insn; \<br>
if (ureg_dst_is_empty(dst)) \<br>
return; \<br>
@@ -756,7 +758,8 @@ static inline void ureg_##op( struct ureg_program *ureg, \<br>
dst.Saturate, \<br>
1, \<br>
2); \<br>
- ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \<br>
+ ureg_emit_texture( ureg, insn.extended_token, target, \<br>
+ return_type, 0 ); \<br>
ureg_emit_dst( ureg, dst ); \<br>
ureg_emit_src( ureg, src0 ); \<br>
ureg_emit_src( ureg, src1 ); \<br>
@@ -796,6 +799,7 @@ static inline void ureg_##op( struct ureg_program *ureg, \<br>
struct ureg_src src3 ) \<br>
{ \<br>
unsigned opcode = TGSI_OPCODE_##op; \<br>
+ unsigned return_type = TGSI_RETURN_TYPE_UNKNOWN; \<br>
struct ureg_emit_insn_result insn; \<br>
if (ureg_dst_is_empty(dst)) \<br>
return; \<br>
@@ -804,7 +808,8 @@ static inline void ureg_##op( struct ureg_program *ureg, \<br>
dst.Saturate, \<br>
1, \<br>
4); \<br>
- ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \<br>
+ ureg_emit_texture( ureg, insn.extended_token, target, \<br>
+ return_type, 0 ); \<br>
ureg_emit_dst( ureg, dst ); \<br>
ureg_emit_src( ureg, src0 ); \<br>
ureg_emit_src( ureg, src1 ); \<br>
diff --git a/src/gallium/include/pipe/p_<wbr>shader_tokens.h b/src/gallium/include/pipe/p_<wbr>shader_tokens.h<br>
index a671121f10..dfc477a73c 100644<br>
--- a/src/gallium/include/pipe/p_<wbr>shader_tokens.h<br>
+++ b/src/gallium/include/pipe/p_<wbr>shader_tokens.h<br>
@@ -233,6 +233,7 @@ enum tgsi_return_type {<br>
TGSI_RETURN_TYPE_SINT,<br>
TGSI_RETURN_TYPE_UINT,<br>
TGSI_RETURN_TYPE_FLOAT,<br>
+ TGSI_RETURN_TYPE_UNKNOWN,<br>
TGSI_RETURN_TYPE_COUNT<br>
};<br>
<br>
@@ -695,6 +696,7 @@ struct tgsi_instruction_texture<br>
unsigned Texture : 8; /* TGSI_TEXTURE_ */<br>
unsigned NumOffsets : 4;<br>
unsigned Padding : 20;<br>
+ unsigned ReturnType : 3; /* TGSI_RETURN_TYPE_x */<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Shouldn't Padding be adjusted here, and probably kept at the end?</div><div dir="auto"><br></div><div dir="auto">BR</div><div dir="auto">Nils</div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
};<br>
<br>
/* for texture offsets in GLSL and DirectX.<br>
diff --git a/src/mesa/state_tracker/st_<wbr>atifs_to_tgsi.c b/src/mesa/state_tracker/st_<wbr>atifs_to_tgsi.c<br>
index 8b9c332feb..ff20511d95 100644<br>
--- a/src/mesa/state_tracker/st_<wbr>atifs_to_tgsi.c<br>
+++ b/src/mesa/state_tracker/st_<wbr>atifs_to_tgsi.c<br>
@@ -334,7 +334,7 @@ compile_setupinst(struct st_translate *t,<br>
src[1] = t->samplers[r];<br>
/* the texture target is still unknown, it will be fixed in the draw call */<br>
ureg_tex_insn(t->ureg, TGSI_OPCODE_TEX, dst, 1, TGSI_TEXTURE_2D,<br>
- NULL, 0, src, 2);<br>
+ TGSI_RETURN_TYPE_UNKNOWN, NULL, 0, src, 2);<br>
} else if (texinst->Opcode == ATI_FRAGMENT_SHADER_PASS_OP) {<br>
ureg_insn(t->ureg, TGSI_OPCODE_MOV, dst, 1, src, 1);<br>
}<br>
diff --git a/src/mesa/state_tracker/st_<wbr>glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_<wbr>glsl_to_tgsi.cpp<br>
index 54bc70f57b..9620ef760f 100644<br>
--- a/src/mesa/state_tracker/st_<wbr>glsl_to_tgsi.cpp<br>
+++ b/src/mesa/state_tracker/st_<wbr>glsl_to_tgsi.cpp<br>
@@ -5877,6 +5877,7 @@ compile_tgsi_instruction(<wbr>struct st_translate *t,<br>
inst->op,<br>
dst, num_dst,<br>
tex_target,<br>
+ st_translate_texture_type(<wbr>inst->tex_type),<br>
texoffsets, inst->tex_offset_num_offset,<br>
src, num_src);<br>
return;<br>
@@ -6570,24 +6571,10 @@ st_translate_program(<br>
/* texture samplers */<br>
for (i = 0; i < frag_const-><wbr>MaxTextureImageUnits; i++) {<br>
if (program->samplers_used & (1u << i)) {<br>
- unsigned type;<br>
+ unsigned type = st_translate_texture_type(<wbr>program->sampler_types[i]);<br>
<br>
t->samplers[i] = ureg_DECL_sampler(ureg, i);<br>
<br>
- switch (program->sampler_types[i]) {<br>
- case GLSL_TYPE_INT:<br>
- type = TGSI_RETURN_TYPE_SINT;<br>
- break;<br>
- case GLSL_TYPE_UINT:<br>
- type = TGSI_RETURN_TYPE_UINT;<br>
- break;<br>
- case GLSL_TYPE_FLOAT:<br>
- type = TGSI_RETURN_TYPE_FLOAT;<br>
- break;<br>
- default:<br>
- unreachable("not reached");<br>
- }<br>
-<br>
ureg_DECL_sampler_view( ureg, i, program->sampler_targets[i],<br>
type, type, type, type );<br>
}<br>
diff --git a/src/mesa/state_tracker/st_<wbr>mesa_to_tgsi.c b/src/mesa/state_tracker/st_<wbr>mesa_to_tgsi.c<br>
index b3721d8703..17cc5f4ea6 100644<br>
--- a/src/mesa/state_tracker/st_<wbr>mesa_to_tgsi.c<br>
+++ b/src/mesa/state_tracker/st_<wbr>mesa_to_tgsi.c<br>
@@ -223,6 +223,26 @@ st_translate_texture_target(<wbr>GLuint textarget, GLboolean shadow)<br>
<br>
<br>
/**<br>
+ * Map GLSL base type to TGSI return type.<br>
+ */<br>
+unsigned<br>
+st_translate_texture_type(<wbr>enum glsl_base_type type)<br>
+{<br>
+ switch (type) {<br>
+ case GLSL_TYPE_INT:<br>
+ return TGSI_RETURN_TYPE_SINT;<br>
+ case GLSL_TYPE_UINT:<br>
+ return TGSI_RETURN_TYPE_UINT;<br>
+ case GLSL_TYPE_FLOAT:<br>
+ return TGSI_RETURN_TYPE_FLOAT;<br>
+ default:<br>
+ debug_assert(!"unexpected texture type");<br>
+ return TGSI_RETURN_TYPE_UNKNOWN;<br>
+ }<br>
+}<br>
+<br>
+<br>
+/**<br>
* Translate a (1 << TEXTURE_x_INDEX) bit into a TGSI_TEXTURE_x enum.<br>
*/<br>
static unsigned<br>
@@ -536,6 +556,7 @@ compile_instruction(<br>
dst, num_dst,<br>
st_translate_texture_target( inst->TexSrcTarget,<br>
inst->TexShadow ),<br>
+ TGSI_RETURN_TYPE_UNKNOWN,<br>
NULL, 0,<br>
src, num_src );<br>
return;<br>
diff --git a/src/mesa/state_tracker/st_<wbr>mesa_to_tgsi.h b/src/mesa/state_tracker/st_<wbr>mesa_to_tgsi.h<br>
index b4d9af635a..106cf85a3e 100644<br>
--- a/src/mesa/state_tracker/st_<wbr>mesa_to_tgsi.h<br>
+++ b/src/mesa/state_tracker/st_<wbr>mesa_to_tgsi.h<br>
@@ -34,6 +34,8 @@<br>
#include "pipe/p_compiler.h"<br>
#include "pipe/p_defines.h"<br>
<br>
+#include "compiler/glsl_types.h"<br>
+<br>
#if defined __cplusplus<br>
extern "C" {<br>
#endif<br>
@@ -63,6 +65,8 @@ st_translate_mesa_program(<br>
unsigned<br>
st_translate_texture_target(<wbr>GLuint textarget, GLboolean shadow);<br>
<br>
+unsigned<br>
+st_translate_texture_type(<wbr>enum glsl_base_type type);<br>
<br>
#if defined __cplusplus<br>
} /* extern "C" */<br>
<font color="#888888">--<br>
2.13.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></blockquote></div><br></div></div></div>