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-01 14:35:16 +00:00
|
|
|
// Id's are bound by 107
|
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
|
|
|
|
Capability Float64
|
|
|
|
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
|
|
|
|
28: TypeFloat 64
|
|
|
|
29: 28(float) SpecConstantOp 115 24
|
|
|
|
30: 23(float) SpecConstantOp 115 29
|
|
|
|
31: 6(int) SpecConstantOp 126 10
|
|
|
|
32: 6(int) SpecConstantOp 200 10
|
|
|
|
33: 6(int) SpecConstantOp 128 10 11
|
|
|
|
34: 6(int) SpecConstantOp 128 10 11
|
|
|
|
35: 6(int) Constant 3
|
|
|
|
36: 6(int) SpecConstantOp 130 34 35
|
|
|
|
37: 6(int) Constant 4
|
|
|
|
38: 6(int) SpecConstantOp 130 33 37
|
|
|
|
39: 6(int) SpecConstantOp 132 27 11
|
|
|
|
40: 25(int) Constant 2
|
|
|
|
41: 25(int) SpecConstantOp 132 26 40
|
|
|
|
42: 6(int) Constant 5
|
|
|
|
43: 6(int) SpecConstantOp 135 39 42
|
|
|
|
44: 25(int) Constant 5
|
|
|
|
45: 25(int) SpecConstantOp 134 41 44
|
|
|
|
46: 6(int) SpecConstantOp 139 27 37
|
|
|
|
47: 25(int) Constant 4
|
|
|
|
48: 25(int) SpecConstantOp 137 26 47
|
|
|
|
49: 6(int) SpecConstantOp 132 27 35
|
|
|
|
50: 6(int) SpecConstantOp 135 49 42
|
|
|
|
51: 6(int) Constant 10
|
|
|
|
52: 6(int) SpecConstantOp 195 27 51
|
|
|
|
53: 6(int) Constant 20
|
|
|
|
54: 25(int) SpecConstantOp 194 26 53
|
|
|
|
55: 6(int) SpecConstantOp 196 27 16
|
|
|
|
56: 25(int) SpecConstantOp 196 26 11
|
|
|
|
57: 6(int) Constant 256
|
|
|
|
58: 6(int) SpecConstantOp 197 27 57
|
|
|
|
59: 25(int) Constant 512
|
|
|
|
60: 25(int) SpecConstantOp 198 26 59
|
|
|
|
61: TypeBool
|
|
|
|
62: 61(bool) SpecConstantOp 177 10 27
|
|
|
|
63: 61(bool) SpecConstantOp 170 26 26
|
|
|
|
64: 61(bool) SpecConstantOp 173 10 27
|
|
|
|
65: TypeVector 6(int) 4
|
|
|
|
66: 6(int) Constant 30
|
|
|
|
67: 65(ivec4) SpecConstantComposite 53 66 10 10
|
|
|
|
68: TypeVector 25(int) 4
|
|
|
|
69: 25(int) Constant 4294967295
|
|
|
|
70: 25(int) Constant 4294967294
|
|
|
|
71: 68(ivec4) SpecConstantComposite 26 26 69 70
|
|
|
|
72: TypeVector 23(float) 4
|
|
|
|
73: 23(float) Constant 1067450368
|
|
|
|
74: 72(fvec4) SpecConstantComposite 24 73 24 73
|
|
|
|
75: TypeVector 28(float) 4
|
|
|
|
76: 75(fvec4) SpecConstantOp 115 74
|
|
|
|
77: 72(fvec4) SpecConstantOp 115 76
|
|
|
|
78: 65(ivec4) SpecConstantOp 200 67
|
|
|
|
79: 65(ivec4) SpecConstantOp 126 67
|
|
|
|
80: 65(ivec4) ConstantComposite 11 11 11 11
|
|
|
|
81: 65(ivec4) SpecConstantOp 128 67 80
|
|
|
|
82: 65(ivec4) SpecConstantOp 128 67 80
|
|
|
|
83: 65(ivec4) ConstantComposite 35 35 35 35
|
|
|
|
84: 65(ivec4) SpecConstantOp 130 82 83
|
|
|
|
85: 65(ivec4) ConstantComposite 37 37 37 37
|
|
|
|
86: 65(ivec4) SpecConstantOp 130 84 85
|
|
|
|
87: 65(ivec4) SpecConstantOp 132 67 80
|
|
|
|
88: 65(ivec4) ConstantComposite 42 42 42 42
|
|
|
|
89: 65(ivec4) SpecConstantOp 135 87 88
|
|
|
|
90: 65(ivec4) SpecConstantOp 139 67 85
|
|
|
|
91: 65(ivec4) ConstantComposite 51 51 51 51
|
|
|
|
92: 65(ivec4) SpecConstantOp 195 67 91
|
|
|
|
93: 65(ivec4) SpecConstantOp 196 67 80
|
|
|
|
94: 6(int) Constant 1024
|
|
|
|
95: 65(ivec4) ConstantComposite 94 94 94 94
|
|
|
|
96: 65(ivec4) SpecConstantOp 197 67 95
|
|
|
|
97: 25(int) Constant 2048
|
|
|
|
98: 68(ivec4) ConstantComposite 97 97 97 97
|
|
|
|
99: 68(ivec4) SpecConstantOp 198 71 98
|
|
|
|
100: 25(int) Constant 0
|
2016-04-06 18:42:01 +00:00
|
|
|
101: 6(int) SpecConstantOp 81 67 0
|
2016-04-01 14:35:16 +00:00
|
|
|
102: TypeVector 6(int) 2
|
2016-04-06 18:42:01 +00:00
|
|
|
103: 102(ivec2) SpecConstantOp 79 67 67 1(GLSL.std.450) 0
|
2016-04-01 14:35:16 +00:00
|
|
|
104: TypeVector 6(int) 3
|
2016-04-06 18:42:01 +00:00
|
|
|
105: 104(ivec3) SpecConstantOp 79 67 67 2 1(GLSL.std.450) 0
|
|
|
|
106: 65(ivec4) SpecConstantOp 79 67 67 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
|