<div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">On Jan 4, 2017 4:54 AM, "Erik Faye-Lund" <<a href="mailto:kusmabite@gmail.com">kusmabite@gmail.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div class="elided-text"><div class="gmail_extra" dir="auto"><div class="gmail_quote">On Jan 3, 2017 16:34, "Jason Ekstrand" <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>> wrote:<br type="attribution"><blockquote class="m_-5204518772582892911quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="m_-5204518772582892911quoted-text">On Fri, Dec 16, 2016 at 6:49 AM, Juan A. Suarez Romero <span dir="ltr"><<a href="mailto:jasuarez@igalia.com" target="_blank">jasuarez@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Samuel Iglesias Gonsálvez <<a href="mailto:siglesias@igalia.com" target="_blank">siglesias@igalia.com</a>><br>
<br>
Signed-off-by: Samuel Iglesias Gonsálvez <<a href="mailto:siglesias@igalia.com" target="_blank">siglesias@igalia.com</a>><br>
---<br>
src/amd/vulkan/radv_pipeline.<wbr>c | 5 +++-<br>
src/compiler/spirv/nir_spirv.<wbr>h | 5 +++-<br>
src/compiler/spirv/spirv_to_n<wbr>ir.c | 51 ++++++++++++++++++++++++++++++<wbr>+++++----<br>
src/intel/vulkan/anv_pipeline<wbr>.c | 5 +++-<br>
4 files changed, 58 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/src/amd/vulkan/radv_pipeline<wbr>.c b/src/amd/vulkan/radv_pipeline<wbr>.c<br>
index 23ed2d2..6d8299e 100644<br>
--- a/src/amd/vulkan/radv_pipeline<wbr>.c<br>
+++ b/src/amd/vulkan/radv_pipeline<wbr>.c<br>
@@ -188,7 +188,10 @@ radv_shader_compile_to_nir(str<wbr>uct radv_device *device,<br>
assert(data + entry.size <= spec_info->pData + spec_info->dataSize);<br>
<br>
spec_entries[i].id = spec_info->pMapEntries[i].cons<wbr>tantID;<br>
- spec_entries[i].data = *(const uint32_t *)data;<br>
+ if (spec_info->dataSize == 8)<br>
+ spec_entries[i].data64 = *(const uint64_t *)data;<br>
+ else<br>
+ spec_entries[i].data32 = *(const uint32_t *)data;<br></blockquote><div><br></div></div><div>radv is silly and uses tabs. :( You used spaces...<br></div><div class="m_-5204518772582892911elided-text"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
}<br>
<br>
diff --git a/src/compiler/spirv/nir_spirv<wbr>.h b/src/compiler/spirv/nir_spirv<wbr>.h<br>
index 500f2cb..33a2781 100644<br>
--- a/src/compiler/spirv/nir_spirv<wbr>.h<br>
+++ b/src/compiler/spirv/nir_spirv<wbr>.h<br>
@@ -38,7 +38,10 @@ extern "C" {<br>
<br>
struct nir_spirv_specialization {<br>
uint32_t id;<br>
- uint32_t data;<br>
+ union {<br>
+ uint32_t data32;<br>
+ uint64_t data64;<br>
+ };<br>
};<br>
<br>
nir_function *spirv_to_nir(const uint32_t *words, size_t word_count,<br>
diff --git a/src/compiler/spirv/spirv_to_<wbr>nir.c b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
index 2a60b53..380fbae 100644<br>
--- a/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
+++ b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
@@ -31,6 +31,14 @@<br>
#include "nir/nir_constant_expressions.<wbr>h"<br>
#include "spirv_info.h"<br>
<br>
+struct spec_constant_value {<br>
+ bool is_double;<br>
+ union {<br>
+ uint32_t data32;<br>
+ uint64_t data64;<br>
+ };<br>
+};<br>
+<br>
void<br>
_vtn_warn(const char *file, int line, const char *msg, ...)<br>
{<br>
@@ -942,11 +950,14 @@ spec_constant_decoration_cb(st<wbr>ruct vtn_builder *b, struct vtn_value *v,<br>
if (dec->decoration != SpvDecorationSpecId)<br>
return;<br>
<br>
- uint32_t *const_value = data;<br>
+ struct spec_constant_value *const_value = data;<br>
<br>
for (unsigned i = 0; i < b->num_specializations; i++) {<br>
if (b->specializations[i].id == dec->literals[0]) {<br>
- *const_value = b->specializations[i].data;<br>
+ if (const_value->is_double)<br>
+ const_value->data64 = b->specializations[i].data64;<br>
+ else<br>
+ const_value->data32 = b->specializations[i].data32;<br>
return;<br>
}<br>
}<br>
@@ -956,8 +967,22 @@ static uint32_t<br>
get_specialization(struct vtn_builder *b, struct vtn_value *val,<br>
uint32_t const_value)<br>
{<br>
- vtn_foreach_decoration(b, val, spec_constant_decoration_cb, &const_value);<br>
- return const_value;<br>
+ struct spec_constant_value data;<br>
+ data.is_double = false;<br>
+ data.data32 = const_value;<br>
+ vtn_foreach_decoration(b, val, spec_constant_decoration_cb, &data);<br>
+ return data.data32;<br>
+}<br>
+<br>
+static uint64_t<br>
+get_specialization64(struct vtn_builder *b, struct vtn_value *val,<br>
+ uint64_t const_value)<br>
+{<br>
+ struct spec_constant_value data;<br>
+ data.is_double = true;<br>
+ data.data64 = const_value;<br>
+ vtn_foreach_decoration(b, val, spec_constant_decoration_cb, &data);<br>
+ return data.data64;<br>
}<br>
<br>
static void<br>
@@ -1016,10 +1041,26 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,<br>
}<br>
break;<br>
}<br>
- case SpvOpSpecConstant:<br>
+ case SpvOpSpecConstant: {<br>
assert(glsl_type_is_scalar(va<wbr>l->const_type));<br>
val->constant->values[0].u32[<wbr>0] = get_specialization(b, val, w[3]);<br>
+ int bit_size = glsl_get_bit_size(val->const_t<wbr>ype);<br>
+ if (bit_size == 64) {<br>
+ union {<br>
+ uint64_t u64;<br>
+ struct {<br>
+ uint32_t u1;<br>
+ uint32_t u2;<br>
+ };<br>
+ } di;<br>
+ di.u1 = w[3];<br>
+ di.u2 = w[4];<br></blockquote><div><br></div></div><div>You could also just do *(const uint64_t *)&w[3]. Might be easier.<br></div><div class="m_-5204518772582892911elided-text"><div> </div></div></div></div></div></blockquote></div></div><div dir="auto"><br></div></div><div dir="auto">That would violate strict-aliasing. </div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Grr... You're right. It's read-only so it probably wouldn't matter but it does violate the rule. Maybe the thing to do would be to add a quick helper:</div><div dir="auto"><br></div><div dir="auto">uint64_t</div><div dir="auto">vtn_u64_literal(uint64_t *w)</div><div dir="auto">{</div><div dir="auto"> return (uint64_t)w[1] << 32 | w[0];</div><div dir="auto">}</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"><div dir="auto"><div class="elided-text"><div class="gmail_extra" dir="auto"><div class="gmail_quote"><blockquote class="m_-5204518772582892911quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="m_-5204518772582892911elided-text"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ val->constant->values[0].u64[<wbr>0] = get_specialization64(b, val, di.u64);<br>
+ } else {<br>
+ val->constant->values[0].u32[<wbr>0] = get_specialization(b, val, w[3]);<br>
+ }<br>
break;<br>
+ }<br>
case SpvOpSpecConstantComposite:<br>
case SpvOpConstantComposite: {<br>
unsigned elem_count = count - 3;<br>
diff --git a/src/intel/vulkan/anv_pipelin<wbr>e.c b/src/intel/vulkan/anv_pipelin<wbr>e.c<br>
index 9104267..30ac19a 100644<br>
--- a/src/intel/vulkan/anv_pipelin<wbr>e.c<br>
+++ b/src/intel/vulkan/anv_pipelin<wbr>e.c<br>
@@ -117,7 +117,10 @@ anv_shader_compile_to_nir(stru<wbr>ct anv_device *device,<br>
assert(data + entry.size <= spec_info->pData + spec_info->dataSize);<br>
<br>
spec_entries[i].id = spec_info->pMapEntries[i].cons<wbr>tantID;<br>
- spec_entries[i].data = *(const uint32_t *)data;<br>
+ if (spec_info->dataSize == 8)<br>
+ spec_entries[i].data64 = *(const uint64_t *)data;<br>
+ else<br>
+ spec_entries[i].data32 = *(const uint32_t *)data;<br>
}<br>
}<br>
<span class="m_-5204518772582892911m_6328578372469543128HOEnZb"><font color="#888888"><br>
--<br>
2.9.3<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">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></div><br></div></div>
<br>______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">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>
<br></blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div>