<div dir="auto"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On May 5, 2017 9:36 AM, "Samuel Pitoiset" <<a href="mailto:samuel.pitoiset@gmail.com">samuel.pitoiset@gmail.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Similar to how image resources are handled. That way we are sure<br>
that inst->resource.file is PROGRAM_SAMPLER for "bound" samplers.<br>
<br>
Signed-off-by: Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com">samuel.pitoiset@gmail.com</a>><br>
---<br>
src/mesa/state_tracker/st_<wbr>glsl_to_tgsi.cpp | 18 +++++++++---------<br>
1 file changed, 9 insertions(+), 9 deletions(-)<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 81c1d00dfb..25050834e3 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>
@@ -4149,7 +4149,6 @@ glsl_to_tgsi_visitor::visit(<wbr>ir_texture *ir)<br>
unsigned opcode = TGSI_OPCODE_NOP;<br>
const glsl_type *sampler_type = ir->sampler->type;<br>
unsigned sampler_array_size = 1, sampler_base = 0;<br>
- uint16_t sampler_index = 0;<br>
bool is_cube_array = false, is_cube_shadow = false;<br>
unsigned i;<br>
<br>
@@ -4380,10 +4379,16 @@ glsl_to_tgsi_visitor::visit(<wbr>ir_texture *ir)<br>
coord_dst.writemask = WRITEMASK_XYZW;<br>
}<br>
<br>
+ st_src_reg sampler(PROGRAM_SAMPLER, 0, GLSL_TYPE_UINT);<br>
+<br>
get_deref_offsets(ir->sampler, &sampler_array_size, &sampler_base,<br>
- &sampler_index, &reladdr, true);<br>
- if (reladdr.file != PROGRAM_UNDEFINED)<br>
+ (uint16_t *)&sampler.index, &reladdr, true);<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Why is this cast ok to do?</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>
+ if (reladdr.file != PROGRAM_UNDEFINED) {<br>
+ sampler.reladdr = ralloc(mem_ctx, st_src_reg);<br>
+ *sampler.reladdr = reladdr;<br>
emit_arl(ir, sampler_reladdr, reladdr);<br>
+ }<br>
<br>
if (opcode == TGSI_OPCODE_TXD)<br>
inst = emit_asm(ir, opcode, result_dst, coord, dx, dy);<br>
@@ -4414,15 +4419,10 @@ glsl_to_tgsi_visitor::visit(<wbr>ir_texture *ir)<br>
if (ir->shadow_comparator)<br>
inst->tex_shadow = GL_TRUE;<br>
<br>
- inst->resource.index = sampler_index;<br>
+ inst->resource = sampler;<br>
inst->sampler_array_size = sampler_array_size;<br>
inst->sampler_base = sampler_base;<br>
<br>
- if (reladdr.file != PROGRAM_UNDEFINED) {<br>
- inst->resource.reladdr = ralloc(mem_ctx, st_src_reg);<br>
- memcpy(inst->resource.reladdr, &reladdr, sizeof(reladdr));<br>
- }<br>
-<br>
if (ir->offset) {<br>
if (!inst->tex_offsets)<br>
inst->tex_offsets = rzalloc_array(inst, st_src_reg, MAX_GLSL_TEXTURE_OFFSET);<br>
<font color="#888888">--<br>
2.12.2<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>