Commit Graph

131 Commits

Author SHA1 Message Date
John Stiles
26c93442b5 Re-re-reland "Rewrite switch statements in GLSL strict-ES2 mode."
This reverts commit 6f06bab632.

Reason for revert: glslGeneration is more trustworthy than GR_GL_VER

Original change's description:
> 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>

Bug: skia:12450
Change-Id: I4bac3a468ae20967fe6ec372561dd44f67c6b730
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452897
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-27 14:35:19 +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
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
Brian Osman
d26d0e6a47 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>
2021-09-24 13:11:05 +00:00
John Stiles
45e3838006 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>
2021-09-23 21:22:09 +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
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
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
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
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
0dc09b190a Update SkSLTest to check a 2x2 surface.
Derivative tests don't really make intuitive sense in a 1x1 surface.
This should give the derivatives a better workout.

Change-Id: I09e5ff2b7815d42d1874e5deef360e9bc2e83aff
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449195
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-09-16 01:56:02 +00:00
John Stiles
c915da9b20 Revert "Enable MatrixConstructors test, outside of Quadro P400."
This reverts commit c6ce617a8a.

Reason for revert: more Golo machines with old drivers

Original change's description:
> Enable MatrixConstructors test, outside of Quadro P400.
>
> Change-Id: Ie228befa747351445981093f6c57308e338c9684
> Bug: skia:12443
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449181
> 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>

Bug: skia:12443
Change-Id: Ica465810257b2f949a0cf0def62e699f7c2877cc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449258
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: 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-15 20:08:13 +00:00
John Stiles
c6ce617a8a Enable MatrixConstructors test, outside of Quadro P400.
Change-Id: Ie228befa747351445981093f6c57308e338c9684
Bug: skia:12443
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449181
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-15 19:23:20 +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
John Stiles
143e850237 Fix Metal row/column confusion, again.
We didn't have any tests which exercised the non-square matrix case
(because such a test requires ES3), so it was silently broken. It's
now fixed. The tests exposed a DIFFERENT Quadro P400 bug which will be
fixed separately.

Change-Id: Icf24acad5ea6f18aea3d8aa5a903e7bea41a5c23
Bug: skia:12443
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448379
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-14 17:06:48 +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
John Stiles
df84ccdb38 Disable SkSLIntrinsicPackUnorm2x16 test.
This test fails on my work laptop (Radeon 5300M) so simply disabling it
on the tree isn't sufficient in this case. We don't seem to have a test
opt-out mechanism that automatically applies to local runs of dm.

Change-Id: I83582f0cdc3c9e6a61e6dc8e07851b9705143423
Bug: skia:12434
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/447057
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-09-09 19:13:46 +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
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
f89a8122a4 Fix flaws in minus-prefix optimization.
We had a logic bug when attempting to optimize the following code:
    const vecN x = vecN(a, b, c);
    -x;

The goal was to replace `-x` with `vecN(-a, -b, -c)` but we accidentally
tried to cast the `x` VariableReference to a Constructor. We
unfortunately didn't cover this in any of our test cases, but the fuzzer
managed to synthesize it by mixing and matching elements from its new
corpus.

This affected several different constructor types: splat, diagonal-
matrix, compound and array.

Change-Id: I10dd2460ab26ba3e820b0cff5db091368fb7e648
Bug: oss-fuzz:37764, oss-fuzz:37861
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/443407
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-08-30 20:40:17 +00:00
John Stiles
dec5ff2286 Reland "Add ES3 intrinsics isinf/isnan to public SkSL ES3."
This reverts commit 9155b338bb.

Reason for revert: disable test for GLSL + Adreno 6xx

Original change's description:
> Revert "Add ES3 intrinsics isinf/isnan to public SkSL ES3."
>
> This reverts commit e43714f490.
>
> Reason for revert: Several Pixel (Adreno) devices failing the test
>
> Original change's description:
> > Add ES3 intrinsics isinf/isnan to public SkSL ES3.
> >
> > The ES3 spec doesn't mandate that `isnan` actually has to do anything,
> > so the Isnan test is not enabled. (It doesn't work on my personal
> > machine unless I make the NaN detectable at compile-time.)
> >
> > We do not support these functions in constant-expressions, as we
> > currently avoid optimizing anything into a non-finite value; we leave
> > expressions alone if we calculate a NaN/inf result for their value.
> >
> > Change-Id: Ibfdfb47b6e6134165c8780db570de04a916d2bfa
> > Bug: skia:12022
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441581
> > Auto-Submit: John Stiles <johnstiles@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
> > Commit-Queue: John Stiles <johnstiles@google.com>
>
> TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com
>
> Change-Id: I89899ed391aa870350d0452bab4a0fb75bd7be38
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:12022
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441716
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>

