Commit Graph

131 Commits

Author SHA1 Message Date
Brian Osman
e9ab391765 Reland "Convert GrDitherEffect to a runtime FP"
This reverts commit 3dd52c758b.

Change-Id: Ie873ad570ffc57b3edd6ffe8612cbc2c73d40450
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424259
Reviewed-by: Brian Osman <brianosman@google.com>
2021-07-02 17:33:15 +00:00
Brian Osman
3dd52c758b Revert "Convert GrDitherEffect to a runtime FP"
This reverts commit 2fa843abc2.

Reason for revert: Oops, SkSL error in the ES2 path.

Original change's description:
> Convert GrDitherEffect to a runtime FP
>
> Includes a change so that we can create non-ES2 runtime effects, even
> outside of tests/tools. It's still locked to a private API, so clients
> can't access the functionality.
>
> Change-Id: Ie0643da2071bd223fccf05b35f3a7b6f7bbc4876
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/423578
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>

TBR=bsalomon@google.com,brianosman@google.com,ethannicholas@google.com,michaelludwig@google.com

Change-Id: Icff68da3cadd00868c94b84fbb39e470a7bf45d0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424100
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-01 22:36:09 +00:00
Brian Osman
2fa843abc2 Convert GrDitherEffect to a runtime FP
Includes a change so that we can create non-ES2 runtime effects, even
outside of tests/tools. It's still locked to a private API, so clients
can't access the functionality.

Change-Id: Ie0643da2071bd223fccf05b35f3a7b6f7bbc4876
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/423578
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-01 20:58:54 +00:00
John Stiles
27724cd169 Disable SkSL test for clamp().
Test is failing on Adreno 6xx + Vulkan.

Change-Id: I8e5e97c82622c77385baef2c71d9381203221139
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412238
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-05-25 19:10:49 +00:00
John Stiles
017ffd7e05 Implement compile-time optimization for step().
$genType step($genType edge, $genType x);
$genType step(float edge, $genType x);
$genHType step($genHType edge, $genHType x);
$genHType step(half edge, $genHType x);

Change-Id: If52634d7a247772e922cb3fd2e3e8a7c36c275f6
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411842
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-05-25 16:59:22 +00:00
John Stiles
b82e93103e Reland "Add support for do-while loops in PipelineStage."
This is a reland of 9c7e04cd6f

The DeadReturnES3 test isn't enabled yet due to crashes in Radeon, but
the PipelineStage fixes need to be landed now.

Original change's description:
> Add support for do-while loops in PipelineStage.
>
> This allows us to run tests which use do-while loops (like
> DeadReturnES3) within dm.
>
> Change-Id: If8ecb6b3fcd23d79451a43edf8e1ee8a182de984
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410459
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Change-Id: I73715f09defd950156cc252be9a52a36620d6d5b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410936
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-05-20 19:49:42 +00:00
John Stiles
d2c5a80281 Enable additional do-while SkSL tests.
These tests were written earlier but not enabled due to the absence of
ES3 support in Runtime Effects.

Change-Id: Idaf81926271e5b2e483a7c5cfce824a0056f5595
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410460
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-05-20 18:45:35 +00:00
Brian Salomon
edb7aa70fc Revert "Add support for do-while loops in PipelineStage."
This reverts commit 9c7e04cd6f.

Reason for revert: ANGLE bots don't like it:
https://logs.chromium.org/logs/skia/53a05ed157eb6c11/+/steps/dm/0/stdout
Exception in SkSLDeadReturnES3_GPU

Original change's description:
> Add support for do-while loops in PipelineStage.
>
> This allows us to run tests which use do-while loops (like
> DeadReturnES3) within dm.
>
> Change-Id: If8ecb6b3fcd23d79451a43edf8e1ee8a182de984
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410459
> 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,ethannicholas@google.com,johnstiles@google.com

Change-Id: Ib8ca1fd28b49c5e7d72290132336252218caac18
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410779
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-05-20 12:58:46 +00:00
John Stiles
9c7e04cd6f Add support for do-while loops in PipelineStage.
This allows us to run tests which use do-while loops (like
DeadReturnES3) within dm.

Change-Id: If8ecb6b3fcd23d79451a43edf8e1ee8a182de984
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410459
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-20 01:18:23 +00:00
John Stiles
325c808ebb Enable additional SkSL tests which require non-ES2 features.
Although these tests are simple, it ended up uncovering a legitimate
SPIR-V bug (skia:12009).

Change-Id: Ie89235157256b97626aa6ada4d9d6ba62abc57fa
Bug: skia:12009
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/409299
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-17 20:24:50 +00:00
John Stiles
f2b08cc9c8 Fix SPIR-V code generation of dead return statements.
If we encounter code like `return 1; return 2;` we need to synthesize a
label, even though the second return statement isn't actually reachable.
This is harmless and satisfies the SPIR-V validator.

Ideally we'd eliminate the dead code entirely, but this case is rare and
isn't likely to cause any problems as-is.

Change-Id: I2d6219dff6868011353e19a662301bec44a015d6
Bug: skia:12009
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/409402
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-17 20:23:40 +00:00
John Stiles
191b4e2a00 Enable proper testing of matrix-scalar ops.
Now that the various Metal and SPIR-V bugs have been shaken out, we can
enable these tests. Knock on wood.

