<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jan 5, 2017 at 2:18 AM, Samuel Iglesias Gonsálvez <span dir="ltr"><<a href="mailto:siglesias@igalia.com" target="_blank">siglesias@igalia.com</a>></span> wrote:<br><blockquote class="gmail_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></blockquote><div><br></div><div>Can we please switch on bit_size once? I think it's probably actually easier to read that way. It's not a complicated blob of code but having everything depend on bit_size makes it look more complex than it is. Also, for what it's worth, switching once is more efficient.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ 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)<br>
+ val->constant->values[0].u64[<wbr>j] = 0xdeadbeefdeadbeef;<br>
+ 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>
+ else<br>
+ val->constant->values[0].u32[<wbr>j] = u32[comp];<br>
}<br>
}<br>
break;<br>
<span class="HOEnZb"><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></span></blockquote></div><br></div></div>