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