<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">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">siglesias@igalia.com</a>><br>
<br>
Signed-off-by: Samuel Iglesias Gonsálvez <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
---<br>
 src/amd/vulkan/radv_pipeline.c    |  5 +++-<br>
 src/compiler/spirv/nir_spirv.h    |  5 +++-<br>
 src/compiler/spirv/spirv_to_<wbr>nir.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_<wbr>pipeline.c b/src/amd/vulkan/radv_<wbr>pipeline.c<br>
index 23ed2d2..6d8299e 100644<br>
--- a/src/amd/vulkan/radv_<wbr>pipeline.c<br>
+++ b/src/amd/vulkan/radv_<wbr>pipeline.c<br>
@@ -188,7 +188,10 @@ radv_shader_compile_to_nir(<wbr>struct radv_device *device,<br>
                                assert(data + entry.size <= spec_info->pData + spec_info->dataSize);<br>
<br>
                                spec_entries[i].id = spec_info->pMapEntries[i].<wbr>constantID;<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>radv is silly and uses tabs. :(  You used spaces...<br></div><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_<wbr>spirv.h b/src/compiler/spirv/nir_<wbr>spirv.h<br>
index 500f2cb..33a2781 100644<br>
--- a/src/compiler/spirv/nir_<wbr>spirv.h<br>
+++ b/src/compiler/spirv/nir_<wbr>spirv.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(<wbr>struct 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(<wbr>val->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_<wbr>type);<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>You could also just do *(const uint64_t *)&w[3].  Might be easier.<br></div><div> </div><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_<wbr>pipeline.c b/src/intel/vulkan/anv_<wbr>pipeline.c<br>
index 9104267..30ac19a 100644<br>
--- a/src/intel/vulkan/anv_<wbr>pipeline.c<br>
+++ b/src/intel/vulkan/anv_<wbr>pipeline.c<br>
@@ -117,7 +117,10 @@ anv_shader_compile_to_nir(<wbr>struct anv_device *device,<br>
          assert(data + entry.size <= spec_info->pData + spec_info->dataSize);<br>
<br>
          spec_entries[i].id = spec_info->pMapEntries[i].<wbr>constantID;<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="HOEnZb"><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">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>