vulkan: Avoid pointer aliasing
Avoids the sanitizer errors:
```
Test case 'dEQP-VK.pipeline.monolithic.spec_constant.graphics.vertex.basic.mixed_packed'..
../src/vulkan/util/vk_util.c:111:38: runtime error: load of misaligned address 0x603002b1c591 for type 'const uint16_t', which requires 2 byte alignment
0x603002b1c591: note: pointer points here
00 00 00 98 76 98 54 76 98 ba 10 32 54 76 98 ba dc fe ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
../src/vulkan/util/vk_util.c:108:38: runtime error: load of misaligned address 0x603002b1c593 for type 'const uint32_t', which requires 4 byte alignment
0x603002b1c593: note: pointer points here
00 98 76 98 54 76 98 ba 10 32 54 76 98 ba dc fe ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
../src/vulkan/util/vk_util.c:105:38: runtime error: load of misaligned address 0x603002b1c597 for type 'const uint64_t', which requires 8 byte alignment
0x603002b1c597: note: pointer points here
54 76 98 ba 10 32 54 76 98 ba dc fe ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 03 11 00
^
```
Fixes: 476dc3c050
("vulkan: add vk_spec_info_to_nir_spirv util method")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32159>
This commit is contained in:
@@ -102,16 +102,16 @@ vk_spec_info_to_nir_spirv(const VkSpecializationInfo *spec_info,
|
||||
spec_entries[i].id = spec_info->pMapEntries[i].constantID;
|
||||
switch (entry.size) {
|
||||
case 8:
|
||||
spec_entries[i].value.u64 = *(const uint64_t *)data;
|
||||
memcpy(&spec_entries[i].value.u64, data, entry.size);
|
||||
break;
|
||||
case 4:
|
||||
spec_entries[i].value.u32 = *(const uint32_t *)data;
|
||||
memcpy(&spec_entries[i].value.u32, data, entry.size);
|
||||
break;
|
||||
case 2:
|
||||
spec_entries[i].value.u16 = *(const uint16_t *)data;
|
||||
memcpy(&spec_entries[i].value.u16, data, entry.size);
|
||||
break;
|
||||
case 1:
|
||||
spec_entries[i].value.u8 = *(const uint8_t *)data;
|
||||
memcpy(&spec_entries[i].value.u8, data, entry.size);
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
|
Reference in New Issue
Block a user