Debian Codegraph @

third_party/spirv-cross/shaders-hlsl-no-opt/frag/spec-constant.frag

raw
1 #version 310 es
2 precision mediump float;
3
4 layout(location = 0) out vec4 FragColor;
5 layout(constant_id = 1) const float a = 1.0;
6 layout(constant_id = 2) const float b = 2.0;
7 layout(constant_id = 3) const int c = 3;
8 layout(constant_id = 4) const int d = 4;
9 layout(constant_id = 5) const uint e = 5u;
10 layout(constant_id = 6) const uint f = 6u;
11 layout(constant_id = 7) const bool g = false;
12 layout(constant_id = 8) const bool h = true;
13 // glslang doesn't seem to support partial spec constants or composites yet, so only test the basics.
14
15 struct Foo
16 {
17 float elems[d + 2];
18 };
19
20 void main()
21 {
22 float t0 = a;
23 float t1 = b;
24
25 uint c0 = uint(c); // OpIAdd with different types.
26 // FConvert, float-to-double.
27 int c1 = -c; // SNegate
28 int c2 = ~c; // OpNot
29 int c3 = c + d; // OpIAdd
30 int c4 = c - d; // OpISub
31 int c5 = c * d; // OpIMul
32 int c6 = c / d; // OpSDiv
33 uint c7 = e / f; // OpUDiv
34 int c8 = c % d; // OpSMod
35 uint c9 = e % f; // OpUMod
36 // TODO: OpSRem, any way to access this in GLSL?
37 int c10 = c >> d; // OpShiftRightArithmetic
38 uint c11 = e >> f; // OpShiftRightLogical
39 int c12 = c << d; // OpShiftLeftLogical
40 int c13 = c | d; // OpBitwiseOr
41 int c14 = c ^ d; // OpBitwiseXor
42 int c15 = c & d; // OpBitwiseAnd
43 // VectorShuffle, CompositeExtract, CompositeInsert, not testable atm.
44 bool c16 = g || h; // OpLogicalOr
45 bool c17 = g && h; // OpLogicalAnd
46 bool c18 = !g; // OpLogicalNot
47 bool c19 = g == h; // OpLogicalEqual
48 bool c20 = g != h; // OpLogicalNotEqual
49 // OpSelect not testable atm.
50 bool c21 = c == d; // OpIEqual
51 bool c22 = c != d; // OpINotEqual
52 bool c23 = c < d; // OpSLessThan
53 bool c24 = e < f; // OpULessThan
54 bool c25 = c > d; // OpSGreaterThan
55 bool c26 = e > f; // OpUGreaterThan
56 bool c27 = c <= d; // OpSLessThanEqual
57 bool c28 = e <= f; // OpULessThanEqual
58 bool c29 = c >= d; // OpSGreaterThanEqual
59 bool c30 = e >= f; // OpUGreaterThanEqual
60 // OpQuantizeToF16 not testable atm.
61
62 int c31 = c8 + c3;
63
64 int c32 = int(e); // OpIAdd with different types.
65 bool c33 = bool(c); // int -> bool
66 bool c34 = bool(e); // uint -> bool
67 int c35 = int(g); // bool -> int
68 uint c36 = uint(g); // bool -> uint
69 float c37 = float(g); // bool -> float
70
71 // Flexible sized arrays with spec constants and spec constant ops.
72 float vec0[c + 3][8];
73 float vec1[c + 2];
74 vec0[0][0] = 10.0;
75 vec1[0] = 20.0;
76
77 Foo foo;
78 foo.elems[c] = 10.0;
79 FragColor = vec4(t0 + t1) + vec0[0][0] + vec1[0] + foo.elems[c];
80 }