skia2/resources/sksl/folding
John Stiles 14a487fd54 Replace getConstantSubexpression with getConstantValue.
The only type of expressions that getConstantSubexpression could ever
return are Literal and nullptr. getConstantValue now returns an
optional<double>; nullopt indicates a non-constant value in the slot.
This simplifies most use cases, and allows us to get rid of some extra
"zero" and "one" Literal objects in some of our Constructor classes.

This change fixes a recent fuzzer issue. The fuzzer had discovered that
calling `getConstantSubexpression` on a ConstructorCompoundCast that
contained a compile-time-constant value would return literals of the
wrong type (the cast was not applied). By nesting repeated matrix casts,
this type confusion could be turned into an assertion.

Change-Id: Icee69219e6db2822ffdfab4e5ccdaff54584a4b6
Bug: oss-fuzz:41000
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/471376
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-11-15 14:46:21 +00:00
..
ArrayFolding.sksl Improve index-folding of arrays and matrices. 2021-11-11 18:59:04 +00:00
ArraySizeFolding.sksl Implement constant folding for index expressions into matrices. 2021-11-10 21:38:56 +00:00
AssignmentOps.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
BoolFolding.sksl Improve constant folding for boolean vectors. 2021-08-24 18:12:12 +00:00
CastFolding.sksl Add test demonstrating missed opportunities with casts. 2021-05-07 22:04:16 +00:00
FloatFolding.sksl Remove 0/x arithmetic simplification. 2021-08-24 19:18:41 +00:00
IntFoldingES2.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
IntFoldingES3.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
MatrixFoldingES2.sksl Replace getConstantSubexpression with getConstantValue. 2021-11-15 14:46:21 +00:00
MatrixFoldingES3.sksl Reland "Add coords parameter to all .sksl test files used as runtime effects" 2021-04-27 20:47:31 +00:00
SelfAssignment.sksl Enforce consistency in swizzle domains. 2021-07-09 20:30:22 +00:00
ShortCircuitBoolFolding.sksl Remove usage of sqrt() as an optimization barrier in tests. 2021-05-24 17:18:54 +00:00
SwizzleFolding.sksl Add test demonstrating swizzled constant folding. 2021-04-29 15:59:37 +00:00
VectorScalarFolding.sksl Remove 0/x arithmetic simplification. 2021-08-24 19:18:41 +00:00
VectorVectorFolding.sksl Remove 0/x arithmetic simplification. 2021-08-24 19:18:41 +00:00