Spec Constant Operations
Approach:
Add a flag in `Builder` to indicate 'spec constant mode' and 'normal
mode'. When the builder is in 'normal mode', nothing changed. When the
builder is in 'spec constant mode', binary, unary and other instruction
creation rountines will be redirected to `createSpecConstantOp()` to
create instrution at module level with `OpSpecConstantOp <original
opcode> <operands>`.
'spec constant mode' should be enabled if and only if we are creating
spec constants. So a flager setter/recover guard is added when handling
binary/unary nodes in `createSpvConstantsFromConstSubTree()`.
Note when handling spec constants which are represented as ConstantUnion
Node, we should not use `OpSpecConstantOp` to initialize the composite
constant, so builder is set to 'normal mode'.
Tests:
Tests are added in Test/spv.specConstantOperations.vert, including:
1) Arithmetic, shift opeations for both scalar and composite type spec constants.
2) Size conversion from/to float and double for both scalar and vector.
3) Bitwise and/or/xor for both scalar and vector.
4) Unary negate/not for both scalar and vector.
5) Vector swizzles.
6) Comparisons for scalars.
7) == and != for composite type spec constants
Issues:
1) To implement == and != for composite type spec constants, the Spec needs
to allow OpAll, OpAny, OpFOrdEqual, OpFUnordEqual, OpOrdNotEqual,
OpFUnordNotEqual. Currently none of them are allowed in the Spec.
2016-03-21 13:51:37 +00:00
|
|
|
spv.specConstantOperations.vert
|
|
|
|
// Module Version 10000
|
2017-10-07 17:33:11 +00:00
|
|
|
// Generated by (magic number): 80002
|
2017-03-30 16:09:28 +00:00
|
|
|
// Id's are bound by 162
|
Spec Constant Operations
Approach:
Add a flag in `Builder` to indicate 'spec constant mode' and 'normal
mode'. When the builder is in 'normal mode', nothing changed. When the
builder is in 'spec constant mode', binary, unary and other instruction
creation rountines will be redirected to `createSpecConstantOp()` to
create instrution at module level with `OpSpecConstantOp <original
opcode> <operands>`.
'spec constant mode' should be enabled if and only if we are creating
spec constants. So a flager setter/recover guard is added when handling
binary/unary nodes in `createSpvConstantsFromConstSubTree()`.
Note when handling spec constants which are represented as ConstantUnion
Node, we should not use `OpSpecConstantOp` to initialize the composite
constant, so builder is set to 'normal mode'.
Tests:
Tests are added in Test/spv.specConstantOperations.vert, including:
1) Arithmetic, shift opeations for both scalar and composite type spec constants.
2) Size conversion from/to float and double for both scalar and vector.
3) Bitwise and/or/xor for both scalar and vector.
4) Unary negate/not for both scalar and vector.
5) Vector swizzles.
6) Comparisons for scalars.
7) == and != for composite type spec constants
Issues:
1) To implement == and != for composite type spec constants, the Spec needs
to allow OpAll, OpAny, OpFOrdEqual, OpFUnordEqual, OpOrdNotEqual,
OpFUnordNotEqual. Currently none of them are allowed in the Spec.
2016-03-21 13:51:37 +00:00
|
|
|
|
|
|
|
Capability Shader
|
2016-09-05 08:10:14 +00:00
|
|
|
Capability Float64
|
Spec Constant Operations
Approach:
Add a flag in `Builder` to indicate 'spec constant mode' and 'normal
mode'. When the builder is in 'normal mode', nothing changed. When the
builder is in 'spec constant mode', binary, unary and other instruction
creation rountines will be redirected to `createSpecConstantOp()` to
create instrution at module level with `OpSpecConstantOp <original
opcode> <operands>`.
'spec constant mode' should be enabled if and only if we are creating
spec constants. So a flager setter/recover guard is added when handling
binary/unary nodes in `createSpvConstantsFromConstSubTree()`.
Note when handling spec constants which are represented as ConstantUnion
Node, we should not use `OpSpecConstantOp` to initialize the composite
constant, so builder is set to 'normal mode'.
Tests:
Tests are added in Test/spv.specConstantOperations.vert, including:
1) Arithmetic, shift opeations for both scalar and composite type spec constants.
2) Size conversion from/to float and double for both scalar and vector.
3) Bitwise and/or/xor for both scalar and vector.
4) Unary negate/not for both scalar and vector.
5) Vector swizzles.
6) Comparisons for scalars.
7) == and != for composite type spec constants
Issues:
1) To implement == and != for composite type spec constants, the Spec needs
to allow OpAll, OpAny, OpFOrdEqual, OpFUnordEqual, OpOrdNotEqual,
OpFUnordNotEqual. Currently none of them are allowed in the Spec.
2016-03-21 13:51:37 +00:00
|
|
|
1: ExtInstImport "GLSL.std.450"
|
|
|
|
MemoryModel Logical GLSL450
|
|
|
|
EntryPoint Vertex 4 "main"
|
|
|
|
Source GLSL 450
|
|
|
|
Name 4 "main"
|
2016-04-01 14:35:16 +00:00
|
|
|
Name 8 "non_const_array_size_from_spec_const("
|
2016-04-07 19:40:27 +00:00
|
|
|
Name 11 "i"
|
2017-01-31 20:08:19 +00:00
|
|
|
Name 19 "sp_int"
|
2016-04-07 19:40:27 +00:00
|
|
|
Name 27 "array"
|
2017-01-31 20:08:19 +00:00
|
|
|
Name 40 "sp_float"
|
|
|
|
Name 42 "sp_uint"
|
|
|
|
Name 43 "sp_sint"
|
|
|
|
Name 45 "sp_double"
|
2017-01-29 02:29:42 +00:00
|
|
|
Name 135 "a"
|
|
|
|
Name 136 "b"
|
|
|
|
Name 137 "c"
|
|
|
|
Name 142 "ternayArray1"
|
2017-01-31 20:08:19 +00:00
|
|
|
Decorate 19(sp_int) SpecId 201
|
|
|
|
Decorate 40(sp_float) SpecId 200
|
|
|
|
Decorate 42(sp_uint) SpecId 202
|
|
|
|
Decorate 43(sp_sint) SpecId 203
|
|
|
|
Decorate 45(sp_double) SpecId 204
|
2017-01-29 02:29:42 +00:00
|
|
|
Decorate 135(a) SpecId 210
|
|
|
|
Decorate 136(b) SpecId 211
|
|
|
|
Decorate 137(c) SpecId 212
|
Spec Constant Operations
Approach:
Add a flag in `Builder` to indicate 'spec constant mode' and 'normal
mode'. When the builder is in 'normal mode', nothing changed. When the
builder is in 'spec constant mode', binary, unary and other instruction
creation rountines will be redirected to `createSpecConstantOp()` to
create instrution at module level with `OpSpecConstantOp <original
opcode> <operands>`.
'spec constant mode' should be enabled if and only if we are creating
spec constants. So a flager setter/recover guard is added when handling
binary/unary nodes in `createSpvConstantsFromConstSubTree()`.
Note when handling spec constants which are represented as ConstantUnion
Node, we should not use `OpSpecConstantOp` to initialize the composite
constant, so builder is set to 'normal mode'.
Tests:
Tests are added in Test/spv.specConstantOperations.vert, including:
1) Arithmetic, shift opeations for both scalar and composite type spec constants.
2) Size conversion from/to float and double for both scalar and vector.
3) Bitwise and/or/xor for both scalar and vector.
4) Unary negate/not for both scalar and vector.
5) Vector swizzles.
6) Comparisons for scalars.
7) == and != for composite type spec constants
Issues:
1) To implement == and != for composite type spec constants, the Spec needs
to allow OpAll, OpAny, OpFOrdEqual, OpFUnordEqual, OpOrdNotEqual,
OpFUnordNotEqual. Currently none of them are allowed in the Spec.
2016-03-21 13:51:37 +00:00
|
|
|
2: TypeVoid
|
|
|
|
3: TypeFunction 2
|
2016-04-01 14:35:16 +00:00
|
|
|
6: TypeInt 32 1
|
|
|
|
7: TypeFunction 6(int)
|
2016-04-07 19:40:27 +00:00
|
|
|
10: TypePointer Function 6(int)
|
|
|
|
12: 6(int) Constant 0
|
2017-01-31 20:08:19 +00:00
|
|
|
19(sp_int): 6(int) SpecConstant 10
|
2016-04-07 19:40:27 +00:00
|
|
|
20: 6(int) Constant 2
|
2017-01-31 20:08:19 +00:00
|
|
|
21: 6(int) SpecConstantOp 128 19(sp_int) 20
|
2016-04-07 19:40:27 +00:00
|
|
|
22: TypeBool
|
2017-01-31 20:08:19 +00:00
|
|
|
24: 6(int) SpecConstantOp 128 19(sp_int) 20
|
2016-04-07 19:40:27 +00:00
|
|
|
25: TypeArray 6(int) 24
|
|
|
|
26: TypePointer Function 25
|
|
|
|
29: 6(int) Constant 1023
|
|
|
|
32: 6(int) Constant 1
|
2017-01-31 20:08:19 +00:00
|
|
|
34: 6(int) SpecConstantOp 128 19(sp_int) 32
|
2016-04-07 19:40:27 +00:00
|
|
|
39: TypeFloat 32
|
2017-01-31 20:08:19 +00:00
|
|
|
40(sp_float): 39(float) SpecConstant 1078530010
|
2016-04-07 19:40:27 +00:00
|
|
|
41: TypeInt 32 0
|
2017-01-31 20:08:19 +00:00
|
|
|
42(sp_uint): 41(int) SpecConstant 100
|
|
|
|
43(sp_sint): 6(int) SpecConstant 4294967286
|
2016-09-05 08:10:14 +00:00
|
|
|
44: TypeFloat 64
|
2017-01-31 20:08:19 +00:00
|
|
|
45(sp_double): 44(float) SpecConstant 2333366019 1074118410
|
|
|
|
46: 39(float) SpecConstantOp 115 45(sp_double)
|
|
|
|
47: 44(float) SpecConstantOp 115 40(sp_float)
|
2016-09-05 08:10:14 +00:00
|
|
|
48: 41(int) Constant 0
|
2017-01-31 20:08:19 +00:00
|
|
|
49: 22(bool) SpecConstantOp 171 19(sp_int) 48
|
|
|
|
50: 22(bool) SpecConstantOp 171 42(sp_uint) 48
|
2016-09-05 08:10:14 +00:00
|
|
|
51: 6(int) SpecConstantOp 169 49 32 12
|
|
|
|
52: 41(int) Constant 1
|
|
|
|
53: 41(int) SpecConstantOp 169 49 52 48
|
2017-01-31 20:08:19 +00:00
|
|
|
54: 41(int) SpecConstantOp 128 43(sp_sint) 48
|
|
|
|
55: 6(int) SpecConstantOp 128 42(sp_uint) 48
|
|
|
|
56: 6(int) SpecConstantOp 126 19(sp_int)
|
|
|
|
57: 6(int) SpecConstantOp 200 19(sp_int)
|
|
|
|
58: 6(int) SpecConstantOp 128 19(sp_int) 20
|
|
|
|
59: 6(int) SpecConstantOp 128 19(sp_int) 20
|
2016-09-05 08:10:14 +00:00
|
|
|
60: 6(int) Constant 3
|
|
|
|
61: 6(int) SpecConstantOp 130 59 60
|
|
|
|
62: 6(int) Constant 4
|
|
|
|
63: 6(int) SpecConstantOp 130 58 62
|
2017-01-31 20:08:19 +00:00
|
|
|
64: 6(int) SpecConstantOp 132 43(sp_sint) 20
|
2016-09-05 08:10:14 +00:00
|
|
|
65: 41(int) Constant 2
|
2017-01-31 20:08:19 +00:00
|
|
|
66: 41(int) SpecConstantOp 132 42(sp_uint) 65
|
2016-09-05 08:10:14 +00:00
|
|
|
67: 6(int) Constant 5
|
|
|
|
68: 6(int) SpecConstantOp 135 64 67
|
|
|
|
69: 41(int) Constant 5
|
|
|
|
70: 41(int) SpecConstantOp 134 66 69
|
2017-01-31 20:08:19 +00:00
|
|
|
71: 6(int) SpecConstantOp 139 43(sp_sint) 62
|
2016-09-05 08:10:14 +00:00
|
|
|
72: 41(int) Constant 4
|
2017-01-31 20:08:19 +00:00
|
|
|
73: 41(int) SpecConstantOp 137 42(sp_uint) 72
|
|
|
|
74: 6(int) SpecConstantOp 132 43(sp_sint) 60
|
2016-09-05 08:10:14 +00:00
|
|
|
75: 6(int) SpecConstantOp 135 74 67
|
|
|
|
76: 6(int) Constant 10
|
2017-01-31 20:08:19 +00:00
|
|
|
77: 6(int) SpecConstantOp 195 43(sp_sint) 76
|
2016-09-05 08:10:14 +00:00
|
|
|
78: 6(int) Constant 20
|
2017-01-31 20:08:19 +00:00
|
|
|
79: 41(int) SpecConstantOp 194 42(sp_uint) 78
|
|
|
|
80: 6(int) SpecConstantOp 196 43(sp_sint) 32
|
|
|
|
81: 41(int) SpecConstantOp 196 42(sp_uint) 20
|
2016-09-05 08:10:14 +00:00
|
|
|
82: 6(int) Constant 256
|
2017-01-31 20:08:19 +00:00
|
|
|
83: 6(int) SpecConstantOp 197 43(sp_sint) 82
|
2016-09-05 08:10:14 +00:00
|
|
|
84: 41(int) Constant 512
|
2017-01-31 20:08:19 +00:00
|
|
|
85: 41(int) SpecConstantOp 198 42(sp_uint) 84
|
|
|
|
86: 22(bool) SpecConstantOp 177 19(sp_int) 43(sp_sint)
|
|
|
|
87: 22(bool) SpecConstantOp 170 42(sp_uint) 42(sp_uint)
|
|
|
|
88: 22(bool) SpecConstantOp 173 19(sp_int) 43(sp_sint)
|
2016-09-05 08:10:14 +00:00
|
|
|
89: 6(int) Constant 30
|
|
|
|
90: TypeVector 6(int) 4
|
2017-01-31 20:08:19 +00:00
|
|
|
91: 90(ivec4) SpecConstantComposite 78 89 19(sp_int) 19(sp_int)
|
2016-09-05 08:10:14 +00:00
|
|
|
92: 41(int) Constant 4294967295
|
|
|
|
93: 41(int) Constant 4294967294
|
|
|
|
94: TypeVector 41(int) 4
|
2017-01-31 20:08:19 +00:00
|
|
|
95: 94(ivec4) SpecConstantComposite 42(sp_uint) 42(sp_uint) 92 93
|
2016-09-05 08:10:14 +00:00
|
|
|
96: TypeVector 22(bool) 4
|
|
|
|
97: 94(ivec4) ConstantComposite 48 48 48 48
|
|
|
|
98: 96(bvec4) SpecConstantOp 171 91 97
|
|
|
|
99: 96(bvec4) SpecConstantOp 171 95 97
|
|
|
|
100: 90(ivec4) ConstantComposite 12 12 12 12
|
|
|
|
101: 90(ivec4) ConstantComposite 32 32 32 32
|
|
|
|
102: 90(ivec4) SpecConstantOp 169 98 101 100
|
|
|
|
103: 94(ivec4) ConstantComposite 52 52 52 52
|
|
|
|
104: 94(ivec4) SpecConstantOp 169 98 103 97
|
|
|
|
105: 94(ivec4) SpecConstantOp 128 91 97
|
|
|
|
106: 90(ivec4) SpecConstantOp 128 95 97
|
|
|
|
107: 90(ivec4) SpecConstantOp 200 91
|
|
|
|
108: 90(ivec4) SpecConstantOp 126 91
|
|
|
|
109: 90(ivec4) ConstantComposite 20 20 20 20
|
|
|
|
110: 90(ivec4) SpecConstantOp 128 91 109
|
|
|
|
111: 90(ivec4) SpecConstantOp 128 91 109
|
|
|
|
112: 90(ivec4) ConstantComposite 60 60 60 60
|
|
|
|
113: 90(ivec4) SpecConstantOp 130 111 112
|
|
|
|
114: 90(ivec4) ConstantComposite 62 62 62 62
|
|
|
|
115: 90(ivec4) SpecConstantOp 130 113 114
|
|
|
|
116: 90(ivec4) SpecConstantOp 132 91 109
|
|
|
|
117: 90(ivec4) ConstantComposite 67 67 67 67
|
|
|
|
118: 90(ivec4) SpecConstantOp 135 116 117
|
|
|
|
119: 90(ivec4) SpecConstantOp 139 91 114
|
|
|
|
120: 90(ivec4) ConstantComposite 76 76 76 76
|
|
|
|
121: 90(ivec4) SpecConstantOp 195 91 120
|
|
|
|
122: 90(ivec4) SpecConstantOp 196 91 109
|
|
|
|
123: 6(int) Constant 1024
|
|
|
|
124: 90(ivec4) ConstantComposite 123 123 123 123
|
|
|
|
125: 90(ivec4) SpecConstantOp 197 91 124
|
|
|
|
126: 41(int) Constant 2048
|
|
|
|
127: 94(ivec4) ConstantComposite 126 126 126 126
|
|
|
|
128: 94(ivec4) SpecConstantOp 198 95 127
|
|
|
|
129: 6(int) SpecConstantOp 81 91 0
|
|
|
|
130: TypeVector 6(int) 2
|
|
|
|
131: 130(ivec2) SpecConstantOp 79 91 91 1(GLSL.std.450) 0
|
|
|
|
132: TypeVector 6(int) 3
|
|
|
|
133: 132(ivec3) SpecConstantOp 79 91 91 2 1(GLSL.std.450) 0
|
|
|
|
134: 90(ivec4) SpecConstantOp 79 91 91 1(GLSL.std.450) 2 0 3
|
2017-01-29 02:29:42 +00:00
|
|
|
135(a): 6(int) SpecConstant 4
|
|
|
|
136(b): 6(int) SpecConstant 6
|
|
|
|
137(c): 22(bool) SpecConstantTrue
|
|
|
|
138: 22(bool) SpecConstantOp 173 135(a) 136(b)
|
|
|
|
139: 6(int) SpecConstantOp 169 138 135(a) 136(b)
|
|
|
|
140: TypeArray 6(int) 139
|
|
|
|
141: TypePointer Private 140
|
|
|
|
142(ternayArray1): 141(ptr) Variable Private
|
|
|
|
143: 6(int) Constant 13
|
|
|
|
144: 6(int) Constant 17
|
|
|
|
145: 6(int) SpecConstantOp 169 137(c) 143 144
|
|
|
|
146: 6(int) SpecConstantOp 169 137(c) 135(a) 144
|
|
|
|
147: 22(bool) ConstantTrue
|
|
|
|
148: 6(int) SpecConstantOp 169 147 135(a) 144
|
|
|
|
149: 22(bool) SpecConstantOp 173 135(a) 136(b)
|
|
|
|
150: 6(int) SpecConstantOp 128 143 135(a)
|
|
|
|
151: 6(int) SpecConstantOp 132 144 136(b)
|
|
|
|
152: 6(int) SpecConstantOp 169 149 150 151
|
|
|
|
153: 22(bool) SpecConstantOp 168 137(c)
|
|
|
|
154: TypeVector 39(float) 2
|
|
|
|
155: 39(float) Constant 1065353216
|
|
|
|
156: 154(fvec2) ConstantComposite 155 155
|
|
|
|
157: 39(float) Constant 1073741824
|
|
|
|
158: 154(fvec2) ConstantComposite 157 157
|
2017-03-30 16:09:28 +00:00
|
|
|
159: TypeVector 22(bool) 2
|
|
|
|
160: 159(bvec2) SpecConstantComposite 153 153
|
|
|
|
161: 154(fvec2) SpecConstantOp 169 160 156 158
|
Spec Constant Operations
Approach:
Add a flag in `Builder` to indicate 'spec constant mode' and 'normal
mode'. When the builder is in 'normal mode', nothing changed. When the
builder is in 'spec constant mode', binary, unary and other instruction
creation rountines will be redirected to `createSpecConstantOp()` to
create instrution at module level with `OpSpecConstantOp <original
opcode> <operands>`.
'spec constant mode' should be enabled if and only if we are creating
spec constants. So a flager setter/recover guard is added when handling
binary/unary nodes in `createSpvConstantsFromConstSubTree()`.
Note when handling spec constants which are represented as ConstantUnion
Node, we should not use `OpSpecConstantOp` to initialize the composite
constant, so builder is set to 'normal mode'.
Tests:
Tests are added in Test/spv.specConstantOperations.vert, including:
1) Arithmetic, shift opeations for both scalar and composite type spec constants.
2) Size conversion from/to float and double for both scalar and vector.
3) Bitwise and/or/xor for both scalar and vector.
4) Unary negate/not for both scalar and vector.
5) Vector swizzles.
6) Comparisons for scalars.
7) == and != for composite type spec constants
Issues:
1) To implement == and != for composite type spec constants, the Spec needs
to allow OpAll, OpAny, OpFOrdEqual, OpFUnordEqual, OpOrdNotEqual,
OpFUnordNotEqual. Currently none of them are allowed in the Spec.
2016-03-21 13:51:37 +00:00
|
|
|
4(main): 2 Function None 3
|
|
|
|
5: Label
|
|
|
|
Return
|
|
|
|
FunctionEnd
|
2016-04-01 14:35:16 +00:00
|
|
|
8(non_const_array_size_from_spec_const(): 6(int) Function None 7
|
|
|
|
9: Label
|
2016-04-07 19:40:27 +00:00
|
|
|
11(i): 10(ptr) Variable Function
|
|
|
|
27(array): 26(ptr) Variable Function
|
|
|
|
Store 11(i) 12
|
|
|
|
Branch 13
|
|
|
|
13: Label
|
|
|
|
LoopMerge 15 16 None
|
|
|
|
Branch 17
|
|
|
|
17: Label
|
|
|
|
18: 6(int) Load 11(i)
|
|
|
|
23: 22(bool) SLessThan 18 21
|
|
|
|
BranchConditional 23 14 15
|
|
|
|
14: Label
|
|
|
|
28: 6(int) Load 11(i)
|
|
|
|
30: 10(ptr) AccessChain 27(array) 28
|
|
|
|
Store 30 29
|
|
|
|
Branch 16
|
|
|
|
16: Label
|
|
|
|
31: 6(int) Load 11(i)
|
|
|
|
33: 6(int) IAdd 31 32
|
|
|
|
Store 11(i) 33
|
|
|
|
Branch 13
|
|
|
|
15: Label
|
|
|
|
35: 10(ptr) AccessChain 27(array) 34
|
|
|
|
36: 6(int) Load 35
|
|
|
|
ReturnValue 36
|
2016-04-01 14:35:16 +00:00
|
|
|
FunctionEnd
|