xref: /aosp_15_r20/external/skia/tests/sksl/blend/BlendSaturation.hlsl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1cbuffer _UniformBuffer : register(b0, space0)
2{
3    float4 _16_src : packoffset(c0);
4    float4 _16_dst : packoffset(c1);
5};
6
7
8static float4 sk_FragColor;
9
10struct SPIRV_Cross_Output
11{
12    float4 sk_FragColor : SV_Target0;
13};
14
15static float _kGuardedDivideEpsilon = 0.0f;
16
17float blend_color_saturation_Qhh3(float3 _22)
18{
19    return max(max(_22.x, _22.y), _22.z) - min(min(_22.x, _22.y), _22.z);
20}
21
22float4 blend_hslc_h4h2h4h4(float2 _45, float4 _46, float4 _47)
23{
24    float _55 = _47.w * _46.w;
25    float alpha = _55;
26    float3 _61 = _46.xyz * _47.w;
27    float3 sda = _61;
28    float3 _67 = _47.xyz * _46.w;
29    float3 dsa = _67;
30    float3 _72 = 0.0f.xxx;
31    if (_45.x != 0.0f)
32    {
33        _72 = _67;
34    }
35    else
36    {
37        _72 = _61;
38    }
39    float3 l = _72;
40    float3 _81 = 0.0f.xxx;
41    if (_45.x != 0.0f)
42    {
43        _81 = _61;
44    }
45    else
46    {
47        _81 = _67;
48    }
49    float3 r = _81;
50    if (_45.y != 0.0f)
51    {
52        float _92 = min(min(_72.x, _72.y), _72.z);
53        float _RESERVED_IDENTIFIER_FIXUP_2_mn = _92;
54        float _98 = max(max(_72.x, _72.y), _72.z);
55        float _RESERVED_IDENTIFIER_FIXUP_3_mx = _98;
56        float3 _101 = 0.0f.xxx;
57        if (_98 > _92)
58        {
59            float3 _107 = _81;
60            _101 = ((_72 - _92.xxx) * blend_color_saturation_Qhh3(_107)) * (1.0f / (_98 - _92));
61        }
62        else
63        {
64            _101 = 0.0f.xxx;
65        }
66        l = _101;
67        r = _67;
68    }
69    float _117 = dot(float3(0.300000011920928955078125f, 0.589999973773956298828125f, 0.10999999940395355224609375f), r);
70    float _RESERVED_IDENTIFIER_FIXUP_4_lum = _117;
71    float3 _129 = (_117 - dot(float3(0.300000011920928955078125f, 0.589999973773956298828125f, 0.10999999940395355224609375f), l)).xxx + l;
72    float3 _RESERVED_IDENTIFIER_FIXUP_5_result = _129;
73    float _133 = _129.x;
74    float _134 = _129.y;
75    float _135 = _129.z;
76    float _131 = min(min(_133, _134), _135);
77    float _RESERVED_IDENTIFIER_FIXUP_6_minComp = _131;
78    float _137 = max(max(_133, _134), _135);
79    float _RESERVED_IDENTIFIER_FIXUP_7_maxComp = _137;
80    bool _143 = false;
81    if (_131 < 0.0f)
82    {
83        _143 = _117 != _131;
84    }
85    else
86    {
87        _143 = false;
88    }
89    if (_143)
90    {
91        float3 _146 = _117.xxx;
92        _RESERVED_IDENTIFIER_FIXUP_5_result = _146 + ((_129 - _146) * (_117 / (((_117 - _131) + 6.103515625e-05f) + _kGuardedDivideEpsilon)));
93    }
94    bool _160 = false;
95    if (_137 > _55)
96    {
97        _160 = _137 != _117;
98    }
99    else
100    {
101        _160 = false;
102    }
103    if (_160)
104    {
105        float3 _164 = _117.xxx;
106        _RESERVED_IDENTIFIER_FIXUP_5_result = _164 + (((_RESERVED_IDENTIFIER_FIXUP_5_result - _164) * (_55 - _117)) * (1.0f / (((_137 - _117) + 6.103515625e-05f) + _kGuardedDivideEpsilon)));
107    }
108    return float4((((_RESERVED_IDENTIFIER_FIXUP_5_result + _47.xyz) - _67) + _46.xyz) - _61, (_46.w + _47.w) - _55);
109}
110
111void frag_main()
112{
113    _kGuardedDivideEpsilon = false ? 9.9999999392252902907785028219223e-09f : 0.0f;
114    float2 _198 = 1.0f.xx;
115    float4 _204 = _16_src;
116    float4 _208 = _16_dst;
117    sk_FragColor = blend_hslc_h4h2h4h4(_198, _204, _208);
118}
119
120SPIRV_Cross_Output main()
121{
122    frag_main();
123    SPIRV_Cross_Output stage_output;
124    stage_output.sk_FragColor = sk_FragColor;
125    return stage_output;
126}
127