<div dir="auto"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Jan 5, 2017 10:20, "Samuel Iglesias Gonsálvez" <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We need to pick two 32-bit values per component to perform the right shuffle operation.<br>
<br>
v2 (Jason):<br>
- Add assert to check matching bit sizes (Jason)<br>
- Simplify the code to pick components (Jason)<br>
<br>
Signed-off-by: Samuel Iglesias Gonsálvez <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
---<br>
src/compiler/spirv/spirv_to_<wbr>nir.c | 40 ++++++++++++++++++++++++++++++<wbr>---------<br>
1 file changed, 31 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/src/compiler/spirv/spirv_to_<wbr>nir.c b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
index b44b8e823d2..a9c1bef1411 100644<br>
--- a/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
+++ b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
@@ -1076,18 +1076,40 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,<br>
unsigned len0 = glsl_get_vector_elements(v0-><wbr>const_type);<br>
unsigned len1 = glsl_get_vector_elements(v1-><wbr>const_type);<br>
<br>
- uint32_t u[8];<br>
- for (unsigned i = 0; i < len0; i++)<br>
- u[i] = v0->constant->values[0].u32[i]<wbr>;<br>
- for (unsigned i = 0; i < len1; i++)<br>
- u[len0 + i] = v1->constant->values[0].u32[i]<wbr>;<br>
+ uint32_t u32[8];<br>
+ uint64_t u64[8];<br>
+ assert(len0 + len1 < 16);<br>
+<br>
+ unsigned bit_size = glsl_get_bit_size(val->const_<wbr>type);<br>
+ assert(bit_size == glsl_get_bit_size(v0->const_<wbr>type) &&<br>
+ bit_size == glsl_get_bit_size(v1->const_<wbr>type));<br>
+<br>
+ for (unsigned i = 0; i < len0; i++) {<br>
+ if (bit_size == 64)<br>
+ u64[i] = v0->constant->values[0].u64[i]<wbr>;<br>
+ else<br>
+ u32[i] = v0->constant->values[0].u32[i]<wbr>;<br>
+ }<br>
+<br>
+ for (unsigned i = 0; i < len1; i++) {<br>
+ if (bit_size == 64)<br>
+ u64[len0 + i] = v1->constant->values[0].u64[i]<wbr>;<br>
+ else<br>
+ u32[len0 + i] = v1->constant->values[0].u32[i]<wbr>;<br>
+ }<br>
<br>
- for (unsigned i = 0; i < count - 6; i++) {<br>
+ for (unsigned i = 0, j = 0; i < count - 6; i++, j++) {<br>
uint32_t comp = w[i + 6];<br>
- if (comp == (uint32_t)-1) {<br>
- val->constant->values[0].u32[<wbr>i] = 0xdeadbeef;<br>
+ if (bit_size == 64) {<br>
+ if (comp == (uint32_t)-1)</blockquote></div></div></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">
+ val->constant->values[0].u64[<wbr>j] = 0xdeadbeefdeadbeef;<br></blockquote></div></div></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"></blockquote></div></div></div><div dir="auto">If this is really intended, shouldn't there be some explanation? </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">
+ else<br>
+ val->constant->values[0].u64[<wbr>j] = u64[comp];<br>
} else {<br>
- val->constant->values[0].u32[<wbr>i] = u[comp];<br>
+ if (comp == (uint32_t)-1)<br>
+ val->constant->values[0].u32[<wbr>j] = 0xdeadbeef;<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Same... </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">
+ else<br>
+ val->constant->values[0].u32[<wbr>j] = u32[comp];<br>
}<br>
}<br>
break;<br>
<font color="#888888">--<br>
2.11.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>