Bug: skia:12022, skia:12377
Change-Id: Ib149dbc1138feb3ee2bf6f7e31e9e8a9414560bc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441884
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-25 19:01:22 +00:00
John Stiles
31c87103c6 Fix parsing error with structs containing arrays.
Previously, a struct containing a vardecl with multiple declarations
would interpret arrays incorrectly. An array would be applied to ALL
variables in the decl after its initial appearance. That is,
`int w, x[10], y, z;` would be interpreted as
`int w, x[10], y[10], z[10];`.

This is now fixed and our test case runs as expected.

Change-Id: I5b4a617c58cdfb83face651effd42770a1f68638
Bug: oss-fuzz:37622
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441879
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-08-25 17:27:12 +00:00
John Stiles
2d3f5e8f25 Demonstrate parsing error with structs and arrays.
The fuzzer detected a serious parsing error; a struct containing a
vardecl with multiple declarations would interpret arrays incorrectly.
An array would be applied to ALL variables in the decl after its initial
appearance. That is, `int w, x[10], y, z;` would be interpreted as
`int w, x[10], y[10], z[10];`. The fuzzer caught this by putting two
arrayed variables in a row; the second variable was interpreted as a
nested array, which led to an assertion.

This CL contains a simple hand-written test case demonstrating the bug,
with the fix coming in a followup.

Change-Id: I42d7372ba77fa1528ae24eb8c29a2e5903784139
Bug: oss-fuzz:37622
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441878
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-25 17:26:54 +00:00
Brian Osman
9155b338bb Revert "Add ES3 intrinsics isinf/isnan to public SkSL ES3."
This reverts commit e43714f490.

Reason for revert: Several Pixel (Adreno) devices failing the test

Original change's description:
> Add ES3 intrinsics isinf/isnan to public SkSL ES3.
>
> The ES3 spec doesn't mandate that `isnan` actually has to do anything,
> so the Isnan test is not enabled. (It doesn't work on my personal
> machine unless I make the NaN detectable at compile-time.)
>
> We do not support these functions in constant-expressions, as we
> currently avoid optimizing anything into a non-finite value; we leave
> expressions alone if we calculate a NaN/inf result for their value.
>
> Change-Id: Ibfdfb47b6e6134165c8780db570de04a916d2bfa
> Bug: skia:12022
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441581
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: I89899ed391aa870350d0452bab4a0fb75bd7be38
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12022
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441716
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-08-25 02:55:09 +00:00
John Stiles
e43714f490 Add ES3 intrinsics isinf/isnan to public SkSL ES3.
The ES3 spec doesn't mandate that `isnan` actually has to do anything,
so the Isnan test is not enabled. (It doesn't work on my personal
machine unless I make the NaN detectable at compile-time.)

We do not support these functions in constant-expressions, as we
currently avoid optimizing anything into a non-finite value; we leave
expressions alone if we calculate a NaN/inf result for their value.

Change-Id: Ibfdfb47b6e6134165c8780db570de04a916d2bfa
Bug: skia:12022
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441581
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-24 19:23:48 +00:00
John Stiles
368166262a Add trunc/round/roundEven SKSL ES3 public APIs.
Improved tests caught a longstanding bug in the compile-time
optimization logic for round/roundEven. These would *always* round to an
even number even when it didn't make sense to do so. (e.g. 3.1 would
round to 4.)

RoundEven isn't available in lower shader models of Direct3D;
SPIRV-Cross throws if it's unavailable. We may need a caps bit for this.

Change-Id: I3cc50238a2116b8d4e2c4059730d8b5cfb2bb056
Bug: skia:12022, skia:12352
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441078
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-23 15:44:15 +00:00
John Stiles
b39236bc0f Add floatBitsToInt family of ES3 intrinsics to SkSL public ES3.
These now have proper testing and compile-time optimization support.