Change-Id: If4b4e302cfdd91464aaf00bc9639989de5e49aac
Bug: skia:11985
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408640
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-05-17 17:36:22 +00:00
John Stiles
c1f6411045 Enable a handful of tests which require ES3.
Previously, these tests were commented out because Runtime Effects could
not compile ES3. More recently, the `enforceES2Restrictions` option flag
was added, which allows these tests to work inside a Runtime Effect.

Most of our commented-out tests can be supported this way; enabling them
a few at a time will make the inevitable debugging simpler when a driver
runs into issues with a test.

Change-Id: I1a7a377d392151df4b4789ed5062706717c5a41b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/409280
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-05-17 15:02:50 +00:00
John Stiles
ab3e6394a0 Re-enable the nonsquare matrix test.
The mat4x2 portion of the test no longer checks its results, as there
are bugs in the Intel and Radeon GPU drivers that prevent mat4x2s
from being constructed properly.

The SkSL optimizer ends up eliminating the 4x2 matrix entirely because
it is unused by the rest of the code, as well at the 4x4 matrix which is
calculated from the 4x2. At this point, I'm OK with this.

Change-Id: If1464f9e4938b0a37b2ec180c686972389d94e83
Bug: skia:12003
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408900
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-05-17 13:27:48 +00:00
John Stiles
024f41828b Disable nonsquare matrix test temporarily.
This test causes issues on a handful of drivers still.

Change-Id: I7dd0df95d174c53cfc05df83d848a90a169ba3d1
Bug: skia:12003
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408897
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-05-14 21:44:11 +00:00
John Stiles
aecf8d5171 Expose non-square matrix types when fEnforceES2Restrictions is off.
This will allow us to write tests that verify the behavior of non-square
matrix ops.

