skia2/tests/sksl
John Stiles d0f712f3fe Add fix for fuzzer-discovered crash at oss-fuzz:27614.
The fuzzer managed to create a test case which temporarily evaluates to
expression `half2(half(0.2)) + 2` as it is optimized. This requires a
bunch of temporary nonsense math as the IR Generator is attempting to
simplify as it goes; various attempts to remove terms from the fuzzer
test-case would cause it to stop reproducing the error.

Constructor::getVecComponent assumed that any constructor with a single
scalar argument would always implement `getConstantFloat` and
`getConstantInt`; however, constructors themselves did not actually
implement these methods. This meant that nesting a scalar constructor
inside a non-scalar constructor would abort when it tried to deduce the
value inside the inner constructor.

This has been fixed by implementing `getConstantFloat` and
`getConstantInt` for Constructors. These methods will assert if the
constructor has more than one argument or is a non-scalar type. This
should allow any number of nested constructors, e.g.
`half4(half(half(half(1))))` should recursively evaluate properly,
should we somehow generate this as an intermediate expression.

Change-Id: Iaee4284cba03974443cd7b5dccfd7909c1a5f3a6
Bug: oss-fuzz:27614
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335868
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-11-18 21:01:15 +00:00
..
blend Directly compute call counts, rather than mutating state 2020-10-19 16:08:39 +00:00
errors Disallow unsized array dimensions on size fields past the frontmost. 2020-11-17 16:44:13 +00:00
fp Fix bad FP codegen when sample() calls are inlined. 2020-11-03 19:54:45 +00:00
glsl Add golden outputs for the Metal backend. 2020-09-25 17:46:43 +00:00
inliner Optimize away swizzles on single-argument constructors. 2020-11-18 17:02:45 +00:00
metal Disallow opaque types in structs and interface blocks. 2020-11-17 15:25:43 +00:00
shared Add fix for fuzzer-discovered crash at oss-fuzz:27614. 2020-11-18 21:01:15 +00:00
workarounds Directly compute call counts, rather than mutating state 2020-10-19 16:08:39 +00:00