Change-Id: I7978161ec126e1c3096b9ca9dfbb2be7d8ea02f5
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440859
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-08-20 14:58:44 +00:00
John Stiles
c61d1bf4e6 Implement determinant() in SkSL ES3 public API.
The prototype has been added sksl_public, compile-time optimization is
implemented, and test code has been improved.

Change-Id: I536d6bd7fcae437a03744941b008940bf2a3b1c1
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440524
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-19 15:27:10 +00:00
John Stiles
0733d48428 Check for SkSL ES3 capabilities in GrShaderCaps.
This lets us set the minimum bar for SkSL ES3 support in one place,
rather than checking this set of bits in multiple spots.

Change-Id: Icba58d8b6a93626ce2ffbe3c4b846cad4749cab5
Bug: skia:12347
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440518
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-18 17:12:12 +00:00
John Stiles
a7ea66372d Revert "Use generation() to detect ES3 support."
This reverts commit fdde20d3ec.

Reason for revert: generation() can promise things that it can't deliver

Original change's description:
> Use generation() to detect ES3 support.
>
> Desktop GLSL 1.30 supports the things we currently consider as "ES3
> only"--nonsquare matrices, derivatives, and unsigned integers.
>
> Change-Id: I4b5a844cf3aabee6b6d2c562e78859a29efc36fc
> Bug: skia:12347
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439937
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

TBR=brianosman@google.com,johnstiles@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: I118e08da078090f404a4fdf33c3a16a48c702753
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12347
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440457
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-18 13:21:57 +00:00
John Stiles
39822cf1e6 Add transpose() to public ES3 API.
We don't have compile-time optimization for this intrinsic yet, but
otherwise everything is working as expected.

Change-Id: Id9c678699baa1d9867848459bf680cc40f29b4bd
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440257
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-17 20:57:40 +00:00
John Stiles
fdde20d3ec Use generation() to detect ES3 support.
Desktop GLSL 1.30 supports the things we currently consider as "ES3
only"--nonsquare matrices, derivatives, and unsigned integers.

Change-Id: I4b5a844cf3aabee6b6d2c562e78859a29efc36fc
Bug: skia:12347
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439937
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-17 17:09:50 +00:00
John Stiles
4e2494870d Allow derivatives in Runtime Effects when ES3 restrictions are off.
We can now add functions to sksl_public.sksl with an $es3 prefix. These
will be allowed in a Runtime Effect when strict-ES2 mode is disabled.
Note that the CPU backend still doesn't have support for these calls,
and will fail ungracefully (assertion, nonsense result) if these
intrinsics are used.

The testing here is limited, due to an unrelated bug in SPIR-V
(skia:12340)

Change-Id: I9c911bc2b77f5051e80844607e7fd08ad386ee56
Bug: skia:12202, skia:12340
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439058
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-13 16:45:17 +00:00
John Stiles
26487162fe Add support for array-cast syntax in SkSL.
Compiling a program with "allow narrowing conversions" actually fixes up
narrowing casts in the program by inserting casts wherever they would be
needed for type-correctness. For instance, compiling the statement
    `half h = myFloat;`
inserts an appropriate narrowing cast:
    `half h = half(myFloat);`.

The Pipeline stage code generator relies on this behavior, as when it
re-emits a runtime effect into a complete SkSL program, the narrowing-
conversions flag will no longer be set, but that is okay, because the
emitted code now contains typecasts anywhere they would be necessary.

Logically, this implies that anything which supports narrowing
conversions must be castable between high and low precision. In GLSL and
SPIR-V, such a cast is trivial, because the types are the same and the
precision qualifiers are treated as individual hints on each variable.
In Metal, we dodge the issue by only emitting full-precision types. But
we also need to emit raw SkSL from an SkSL program (that is what the
Pipeline stage generator does).

