Unverified Commit f9edfdab by John Kessenich Committed by GitHub

Merge pull request #1603 from KhronosGroup/uint-array-length

SPV: Generate OpArrayLength with no signedness.
parents f44b17ee 4efc6f1e
......@@ -1825,6 +1825,12 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
unsigned int member = node->getOperand()->getAsBinaryNode()->getRight()->getAsConstantUnion()->getConstArray()[0].getUConst();
spv::Id length = builder.createArrayLength(builder.accessChainGetLValue(), member);
// GLSL semantics say the result of .length() is an int, while SPIR-V says
// signedness must be 0. So, convert from SPIR-V unsigned back to GLSL's
// AST expectation of a signed result.
if (glslangIntermediate->getSource() == glslang::EShSourceGlsl)
length = builder.createUnaryOp(spv::OpBitcast, builder.makeIntType(32), length);
builder.clearAccessChain();
builder.setAccessChainRValue(length);
......
......@@ -1293,7 +1293,7 @@ Id Builder::createAccessChain(StorageClass storageClass, Id base, const std::vec
Id Builder::createArrayLength(Id base, unsigned int member)
{
spv::Id intType = makeIntType(32);
spv::Id intType = makeUintType(32);
Instruction* length = new Instruction(getUniqueId(), intType, OpArrayLength);
length->addIdOperand(base);
length->addImmediateOperand(member);
......
......@@ -323,10 +323,6 @@ gl_FragCoord origin is upper left
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:? 'pos' (layout( location=0) flat in uint)
error: SPIRV-Tools Validation Errors
error: OpStore Pointer <id> '14[size]'s type does not match Object <id> '20's type.
OpStore %size %20
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 114
......@@ -370,13 +366,13 @@ error: OpStore Pointer <id> '14[size]'s type does not match Object <id> '20's ty
16(sbuf): TypeStruct 15
17: TypePointer Uniform 16(sbuf)
18(sbuf): 17(ptr) Variable Uniform
19: TypeInt 32 1
21: 19(int) Constant 0
23: 19(int) Constant 2
20: TypeInt 32 1
21: 20(int) Constant 0
23: 20(int) Constant 2
25: TypePointer Uniform 6(int)
29: TypePointer Function 19(int)
29: TypePointer Function 20(int)
32: 6(int) Constant 4
39: 19(int) Constant 1
39: 20(int) Constant 1
43: TypeVector 6(int) 2
45: TypeVector 8(float) 2
47: 8(float) Constant 0
......@@ -384,7 +380,7 @@ error: OpStore Pointer <id> '14[size]'s type does not match Object <id> '20's ty
69: TypeVector 6(int) 3
71: TypeVector 8(float) 3
80: 6(int) Constant 12
95: 19(int) Constant 3
95: 20(int) Constant 3
99: TypeVector 6(int) 4
106: TypePointer Input 6(int)
107(pos): 106(ptr) Variable Input
......@@ -409,22 +405,22 @@ error: OpStore Pointer <id> '14[size]'s type does not match Object <id> '20's ty
30(byteAddrTemp): 29(ptr) Variable Function
53(byteAddrTemp): 29(ptr) Variable Function
78(byteAddrTemp): 29(ptr) Variable Function
20: 19(int) ArrayLength 18(sbuf) 0
Store 14(size) 20
19: 6(int) ArrayLength 18(sbuf) 0
Store 14(size) 19
22: 6(int) Load 11(pos)
24: 19(int) ShiftRightLogical 22 23
24: 20(int) ShiftRightLogical 22 23
26: 25(ptr) AccessChain 18(sbuf) 21 24
27: 6(int) Load 26
28: 8(float) ConvertUToF 27
31: 6(int) Load 11(pos)
33: 6(int) IAdd 31 32
34: 19(int) ShiftRightLogical 33 23
34: 20(int) ShiftRightLogical 33 23
Store 30(byteAddrTemp) 34
35: 19(int) Load 30(byteAddrTemp)
35: 20(int) Load 30(byteAddrTemp)
36: 25(ptr) AccessChain 18(sbuf) 21 35
37: 6(int) Load 36
38: 19(int) Load 30(byteAddrTemp)
40: 19(int) IAdd 38 39
38: 20(int) Load 30(byteAddrTemp)
40: 20(int) IAdd 38 39
41: 25(ptr) AccessChain 18(sbuf) 21 40
42: 6(int) Load 41
44: 43(ivec2) CompositeConstruct 37 42
......@@ -436,17 +432,17 @@ error: OpStore Pointer <id> '14[size]'s type does not match Object <id> '20's ty
52: 9(fvec4) FAdd 51 50
54: 6(int) Load 11(pos)
56: 6(int) IAdd 54 55
57: 19(int) ShiftRightLogical 56 23
57: 20(int) ShiftRightLogical 56 23
Store 53(byteAddrTemp) 57
58: 19(int) Load 53(byteAddrTemp)
58: 20(int) Load 53(byteAddrTemp)
59: 25(ptr) AccessChain 18(sbuf) 21 58
60: 6(int) Load 59
61: 19(int) Load 53(byteAddrTemp)
62: 19(int) IAdd 61 39
61: 20(int) Load 53(byteAddrTemp)
62: 20(int) IAdd 61 39
63: 25(ptr) AccessChain 18(sbuf) 21 62
64: 6(int) Load 63
65: 19(int) Load 53(byteAddrTemp)
66: 19(int) IAdd 65 23
65: 20(int) Load 53(byteAddrTemp)
66: 20(int) IAdd 65 23
67: 25(ptr) AccessChain 18(sbuf) 21 66
68: 6(int) Load 67
70: 69(ivec3) CompositeConstruct 60 64 68
......@@ -458,21 +454,21 @@ error: OpStore Pointer <id> '14[size]'s type does not match Object <id> '20's ty
77: 9(fvec4) FAdd 52 76
79: 6(int) Load 11(pos)
81: 6(int) IAdd 79 80
82: 19(int) ShiftRightLogical 81 23
82: 20(int) ShiftRightLogical 81 23
Store 78(byteAddrTemp) 82
83: 19(int) Load 78(byteAddrTemp)
83: 20(int) Load 78(byteAddrTemp)
84: 25(ptr) AccessChain 18(sbuf) 21 83
85: 6(int) Load 84
86: 19(int) Load 78(byteAddrTemp)
87: 19(int) IAdd 86 39
86: 20(int) Load 78(byteAddrTemp)
87: 20(int) IAdd 86 39
88: 25(ptr) AccessChain 18(sbuf) 21 87
89: 6(int) Load 88
90: 19(int) Load 78(byteAddrTemp)
91: 19(int) IAdd 90 23
90: 20(int) Load 78(byteAddrTemp)
91: 20(int) IAdd 90 23
92: 25(ptr) AccessChain 18(sbuf) 21 91
93: 6(int) Load 92
94: 19(int) Load 78(byteAddrTemp)
96: 19(int) IAdd 94 95
94: 20(int) Load 78(byteAddrTemp)
96: 20(int) IAdd 94 95
97: 25(ptr) AccessChain 18(sbuf) 21 96
98: 6(int) Load 97
100: 99(ivec4) CompositeConstruct 85 89 93 98
......
......@@ -175,10 +175,6 @@ gl_FragCoord origin is upper left
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:? 'pos' (layout( location=0) flat in uint)
error: SPIRV-Tools Validation Errors
error: OpStore Pointer <id> '26[size]'s type does not match Object <id> '33's type.
OpStore %size %33
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 78
......@@ -276,7 +272,7 @@ error: OpStore Pointer <id> '26[size]'s type does not match Object <id> '33's ty
22: 6(int) IAdd 20 21
25: 24(ptr) AccessChain 17(sbuf2) 19 22
Store 25 23
33: 18(int) ArrayLength 32(sbuf) 0
33: 6(int) ArrayLength 32(sbuf) 0
Store 26(size) 33
Store 34(stride) 35
36: 6(int) Load 11(pos)
......
......@@ -187,10 +187,6 @@ gl_FragCoord origin is upper left
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:? 'pos' (layout( location=0) flat in uint)
error: SPIRV-Tools Validation Errors
error: OpStore Pointer <id> '43[size]'s type does not match Object <id> '44's type.
OpStore %size %44
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 96
......@@ -312,7 +308,7 @@ error: OpStore Pointer <id> '43[size]'s type does not match Object <id> '44's ty
41: 15(bool) INotEqual 39 35
42: 37(ptr) AccessChain 18(mydata) 40
Store 42 41
44: 24(int) ArrayLength 23(sbuf) 0
44: 6(int) ArrayLength 23(sbuf) 0
Store 43(size) 44
Store 45(stride) 46
47: 6(int) Load 11(pos)
......
......@@ -175,10 +175,6 @@ gl_FragCoord origin is upper left
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
0:? 'pos' (layout( location=0) flat in uint)
error: SPIRV-Tools Validation Errors
error: OpStore Pointer <id> '26[size]'s type does not match Object <id> '33's type.
OpStore %size %33
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 78
......@@ -274,7 +270,7 @@ error: OpStore Pointer <id> '26[size]'s type does not match Object <id> '33's ty
22: 6(int) IAdd 20 21
25: 24(ptr) AccessChain 17(sbuf2) 19 22
Store 25 23
33: 18(int) ArrayLength 32(sbuf) 0
33: 6(int) ArrayLength 32(sbuf) 0
Store 26(size) 33
Store 34(stride) 35
36: 6(int) Load 11(pos)
......
spv.310.comp
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 71
// Id's are bound by 72
Capability Shader
Capability DeviceGroup
Extension "SPV_KHR_device_group"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "main" 53 64
EntryPoint GLCompute 4 "main" 53 65
ExecutionMode 4 LocalSize 16 32 4
Source ESSL 310
SourceExtension "GL_EXT_device_group"
......@@ -30,7 +30,7 @@ spv.310.comp
MemberName 48(outs) 1 "va"
Name 50 "outnames"
Name 53 "gl_LocalInvocationID"
Name 64 "gl_DeviceIndex"
Name 65 "gl_DeviceIndex"
Decorate 11 ArrayStride 16
MemberDecorate 12(outb) 0 Offset 0
MemberDecorate 12(outb) 1 Offset 4
......@@ -48,8 +48,8 @@ spv.310.comp
Decorate 48(outs) BufferBlock
Decorate 50(outnames) DescriptorSet 0
Decorate 53(gl_LocalInvocationID) BuiltIn LocalInvocationId
Decorate 64(gl_DeviceIndex) BuiltIn DeviceIndex
Decorate 70 BuiltIn WorkgroupSize
Decorate 65(gl_DeviceIndex) BuiltIn DeviceIndex
Decorate 71 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
......@@ -89,15 +89,15 @@ spv.310.comp
52: TypePointer Input 51(ivec3)
53(gl_LocalInvocationID): 52(ptr) Variable Input
54: TypePointer Input 6(int)
61: TypePointer Uniform 15(int)
63: TypePointer Input 15(int)
64(gl_DeviceIndex): 63(ptr) Variable Input
65: 6(int) Constant 1
66: 6(int) Constant 3400
67: 6(int) Constant 16
68: 6(int) Constant 32
69: 6(int) Constant 4
70: 51(ivec3) ConstantComposite 67 68 69
62: TypePointer Uniform 15(int)
64: TypePointer Input 15(int)
65(gl_DeviceIndex): 64(ptr) Variable Input
66: 6(int) Constant 1
67: 6(int) Constant 3400
68: 6(int) Constant 16
69: 6(int) Constant 32
70: 6(int) Constant 4
71: 51(ivec3) ConstantComposite 68 69 70
4(main): 2 Function None 3
5: Label
ControlBarrier 7 7 8
......@@ -124,10 +124,11 @@ spv.310.comp
58: 22(fvec4) CompositeConstruct 57 57 57 57
59: 29(ptr) AccessChain 50(outnames) 26 56
Store 59 58
60: 15(int) ArrayLength 14(outbname) 3
62: 61(ptr) AccessChain 50(outnames) 16
Store 62 60
MemoryBarrier 65 8
MemoryBarrier 7 66
60: 6(int) ArrayLength 14(outbname) 3
61: 15(int) Bitcast 60
63: 62(ptr) AccessChain 50(outnames) 16
Store 63 61
MemoryBarrier 66 8
MemoryBarrier 7 67
Return
FunctionEnd
// This header is generated by the make-revision script.
#define GLSLANG_PATCH_LEVEL 3006
#define GLSLANG_PATCH_LEVEL 3009
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment