xref: /aosp_15_r20/external/skia/tests/sksl/shared/SwizzleIndexLookup.hlsl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1cbuffer _UniformBuffer : register(b0, space0)
2{
3    float4 _9_colorGreen : packoffset(c0);
4    float4 _9_colorRed : packoffset(c1);
5    row_major float3x3 _9_testMatrix3x3 : packoffset(c2);
6    row_major float4x4 _9_testMatrix4x4 : packoffset(c5);
7};
8
9
10static float4 sk_FragColor;
11
12struct SPIRV_Cross_Output
13{
14    float4 sk_FragColor : SV_Target0;
15};
16
17bool test3x3_b()
18{
19    float3 expected = float3(3.0f, 2.0f, 1.0f);
20    for (int c = 0; c < 3; c++)
21    {
22        float3 vec = _9_testMatrix3x3[c];
23        for (int r = 0; r < 3; r++)
24        {
25            if (vec.zyx[r] != expected[r])
26            {
27                return false;
28            }
29        }
30        expected += 3.0f.xxx;
31    }
32    return true;
33}
34
35bool test4x4_b()
36{
37    float4 expected = float4(4.0f, 3.0f, 2.0f, 1.0f);
38    for (int c = 0; c < 4; c++)
39    {
40        float4 vec = _9_testMatrix4x4[c];
41        for (int r = 0; r < 4; r++)
42        {
43            if (vec.wzyx[r] != expected[r])
44            {
45                return false;
46            }
47        }
48        expected += 4.0f.xxxx;
49    }
50    return true;
51}
52
53float4 main(float2 _129)
54{
55    bool _135 = false;
56    if (test3x3_b())
57    {
58        _135 = test4x4_b();
59    }
60    else
61    {
62        _135 = false;
63    }
64    float4 _136 = 0.0f.xxxx;
65    if (_135)
66    {
67        _136 = _9_colorGreen;
68    }
69    else
70    {
71        _136 = _9_colorRed;
72    }
73    return _136;
74}
75
76void frag_main()
77{
78    float2 _22 = 0.0f.xx;
79    sk_FragColor = main(_22);
80}
81
82SPIRV_Cross_Output main()
83{
84    frag_main();
85    SPIRV_Cross_Output stage_output;
86    stage_output.sk_FragColor = sk_FragColor;
87    return stage_output;
88}
89