SkSL already supported every typical cast, but GLSL lacked any syntax
for casting an array to a different type. This meant SkSL had no array
casting syntax as well. SkSL now has array-cast syntax, but it is only
allowed for casting low/high-precision arrays to the same base type.
(You can't cast an int array to float, or a signed array to unsigned.)

Change-Id: Ia20933541c3bd4a946c1ea38209f93008acdb9cb
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437687
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-11 12:56:40 +00:00
John Stiles
2195f94a0c Add unit test for array narrowing conversions.
Change-Id: Ibadda2a10e19984c7a0efb66fd3187f280666445
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436996
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-06 13:05:35 +00:00
John Stiles
9ae6ea0711 Fix fuzzer-discovered error with swizzling matrices.
The optimization logic for swizzling a constructor assumed that every
argument to the constructor was a scalar or vector. When it was written,
this assumption was true. However, we recently added support for casting
mat2x2 to float4 which violates the assumption.

We now check every argument and do not attempt to optimize if a
non-scalar, non-vector arg is found.

Change-Id: Ia2b297bd62dfdf4af56712164fbc80c29c9611eb
Bug: oss-fuzz:36852
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437017
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-05 21:59:23 +00:00
Brian Osman
7da0657fda Explicitly detect static recursion in SkSL
This relaxes our rules to allow calls to declared (but not yet defined)
functions. With that rule change, we have to specifically detect static
recursion and produce an error.

Bug: skia:12137
Change-Id: I39cc281fcd73fb30014bc7b43043552623727e03
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431537
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-24 00:01:15 +00:00
Brian Osman
fb212256ca Improve tests/comments, to prepare for calling functions before definition
Bug: skia:12137
Change-Id: I609dd2578bf39a30e036ea85281886f8c4554579
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431038
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-22 13:19:39 +00:00
John Stiles
010c0ec061 Allow swizzles on Boolean scalar expressions.
Boolean vector expressions already allowed swizzles (see the
SwizzleBoolConstants.sksl test), but scalars had been inadvertently
disallowed.

Change-Id: I89e7139db50981f0ee1a9a5086b02603e57f967d
Bug: skia:12195
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/427196
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-07-12 20:33:10 +00:00
John Stiles
7f56b41fc0 Add scalar-swizzling tests for int and bool types.
Boolean scalar-swizzling is currently not working.

Change-Id: Icd965e4b64a12311d098168f65622110d5fb3437
Bug: skia:12195
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/427038
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-07-12 19:54:40 +00:00
John Stiles
6de2e1db03 Add support for matrix-to-vector conversions in SkSL.
GLSL supports casting vec4 into mat2 and vice versa, so SkSL should have
equivalent support. This CL allows the Compound constructor to take a
matrix as input, and fixes up backends to do the right thing when a
matrix shows up in the compound-constructor path.

Change-Id: I13289ad0a27ba59bddc3706093820594efebc693
Bug: skia:12067
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426003
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-07-09 17:55:22 +00:00
John Stiles
5a825da698 Reland "Add tests for matrix-vector conversions."
This reverts commit f009db5b85.

Reason for revert: test disabled on Win10 + Intel 4400/6100

Original change's description:
> Revert "Add tests for matrix-vector conversions."
>
> This reverts commit a89781215a.
>
> Reason for revert: breakage on Windows
>
> Original change's description:
> > Add tests for matrix-vector conversions.
> >
> > GLSL supports casting vec4 into mat2 and vice versa, so SkSL should have
> > equivalent support. Adding tests as a starting point.
> >
> > Change-Id: If8bcbf99afcec94d948d5da9e6205cb4a232af18
> > Bug: skia:12067
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425837
> > Auto-Submit: John Stiles <johnstiles@google.com>
> > Commit-Queue: Brian Osman <brianosman@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com
>
> Change-Id: I2563041f538b1b20074385f1b61af5fc506ffad5
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:12067
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426057
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

Bug: skia:12067
Change-Id: I1379914ee39ce340f09b11b3754820db9c645378
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426058
Reviewed-by: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-07-08 23:28:22 +00:00
John Stiles
f009db5b85 Revert "Add tests for matrix-vector conversions."
This reverts commit a89781215a.

Reason for revert: breakage on Windows 

Original change's description:
> Add tests for matrix-vector conversions.
>
> GLSL supports casting vec4 into mat2 and vice versa, so SkSL should have
> equivalent support. Adding tests as a starting point.
>
> Change-Id: If8bcbf99afcec94d948d5da9e6205cb4a232af18
> Bug: skia:12067
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425837
> Auto-Submit: John Stiles <johnstiles@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com

Change-Id: I2563041f538b1b20074385f1b61af5fc506ffad5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12067
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426057
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-07-08 21:46:40 +00:00
John Stiles
a89781215a Add tests for matrix-vector conversions.
GLSL supports casting vec4 into mat2 and vice versa, so SkSL should have
equivalent support. Adding tests as a starting point.

Change-Id: If8bcbf99afcec94d948d5da9e6205cb4a232af18
Bug: skia:12067
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425837
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-07-08 18:36:07 +00:00