yum-mirror/glslang

git clone https://git.yummers.dev/yum-mirror/glslang

Ralph Potterfix 32-bit identity fillers in 16-bit matrix constructorsee3ae468

main
1.6 KiB64 linesraw
1#version 420
2
3// A 64-bit counterpart to spv.matrix.frag, covering the same matrix operations
4// at double precision. As in the 16-bit counterpart, the operands are converted
5// from a 32-bit input rather than declared as double fragment inputs, so that
6// the three shaders differ only in the width being exercised.
7
8layout(location = 0) in vec4 src;
9
10layout(location = 0) out vec4 color;
11
12void main()
13{
14    dmat3x4 m1 = dmat3x4(double(src.x));
15    dmat3x4 m2 = dmat3x4(double(src.y));
16    double  f  = double(src.z);
17    dvec3   v3 = dvec3(double(src.w));
18    dvec4   v4 = dvec4(double(src.x));
19
20    dmat3x4 sum34;
21    mat3x4  fm;
22    dvec3   sum3;
23    dvec4   sum4;
24
25    sum34 = m1 - m2;
26    sum34 += m1 * f;
27    sum34 += f * m1;
28    sum34 /= matrixCompMult(m1, m2);
29    sum34 += m1 / f;
30    sum34 += f / m1;
31    sum34 += f;
32    sum34 -= f;
33    fm = mat3x4(sum34);
34    sum34 = dmat3x4(fm);
35
36    sum3 = v4 * m2;
37    sum4 = m2 * v3;
38
39    dmat4x3 m43 = transpose(sum34);
40    dmat4   m4  = m1 * m43;
41
42    sum4 = v4 * m4;
43
44    dvec4 acc = sum4;
45
46    ++sum34;
47    --sum34;
48
49    sum34 += dmat3x4(f);
50    sum34 += dmat3x4(v3, f, v3, f, v3, f);
51
52    acc += sum3 * m43 + sum4;
53
54    acc += dvec4(m43);
55    acc += dvec4(dvec3(dmat2(f)), 7.2lf);
56
57    // Beyond what spv.matrix.frag covers. Growing a matrix from a smaller one
58    // leaves the trailing diagonal at the identity, and is the only construction
59    // that uses the one filler rather than just the zero filler.
60    dmat4 grown = dmat4(dmat2(f));
61    acc += dvec4(grown[3][3]);
62
63    color = vec4(acc);
64}