anv/pipeline: Refactor specialization constant handling a bit
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 31 May 2016 23:27:19 +0000 (16:27 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 4 Jun 2016 02:29:28 +0000 (19:29 -0700)
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
src/intel/vulkan/anv_pipeline.c

index 504f0be289f661ec7324ff582c4a74559938e1d9..cdbf60bc218a6eb751b301a74ba52ba64890c0ad 100644 (file)
@@ -123,13 +123,12 @@ anv_shader_compile_to_nir(struct anv_device *device,
          num_spec_entries = spec_info->mapEntryCount;
          spec_entries = malloc(num_spec_entries * sizeof(*spec_entries));
          for (uint32_t i = 0; i < num_spec_entries; i++) {
-            const uint32_t *data =
-               spec_info->pData + spec_info->pMapEntries[i].offset;
-            assert((const void *)(data + 1) <=
-                   spec_info->pData + spec_info->dataSize);
+            VkSpecializationMapEntry entry = spec_info->pMapEntries[i];
+            const void *data = spec_info->pData + entry.offset;
+            assert(data + entry.size <= spec_info->pData + spec_info->dataSize);
 
             spec_entries[i].id = spec_info->pMapEntries[i].constantID;
-            spec_entries[i].data = *data;
+            spec_entries[i].data = *(const uint32_t *)data;
          }
       }