skia2/tests/sksl/blend/golden/BlendLuminosity.glsl
John Stiles 345d72124d Eliminate inliner temporary variables for functions with a single exit.
When we determine that a function only contains a single return
statement, there is no need to create a temporary variable and store the
result expression into a variable. Instead, we can directly replace the
function-call expression with the return-statement's expression.

This dramatically simplifies the final optimized output from chains of
very simple inlined functions, which is a very common pattern for trees
of Skia fragment processors.

Change-Id: I6789064a321daf43db2e1cef4915f25ed74d6131
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344665
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-16 17:26:06 +00:00

31 lines
1.0 KiB
GLSL

#version 400
out vec4 sk_FragColor;
in vec4 src;
in vec4 dst;
void main() {
float _1_alpha;
vec3 _2_sda;
vec3 _3_dsa;
_1_alpha = dst.w * src.w;
_2_sda = src.xyz * dst.w;
_3_dsa = dst.xyz * src.w;
float _5_lum;
vec3 _6_result;
float _7_minComp;
float _8_maxComp;
_5_lum = dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _2_sda);
_6_result = (_5_lum - dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _3_dsa)) + _3_dsa;
_7_minComp = min(min(_6_result.x, _6_result.y), _6_result.z);
_8_maxComp = max(max(_6_result.x, _6_result.y), _6_result.z);
if (_7_minComp < 0.0 && _5_lum != _7_minComp) {
_6_result = _5_lum + ((_6_result - _5_lum) * _5_lum) / (_5_lum - _7_minComp);
}
sk_FragColor = vec4(((((_8_maxComp > _1_alpha && _8_maxComp != _5_lum ? _5_lum + ((_6_result - _5_lum) * (_1_alpha - _5_lum)) / (_8_maxComp - _5_lum) : _6_result) + dst.xyz) - _3_dsa) + src.xyz) - _2_sda, (src.w + dst.w) - _1_alpha);
}