Commit Graph

777 Commits

Author SHA1 Message Date
Florin Malita
6ba939d288 [skottie] Improved Hue/Saturation effect
The current HueSaturation effect implementation relies on a simple
HSLA color matrix operation and assumes the controls are linear.

Turns out AE's saturation is more sophisticated, both in implementation
and in control mapping.

Updating the effect to use a chain of specialized color filters:

  - keep HSLAMatrix() for hue adjustments
  - introduce a custom runtime effect for saturation
    (following AE's semantics)
  - use a plain Matrix() CF for lightness adjustments

Change-Id: Iba6c9f7fd8c01dc33c1cd00822ea546867c057ac
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452976
Commit-Queue: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-27 13:30:48 +00:00
Brian Osman
6f06bab632 Revert "Re-reland "Rewrite switch statements in GLSL strict-ES2 mode."""
This reverts commit 64560c7cd5.

Reason for revert: Nexus5, also

Original change's description:
> Re-reland "Rewrite switch statements in GLSL strict-ES2 mode.""
>
> This reverts commit c4c355940c.
>
> Reason for revert: disabled offending tests
>
> Original change's description:
> > Revert "Reland "Rewrite switch statements in GLSL strict-ES2 mode.""
> >
> > This reverts commit c81edd0e8c.
> >
> > Reason for revert: ANGLE still unhappy
> > Original change's description:
> > > Reland "Rewrite switch statements in GLSL strict-ES2 mode."
> > >
> > > This reverts commit d26d0e6a47.
> > >
> > > Reason for revert: uses dedicated caps bit
> > >
> > > Original change's description:
> > > > Revert "Rewrite switch statements in GLSL strict-ES2 mode."
> > > >
> > > > This reverts commit 45e3838006.
> > > >
> > > > Reason for revert: Also need to rewrite them in actual ES2 mode.
> > > >
> > > > Original change's description:
> > > > > Rewrite switch statements in GLSL strict-ES2 mode.
> > > > >
> > > > > Once this lands, switch statements will work everywhere--Metal, SPIR-V,
> > > > > GLSL, and SkVM.
> > > > >
> > > > > Change-Id: I2797d0a872de8be77bb9f7aa6acb93421d571d70
> > > > > Bug: skia:12450
> > > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452356
> > > > > Commit-Queue: John Stiles <johnstiles@google.com>
> > > > > Auto-Submit: John Stiles <johnstiles@google.com>
> > > > > Reviewed-by: Brian Osman <brianosman@google.com>
> > > >
> > > > Bug: skia:12450
> > > > Change-Id: I92656ed40289872405c0873f2c56a52b04e35b1d
> > > > No-Presubmit: true
> > > > No-Tree-Checks: true
> > > > No-Try: true
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452556
> > > > Auto-Submit: Brian Osman <brianosman@google.com>
> > > > Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> > > > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> > >
> > > Bug: skia:12450
> > > Change-Id: I0d3b0969d2040dbb4ee808132146687767c97442
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452560
> > > 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>
> >
> > Bug: skia:12450
> > Change-Id: I869cf3e2c47fe94981aa2ffa6c1f0b3e4d6e6862
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452717
> > Auto-Submit: Brian Osman <brianosman@google.com>
> > Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
>
> Bug: skia:12450
> Change-Id: Ia0e23e20794ea707e54be50123b5323369354a03
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452721
> 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>

Bug: skia:12450
Change-Id: Id0c0cdfbf146000ec532e57e380c18ff391ca1da
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452896
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2021-09-25 13:29:08 +00:00
John Stiles
64560c7cd5 Re-reland "Rewrite switch statements in GLSL strict-ES2 mode.""
This reverts commit c4c355940c.

Reason for revert: disabled offending tests

Original change's description:
> Revert "Reland "Rewrite switch statements in GLSL strict-ES2 mode.""
>
> This reverts commit c81edd0e8c.
>
> Reason for revert: ANGLE still unhappy
> Original change's description:
> > Reland "Rewrite switch statements in GLSL strict-ES2 mode."
> >
> > This reverts commit d26d0e6a47.
> >
> > Reason for revert: uses dedicated caps bit
> >
> > Original change's description:
> > > Revert "Rewrite switch statements in GLSL strict-ES2 mode."
> > >
> > > This reverts commit 45e3838006.
> > >
> > > Reason for revert: Also need to rewrite them in actual ES2 mode.
> > >
> > > Original change's description:
> > > > Rewrite switch statements in GLSL strict-ES2 mode.
> > > >
> > > > Once this lands, switch statements will work everywhere--Metal, SPIR-V,
> > > > GLSL, and SkVM.
> > > >
> > > > Change-Id: I2797d0a872de8be77bb9f7aa6acb93421d571d70
> > > > Bug: skia:12450
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452356
> > > > Commit-Queue: John Stiles <johnstiles@google.com>
> > > > Auto-Submit: John Stiles <johnstiles@google.com>
> > > > Reviewed-by: Brian Osman <brianosman@google.com>
> > >
> > > Bug: skia:12450
> > > Change-Id: I92656ed40289872405c0873f2c56a52b04e35b1d
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452556
> > > Auto-Submit: Brian Osman <brianosman@google.com>
> > > Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> > > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> >
> > Bug: skia:12450
> > Change-Id: I0d3b0969d2040dbb4ee808132146687767c97442
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452560
> > 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>
>
> Bug: skia:12450
> Change-Id: I869cf3e2c47fe94981aa2ffa6c1f0b3e4d6e6862
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452717
> Auto-Submit: Brian Osman <brianosman@google.com>
> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>

Bug: skia:12450
Change-Id: Ia0e23e20794ea707e54be50123b5323369354a03
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452721
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>
2021-09-24 20:50:20 +00:00
John Stiles
b05bbd03f9 Fix for fuzzer-discovered error with invalid var-initializers.
If a VarDeclaration line contained multiple variables, and the first
variable had an illegal initializer-expression, the Declare() would
return a Nop. AddVarDeclaration did not expect to see a Nop and would
assert once we tried to process the second var-declaration. Now, we
allow adding var declarations to a Nop.

Bulked up some tests to cover local and global variables (since those
are parsed in separate functions) and to check both the first
initializer as well as follow-on initializers (since those are parsed in
separate parts of the var-decl handler).

Change-Id: I66341191698175b490a659715cb8edaafe2f75ae
Bug: oss-fuzz:39032
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452696
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-24 20:15:31 +00:00
Brian Osman
c4c355940c Revert "Reland "Rewrite switch statements in GLSL strict-ES2 mode.""
This reverts commit c81edd0e8c.

Reason for revert: ANGLE still unhappy
Original change's description:
> Reland "Rewrite switch statements in GLSL strict-ES2 mode."
>
> This reverts commit d26d0e6a47.
>
> Reason for revert: uses dedicated caps bit
>
> Original change's description:
> > Revert "Rewrite switch statements in GLSL strict-ES2 mode."
> >
> > This reverts commit 45e3838006.
> >
> > Reason for revert: Also need to rewrite them in actual ES2 mode.
> >
> > Original change's description:
> > > Rewrite switch statements in GLSL strict-ES2 mode.
> > >
> > > Once this lands, switch statements will work everywhere--Metal, SPIR-V,
> > > GLSL, and SkVM.
> > >
> > > Change-Id: I2797d0a872de8be77bb9f7aa6acb93421d571d70
> > > Bug: skia:12450
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452356
> > > Commit-Queue: John Stiles <johnstiles@google.com>
> > > Auto-Submit: John Stiles <johnstiles@google.com>
> > > Reviewed-by: Brian Osman <brianosman@google.com>
> >
> > Bug: skia:12450
> > Change-Id: I92656ed40289872405c0873f2c56a52b04e35b1d
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452556
> > Auto-Submit: Brian Osman <brianosman@google.com>
> > Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
>
> Bug: skia:12450
> Change-Id: I0d3b0969d2040dbb4ee808132146687767c97442
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452560
> 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>

Bug: skia:12450
Change-Id: I869cf3e2c47fe94981aa2ffa6c1f0b3e4d6e6862
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452717
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2021-09-24 18:58:15 +00:00
John Stiles
c81edd0e8c Reland "Rewrite switch statements in GLSL strict-ES2 mode."
This reverts commit d26d0e6a47.

Reason for revert: uses dedicated caps bit

Original change's description:
> Revert "Rewrite switch statements in GLSL strict-ES2 mode."
>
> This reverts commit 45e3838006.
>
> Reason for revert: Also need to rewrite them in actual ES2 mode.
>
> Original change's description:
> > Rewrite switch statements in GLSL strict-ES2 mode.
> >
> > Once this lands, switch statements will work everywhere--Metal, SPIR-V,
> > GLSL, and SkVM.
> >
> > Change-Id: I2797d0a872de8be77bb9f7aa6acb93421d571d70
> > Bug: skia:12450
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452356
> > Commit-Queue: John Stiles <johnstiles@google.com>
> > Auto-Submit: John Stiles <johnstiles@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> Bug: skia:12450
> Change-Id: I92656ed40289872405c0873f2c56a52b04e35b1d
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452556
> Auto-Submit: Brian Osman <brianosman@google.com>
> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>

Bug: skia:12450
Change-Id: I0d3b0969d2040dbb4ee808132146687767c97442
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452560
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>
2021-09-24 16:43:42 +00:00
John Stiles
cb40008b43 Implement switch in SkVM.
SkVM implements switches as a pseudo-loop; breaks are handled with the
condition mask just like a for loop. Fallthrough is handled via a
scratch Value in a temporary slot. `writeStore` neeeded to be refactored
to support writing into slot(s) without an associated Variable.

At IR generation time, SwitchStatements are now emitted without error
even in strict-ES2 mode. The GLSL code generator currently reports these
as an error in strict-ES2 mode, but this will be fixed in a followup
coming shortly (the switch will be rewritten as ifs inside a one-shot
loop, similar to our IR-rewrite strategy).

Change-Id: I5507257246c42a35d2f46b4b9a89492a5ffeff9b
Bug: skia:12450
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/451421
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-09-23 19:58:55 +00:00
Avery Musbach
92ae58f338 Reland "bench: Add PhoneHub assets to skottie-vs-png decode bench"
This is a reland of 0541a983ef

This time with Generic_Error.png instead of Generic Error.png, because
the space caused problems.

Original change's description:
> bench: Add PhoneHub assets to skottie-vs-png decode bench
>
> The skottie-vs-png decode bench is intended to facilitate comparison
> between Lottie and PNG, but such a comparison cannot really be made when
> the Lottie files are unrelated to the PNG files (Lottie files chosen to
> represent a range of vector graphic complexity, versus PNG files chosen
> to represent a range of image dimensions). This CL adds PhoneHub assets
> in PNG and Lottie, including various Lottie files created using
> different optimization strategies (see added code comments for details).
>
> Change-Id: I1a4357ab0af22b9db7b7ce83fd07d48c77db7680
> Bug: chromium:1128684
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442476
> Reviewed-by: Avery Musbach <amusbach@google.com>
> Reviewed-by: Florin Malita <fmalita@google.com>
> Commit-Queue: Florin Malita <fmalita@google.com>

Bug: chromium:1128684
Change-Id: I1a5e21f67f52b03fa1c06192ef7190f41b04e3dc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452300
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
Commit-Queue: Avery Musbach <amusbach@chromium.org>
2021-09-23 17:40:09 +00:00
Brian Osman
448b2d5795 Add GetConstantValue, fix const-variable ES2 loop bounds
Prior to this fix, the new test cases would report that the various loop
terms needed to be constant expressions.

Bug: skia:12472
Change-Id: Ic377ed0c4598136ae38fb2b65c93b6d8609d54cb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452276
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-09-23 16:30:12 +00:00
Brian Osman
bd8bbcd016 Revert "bench: Add PhoneHub assets to skottie-vs-png decode bench"
This reverts commit 0541a983ef.

Reason for revert: Android roll failing

Original change's description:
> bench: Add PhoneHub assets to skottie-vs-png decode bench
>
> The skottie-vs-png decode bench is intended to facilitate comparison
> between Lottie and PNG, but such a comparison cannot really be made when
> the Lottie files are unrelated to the PNG files (Lottie files chosen to
> represent a range of vector graphic complexity, versus PNG files chosen
> to represent a range of image dimensions). This CL adds PhoneHub assets
> in PNG and Lottie, including various Lottie files created using
> different optimization strategies (see added code comments for details).
>
> Change-Id: I1a4357ab0af22b9db7b7ce83fd07d48c77db7680
> Bug: chromium:1128684
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442476
> Reviewed-by: Avery Musbach <amusbach@google.com>
> Reviewed-by: Florin Malita <fmalita@google.com>
> Commit-Queue: Florin Malita <fmalita@google.com>

Bug: chromium:1128684
Change-Id: Ib6364a482cfff5ca63e74eeb24c2688e49bc4b72
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452096
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2021-09-23 12:36:08 +00:00
Avery Musbach
0541a983ef bench: Add PhoneHub assets to skottie-vs-png decode bench
The skottie-vs-png decode bench is intended to facilitate comparison
between Lottie and PNG, but such a comparison cannot really be made when
the Lottie files are unrelated to the PNG files (Lottie files chosen to
represent a range of vector graphic complexity, versus PNG files chosen
to represent a range of image dimensions). This CL adds PhoneHub assets
in PNG and Lottie, including various Lottie files created using
different optimization strategies (see added code comments for details).

Change-Id: I1a4357ab0af22b9db7b7ce83fd07d48c77db7680
Bug: chromium:1128684
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442476
Reviewed-by: Avery Musbach <amusbach@google.com>
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
2021-09-22 17:23:33 +00:00
John Stiles
d668d4da68 Fix SwitchWithFallthrough test on iOS.
It looks like returning from inside a switch on iOS gives wrong results
in GLSL.

Change-Id: I9d6d8971a7a54600268e27443815444fca6f3c61
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450994
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-09-21 20:15:32 +00:00
John Stiles
1c5eb4b371 Disallow continue inside a switch.
This fails on several platforms in practice, and is of very limited
real-world utility.

Change-Id: Ib476396fc33cb51af6bbcf7fe822d30703ed995d
Bug: skia:12467
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450993
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>
2021-09-21 19:26:40 +00:00
John Stiles
35bd92638f Add tests for switch + loop constructs.
Change-Id: I17b5e21a28140b8e9313d87af9b1145674214fdb
Bug: skia:12450
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450989
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-21 17:23:47 +00:00
Dominik Röttsches
8abb52f212 Roll FreeType
fed5521016..6190360967

Contains a change that accepts ClipBoxes only in format number 0 instead
of 1 after a spec change to harmonize format numbering, thus needs
an update to the test font.

Change-Id: I837802648aec1acc0d0424b2b381e3f7031b181e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450916
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2021-09-21 16:37:14 +00:00
John Stiles
e32309d771 Update switch-fallthrough test to run in dm.
Also, removed "switch containing dead code" test. This wasn't testing
anything meaningful. (When we had full CFG analysis, we could have
eliminated some of the assignments inside the switch body, but this is
not something we do anymore.)

Change-Id: Iaeb74ebee41a7f368113ede9a4e30c033b9de8ac
Bug: skia:12450
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450985
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-09-21 15:41:37 +00:00
John Stiles
b8f1651f9b Add workaround for switch() containing only a default case.
The Mac Radeon GLSL driver crashes when given a switch statement that
only contains a default case and returns a value. Adding a case works
around the crash, and doesn't affect the meaning of the switch.

Change-Id: Iabbd267e0e31e8df7d3b7e747a7204d50931d0be
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450977
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-09-21 14:22:17 +00:00
Ethan Nicholas
2816dcfc67 Fixed fuzzer-discovered bug with interface blocks
While I was in this code, I realized that the setVariable method of
InterfaceBlock was unused and there was therefore no reason to be
storing a pointer instead of a reference.

Bug: oss-fuzz:39000
Change-Id: If7505ba87f4060370cfd32ca2e30c76648965101
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450446
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-09-21 14:12:47 +00:00
John Stiles
ed2babaf94 Reland "Add switch statement support to PipelineStage."
This is a reland of be056f4f62

The Switch test has been restructured to dodge an iOS bug.

Original change's description:
> Add switch statement support to PipelineStage.
>
> This allows us to write SKSL_TEST_ES3 tests in SkSLTest and have them
> run properly. Previously, such a test would assert inside the pipeline-
> stage generator. In ES2 mode, we will rewrite switches as chained ifs,
> but in ES3 mode we will want to continue emitting them as-is (they will
> be faster than chained ifs on a modern GPU).
>
> `writeSwitchStatement` is adapted from GLSLCodeGenerator.
>
> Change-Id: I532ea5ed49869e7cdffced0cdcd0e353af8d4d79
> Bug: skia:12450
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450478
> 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>

Bug: skia:12450
Change-Id: I5102081c636ef09cd23f5bc894e6c96e92a4c121
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450757
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-09-21 13:07:50 +00:00
John Stiles
8e369b0a5a Replace break with continue inside empty (post-optimization) loop.
This fixes a driver bug with the Nexus 7 while retaining the meaningful
part of the test.

Change-Id: I98edab32132f0c52a1f69b03efd403fae43c336b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450482
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-09-21 13:06:50 +00:00
John Stiles
d288d8bc84 Revert "Add switch statement support to PipelineStage."
This reverts commit be056f4f62.

Reason for revert: apparently switch on iOS GLSL is extremely broken

Original change's description:
> Add switch statement support to PipelineStage.
>
> This allows us to write SKSL_TEST_ES3 tests in SkSLTest and have them
> run properly. Previously, such a test would assert inside the pipeline-
> stage generator. In ES2 mode, we will rewrite switches as chained ifs,
> but in ES3 mode we will want to continue emitting them as-is (they will
> be faster than chained ifs on a modern GPU).
>
> `writeSwitchStatement` is adapted from GLSLCodeGenerator.
>
> Change-Id: I532ea5ed49869e7cdffced0cdcd0e353af8d4d79
> Bug: skia:12450
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450478
> 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>

Bug: skia:12450
Change-Id: If40c90023a64c608181285f6470b3e75303cc3cc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450756
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2021-09-20 21:57:09 +00:00
John Stiles
be056f4f62 Add switch statement support to PipelineStage.
This allows us to write SKSL_TEST_ES3 tests in SkSLTest and have them
run properly. Previously, such a test would assert inside the pipeline-
stage generator. In ES2 mode, we will rewrite switches as chained ifs,
but in ES3 mode we will want to continue emitting them as-is (they will
be faster than chained ifs on a modern GPU).

`writeSwitchStatement` is adapted from GLSLCodeGenerator.

Change-Id: I532ea5ed49869e7cdffced0cdcd0e353af8d4d79
Bug: skia:12450
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450478
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>
2021-09-20 18:55:09 +00:00
Ethan Nicholas
f62934b85a Fixed DSLParser error uncovered by ossfuzz
Missed one more case of Optional<Wrapper<Expression>>. This should be
the last one.

Bug: oss-fuzz:38944
Change-Id: Ic7f790cd99e2a3ee1c3874cc767a4702265d1723
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450476
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-09-20 17:57:14 +00:00
John Stiles
498bfa4a85 Add test case for 'loop over switch with continue inside.'
We didn't have a test case for this particular construct, but we will
emit special code to handle it when rewriting switch statements.

Change-Id: I7ac632f7bee348194940812c956c8a7df51ffaff
Bug: skia:12450
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450477
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-20 16:47:02 +00:00
John Stiles
b42b926513 Add additional examples to UnusedVariables test.
`increment` and `float a` could be eliminated, but are not.
This is fixed in a followup CL.

Change-Id: I7a5c3ab7341f40020f84f157b08a7152bc067af0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450276
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-09-20 13:57:39 +00:00
Ethan Nicholas
c973d26854 Fixed DSLParser assertion error uncovered by fuzzer
Bug: oss-fuzz:38108
Change-Id: I0e055d837923f00b982bc395dbf29b6ff59a3b21
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448896
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-09-20 13:48:41 +00:00
Ethan Nicholas
0dc1e0f797 Fixed DSLParser unary expression error handling
Missed a case when eliminating optional/wrapper in an earlier CL.

Change-Id: If7f80ea6e2172acadf7b0087fe1a05853ccae445
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449838
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-09-17 17:55:13 +00:00
John Stiles
d0665d9a04 Fix fuzzer-discovered null deref with empty interface blocks.
Change-Id: I95bfa33f674bce0098cc6d4469c8c85ee8b051f5
Fixes: oss-fuzz:38875
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449817
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-09-17 14:19:14 +00:00
John Stiles
eb68973c2f Disallow matrix ctors which overflow a column.
The GLSL spec allows matrix constructors containing vectors that would
split between multiple columns of the matrix. However, in practice, this
does not actually work well on a lot of GPUs!

- "cast not allowed", "internal error":
	Tegra 3
	Quadro P400
	GTX 660
	GTX 960
- Compiles, but generates wrong result:
	RadeonR9M470X
	RadeonHD7770

Since this isn't a pattern we expect to see in user code, we now report
it as an error at compile time. mat2(vec4) is treated as an exceptional
case and still allowed.

Change-Id: Id6925984a2d1ec948aec4defcc790a197a96cf86
Bug: skia:12443
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449518
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-09-16 22:14:49 +00:00
John Stiles
25868511fd Add fwidth intrinsic to public SkSL in ES3.
Change-Id: Icd55cc62db41ba6c7008161512e5584927f21757
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449190
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-09-16 01:56:32 +00:00
John Stiles
a047e8bf4d Improve overflow checks in CheckProgramUnrolledSize.
The fuzzer discovered that it could overflow the program-size value.
Rewrote the logic to use SkSafeMath everywhere, and to early-exit as
soon as a statement manages to exceed the program size.

Change-Id: I01511b2201173c95ebc1ac602901410ac9d74d73
Bug: oss-fuzz:38697
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449098
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-09-15 16:42:45 +00:00
Brian Osman
a81e7e2e71 Report an error if sk_LastFragColor is referenced without fbFetchSupport
Adjusted default caps in skslc to be consistent with runtime behavior,
and added optional settings mode to enable the feature. Tests for both
scenarios. (The error test crashed prior to the fix).

Bug: oss-fuzz:38726
Change-Id: I5270d4837ac982085d7baf5abd4b361f7bfb8562
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449062
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-09-15 15:41:49 +00:00
Ethan Nicholas
fd1332f5a7 Reland "Fixed DSL assertion error on source files containing nulls"
This is a reland of db38ad7b14

Original change's description:
> Fixed DSL assertion error on source files containing nulls
>
> The assertion was there to make sure we weren't running off the end of
> the source, but naturally fails in the presence of legitimate embedded
> nulls.
>
> Change-Id: I3b80499e9b182c9ea046c479f35d7a965d548401
> Bug: oss-fuzz:38107
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/447182
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: oss-fuzz:38107
Change-Id: Idb1a6b7c64d2bb954edadae828d6de808158fd3f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448660
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-09-15 15:00:23 +00:00
John Stiles
857c7f9dc5 Add program-too-large test using for loops without blocks.
The fuzzer has discovered a bug in our program size-checking logic; for
loops that immediately contain another for loop (with no block) were not
counting the inner loop's iterations. This allowed it to exceed our
maximum program-size threshold (and time out during SkVM compilation).

This test demonstrates the issue. A followup will fix it.

Change-Id: I3b7d4c8a4f0ed04cf0aba3f1a32fdad7d6d784e7
Bug: oss-fuzz:37837
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449096
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>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-09-15 14:19:00 +00:00
John Stiles
b701fa0ac0 Add non-square MatrixCompMult support to public SkSL in ES3 mode.
We already had a test case here, but it wasn't actually in operation.
The test has been split into ES2 (square) and ES3 (non-square) halves,
returns the color like a proper runtime effect, and it's now running in
dm.

Also, Metal doesn't natively support matrixCompMult, so it injects a
helper function; I tweaked the helper so it no longer requires an extra
result variable.

Change-Id: Ie79242768966fcbe879ad73461d17b4fb8e55670
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448117
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-14 18:15:23 +00:00
Brian Osman
eae4ad9bc0 Remove SkSL sample() intrinsic for Skia object types
Bug: skia:12302
Change-Id: Ifc107ca2cf13c1daa59521b93fe4ad1d3c215258
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/447297
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-09-14 14:18:03 +00:00
John Stiles
7d19065eef Add test of off-kilter matrix constructors.
This exposes a bug in the Metal code generator which will be resolved
in a followup CL.

Change-Id: If073835dbee474ea9a805eb92b42dc1fca2afbd0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448378
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-09-14 13:01:26 +00:00
John Stiles
dc652564a7 Fix for-statement assertion detected by the fuzzer.
The fuzzer found that the `DetectVarDeclarationWithoutScope` check was
placed too late in the function, and could be skipped over by for-loops
containing multiple variables. This was caught in ForStatement::Make,
which mirrors the Convert postconditions with matching assertions.

Change-Id: I6e9d97c7c9ca969aba65e601bbcd9fe676105838
Bug: oss-fuzz:38560
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448116
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>
2021-09-13 13:34:48 +00:00
Michael Ludwig
47d824415e Revert "Fixed DSL assertion error on source files containing nulls"
This reverts commit db38ad7b14.

Reason for revert: breaking g3 roll since it thinks the test case is "binary" not flagged as binary

Original change's description:
> Fixed DSL assertion error on source files containing nulls
>
> The assertion was there to make sure we weren't running off the end of
> the source, but naturally fails in the presence of legitimate embedded
> nulls.
>
> Change-Id: I3b80499e9b182c9ea046c479f35d7a965d548401
> Bug: oss-fuzz:38107
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/447182
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: oss-fuzz:38107
Change-Id: I650d12d728b5d932bda79e81205b873d8b44771f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/447936
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-09-11 18:13:13 +00:00
Ethan Nicholas
db38ad7b14 Fixed DSL assertion error on source files containing nulls
The assertion was there to make sure we weren't running off the end of
the source, but naturally fails in the presence of legitimate embedded
nulls.

Change-Id: I3b80499e9b182c9ea046c479f35d7a965d548401
Bug: oss-fuzz:38107
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/447182
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-10 18:44:22 +00:00
Ethan Nicholas
c9d65f0b8a Fixed duplicate function definition error discovered by fuzzer
Bug: oss-fuzz:38140
Change-Id: I76a1b3ef8289b3089192d043d173677c00741a54
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445836
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-10 17:35:52 +00:00
John Stiles
144ea42b1a Enable outerProduct() in public SkSL and add unit tests.
Compile-time optimization is not yet implemented so the generated code
contains a lot of checks which will be optimized away in a followup CL.

Change-Id: I83b5df8580a6712686d18812e3848a703feac315
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/447300
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>
2021-09-10 14:32:50 +00:00
Ethan Nicholas
bf4a7d5235 Fixed DSLParser crash with invalid swizzle
In response to a non-identifier token after a dot, DSLParser would
attempt to swizzle a zero-length field and fail an assertion.

The same basic code path exists in the old compiler, but the resulting
parse error causes the process to abort before it attempts to process
the zero-length swizzle.

Bug: oss-fuzz:38106
Change-Id: Ifd997ce1d564b5f6ef0a9a785d8d9e254785e600
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/446185
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-09-10 14:29:22 +00:00
John Stiles
8d0dd0d1c1 Add support for pack/unpackUnorm2x16 to public SkSL.
This includes compile-time optimization and tests.

The unit test is disabled in a followup CL
(http://review.skia.org/447057) because it exposes a Radeon 5300M bug
in OpenGL.

Change-Id: I8b2f0411358aeb68c4edfeb0bd7a2814c4be1f40
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/447056
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-09-09 18:59:15 +00:00
John Stiles
14c3175d7a Add ES3 intrinsic modf to sksl_public.
The test has been improved and now covers a variety of values. Because
this intrinsic has side-effects (an out-param), we do not support
optimizing it or treating it as a constant-expression.

The modf documentation doesn't mention anything about constant-
expression support or lack thereof. Experimentally, modf is also not
treated as a constant-expression by Apple GLSL or glslang:

http://screen/4RWwYKr6vCjxCPQ
http://screen/45ttDTVAFGDRyxP

Change-Id: I15bb1de80e90fa97ddf8e9d3803352603b9608d0
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/446396
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-08 18:45:16 +00:00
Ethan Nicholas
a2c76c77c4 Fixed illegal interface block reporting
DSL was improperly allowing interface blocks in runtime shaders, which
caused PipelineStageGenerator to get upset.

Bug: oss-fuzz:38131
Change-Id: I593e68f2cab3db9151d606e65e2826ffa9c494e2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/446324
Commit-Queue: Ravi Mistry <rmistry@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-09-07 20:18:00 +00:00
John Stiles
106e0cd412 Increase GetLoopUnrollInfo loop-count limit to 100,000.
To do this with a clean conscience, I needed to convert the unroll-
counting logic from a linear time algorithm to constant-time. Getting
all the edge cases correct requires a lot of care, and there are now
plenty of unit tests.

Change-Id: I620909d069ac425b7310e345bf80ec844fe035f8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445643
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-09-07 19:28:08 +00:00
Dominik Röttsches
09961b554d [COLRv1] Fix blending and compositing
An additional layer is required to composite correctly. PaintComposite
blends/composites between source and destination. The result is
then drawn on top of previous paint results. Previously, the source
layer was just drawn atop previous paints, then the destination
layer was composited down with composite mode, which was incorrect.

More details in [1].

Add tests for composite modes, compare [2]

[1] https://github.com/googlefonts/nanoemoji/issues/332
[2] https://github.com/googlefonts/color-fonts/pull/73

Cq-Include-Trybots: luci.skia.skia.primary:Test-Android-Clang-GalaxyS6-GPU-MaliT760-arm64-Release-All-Android_NativeFonts,FM-Debian10-Clang-GCE-CPU-AVX2-x86_64-Release-All-MSAN
Bug: skia:12424
Change-Id: I8ff69022ec09758af7021756b0fb26443216fcca
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445936
Commit-Queue: Dominik Röttsches <drott@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2021-09-07 15:09:58 +00:00
John Stiles
733fd74c29 Improve unit testing of for-loops.
An ES2-compatible for loop supports six separate rel-ops:
   < <= > >= != ==
Each rel-op, in addition to its expected usage, is also able to
represent a loop which never terminates, as well as a loop which
terminates instantly. Since SkVM unrolls these loops, we should make
sure we do it properly. We now have unit tests for all of these cases.

Change-Id: Icae04d48bc158bf8c0c98db97f76756a1a29110c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445756
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-09-07 14:11:04 +00:00
John Stiles
3ff77f4862 Fix inliner bug discovered by fuzzer.
Intrinsic-call optimization can be triggered during inlining. In this
case, inlining turned `normalize(x)` into `normalize(constant-value)`.

DSL is used to implement optimizations for a handful of intrinsic calls,
including `normalize`, which internally relies on `length`.

The DSL expects that it can use the IRGenerator to handle function
calls. This was not working because we were finished with the initial
compilation pass, and the IRGenerator's symbol table is removed when
finish() was called.

We now temporarily give a symbol table back to the IRGenerator while
the inliner runs. We remove it again as soon as inlining is complete.

Change-Id: I6da98788d93749ffeb008c1f4c3f72b436e8ceeb
Bug: oss-fuzz:37994
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445956
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-09-07 13:29:37 +00:00