skia2/tests/sksl/shared/VectorConstructors.glsl
John Stiles b14a819122 Represent vector-cast constructors with ConstructorVectorCast.
Making a VectorCast from a compile-time constant will perform the cast
at compile-time instead; previously, we did not apply this optimization.
This simplified a few test outputs in subtle ways. (In particular, the
SPIR-V codegen used to occasionally decorate OpConstantComposite of
constant numbers with RelaxedPrecision, and no longer appears to do
this. This should have no effect on results either way AFAICS.)

Because we don't return VectorCast constructors containing compile-time
constant values, we do not need to implement compareConstant for this
constructor; they only wrap non-compile-time-constant expressions.

Change-Id: I28c1f337f64d6f20fb86bc0f58e225af4bd7b26c
Bug: skia:11032
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392197
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-05 16:28:06 +00:00

28 lines
1.2 KiB
GLSL

out vec4 sk_FragColor;
uniform vec4 colorGreen;
uniform vec4 colorRed;
bool check_bf2f2f2f3i2i2f2f2f4i2b4f2f2f2b2b2b3(vec2 v1, vec2 v2, vec2 v3, vec3 v4, ivec2 v5, ivec2 v6, vec2 v7, vec2 v8, vec4 v9, ivec2 v10, bvec4 v11, vec2 v12, vec2 v13, vec2 v14, bvec2 v15, bvec2 v16, bvec3 v17) {
return (((((((((((((((v1.x + v2.x) + v3.x) + v4.x) + float(v5.x)) + float(v6.x)) + v7.x) + v8.x) + v9.x) + float(v10.x)) + float(v11.x)) + v12.x) + v13.x) + v14.x) + float(v15.x)) + float(v16.x)) + float(v17.x) == 17.0;
}
vec4 main() {
vec2 v1 = vec2(1.0);
vec2 v2 = vec2(1.0, 2.0);
vec2 v3 = vec2(1.0);
vec3 v4 = vec3(vec2(1.0), 1.0);
ivec2 v5 = ivec2(1);
ivec2 v6 = ivec2(1, 2);
vec2 v7 = vec2(1.0, 2.0);
vec2 v8 = vec2(v5);
vec4 v9 = vec4(float(v6.x), sqrt(2.0), 3.0, 4.0);
ivec2 v10 = ivec2(3, int(v1.x));
bvec4 v11 = bvec4(true, false, true, false);
vec2 v12 = vec2(1.0, 0.0);
vec2 v13 = vec2(0.0);
vec2 v14 = vec2(0.0);
bvec2 v15 = bvec2(true);
bvec2 v16 = bvec2(true);
bvec3 v17 = bvec3(true, bvec2(true));
return check_bf2f2f2f3i2i2f2f2f4i2b4f2f2f2b2b2b3(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) ? colorGreen : colorRed;
}