Description
Given a structure that contains an array and a vk::BufferPointer pointing to it, such as:
struct Foo {
int val[4];
};
vk::BufferPointer<Foo> fooBuf;
Attempting to load an element of the array through the buffer pointer produces invalid SPIR-V:
fatal error: generated SPIR-V is invalid: OpLoad Result Type '20[%_ptr_PhysicalStorageBuffer_Foo_0]' does not match Pointer '23[%23]'s type.
%24 = OpLoad %_ptr_PhysicalStorageBuffer_Foo_0 %23
Looking at the output, DXC seems to generate a duplicate definition of the array (%_arr_int_uint_4 and %_arr_int_uint_4_0) which then propagates to duplicates %_ptr_PhysicalStorageBuffer_Foo and %_ptr_PhysicalStorageBuffer_Foo_0. It then attempts to load the latter from a pointer to the former.
Steps to Reproduce
https://godbolt.org/z/hx7Y8MYvf
Environment
- DXC version: trunk
- Host Operating System: Windows 11