skia2/tests/sksl/shared/NumberCasts.sksl
John Stiles ab8ed92a0c Add unit test for casting between float, int and bool.
This actually exposed a latent bug: we don't support bool(1.23) or
bool(1) casts, but these are valid in GLSL:

https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Conversion_constructors

"to bool: A value equal to 0 or 0.0 becomes false; anything else is
true."

Change-Id: Ia929a09914ffc96f081d0402d7bb05b5428f8db6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/349977
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-01-05 16:30:11 +00:00

24 lines
487 B
Plaintext

bool BF = bool(1.23);
bool BI = bool(1);
bool BB = bool(true);
float FF = float(1.23);
float FI = float(1);
float FB = float(true);
int IF = int(1.23);
int II = int(1);
int IB = int(true);
void main() {
sk_FragColor.x = half(BF);
sk_FragColor.x = half(BI);
sk_FragColor.x = half(BB);
sk_FragColor.x = half(FF);
sk_FragColor.x = half(FI);
sk_FragColor.x = half(FB);
sk_FragColor.x = half(IF);
sk_FragColor.x = half(II);
sk_FragColor.x = half(IB);
}