Debian Codegraph @

third_party/spirv-cross/shaders/frag/partial-write-preserve.frag

raw
1 #version 310 es
2 precision mediump float;
3
4 layout(std140, binding = 0) uniform UBO
5 {
6 int some_value;
7 };
8
9 struct B
10 {
11 float a;
12 float b;
13 };
14
15 void partial_inout(inout vec4 x)
16 {
17 x.x = 10.0;
18 }
19
20 void partial_inout(inout B b)
21 {
22 b.b = 40.0;
23 }
24
25 // Make a complete write, but only conditionally ...
26 void branchy_inout(inout vec4 v)
27 {
28 v.y = 20.0;
29 if (some_value == 20)
30 {
31 v = vec4(50.0);
32 }
33 }
34
35 void branchy_inout(inout B b)
36 {
37 b.b = 20.0;
38 if (some_value == 20)
39 {
40 b = B(10.0, 40.0);
41 }
42 }
43
44 void branchy_inout_2(out vec4 v)
45 {
46 if (some_value == 20)
47 {
48 v = vec4(50.0);
49 }
50 else
51 {
52 v = vec4(70.0);
53 }
54 v.y = 20.0;
55 }
56
57 void branchy_inout_2(out B b)
58 {
59 if (some_value == 20)
60 {
61 b = B(10.0, 40.0);
62 }
63 else
64 {
65 b = B(70.0, 70.0);
66 }
67 b.b = 20.0;
68 }
69
70
71 void complete_inout(out vec4 x)
72 {
73 x = vec4(50.0);
74 }
75
76 void complete_inout(out B b)
77 {
78 b = B(100.0, 200.0);
79 }
80
81 void main()
82 {
83 vec4 a = vec4(10.0);
84 partial_inout(a);
85 complete_inout(a);
86 branchy_inout(a);
87 branchy_inout_2(a);
88
89 B b = B(10.0, 20.0);
90 partial_inout(b);
91 complete_inout(b);
92 branchy_inout(b);
93 branchy_inout_2(b);
94 }
95