skia2/tests/sksl/folding/VectorVectorFolding.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

101 lines
2.2 KiB
GLSL

out vec4 sk_FragColor;
uniform float unknownInput;
uniform vec4 colorRed;
uniform vec4 colorGreen;
bool test_int() {
int unknown = int(unknownInput);
bool ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = true;
ok = ivec4(unknown) == ivec4(unknown);
ok = ok && ivec4(unknown) == ivec4(unknown);
ok = ok;
ok = ok;
ok = ok;
ok = ok && ivec4(unknown) == ivec4(unknown);
ok = ok && ivec4(unknown) == ivec4(unknown);
ok = ok && ivec4(unknown) == ivec4(unknown);
ivec4 val = ivec4(unknown);
val += ivec4(1);
val -= ivec4(1);
ok = ok && val == ivec4(unknown);
val *= ivec4(2);
val /= ivec4(2);
ok = ok && val == ivec4(unknown);
return ok;
}
vec4 main() {
float _1_unknown = unknownInput;
bool _2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = true;
_2_ok = vec4(_1_unknown) == vec4(_1_unknown);
_2_ok = _2_ok && vec4(_1_unknown) == vec4(_1_unknown);
_2_ok = _2_ok;
_2_ok = _2_ok;
_2_ok = _2_ok;
_2_ok = _2_ok && vec4(_1_unknown) == vec4(_1_unknown);
_2_ok = _2_ok && vec4(_1_unknown) == vec4(_1_unknown);
_2_ok = _2_ok && vec4(_1_unknown) == vec4(_1_unknown);
vec4 _3_val = vec4(_1_unknown);
_3_val += vec4(1.0);
_3_val -= vec4(1.0);
_2_ok = _2_ok && _3_val == vec4(_1_unknown);
_3_val *= vec4(2.0);
_3_val /= vec4(2.0);
_2_ok = _2_ok && _3_val == vec4(_1_unknown);
return _2_ok && test_int() ? colorGreen : colorRed;
}