Debian Codegraph @

third_party/spirv-cross/shaders-hlsl/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_2(out vec4 v)
36 {
37 if (some_value == 20)
38 {
39 v = vec4(50.0);
40 }
41 else
42 {
43 v = vec4(70.0);
44 }
45 v.y = 20.0;
46 }
47
48 void complete_inout(out vec4 x)
49 {
50 x = vec4(50.0);
51 }
52
53 void main()
54 {
55 vec4 a = vec4(10.0);
56 partial_inout(a);
57 complete_inout(a);
58 branchy_inout(a);
59 branchy_inout_2(a);
60
61 B b = B(10.0, 20.0);
62 partial_inout(b);
63 }
64