xref: /aosp_15_r20/external/skia/tests/sksl/shared/SwizzleIndexStore.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    float3 vec = 0.0f.xxx;
21    for (int c = 0; c < 3; c++)
22    {
23        for (int r = 0; r < 3; r++)
24        {
25            vec[int3(2, 1, 0)[r]] = _9_testMatrix3x3[c][r];
26        }
27        if (any(bool3(vec.x != expected.x, vec.y != expected.y, vec.z != expected.z)))
28        {
29            return false;
30        }
31        expected += 3.0f.xxx;
32    }
33    return true;
34}
35
36bool test4x4_b()
37{
38    float4 expected = float4(4.0f, 3.0f, 2.0f, 1.0f);
39    float4 vec = 0.0f.xxxx;
40    for (int c = 0; c < 4; c++)
41    {
42        for (int r = 0; r < 4; r++)
43        {
44            vec[int4(3, 2, 1, 0)[r]] = _9_testMatrix4x4[c][r];
45        }
46        if (any(bool4(vec.x != expected.x, vec.y != expected.y, vec.z != expected.z, vec.w != expected.w)))
47        {
48            return false;
49        }
50        expected += 4.0f.xxxx;
51    }
52    return true;
53}
54
55float4 main(float2 _138)
56{
57    bool _144 = false;
58    if (test3x3_b())
59    {
60        _144 = test4x4_b();
61    }
62    else
63    {
64        _144 = false;
65    }
66    float4 _145 = 0.0f.xxxx;
67    if (_144)
68    {
69        _145 = _9_colorGreen;
70    }
71    else
72    {
73        _145 = _9_colorRed;
74    }
75    return _145;
76}
77
78void frag_main()
79{
80    float2 _22 = 0.0f.xx;
81    sk_FragColor = main(_22);
82}
83
84SPIRV_Cross_Output main()
85{
86    frag_main();
87    SPIRV_Cross_Output stage_output;
88    stage_output.sk_FragColor = sk_FragColor;
89    return stage_output;
90}
91