skia2/tests/sksl/shared/golden/SwizzleOpt.glsl
John Stiles 3d921f1b2c Add unit test to demonstrate lack of SkSL swizzle optimization.
The right side of assignments will collapse redundant swizzles, but the
left side does not. Code like this can actually cause the ByteCode-
Generator to assert if it is run (it asserts in `swizzle_is_simple`
during code generation).

Change-Id: I891912fe0b5de2670dfa95f6702a86d5c42bb2ec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320296
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-09-28 19:02:03 +00:00

18 lines
580 B
GLSL

out vec4 sk_FragColor;
void main() {
float v = sqrt(1.0);
sk_FragColor = vec4(v);
sk_FragColor = vec4(vec4(v).xyz, 0.0).wzyx;
sk_FragColor = vec3(vec4(v).xw, 0.0).zzxy;
sk_FragColor = vec3(vec3(vec4(v).xw, 0.0).yx, 1.0).zzxy;
sk_FragColor = vec3(vec4(v).zy, 1.0).xyzz;
sk_FragColor = vec4(v);
sk_FragColor = vec4(vec4(v).xx, 1.0, 1.0);
sk_FragColor = vec4(v).wzwz;
sk_FragColor.xyzw = sk_FragColor;
sk_FragColor.wzyx = sk_FragColor;
sk_FragColor.xyzw.xw = sk_FragColor.yz;
sk_FragColor.wzyx.yzw = vec3(sk_FragColor.ww, 1.0);
}