skia2/tests/sksl/folding/FloatFolding.glsl
John Stiles 4d6310ab20 Support half4 return values from main() in the SPIR-V code generator.
This creates a helper function, _entrypoint, which invokes main() and
assigns its result into sk_FragColor. We also make sure to prevent
sk_FragColor from being dead-stripped from the code during IR
generation.

At present this is useful for allowing our SkSL test shaders to compile.

Change-Id: I2d7fab0e1959a77778ffdb18ca569e869bcaeece
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/358525
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-01-27 02:46:03 +00:00

75 lines
1.6 KiB
GLSL

out vec4 sk_FragColor;
uniform vec4 colorRed;
uniform vec4 colorGreen;
vec4 main() {
bool _1_ok = true;
float _2_x = 34.0;
_1_ok = true;
_2_x = 30.0;
_1_ok = true;
_2_x = 64.0;
_1_ok = true;
_2_x = 16.0;
_1_ok = true;
_2_x = 19.0;
_1_ok = true;
_2_x = 1.0;
_1_ok = true;
_2_x = -2.0;
_1_ok = true;
_2_x = 3.0;
_1_ok = true;
_2_x = -4.0;
_1_ok = true;
_2_x = 5.0;
_1_ok = true;
_2_x = -6.0;
_1_ok = true;
_2_x = 7.0;
_1_ok = true;
_2_x = -8.0;
_1_ok = true;
_2_x = 9.0;
_1_ok = true;
_2_x = -10.0;
_1_ok = true;
_2_x = 11.0;
_1_ok = true;
_2_x = -12.0;
_1_ok = true;
float _3_unknown = sqrt(4.0);
_2_x = _3_unknown;
_1_ok = _2_x == _3_unknown;
_2_x = _3_unknown;
_1_ok = _1_ok && _2_x == _3_unknown;
_2_x = _3_unknown;
_1_ok = _1_ok && _2_x == _3_unknown;
_2_x = 0.0;
_1_ok = _1_ok;
_2_x = _3_unknown;
_1_ok = _1_ok && _2_x == _3_unknown;
_2_x = _3_unknown;
_1_ok = _1_ok && _2_x == _3_unknown;
_2_x = 0.0;
_1_ok = _1_ok;
_2_x = _3_unknown;
_1_ok = _1_ok && _2_x == _3_unknown;
_2_x = 0.0;
_1_ok = _1_ok;
_2_x += 1.0;
_1_ok = _1_ok && _2_x == 1.0;
_1_ok = _1_ok && _2_x == 1.0;
_2_x -= 2.0;
_1_ok = _1_ok && _2_x == -1.0;
_1_ok = _1_ok && _2_x == -1.0;
_1_ok = _1_ok && _2_x == -1.0;
_2_x *= 2.0;
_1_ok = _1_ok && _2_x == -2.0;
_1_ok = _1_ok && _2_x == -2.0;
_2_x /= 2.0;
_1_ok = _1_ok && _2_x == -1.0;
return _1_ok ? colorGreen : colorRed;
}