aboutsummaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2020-04-22 14:05:13 -0500
committerMarge Bot <[email protected]>2020-04-24 09:23:59 +0000
commitf4addfdde39070879ed8b1f08fe3bd85f2b0e392 (patch)
tree28b0ba769682558d79f4baff1984d11b9a374ec2 /src/amd/vulkan
parent6211e79ba5f4be57c088fdf6140854f67c9a37ec (diff)
spirv: Use nir_const_value for spec constants
When we originally wrote spirv_to_nir we didn't have a good scalar value union to handily use so we rolled our own thing for spec constants. Now that we have nir_const_value, we can use that and simplify a bunch of the spec constant logic. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4675>
Diffstat (limited to 'src/amd/vulkan')
-rw-r--r--src/amd/vulkan/radv_shader.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 7d8e8a29011..7ed697057b4 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -320,7 +320,7 @@ radv_shader_compile_to_nir(struct radv_device *device,
struct nir_spirv_specialization *spec_entries = NULL;
if (spec_info && spec_info->mapEntryCount > 0) {
num_spec_entries = spec_info->mapEntryCount;
- spec_entries = malloc(num_spec_entries * sizeof(*spec_entries));
+ spec_entries = calloc(num_spec_entries, sizeof(*spec_entries));
for (uint32_t i = 0; i < num_spec_entries; i++) {
VkSpecializationMapEntry entry = spec_info->pMapEntries[i];
const void *data = spec_info->pData + entry.offset;
@@ -329,16 +329,16 @@ radv_shader_compile_to_nir(struct radv_device *device,
spec_entries[i].id = spec_info->pMapEntries[i].constantID;
switch (entry.size) {
case 8:
- spec_entries[i].data64 = *(const uint64_t *)data;
+ spec_entries[i].value.u64 = *(const uint64_t *)data;
break;
case 4:
- spec_entries[i].data32 = *(const uint32_t *)data;
+ spec_entries[i].value.u32 = *(const uint32_t *)data;
break;
case 2:
- spec_entries[i].data32 = *(const uint16_t *)data;
+ spec_entries[i].value.u16 = *(const uint16_t *)data;
break;
case 1:
- spec_entries[i].data32 = *(const uint8_t *)data;
+ spec_entries[i].value.u8 = *(const uint8_t *)data;
break;
default:
assert(!"Invalid spec constant size");