c14defb8bf
GLSL does not support assigning to ternaries, and will fail to compile and/or generate non-functional shaders if we pass in a shader that tries to assign into a ternary expression. If SkSL is able to completely eliminate the ternary (e.g. if it boils down to a simple `true ? x : y` or `false ? x : y`), SkSL can strip out the ternary entirely and generate valid GLSL. This case is harmless and so it is still allowed. Change-Id: I960f119fb9934f998697634e6c4e519cd77d3780 Bug: skia:10767 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319679 Commit-Queue: John Stiles <johnstiles@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
20 lines
1.0 KiB
Plaintext
20 lines
1.0 KiB
Plaintext
struct S {
|
|
float f;
|
|
};
|
|
|
|
uniform int u;
|
|
|
|
void assign_to_literal() { 1 = 2; }
|
|
void assign_to_uniform() { u = 0; }
|
|
void assign_to_const() { const int x; x = 0; }
|
|
void assign_to_const_array() { const int x[1]; x[0] = 0; }
|
|
void assign_to_const_swizzle() { const half4 x; x.w = 0; }
|
|
void assign_to_repeated_swizzle() { half4 x; x.yy = half2(0); }
|
|
void assign_to_const_struct() { const S s; s.f = 0; }
|
|
void assign_to_foldable_ternary_const_left() { const float l; float r; (true ? l : r) = 0; }
|
|
void assign_to_foldable_ternary_const_right() { float l; const float r; (false ? l : r) = 0; }
|
|
void assign_to_foldable_ternary_const_both() { const float l; const float r; (true ? l : r) = 0; }
|
|
void assign_to_unfoldable_ternary() { float l, r; (sqrt(1) > 0 ? l : r) = 0; }
|
|
void assign_to_unary_minus() { float x; -x = 0; }
|
|
void assign_to_unary_plus() { float x; +x = 0; } // TODO(skbug.com/10766)
|