mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-09 12:00:05 +00:00
Add decorations to structs with buffer references
The containsPhysicalStorageBufferOrArray function now handles struct types correctly, checking their contents recursively for buffer reference types. As a result, OpVariables containing structs that have members that are buffer references now have the appropriate AliasedPointer or RestrictPointer decoration as per the spec. Fixes #3188
This commit is contained in:
parent
d1517d64cf
commit
9caca7a17b
@ -1373,7 +1373,7 @@ bool Builder::containsType(Id typeId, spv::Op typeOp, unsigned int width) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// return true if the type is a pointer to PhysicalStorageBufferEXT or an
|
// return true if the type is a pointer to PhysicalStorageBufferEXT or an
|
||||||
// array of such pointers. These require restrict/aliased decorations.
|
// contains such a pointer. These require restrict/aliased decorations.
|
||||||
bool Builder::containsPhysicalStorageBufferOrArray(Id typeId) const
|
bool Builder::containsPhysicalStorageBufferOrArray(Id typeId) const
|
||||||
{
|
{
|
||||||
const Instruction& instr = *module.getInstruction(typeId);
|
const Instruction& instr = *module.getInstruction(typeId);
|
||||||
@ -1385,6 +1385,12 @@ bool Builder::containsPhysicalStorageBufferOrArray(Id typeId) const
|
|||||||
return getTypeStorageClass(typeId) == StorageClassPhysicalStorageBufferEXT;
|
return getTypeStorageClass(typeId) == StorageClassPhysicalStorageBufferEXT;
|
||||||
case OpTypeArray:
|
case OpTypeArray:
|
||||||
return containsPhysicalStorageBufferOrArray(getContainedTypeId(typeId));
|
return containsPhysicalStorageBufferOrArray(getContainedTypeId(typeId));
|
||||||
|
case OpTypeStruct:
|
||||||
|
for (int m = 0; m < instr.getNumOperands(); ++m) {
|
||||||
|
if (containsPhysicalStorageBufferOrArray(instr.getIdOperand(m)))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
spv.bufferhandle8.frag
|
spv.bufferhandle8.frag
|
||||||
// Module Version 10000
|
// Module Version 10000
|
||||||
// Generated by (magic number): 8000b
|
// Generated by (magic number): 8000b
|
||||||
// Id's are bound by 27
|
// Id's are bound by 39
|
||||||
|
|
||||||
Capability Shader
|
Capability Shader
|
||||||
Capability PhysicalStorageBufferAddressesEXT
|
Capability PhysicalStorageBufferAddressesEXT
|
||||||
@ -21,41 +21,46 @@ spv.bufferhandle8.frag
|
|||||||
MemberName 10(T1) 0 "x"
|
MemberName 10(T1) 0 "x"
|
||||||
Name 11 "T2"
|
Name 11 "T2"
|
||||||
MemberName 11(T2) 0 "x"
|
MemberName 11(T2) 0 "x"
|
||||||
Name 13 "T3"
|
Name 13 "x"
|
||||||
MemberName 13(T3) 0 "Bindings"
|
Name 14 "Blah"
|
||||||
Name 15 "t3"
|
MemberName 14(Blah) 0 "t1"
|
||||||
Name 23 "t2"
|
MemberName 14(Blah) 1 "t2"
|
||||||
MemberName 23(t2) 0 "f"
|
Name 16 "T3"
|
||||||
MemberName 23(t2) 1 "g"
|
MemberName 16(T3) 0 "Bindings"
|
||||||
Name 24 "blockType"
|
Name 18 "t3"
|
||||||
MemberName 24(blockType) 0 "a"
|
Name 35 "t2"
|
||||||
MemberName 24(blockType) 1 "b"
|
MemberName 35(t2) 0 "f"
|
||||||
MemberName 24(blockType) 2 "c"
|
MemberName 35(t2) 1 "g"
|
||||||
MemberName 24(blockType) 3 "d"
|
Name 36 "blockType"
|
||||||
MemberName 24(blockType) 4 "e"
|
MemberName 36(blockType) 0 "a"
|
||||||
Name 26 "t"
|
MemberName 36(blockType) 1 "b"
|
||||||
MemberDecorate 8(Blah) 0 Offset 0
|
MemberName 36(blockType) 2 "c"
|
||||||
MemberDecorate 8(Blah) 1 Offset 8
|
MemberName 36(blockType) 3 "d"
|
||||||
|
MemberName 36(blockType) 4 "e"
|
||||||
|
Name 38 "t"
|
||||||
MemberDecorate 10(T1) 0 Offset 0
|
MemberDecorate 10(T1) 0 Offset 0
|
||||||
Decorate 10(T1) Block
|
Decorate 10(T1) Block
|
||||||
MemberDecorate 11(T2) 0 Offset 0
|
MemberDecorate 11(T2) 0 Offset 0
|
||||||
Decorate 11(T2) Block
|
Decorate 11(T2) Block
|
||||||
Decorate 12 ArrayStride 16
|
MemberDecorate 14(Blah) 0 Offset 0
|
||||||
MemberDecorate 13(T3) 0 Offset 0
|
MemberDecorate 14(Blah) 1 Offset 8
|
||||||
Decorate 13(T3) Block
|
Decorate 15 ArrayStride 16
|
||||||
Decorate 15(t3) DescriptorSet 0
|
MemberDecorate 16(T3) 0 Offset 0
|
||||||
Decorate 15(t3) Binding 0
|
Decorate 16(T3) Block
|
||||||
MemberDecorate 23(t2) 0 Offset 0
|
Decorate 18(t3) DescriptorSet 0
|
||||||
MemberDecorate 23(t2) 1 Offset 8
|
Decorate 18(t3) Binding 0
|
||||||
Decorate 23(t2) Block
|
MemberDecorate 35(t2) 0 Offset 0
|
||||||
MemberDecorate 24(blockType) 0 Offset 0
|
MemberDecorate 35(t2) 1 Offset 8
|
||||||
MemberDecorate 24(blockType) 1 Offset 4
|
Decorate 35(t2) Block
|
||||||
MemberDecorate 24(blockType) 2 Offset 8
|
MemberDecorate 36(blockType) 0 Offset 0
|
||||||
MemberDecorate 24(blockType) 3 Offset 12
|
MemberDecorate 36(blockType) 1 Offset 4
|
||||||
MemberDecorate 24(blockType) 4 Offset 16
|
MemberDecorate 36(blockType) 2 Offset 8
|
||||||
Decorate 24(blockType) Block
|
MemberDecorate 36(blockType) 3 Offset 12
|
||||||
Decorate 26(t) DescriptorSet 0
|
MemberDecorate 36(blockType) 4 Offset 16
|
||||||
Decorate 26(t) Binding 0
|
Decorate 36(blockType) Block
|
||||||
|
Decorate 38(t) DescriptorSet 0
|
||||||
|
Decorate 38(t) Binding 0
|
||||||
|
Decorate 13(x) DecorationAliasedPointerEXT
|
||||||
2: TypeVoid
|
2: TypeVoid
|
||||||
3: TypeFunction 2
|
3: TypeFunction 2
|
||||||
TypeForwardPointer 6 PhysicalStorageBufferEXT
|
TypeForwardPointer 6 PhysicalStorageBufferEXT
|
||||||
@ -66,24 +71,38 @@ spv.bufferhandle8.frag
|
|||||||
6: TypePointer PhysicalStorageBufferEXT 10(T1)
|
6: TypePointer PhysicalStorageBufferEXT 10(T1)
|
||||||
11(T2): TypeStruct 9(int)
|
11(T2): TypeStruct 9(int)
|
||||||
7: TypePointer PhysicalStorageBufferEXT 11(T2)
|
7: TypePointer PhysicalStorageBufferEXT 11(T2)
|
||||||
12: TypeRuntimeArray 8(Blah)
|
12: TypePointer Function 8(Blah)
|
||||||
13(T3): TypeStruct 12
|
14(Blah): TypeStruct 6(ptr) 7(ptr)
|
||||||
14: TypePointer StorageBuffer 13(T3)
|
15: TypeRuntimeArray 14(Blah)
|
||||||
15(t3): 14(ptr) Variable StorageBuffer
|
16(T3): TypeStruct 15
|
||||||
16: 9(int) Constant 0
|
17: TypePointer StorageBuffer 16(T3)
|
||||||
17: 9(int) Constant 1
|
18(t3): 17(ptr) Variable StorageBuffer
|
||||||
18: TypePointer StorageBuffer 8(Blah)
|
19: 9(int) Constant 0
|
||||||
TypeForwardPointer 22 PhysicalStorageBufferEXT
|
20: 9(int) Constant 2
|
||||||
23(t2): TypeStruct 22 22
|
21: TypePointer StorageBuffer 14(Blah)
|
||||||
24(blockType): TypeStruct 9(int) 9(int) 9(int) 9(int) 9(int)
|
25: TypePointer Function 6(ptr)
|
||||||
22: TypePointer PhysicalStorageBufferEXT 24(blockType)
|
28: 9(int) Constant 1
|
||||||
25: TypePointer StorageBuffer 23(t2)
|
29: TypePointer Function 7(ptr)
|
||||||
26(t): 25(ptr) Variable StorageBuffer
|
TypeForwardPointer 34 PhysicalStorageBufferEXT
|
||||||
|
35(t2): TypeStruct 34 34
|
||||||
|
36(blockType): TypeStruct 9(int) 9(int) 9(int) 9(int) 9(int)
|
||||||
|
34: TypePointer PhysicalStorageBufferEXT 36(blockType)
|
||||||
|
37: TypePointer StorageBuffer 35(t2)
|
||||||
|
38(t): 37(ptr) Variable StorageBuffer
|
||||||
4(main): 2 Function None 3
|
4(main): 2 Function None 3
|
||||||
5: Label
|
5: Label
|
||||||
19: 18(ptr) AccessChain 15(t3) 16 17
|
13(x): 12(ptr) Variable Function
|
||||||
20: 8(Blah) Load 19
|
22: 21(ptr) AccessChain 18(t3) 19 20
|
||||||
21: 18(ptr) AccessChain 15(t3) 16 16
|
23: 14(Blah) Load 22
|
||||||
Store 21 20
|
24: 6(ptr) CompositeExtract 23 0
|
||||||
|
26: 25(ptr) AccessChain 13(x) 19
|
||||||
|
Store 26 24
|
||||||
|
27: 7(ptr) CompositeExtract 23 1
|
||||||
|
30: 29(ptr) AccessChain 13(x) 28
|
||||||
|
Store 30 27
|
||||||
|
31: 21(ptr) AccessChain 18(t3) 19 28
|
||||||
|
32: 14(Blah) Load 31
|
||||||
|
33: 21(ptr) AccessChain 18(t3) 19 19
|
||||||
|
Store 33 32
|
||||||
Return
|
Return
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
@ -27,6 +27,8 @@ layout(set=0, binding=0) buffer T3 {
|
|||||||
Blah Bindings[];
|
Blah Bindings[];
|
||||||
} t3;
|
} t3;
|
||||||
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
Blah x = t3.Bindings[2];
|
||||||
t3.Bindings[0] = t3.Bindings[1];
|
t3.Bindings[0] = t3.Bindings[1];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user