mirror of
https://github.com/KhronosGroup/SPIRV-Cross.git
synced 2024-09-19 22:30:03 +00:00
Merge pull request #2205 from Try/hlsl-ssbo-array-store-fix
Fix unroll, when storing to pointer to array
This commit is contained in:
commit
37fee00a71
22
reference/shaders-hlsl/comp/ssbo-store-array.comp
Normal file
22
reference/shaders-hlsl/comp/ssbo-store-array.comp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
struct Data
|
||||||
|
{
|
||||||
|
uint arr[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
RWByteAddressBuffer _13 : register(u0);
|
||||||
|
|
||||||
|
void comp_main()
|
||||||
|
{
|
||||||
|
Data d1;
|
||||||
|
[unroll]
|
||||||
|
for (int _0ident = 0; _0ident < 3; _0ident++)
|
||||||
|
{
|
||||||
|
_13.Store(_0ident * 4 + 0, d1.arr[_0ident]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
comp_main();
|
||||||
|
}
|
19
shaders-hlsl/comp/ssbo-store-array.comp
Normal file
19
shaders-hlsl/comp/ssbo-store-array.comp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#version 460
|
||||||
|
|
||||||
|
struct Data
|
||||||
|
{
|
||||||
|
uint arr[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(set = 0, binding = 0, std430) buffer B0
|
||||||
|
{
|
||||||
|
Data d[];
|
||||||
|
};
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
Data d1;
|
||||||
|
d[0].arr = d1.arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -4696,7 +4696,12 @@ void CompilerHLSL::emit_load(const Instruction &instruction)
|
|||||||
void CompilerHLSL::write_access_chain_array(const SPIRAccessChain &chain, uint32_t value,
|
void CompilerHLSL::write_access_chain_array(const SPIRAccessChain &chain, uint32_t value,
|
||||||
const SmallVector<uint32_t> &composite_chain)
|
const SmallVector<uint32_t> &composite_chain)
|
||||||
{
|
{
|
||||||
auto &type = get<SPIRType>(chain.basetype);
|
auto *ptype = &get<SPIRType>(chain.basetype);
|
||||||
|
while (ptype->pointer)
|
||||||
|
{
|
||||||
|
ptype = &get<SPIRType>(ptype->basetype);
|
||||||
|
}
|
||||||
|
auto &type = *ptype;
|
||||||
|
|
||||||
// Need to use a reserved identifier here since it might shadow an identifier in the access chain input or other loops.
|
// Need to use a reserved identifier here since it might shadow an identifier in the access chain input or other loops.
|
||||||
auto ident = get_unique_identifier();
|
auto ident = get_unique_identifier();
|
||||||
|
Loading…
Reference in New Issue
Block a user