xref: /aosp_15_r20/external/skia/tests/sksl/shared/StructsInFunctions.hlsl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1struct S
2{
3    float x;
4    int y;
5};
6
7struct Nested
8{
9    S a;
10    S b;
11};
12
13struct Compound
14{
15    float4 f4;
16    int3 i3;
17};
18
19cbuffer _UniformBuffer : register(b0, space0)
20{
21    float4 _11_colorRed : packoffset(c0);
22    float4 _11_colorGreen : packoffset(c1);
23};
24
25
26static float4 sk_FragColor;
27
28struct SPIRV_Cross_Output
29{
30    float4 sk_FragColor : SV_Target0;
31};
32
33S returns_a_struct_S()
34{
35    S s = { 0.0f, 0 };
36    s.x = 1.0f;
37    s.y = 2;
38    return s;
39}
40
41float accepts_a_struct_fS(S _44)
42{
43    return _44.x + float(_44.y);
44}
45
46void modifies_a_struct_vS(inout S _53)
47{
48    _53.x += 1.0f;
49    _53.y++;
50}
51
52S constructs_a_struct_S()
53{
54    S _42 = { 2.0f, 3 };
55    return _42;
56}
57
58float4 main(float2 _62)
59{
60    S _65 = returns_a_struct_S();
61    S s = _65;
62    S _67 = _65;
63    float x = accepts_a_struct_fS(_67);
64    S _69 = _65;
65    modifies_a_struct_vS(_69);
66    s = _69;
67    S expected = constructs_a_struct_S();
68    Nested n1 = { { 0.0f, 0 }, { 0.0f, 0 } };
69    n1.a = returns_a_struct_S();
70    n1.b = n1.a;
71    Nested n2 = n1;
72    Nested n3 = n1;
73    S _87 = n3.b;
74    modifies_a_struct_vS(_87);
75    n3.b = _87;
76    Compound _101 = { float4(1.0f, 2.0f, 3.0f, 4.0f), int3(5, 6, 7) };
77    Compound c1 = _101;
78    float4 _107 = float4(_11_colorGreen.y, 2.0f, 3.0f, 4.0f);
79    Compound _108 = { _107, int3(5, 6, 7) };
80    Compound c2 = _108;
81    float4 _113 = float4(_11_colorGreen.x, 2.0f, 3.0f, 4.0f);
82    Compound _114 = { _113, int3(5, 6, 7) };
83    Compound c3 = _114;
84    bool _126 = false;
85    if (x == 3.0f)
86    {
87        _126 = s.x == 2.0f;
88    }
89    else
90    {
91        _126 = false;
92    }
93    bool _132 = false;
94    if (_126)
95    {
96        _132 = s.y == 3;
97    }
98    else
99    {
100        _132 = false;
101    }
102    bool _144 = false;
103    if (_132)
104    {
105        _144 = (s.y == expected.y) && (s.x == expected.x);
106    }
107    else
108    {
109        _144 = false;
110    }
111    bool _154 = false;
112    if (_144)
113    {
114        S _148 = { 2.0f, 3 };
115        _154 = (s.y == 3) && (s.x == 2.0f);
116    }
117    else
118    {
119        _154 = false;
120    }
121    bool _166 = false;
122    if (_154)
123    {
124        S _158 = returns_a_struct_S();
125        _166 = (s.y != _158.y) || (s.x != _158.x);
126    }
127    else
128    {
129        _166 = false;
130    }
131    bool _190 = false;
132    if (_166)
133    {
134        _190 = ((n1.b.y == n2.b.y) && (n1.b.x == n2.b.x)) && ((n1.a.y == n2.a.y) && (n1.a.x == n2.a.x));
135    }
136    else
137    {
138        _190 = false;
139    }
140    bool _214 = false;
141    if (_190)
142    {
143        _214 = ((n1.b.y != n3.b.y) || (n1.b.x != n3.b.x)) || ((n1.a.y != n3.a.y) || (n1.a.x != n3.a.x));
144    }
145    else
146    {
147        _214 = false;
148    }
149    bool _234 = false;
150    if (_214)
151    {
152        S _218 = { 1.0f, 2 };
153        S _219 = { 2.0f, 3 };
154        Nested _220 = { _218, _219 };
155        _234 = ((n3.b.y == 3) && (n3.b.x == 2.0f)) && ((n3.a.y == 2) && (n3.a.x == 1.0f));
156    }
157    else
158    {
159        _234 = false;
160    }
161    bool _242 = false;
162    if (_234)
163    {
164        _242 = true && all(bool4(float4(1.0f, 2.0f, 3.0f, 4.0f).x == _107.x, float4(1.0f, 2.0f, 3.0f, 4.0f).y == _107.y, float4(1.0f, 2.0f, 3.0f, 4.0f).z == _107.z, float4(1.0f, 2.0f, 3.0f, 4.0f).w == _107.w));
165    }
166    else
167    {
168        _242 = false;
169    }
170    bool _248 = false;
171    if (_242)
172    {
173        _248 = false || any(bool4(_107.x != _113.x, _107.y != _113.y, _107.z != _113.z, _107.w != _113.w));
174    }
175    else
176    {
177        _248 = false;
178    }
179    bool valid = _248;
180    float4 _249 = 0.0f.xxxx;
181    if (_248)
182    {
183        _249 = _11_colorGreen;
184    }
185    else
186    {
187        _249 = _11_colorRed;
188    }
189    return _249;
190}
191
192void frag_main()
193{
194    float2 _21 = 0.0f.xx;
195    sk_FragColor = main(_21);
196}
197
198SPIRV_Cross_Output main()
199{
200    frag_main();
201    SPIRV_Cross_Output stage_output;
202    stage_output.sk_FragColor = sk_FragColor;
203    return stage_output;
204}
205