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
|
|
|
|
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
|
|
|
|
|
|
|
|
|
|
|
|
Linked vertex stage:
|
|
|
|
|
|
|
|
|
|
|
|
// Module Version 10000
|
|
|
|
// Generated by (magic number): 80001
|
2016-04-06 19:32:44 +00:00
|
|
|
// Id's are bound by 101
|
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
|
|
|
|
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("
|
|
|
|
Name 15 "array"
|
|
|
|
Decorate 10 SpecId 201
|
|
|
|
Decorate 24 SpecId 200
|
|
|
|
Decorate 26 SpecId 202
|
|
|
|
Decorate 27 SpecId 203
|
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)
|
|
|
|
10: 6(int) SpecConstant 10
|
|
|
|
11: 6(int) Constant 2
|
|
|
|
12: 6(int) SpecConstantOp 128 10 11
|
|
|
|
13: TypeArray 6(int) 12
|
|
|
|
14: TypePointer Function 13
|
|
|
|
16: 6(int) Constant 1
|
2016-04-04 02:20:42 +00:00
|
|
|
17: 6(int) SpecConstantOp 128 10 16
|
2016-04-01 14:35:16 +00:00
|
|
|
18: TypePointer Function 6(int)
|
|
|
|
23: TypeFloat 32
|
|
|
|
24: 23(float) SpecConstant 1078530010
|
|
|
|
25: TypeInt 32 0
|
|
|
|
26: 25(int) SpecConstant 100
|
|
|
|
27: 6(int) SpecConstant 4294967286
|
2016-04-06 19:32:44 +00:00
|
|
|
28: 6(int) SpecConstantOp 126 10
|
|
|
|
29: 6(int) SpecConstantOp 200 10
|
|
|
|
30: 6(int) SpecConstantOp 128 10 11
|
|
|
|
31: 6(int) SpecConstantOp 128 10 11
|
|
|
|
32: 6(int) Constant 3
|
|
|
|
33: 6(int) SpecConstantOp 130 31 32
|
|
|
|
34: 6(int) Constant 4
|
|
|
|
35: 6(int) SpecConstantOp 130 30 34
|
|
|
|
36: 6(int) SpecConstantOp 132 27 11
|
|
|
|
37: 25(int) Constant 2
|
|
|
|
38: 25(int) SpecConstantOp 132 26 37
|
|
|
|
39: 6(int) Constant 5
|
|
|
|
40: 6(int) SpecConstantOp 135 36 39
|
|
|
|
41: 25(int) Constant 5
|
|
|
|
42: 25(int) SpecConstantOp 134 38 41
|
|
|
|
43: 6(int) SpecConstantOp 139 27 34
|
|
|
|
44: 25(int) Constant 4
|
|
|
|
45: 25(int) SpecConstantOp 137 26 44
|
|
|
|
46: 6(int) SpecConstantOp 132 27 32
|
|
|
|
47: 6(int) SpecConstantOp 135 46 39
|
|
|
|
48: 6(int) Constant 10
|
|
|
|
49: 6(int) SpecConstantOp 195 27 48
|
|
|
|
50: 6(int) Constant 20
|
|
|
|
51: 25(int) SpecConstantOp 194 26 50
|
|
|
|
52: 6(int) SpecConstantOp 196 27 16
|
|
|
|
53: 25(int) SpecConstantOp 196 26 11
|
|
|
|
54: 6(int) Constant 256
|
|
|
|
55: 6(int) SpecConstantOp 197 27 54
|
|
|
|
56: 25(int) Constant 512
|
|
|
|
57: 25(int) SpecConstantOp 198 26 56
|
|
|
|
58: TypeBool
|
|
|
|
59: 58(bool) SpecConstantOp 177 10 27
|
|
|
|
60: 58(bool) SpecConstantOp 170 26 26
|
|
|
|
61: 58(bool) SpecConstantOp 173 10 27
|
|
|
|
62: TypeVector 6(int) 4
|
|
|
|
63: 6(int) Constant 30
|
|
|
|
64: 62(ivec4) SpecConstantComposite 50 63 10 10
|
|
|
|
65: TypeVector 25(int) 4
|
|
|
|
66: 25(int) Constant 4294967295
|
|
|
|
67: 25(int) Constant 4294967294
|
|
|
|
68: 65(ivec4) SpecConstantComposite 26 26 66 67
|
|
|
|
69: TypeVector 23(float) 4
|
|
|
|
70: 23(float) Constant 1067450368
|
|
|
|
71: 69(fvec4) SpecConstantComposite 24 70 24 70
|
|
|
|
72: 62(ivec4) SpecConstantOp 200 64
|
|
|
|
73: 62(ivec4) SpecConstantOp 126 64
|
|
|
|
74: 62(ivec4) ConstantComposite 11 11 11 11
|
|
|
|
75: 62(ivec4) SpecConstantOp 128 64 74
|
|
|
|
76: 62(ivec4) SpecConstantOp 128 64 74
|
|
|
|
77: 62(ivec4) ConstantComposite 32 32 32 32
|
|
|
|
78: 62(ivec4) SpecConstantOp 130 76 77
|
|
|
|
79: 62(ivec4) ConstantComposite 34 34 34 34
|
|
|
|
80: 62(ivec4) SpecConstantOp 130 78 79
|
|
|
|
81: 62(ivec4) SpecConstantOp 132 64 74
|
|
|
|
82: 62(ivec4) ConstantComposite 39 39 39 39
|
|
|
|
83: 62(ivec4) SpecConstantOp 135 81 82
|
|
|
|
84: 62(ivec4) SpecConstantOp 139 64 79
|
|
|
|
85: 62(ivec4) ConstantComposite 48 48 48 48
|
|
|
|
86: 62(ivec4) SpecConstantOp 195 64 85
|
|
|
|
87: 62(ivec4) SpecConstantOp 196 64 74
|
|
|
|
88: 6(int) Constant 1024
|
|
|
|
89: 62(ivec4) ConstantComposite 88 88 88 88
|
|
|
|
90: 62(ivec4) SpecConstantOp 197 64 89
|
|
|
|
91: 25(int) Constant 2048
|
|
|
|
92: 65(ivec4) ConstantComposite 91 91 91 91
|
|
|
|
93: 65(ivec4) SpecConstantOp 198 68 92
|
|
|
|
94: 25(int) Constant 0
|
|
|
|
95: 6(int) SpecConstantOp 81 64 0
|
|
|
|
96: TypeVector 6(int) 2
|
|
|
|
97: 96(ivec2) SpecConstantOp 79 64 64 1(GLSL.std.450) 0
|
|
|
|
98: TypeVector 6(int) 3
|
|
|
|
99: 98(ivec3) SpecConstantOp 79 64 64 2 1(GLSL.std.450) 0
|
|
|
|
100: 62(ivec4) SpecConstantOp 79 64 64 1(GLSL.std.450) 2 0 3
|
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
|
|
|
|
15(array): 14(ptr) Variable Function
|
|
|
|
19: 18(ptr) AccessChain 15(array) 17
|
|
|
|
20: 6(int) Load 19
|
|
|
|
ReturnValue 20
|
|
|
|
FunctionEnd
|