SPV: Implement specialization constants for ?:.

This commit is contained in:
John Kessenich
2017-01-28 19:29:42 -07:00
parent 433e9ff896
commit 8e6c6cef6a
5 changed files with 73 additions and 12 deletions

View File

@@ -3,7 +3,7 @@ Warning, version 450 is not yet complete; most version-specific features are pre
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 135
// Id's are bound by 160
Capability Shader
Capability Float64
@@ -20,11 +20,18 @@ Warning, version 450 is not yet complete; most version-specific features are pre
Name 42 "sp_uint"
Name 43 "sp_sint"
Name 45 "sp_double"
Name 135 "a"
Name 136 "b"
Name 137 "c"
Name 142 "ternayArray1"
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
Decorate 135(a) SpecId 210
Decorate 136(b) SpecId 211
Decorate 137(c) SpecId 212
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
@@ -137,6 +144,31 @@ Warning, version 450 is not yet complete; most version-specific features are pre
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
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
159: 154(fvec2) SpecConstantOp 169 153 156 158
4(main): 2 Function None 3
5: Label
Return

View File

@@ -110,5 +110,15 @@ int non_const_array_size_from_spec_const() {
return array[sp_int + 1];
}
void main() {}
// ternary
layout(constant_id = 210) const int a = 4;
layout(constant_id = 211) const int b = 6;
layout(constant_id = 212) const bool c = true;
int ternayArray1[a > b ? a : b];
const int t1 = c ? 13 : 17;
const int t2 = c ? a : 17;
const int t3 = true ? a : 17;
const int t4 = a > b ? 13 + a : 17 * b;
const vec2 v2 = !c ? vec2(1.0) : vec2(2.0);
void main() {}