Change-Id: I1490c4675778cbdc8428ac7a6c9de16083179fc8
Bug: skia:11985
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408645
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-05-14 16:50:42 +00:00
John Stiles
82491c5d65 Enable proper testing of const arrays.
This test was generating invalid code in Metal
(http://review.skia.org/408356), but we didn't catch it because the code
wasn't actually being run.

Change-Id: I649034593a566f9e835b1cf7b0702c64952d31ef
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408641
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-14 13:37:12 +00:00
John Stiles
27193d4bce Add test demonstrating missed opportunities with casts.
A cast like `float(five)` or `int4(colorGreen)` should detect const
variables and replace the expression with its compile-time constant
equivalent value. At present, this replacement is missed, which inhibits
further optimization opportunities on the expression.

(This CL is very similar in spirit to http://review.skia.org/404676)

Change-Id: I04b5c435a30d2afcdbdb3d020adc15e9c651cc31
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405682
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-05-07 22:04:16 +00:00
John Stiles
3934647d22 Reland "Implement operator== and != for Metal structs and arrays."
This is a reland of 830c69ca66

Original change's description:
> Implement operator== and != for Metal structs and arrays.
>
> GLSL/SkSL assumes that == and != on struct/array types should work.
> We need to emit equality and inequality operators whenever we find code
> that compares a struct or array.
>
> Structs and arrays can be arbitrarily nested, and either type can
> contain a matrix. All of these things need custom equality operators in
> Metal. Therefore, we need to recursively generate comparison operators
> when any of these types are encountered.
>
> For arrays we get lucky, and we can cover all possible array types and
> sizes with a single templated operator== method. Structs and matrices
> have no such luck, and are generated separately on a per-type basis.
>
> For each of these types, operator== is implemented as an equality check
> on each field, and operator!= is implemented in terms of operator==.
> Equality and inequality are always emitted together. (Previously, matrix
> equality and inequality were emitted and implemented independently, but
> this is no longer the case.)
>
> Change-Id: I69ee01c0a390d7db6bcb2253ed6336ab20cc4d1d
> Bug: skia:11908, skia:11924
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402016
> Auto-Submit: John Stiles <johnstiles@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: skia:11908, skia:11924, skia:11929
Change-Id: I6336b6125e9774c1ca73e3d497e3466f11f6f25f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402559
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-29 22:55:58 +00:00
John Stiles
fb7d378a1a Add test demonstrating swizzled constant folding.
At present, this is a missed optimization opportunity. These will be
optimized in a followup CL.

Change-Id: I8882058900cdc12c8ab0df03e36ebfb9d8022f01
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402580
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-04-29 15:59:37 +00:00
John Stiles
35c4552254 Revert "Implement operator== and != for Metal structs and arrays."
This reverts commit 830c69ca66.

Reason for revert: Pixel5 issues on tree

Original change's description:
> Implement operator== and != for Metal structs and arrays.
>
> GLSL/SkSL assumes that == and != on struct/array types should work.
> We need to emit equality and inequality operators whenever we find code
> that compares a struct or array.
>
> Structs and arrays can be arbitrarily nested, and either type can
> contain a matrix. All of these things need custom equality operators in
> Metal. Therefore, we need to recursively generate comparison operators
> when any of these types are encountered.
>
> For arrays we get lucky, and we can cover all possible array types and
> sizes with a single templated operator== method. Structs and matrices
> have no such luck, and are generated separately on a per-type basis.
>
> For each of these types, operator== is implemented as an equality check
> on each field, and operator!= is implemented in terms of operator==.
> Equality and inequality are always emitted together. (Previously, matrix
> equality and inequality were emitted and implemented independently, but
> this is no longer the case.)
>
> Change-Id: I69ee01c0a390d7db6bcb2253ed6336ab20cc4d1d
> Bug: skia:11908, skia:11924
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402016
> 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: I06c47923649ea9fb675bab6baab121eb504d5ab8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11908
Bug: skia:11924
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402558
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-29 13:37:28 +00:00
John Stiles
830c69ca66 Implement operator== and != for Metal structs and arrays.
GLSL/SkSL assumes that == and != on struct/array types should work.
We need to emit equality and inequality operators whenever we find code
that compares a struct or array.

Structs and arrays can be arbitrarily nested, and either type can
contain a matrix. All of these things need custom equality operators in
Metal. Therefore, we need to recursively generate comparison operators
when any of these types are encountered.

For arrays we get lucky, and we can cover all possible array types and
sizes with a single templated operator== method. Structs and matrices
have no such luck, and are generated separately on a per-type basis.

For each of these types, operator== is implemented as an equality check
on each field, and operator!= is implemented in terms of operator==.
Equality and inequality are always emitted together. (Previously, matrix
equality and inequality were emitted and implemented independently, but
this is no longer the case.)

Change-Id: I69ee01c0a390d7db6bcb2253ed6336ab20cc4d1d
Bug: skia:11908, skia:11924
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402016
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-29 13:03:17 +00:00
John Stiles
65d7ab2c07 Loosen ES3 restrictions in Runtime Effects for debugging.
This CL adds a RuntimeEffect option flag which skips over the various
`strictES2Mode` checks sprinkled throughout IR generation.

Runtime Effects still won't allow a lot of ES3 things (the Pipeline
stage will reject unsupported statement types, SkVM doesn't support most
non-ES2 constructs, etc). However, this change will give us the ability
to test many more features involving arrays and structs that previously
were off-limits due to ES2 restrictions, and will shore up some
legitimate gaps in our testing. This is a useful starting point to allow
for improved test coverage.

Change-Id: I4a5bc43914e65fc7e59f1cecb76a0ec5a7f05f2f
Bug: skia:11209
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402157
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-04-28 19:59:36 +00:00
Brian Osman
169c8903be Reland "Add coords parameter to all .sksl test files used as runtime effects"
This is a reland of 22dcb5fd7e

Original change's description:
> Add coords parameter to all .sksl test files used as runtime effects
>
> Convert to use the newer MakeForShader factory, which requires this.
>
> Change-Id: Ifaf6054054027c78f3f3fe15596e435e0f79b877
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399336
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>

Bug: skia:11919
Change-Id: I5f745c54b2bc3712f2281db6e067345903e81931
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401836
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-27 20:47:31 +00:00
Joe Gregorio
67baf2dd48 Revert "Add coords parameter to all .sksl test files used as runtime effects"
This reverts commit 22dcb5fd7e.

Reason for revert: Lot's of red Android and Win bots.

Original change's description:
> Add coords parameter to all .sksl test files used as runtime effects
>
> Convert to use the newer MakeForShader factory, which requires this.
>
> Change-Id: Ifaf6054054027c78f3f3fe15596e435e0f79b877
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399336
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>

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

Change-Id: I0fa844c6cf985d16e72c7f26aa217752612dcfc1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401077
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Commit-Queue: Joe Gregorio <jcgregorio@google.com>
2021-04-26 19:40:30 +00:00
Brian Osman
22dcb5fd7e Add coords parameter to all .sksl test files used as runtime effects
Convert to use the newer MakeForShader factory, which requires this.

Change-Id: Ifaf6054054027c78f3f3fe15596e435e0f79b877
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399336
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-26 18:34:38 +00:00
John Stiles
d94bfdd7d8 Fix codegen for integer vector-scalar arithmetic in SPIR-V.
Due to missing type-checks, we would emit `OpVectorTimesScalar` when
multiplying an ivec with an int, or an `OpFDiv` when dividing an ivec
against an int.

Change-Id: Idc214dbe0ec208cb44f28b22e585584ac2ab7dae
Bug: skia:11267, skia:11788
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388742
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-26 02:30:04 +00:00
John Stiles
2febb5b423 Add SkSL test for vector-scalar math.
We had constant-folding tests for vector-scalar arithmetic, but didn't
have an equivalent SkSL unit test for vector-scalar arithmetic that
actually needs to be computed at runtime.

This exposes two SPIR-V bugs: one was previously known, but the other
is a new discovery.

Change-Id: I28737128f20b445797c6c29872335d05f94cc95c
Bug: skia:11267, skia:11788
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388739
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-25 23:30:34 +00:00
John Stiles
0c9d888748 Run SkSL inliner tests as part of dm.
Previously, these tests were never actually executed, only read during
code review. They are now properly tested for correctness whenever dm
is run. Non-ES2 compliant statements (do/while/switch) are unfortunately
excluded here, as they are not compatible with Runtime Effects yet.

Change-Id: I965c782baad6f8dd3961a400ae791fb2c1f844d3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/389296
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-25 22:58:54 +00:00
John Stiles
9d26af9a82 Fix testing of Runtime Effects with inlining enabled and disabled.
Previously, the act of painting a Runtime Effect was causing its helper
functions to get inlined, even if inlining was disabled during the
initial SkSL generation. This meant that the "NoInline" path was not
actually very effective.

Change-Id: If8e3933be61df4a49d2e11d916d7fff22876315e
Bug: skia:11362
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388099
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-23 14:23:28 +00:00
John Stiles
3150839b59 Disable CommaSideEffects test on GPU.
This test causes the Adreno 330 driver to crash, and does not pass on
Quadro P400 in wasm. The CPU test confirms that we can get it right,
even if not all drivers do.

Change-Id: I5ffb72ac647a49dab7130ab2c6e94f587ded6cf9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386216
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-03-17 21:56:00 +00:00
John Stiles
bff24abab8 Disallow inlining a function with out-parameters.
It is difficult to do this both efficiently and correctly while honoring
GLSL semantics (which require the lvalues to be kept distinct, even when
they point to the same variable). We could make it work by making copies
of every out parameter in each direction (going in for inouts, and
coming out for outs and inouts).

However, this could be self-defeating if it makes it harder for the
driver to track variable lifetimes. Simply opting out of inlining these
functions entirely seems like the best tradeoff; let the driver optimize
them if it can, and we can enjoy reduced complexity in the SkSL inliner.

Change-Id: I62f7b4550cc181cfe789e4f2ff4e408ba1baf9cb
Bug: skia:11326
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/370257
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-03-17 18:04:00 +00:00
Ethan Nicholas
e0707b7075 No longer passing the results of OpAccessChain to function calls
It turns out it is not legal to pass the results of OpAccessChain as a
function argument, for... reasons. This CL switches us over to passing
the argument via a temp variable instead.

Bug: skia:11748
Change-Id: Ib5e86c1d000655ebd7bb62ceea6a27b823808645
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385936
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-03-17 16:37:00 +00:00
John Stiles
65abd2f556 Disable OutParams test on GPU.
This test fails on SPIR-V when the inliner is turned off:

error: SPIR-V validation error: Pointer operand 250[%250] must be a memory object declaration
  %252 = OpFunctionCall %void %out_half %250

Change-Id: Ibfa9cef371af2eea766a4218ec8a581289ee100e
Bug: skia:11748
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/384999
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-15 19:46:16 +00:00
John Stiles
28054added Optimize ternary tests that check a const variable.
This enables the ternary to be optimized away in code like:
   const bool SHINY = true;
   color = SHINY ? add_shine(x) : x; // to --> `color = add_shine(x);`

Without constant propagation.

Also, I added a unit test for ternary expression simplification; I
wasn't able to find an existing one.

When the optimization flag is disabled, this CL actually removes the
optimization of `true ? x : y` --> `x` entirely; previously, this
substitution would be made regardless of optimization settings.

Change-Id: I93a8b9d4027902d35f8a19cfd6417170b209d056
Bug: skia:11343
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/379297
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-03-05 21:41:05 +00:00
John Stiles
b3dcbb12ef Detect functions that fail to return a value, without using CFG.
This check now runs at function finalization time, before constant
propagation has occurred; this affected the "DeadIfStatement" test.

Our detection isn't smart enough to realize that a loop will run zero
times, so it treats `for` and `while` loops as always running at least
once. This isn't strictly correct, but it actually mirrors how the CFG
implementation works anyway. The only downside is that we would not flag
code like `for (i=0; i<0; ++i) { return x; }` as an error.

Change-Id: I5e43a6ee3a3993045559f0fb0646d36112543a94
Bug: skia:11377
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/379056
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-04 22:47:05 +00:00
Ethan Nicholas
daed2592bb Made SkSL DSL into public API
In addition to the unsurprising changes to eliminate references to
src/, we also had to tighten up some C++17-isms as they are not
permitted in public headers.

Change-Id: Ie5005a33d7a135e69fb66beca5e7a5f960dbd453
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378496
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-04 21:03:58 +00:00
John Stiles
03467a53e6 Revert "Disable control-flow analysis in SkSL. (Performance experiment)"
This reverts commit 50b1b2b90d.

Reason for revert: ending experiment

Original change's description:
> Disable control-flow analysis in SkSL. (Performance experiment)
>
> This CL will be used to test for potential performance regressions (or
> improvements?) that we might incur by disabling this optimization pass.
>
> It will be reverted in ~1 day.
>
> Change-Id: I775cdb0c95df81fa25ebbd66e4ff01f64c660f68
> Bug: skia:11319
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378456
> Commit-Queue: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>

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

Change-Id: Ie385a82db237ff5651348d82b9651f8ba09375b9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/379581
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-03-04 15:20:09 +00:00
John Stiles
50b1b2b90d Disable control-flow analysis in SkSL. (Performance experiment)
This CL will be used to test for potential performance regressions (or
improvements?) that we might incur by disabling this optimization pass.

It will be reverted in ~1 day.

Change-Id: I775cdb0c95df81fa25ebbd66e4ff01f64c660f68
Bug: skia:11319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378456
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-03 22:08:56 +00:00
Brian Osman
8e756f379c Support structs in runtime effects
Uses the pipeline-stage callback mechanism. It mangles the type name
(with a test to verify that this works), and then calls defineStruct
with the entire SkSL struct definition string.

Bug: skia:10939
Change-Id: If14cf1b11faaa80ad8d4086cdacf68532bac43fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368809
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-02-11 21:09:15 +00:00
John Stiles
0ac6c15075 Reduce self-assignment expressions (x = x) into just x.
Change-Id: I44356aa781f208f4941dbeb617a30318e36c1081
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/367062
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-10 20:00:05 +00:00
John Stiles
a0e407d4b7 Add SkSL test for matrix equality/inequality operators.
Disabled on Adreno 5xx/6xx as the tests do not pass on those GPUs:
http://screen/3Dkgs9syj37cjBV

Change-Id: Ib935d01e8f06dbfe7decd5cc4e52e0688b48be08
Bug: skia:11306, skia:11308
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368805
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-10 18:57:22 +00:00
John Stiles
01cdf0122f Reland "Add support for matrix == and != in Metal shaders."
This reverts commit 4908a24d4b.

Reason for revert: test fails on Adreno 5xx/6xx, will land tests
separately and disable on Adreno

Original change's description:
> Revert "Add support for matrix == and != in Metal shaders."
>
> This reverts commit c501857188.
>
> Reason for revert: breaking many bots
>
> Original change's description:
> > Add support for matrix == and != in Metal shaders.
> >
> > We need to polyfill an operator== and != when these are first
> > encountered in the code.
> >
> > Change-Id: I539c838ee1871bcb0c4b66abb8a4a0f91146cd4f
> > Bug: skia:11306
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368496
> > Auto-Submit: John Stiles <johnstiles@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com
>
> Change-Id: Id583109a0d167c2c58a57644b14cd5f49d670737
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:11306
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368801
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>

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

Bug: skia:11306
Change-Id: If7c628b8c7a2ce40d6c88599a7660ff91c4ac67a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368804
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-10 16:13:30 +00:00
Greg Daniel
4908a24d4b Revert "Add support for matrix == and != in Metal shaders."
This reverts commit c501857188.

Reason for revert: breaking many bots

Original change's description:
> Add support for matrix == and != in Metal shaders.
>
> We need to polyfill an operator== and != when these are first
> encountered in the code.
>
> Change-Id: I539c838ee1871bcb0c4b66abb8a4a0f91146cd4f
> Bug: skia:11306
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368496
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

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

Change-Id: Id583109a0d167c2c58a57644b14cd5f49d670737
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11306
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368801
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-02-10 14:25:54 +00:00
John Stiles
c501857188 Add support for matrix == and != in Metal shaders.
We need to polyfill an operator== and != when these are first
encountered in the code.

Change-Id: I539c838ee1871bcb0c4b66abb8a4a0f91146cd4f
Bug: skia:11306
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368496
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-09 22:53:18 +00:00
John Stiles
34c098d7f8 Add SkSL test demonstrating missed optimization with +=.
Currently, SkSL is able to constant-propagate `x = x + constant` into
`x = constant` when the starting value of x is known. However, it is not
able to do the same optimization for `x += constant`. This test
demonstrates that once += is encountered, we lose track of x's value and
can no longer propagate its value.

(This is equally true of all the op-assignment operators, += -=
*= /= etc.)

Change-Id: I3523e96baf9a73982cf3b09f0d23b95adacf106b
Bug: skia:11192
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368248
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-09 19:17:26 +00:00
John Stiles
ecd7c2278f Migrate the last SkSL tests in shared/ to dm.
The leftover tests in shared/ are not easily testable as Runtime
Effects; they do things that ES2 doesn't support or use a feature not
exposed directly by Runtime Effects.

Change-Id: I7ebe170cf713c4a0d2dbef333c1fcbac2410c67f
Bug: skia:11009
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/367059
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-02-08 21:37:48 +00:00
John Stiles
c2c1b0c460 Migrate some SkSL swizzle tests to dm.
Change-Id: I2bd6bf9c368359a2b21861c1b6f621040d335111
Bug: skia:11009
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/367056
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-02-08 16:16:28 +00:00
John Stiles
d437478348 Migrate even more SkSL tests to run in dm.
- ResizeMatrix
- ScalarConversionConstructorsES2
- StackingVectorCasts
- StaticIf
- SwizzleBoolConstants

Non-ES2 compatible tests:

- ResizeMatrixNonsquare
- ScalarConversionConstructorsES3

Newly discovered bugs:
- skia:11278 SPIR-V does not support casting non-square matrices

Change-Id: I7feb78f0380d0a9cb328ec61f96a364ad1281432
Bug: skia:11009, skia:11278
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366408
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-05 16:04:43 +00:00
John Stiles
3f14d28b59 Add SPIR-V support for doubly-swizzled lvalues.
This fixes the OutParamsTricky test.

Change-Id: If59637bc946b71b141ae1d90cf1652bf80b163c4
Bug: skia:11269
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366399
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-05 15:58:53 +00:00
John Stiles
b88b4e1a12 Migrate additional SkSL tests to run in dm.
- MultipleAssignments
- NegatedVectorLiteral
- NumberCasts
- OutParams
- OutParamsTricky (disabled on GPU due to skia:11269)

Change-Id: I87dc9c5019931f3d2dc3aafbe1e02d0eee2e1a05
Bug: skia:11009, skia:11269
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366400
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-02-04 22:12:27 +00:00
John Stiles
b44185086e Reland "Improve support for arrays in Metal."
This reverts commit 38df4c8470.

Reason for revert: updated ArrayTypes test for ES2 compatibility

Original change's description:
> Revert "Improve support for arrays in Metal."
>
> This reverts commit dd904af566.
>
> Reason for revert: breaks ANGLE
>
> Original change's description:
> > Improve support for arrays in Metal.
> >
> > Arrays in Metal now use the `array<T, N>` type instead of the C-style
> > `T[N]` type. This gives them semantics much more in line with GLSL,
> > so they can be initialized and assigned like GLSL arrays.
> >
> > This allows the ArrayTypes and Assignment tests to pass, so they have
> > been added to our dm SkSL tests. (ArrayConstructors also passes, but
> > is not ES2-compliant so it is not enabled.)
> >
> > Change-Id: Id1028311963084befd0e044e11e223af6a064dda
> > Bug: skia:10761, skia:10760, skia:11022, skia:10939
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365699
> > 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,ethannicholas@google.com,johnstiles@google.com
>
> Change-Id: If6a18dea7d6a45fa7836e9129bf81c2e536f07e3
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:10761
> Bug: skia:10760
> Bug: skia:11022
> Bug: skia:10939
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365976
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

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

Bug: skia:10761
Bug: skia:10760
Bug: skia:11022
Bug: skia:10939
Change-Id: Ia1c4917f5d3c41162d282b3093814d861707ad30
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366144
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-02-04 17:33:28 +00:00
John Stiles
16a97bb2cb Re-enable SkSL Hex test with constants that fit in 16 bits.
Larger constants caused failures on Adreno 330 (Nexus 5).

Change-Id: I1af1df786f8e4d34f8ec47152875927bfe948190
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366336
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-02-04 17:15:08 +00:00
John Stiles
1aa55de9a2 Disable SkSLHex test.
Fixes breakage on tree.

Change-Id: Ifc951535e482227bb415c85a3ee4d7523d17c43b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366278
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2021-02-04 14:24:40 +00:00
John Stiles
38df4c8470 Revert "Improve support for arrays in Metal."
This reverts commit dd904af566.

Reason for revert: breaks ANGLE

Original change's description:
> Improve support for arrays in Metal.
>
> Arrays in Metal now use the `array<T, N>` type instead of the C-style
> `T[N]` type. This gives them semantics much more in line with GLSL,
> so they can be initialized and assigned like GLSL arrays.
>
> This allows the ArrayTypes and Assignment tests to pass, so they have
> been added to our dm SkSL tests. (ArrayConstructors also passes, but
> is not ES2-compliant so it is not enabled.)
>
> Change-Id: Id1028311963084befd0e044e11e223af6a064dda
> Bug: skia:10761, skia:10760, skia:11022, skia:10939
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365699
> 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,ethannicholas@google.com,johnstiles@google.com

Change-Id: If6a18dea7d6a45fa7836e9129bf81c2e536f07e3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10761
Bug: skia:10760
Bug: skia:11022
Bug: skia:10939
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365976
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-02-04 00:50:34 +00:00
John Stiles
ecd2036eae Migrate more SkSL tests to run in dm.
- CastsRoundTowardZero
- Functions
- GeometricIntrinsics
- HelloWorld
- Hex

Other test updates:
- DeadLoopVariable (for-loop structure incompatible with ES2)
- FunctionPrototype (RTE currently disallows calling undef'd functions)
- HexUnsigned (unsigned types incompatible with ES2)

Change-Id: I794bee24dfac55281c9b8b130529888ba2546290
Bug: skia:11009
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/364678
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-03 23:45:15 +00:00
John Stiles
dd904af566 Improve support for arrays in Metal.
Arrays in Metal now use the `array<T, N>` type instead of the C-style
`T[N]` type. This gives them semantics much more in line with GLSL,
so they can be initialized and assigned like GLSL arrays.

This allows the ArrayTypes and Assignment tests to pass, so they have
been added to our dm SkSL tests. (ArrayConstructors also passes, but
is not ES2-compliant so it is not enabled.)

Change-Id: Id1028311963084befd0e044e11e223af6a064dda
Bug: skia:10761, skia:10760, skia:11022, skia:10939
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365699
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-03 22:33:19 +00:00
John Stiles
56233d1379 Migrate matrix SkSL test to dm.
This uncovered a bug in Metal code generation of `matX *= matY` which is
now fixed. (It was emitting the helper function more than once.)

Change-Id: I0aeb0efe7ab5fbf5592a8ca6f4f5b50354d3d7f4
Bug: skia:11262
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365489
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-02-03 20:42:57 +00:00
John Stiles
d80f966d25 Run SkSL tests with and without inlining.
Change-Id: Ie0f5485acf2a87321e881e98dc11115ab80dff95
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365484
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-03 18:50:49 +00:00
John Stiles
5a956ce54b Add more dm tests for the comma operator.
Change-Id: I37a95fd95c23a91c3510f922bab0569093e612a5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/364604
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-02-03 01:28:48 +00:00
John Stiles
931cad1d74 Update function-type-matching tests to work as Runtime Effects.
Previously, our only test was invoking `sin(1)` which is a pretty
ineffective test. Now, we test args and return types for all the basic
scalars/vectors/matrices.

Change-Id: I7d335303eef8b9c9c6cfef2265a15bbd9bd73e0c
Bug: skia:11246
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/363943
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-02-02 13:47:35 +00:00
John Stiles
c068a8f00b Update various shared/ tests to run in dm.
These tests have updated to return green on success, or red on failure.
Some tests were modified slightly to conform to ES2 limitations, or
split into separate ES2 and ES3 parts.

Change-Id: Ib47aeca217aef33f3c4b5999d93afed5d42a1e62
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/363876
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-01 22:06:59 +00:00
John Stiles
2ff8f86205 Run the SkSL Operators test as a Runtime Effect.
The test has been split into an ES2 version and ES3 version; the ES2
side omits unsupported integer ops like << >> & | ^ %.

Change-Id: Iba16d469a477809b17a823b1c68ae8937624c68e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362616
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-02-01 17:21:33 +00:00
John Stiles
94e72b90b8 Add test to verify side effects from the comma operator.
SkVMCodeGenerator was lacking support for the comma operator entirely;
this has now been implemented.

Change-Id: I9350f54e6ee52764c620116e6dbfe4ca3e9cd47e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/363096
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-02-01 16:16:58 +00:00
Mike Klein
6eee6b2736 Revert "Add intrinsic tests for mod() and fract()."
This reverts commit f06aeedcf1.

Reason for revert: fract failing on Tegra3

Original change's description:
> Add intrinsic tests for mod() and fract().
>
> These are fully supported by ES2 and will be covered by dm tests.
>
> Change-Id: Iebf4effe8ab928662b55c0bb5b09e8b2a61487ca
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362460
> 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>

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

Change-Id: Ib2071c90addd01e3b299553e020950a89eb01e4d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/363036
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-01-30 13:38:31 +00:00
John Stiles
f06aeedcf1 Add intrinsic tests for mod() and fract().
These are fully supported by ES2 and will be covered by dm tests.

Change-Id: Iebf4effe8ab928662b55c0bb5b09e8b2a61487ca
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362460
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-01-29 21:51:54 +00:00
John Stiles
9c9f60cdb4 Implement additional Runtime Effect intrinsic tests.
Tested in dm:
- max(halfN, halfN)
- max(halfN, half)
- min(halfN, halfN)
- min(halfN, half)
- clamp(halfN, halfN, halfN)
- clamp(halfN, half, half)
- mix(halfN, halfN, halfN)
- mix(halfN, halfN, half)

Compiled outputs only (not in ES2):
- max(intN, intN)
- max(intN, int)
- min(intN, intN)
- min(intN, int)
- clamp(intN, intN, intN)
- clamp(intN, int, int)
- mix(halfN, halfN, boolN)  - broken in Metal/SPIR-V (skia:11222)
- mix(intN, intN, boolN)    - broken in Metal/SPIR-V (skia:11222)

Change-Id: Iaafc5429b16d2a8710b9d171ae281c268c0fd70d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361438
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-01-29 18:23:48 +00:00
John Stiles
e1658b5977 Reland "Add some SkSL intrinsics to our dm tests."
This reverts commit b576168c8c.

Reason for revert: disabled floor test due to undiagnosed ANGLE + DX9 + Intel6000 failures

Original change's description:
> Revert "Add some SkSL intrinsics to our dm tests."
>
> This reverts commit 0492a744a5.
>
> Reason for revert: Intel HD6000 + ANGLE DX9 fails the floor() test.
>
> Original change's description:
> > Add some SkSL intrinsics to our dm tests.
> >
> > This CL adds dm coverage for:
> > - abs(half)
> > - sign(half)
> > - floor
> > - ceil
> >
> > And creates test output for abs(int) and sign(int); these aren't covered
> > by dm because they don't exist in ES2 and so are unsupported by Runtime
> > Effects.
> >
> > Change-Id: Ia3e660408cef50dec8fa4b6bdc12906e96179f6e
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/360419
> > Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
> > Commit-Queue: John Stiles <johnstiles@google.com>
> > Auto-Submit: John Stiles <johnstiles@google.com>
>
> TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com
>
> Change-Id: I62121efee9315b16e61e7d38659b6f629bdf8bd8
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362056
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

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

Change-Id: I22f22f631d85d93a8fe5686a99311ec2cf85fa4d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362103
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-01-29 17:58:18 +00:00
John Stiles
b576168c8c Revert "Add some SkSL intrinsics to our dm tests."
This reverts commit 0492a744a5.

Reason for revert: Intel HD6000 + ANGLE DX9 fails the floor() test.

Original change's description:
> Add some SkSL intrinsics to our dm tests.
>
> This CL adds dm coverage for:
> - abs(half)
> - sign(half)
> - floor
> - ceil
>
> And creates test output for abs(int) and sign(int); these aren't covered
> by dm because they don't exist in ES2 and so are unsupported by Runtime
> Effects.
>
> Change-Id: Ia3e660408cef50dec8fa4b6bdc12906e96179f6e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/360419
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>

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

Change-Id: I62121efee9315b16e61e7d38659b6f629bdf8bd8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362056
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-01-29 14:03:36 +00:00
John Stiles
0492a744a5 Add some SkSL intrinsics to our dm tests.
This CL adds dm coverage for:
- abs(half)
- sign(half)
- floor
- ceil

And creates test output for abs(int) and sign(int); these aren't covered
by dm because they don't exist in ES2 and so are unsupported by Runtime
Effects.

Change-Id: Ia3e660408cef50dec8fa4b6bdc12906e96179f6e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/360419
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-01-28 21:20:00 +00:00
Brian Osman
bf7b4b8890 Add SkSL test for functions that operate on structs
This is a known deficiency of runtime effects, next step is to fix how
they manage function signatures to solve the problem.

Bug: skia:10939
Change-Id: Id934e0acdf774b03bd6edce78d7b2c077bdeae00
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/360603
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-01-28 17:01:59 +00:00
John Stiles
7b92897d62 Reland "Add SkSL for-loop control flow test to dm."
This reverts commit 578f1acbe8.

Reason for revert: updated test to pass on Mac Intel 5100/6000

Original change's description:
> Revert "Add SkSL for-loop control flow test to dm."
>
> This reverts commit a0c266283a.
>
> Reason for revert: failing on Mac Intel
>
> Original change's description:
> > Add SkSL for-loop control flow test to dm.
> >
> > While loops and do-while loops remain untested in dm, as they are not
> > supported in ES2 (and therefore not available in Runtime Effects).
> >
> > Change-Id: I2f1bfccccd571cc4ced096bc18ebbb9ecc9f9b4a
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/359556
> > 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>
>
> TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com
>
> Change-Id: I45335d16a695644eaeb8a535298c0efcc616c1ce
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/359840
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

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

Change-Id: I2dc6e870393708a12286658001b723f25a6aec4a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/359856
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-01-27 15:46:39 +00:00
John Stiles
b41d5bb3a7 Add helper uniforms to Runtime Effect tests.
This lets us use descriptive names like `colorRed` and `colorGreen`
instead of `half4(1,0,0,1)` and `half4(0,1,0,1)`. It also lets us use
actual unknown values instead of synthesizing sorta-kinda-unknowns by
calling sqrt.

Change-Id: I61481c33b7ff42182955777b05cfa5fcc13e0efc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/359567
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-01-27 00:53:46 +00:00
John Stiles
578f1acbe8 Revert "Add SkSL for-loop control flow test to dm."
This reverts commit a0c266283a.

Reason for revert: failing on Mac Intel

Original change's description:
> Add SkSL for-loop control flow test to dm.
>
> While loops and do-while loops remain untested in dm, as they are not
> supported in ES2 (and therefore not available in Runtime Effects).
>
> Change-Id: I2f1bfccccd571cc4ced096bc18ebbb9ecc9f9b4a
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/359556
> 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>

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

Change-Id: I45335d16a695644eaeb8a535298c0efcc616c1ce
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/359840
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-01-26 21:35:45 +00:00
John Stiles
a0c266283a Add SkSL for-loop control flow test to dm.
While loops and do-while loops remain untested in dm, as they are not
supported in ES2 (and therefore not available in Runtime Effects).

Change-Id: I2f1bfccccd571cc4ced096bc18ebbb9ecc9f9b4a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/359556
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-01-26 19:55:55 +00:00
John Stiles
053f785903 Avoid relying on bit-perfect irrational numbers in test code.
Comparing sqrt(5) against a variable containing sqrt(5) was not working
properly in some versions of Android running Vulkan.

Change-Id: I4f6bbff78a9ba56ec6e222f2037d66b13e3cd635
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/358530
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-01-25 21:27:19 +00:00
John Stiles
232dd2b61b Reland "Run unit tests to verify SkSL folding behavior."
This is a reland of 4ecab92584

This reland folds in subsequent code cleanups and disables a test that
failed on Android + Vulkan.

Original change's description:
> Run unit tests to verify SkSL folding behavior.
>
> The unit test loads SkSL source files from `resources/sksl`, compiles
> the code, and uses SkRuntimeEffect to render a pixel using the effect.
> If solid green is rendered, the test passes.
>
> Change-Id: I2ccb427a907975ae84aee19d8e68d774b2cb638c
> Bug: skia:11009
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/355983
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: skia:11009
Change-Id: I09196c8ca3041e8957324a0cbb7f7d6963c6e4e7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/358523
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-01-25 17:49:36 +00:00
Greg Daniel
95c2994048 Revert "Run unit tests to verify SkSL folding behavior."
This reverts commit 4ecab92584.

Reason for revert: breaking all the vulkan bots

Original change's description:
> Run unit tests to verify SkSL folding behavior.
>
> The unit test loads SkSL source files from `resources/sksl`, compiles
> the code, and uses SkRuntimeEffect to render a pixel using the effect.
> If solid green is rendered, the test passes.
>
> Change-Id: I2ccb427a907975ae84aee19d8e68d774b2cb638c
> Bug: skia:11009
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/355983
> 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,ethannicholas@google.com,johnstiles@google.com

Change-Id: Ife32f6c33d9ba7a9580b66eb312cffb249c43cb2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11009
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/357780
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2021-01-23 00:01:23 +00:00
Mike Klein
e50b322e82 Revert "Consolidate SkSL CPU and GPU test code."
This reverts commit eeeaae9a02.

Reason for revert: other reverts
Original change's description:
> Consolidate SkSL CPU and GPU test code.
>
> This doesn't change any behavior conceptually, just allows the test code
> to share more logic between CPU and GPU sides.
>
> Change-Id: I3564f0310fd45c6ead9cd1ee6975915fe33919ee
> Bug: skia:11009
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/357596
> 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,ethannicholas@google.com,johnstiles@google.com

Change-Id: I7c6f26d0f84b8c290093c3e6088553f1130fc67e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11009
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/357996
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-01-23 00:00:44 +00:00
John Stiles
eeeaae9a02 Consolidate SkSL CPU and GPU test code.
This doesn't change any behavior conceptually, just allows the test code
to share more logic between CPU and GPU sides.

Change-Id: I3564f0310fd45c6ead9cd1ee6975915fe33919ee
Bug: skia:11009
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/357596
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-01-22 21:49:49 +00:00
John Stiles
4ecab92584 Run unit tests to verify SkSL folding behavior.
The unit test loads SkSL source files from `resources/sksl`, compiles
the code, and uses SkRuntimeEffect to render a pixel using the effect.
If solid green is rendered, the test passes.

Change-Id: I2ccb427a907975ae84aee19d8e68d774b2cb638c
Bug: skia:11009
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/355983
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-01-22 20:34:28 +00:00