Commit Graph

9394 Commits

Author SHA1 Message Date
John Stiles
83b0c830c6 Add support for built-in functions to DSLCPPCodeGenerator.
Change-Id: Idf65ff46cd75d23f550c8e763cf3618ec7501b38
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398877
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-04-22 21:56:22 +00:00
John Stiles
d85d720800 Add support for sample() to DSLCPPCodeGenerator.
This CL also removes some vestiges of the kSampler type, which hasn't
been used in .fp files for a long time.

Change-Id: Iaca1d0c6e77ad2df2b6c5dacd1c68079d6dd5cf2
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398738
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-04-22 21:13:13 +00:00
John Stiles
abde8fc182 Enable DSL FP tests.
These new tests rely on compiled shaders that live in the
`tests/sksl/dslfp/` directory; this CL updates the Bazel and
emscripten build scripts to include these shaders.

Change-Id: Ib670682af8bf451a4473504dd4cc76a0e9222129
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/400097
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-22 21:03:43 +00:00
Chris Dalton
57ab06c14e Delete mixed samples
Mixed samples is no longer relevant for Ganesh. DMSAA and the new
Ganesh architecture both rely on full MSAA, and any platform where
mixed samples is supported will ultimately not use the old
architecture.

Change-Id: I5acc745010e090ef26310d92ec6240be2cd494cf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399837
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-04-22 20:11:34 +00:00
John Stiles
47b48bc2be Reland "Add support for uniforms and layout(key)s to DSLCPPCodeGenerator."
This reverts commit 289da86e37.

Reason for revert: relanding

Original change's description:
> Revert "Add support for uniforms and layout(key)s to DSLCPPCodeGenerator."
>
> This reverts commit f33b061e3b.
>
> Reason for revert: Google3 roll and wasm build
>
> Original change's description:
> > Add support for uniforms and layout(key)s to DSLCPPCodeGenerator.
> >
> > Change-Id: I77c386e3d72fb4a5986e5efb8bc9d409200534d1
> > Bug: skia:11854
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398457
> > 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: I006ece639fa6051ff6ef1c496e648db9d5d0b30a
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:11854
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399498
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>


Bug: skia:11854
Change-Id: I1a4a4db471e2ad0b169b2b77784ca17e6286fbd2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/400036
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-22 20:04:32 +00:00
John Stiles
956802335d Reland "Reland "Implement statements and expressions in DSL C++ code generator.""
This is a reland of c412688798

This CL lands the code changes but not the dm test, which is causing
link errors. Tests will be relanded as a separate CL, at
http://review.skia.org/400097

Original change's description:
> Reland "Implement statements and expressions in DSL C++ code generator."
>
> This is a reland of 16cbfb41df
>
> Tests now rely on `shaderDerivativeSupport` and `integerSupport` as
> proxies to indicate ES3 support. The SwitchStatement test has been
> adjusted to hopefully confuse fewer compilers.
>
> Original change's description:
> > Implement statements and expressions in DSL C++ code generator.
> >
> > This CL removes the bulk of the existing C++ code generator, especially
> > all the complex format-string assembly code. It has been replaced with
> > actual DSL code generation. Simple IR can now be successfully translated
> > to a working DSL fragment processor.
> >
> > This CL also adds a simple test harness which is patterned after the
> > existing SkSLTest; it renders a pixel, reads it back, and fails the test
> > if the result isn't solid green (RGBA=0101).
> >
> > This CL doesn't implement every feature. Some obvious gaps include:
> > - Sampling from children
> > - Uniforms/inputs of any kind
> > - Function calls of any kind
> >
> > Change-Id: Ib80c23fe1ba4453f7c3cb43b65f93c5ea0deb709
> > Bug: skia:11854
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396757
> > Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
> > Commit-Queue: John Stiles <johnstiles@google.com>
>
> Bug: skia:11854, skia:11891
> Change-Id: I91363e31f34611d15ae350b52d6fc459feeace9c
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399076
> Auto-Submit: John Stiles <johnstiles@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>

Bug: skia:11854
Bug: skia:11891
Change-Id: Ib1f08256c84d1da2130e0b61356f72435dc0a5a8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399740
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-04-22 20:01:33 +00:00
John Stiles
126128b37c Revert "Reland "Implement statements and expressions in DSL C++ code generator.""
This reverts commit c412688798.

Reason for revert: fix Google3 roll and wasm build

Original change's description:
> Reland "Implement statements and expressions in DSL C++ code generator."
>
> This is a reland of 16cbfb41df
>
> Tests now rely on `shaderDerivativeSupport` and `integerSupport` as
> proxies to indicate ES3 support. The SwitchStatement test has been
> adjusted to hopefully confuse fewer compilers.
>
> Original change's description:
> > Implement statements and expressions in DSL C++ code generator.
> >
> > This CL removes the bulk of the existing C++ code generator, especially
> > all the complex format-string assembly code. It has been replaced with
> > actual DSL code generation. Simple IR can now be successfully translated
> > to a working DSL fragment processor.
> >
> > This CL also adds a simple test harness which is patterned after the
> > existing SkSLTest; it renders a pixel, reads it back, and fails the test
> > if the result isn't solid green (RGBA=0101).
> >
> > This CL doesn't implement every feature. Some obvious gaps include:
> > - Sampling from children
> > - Uniforms/inputs of any kind
> > - Function calls of any kind
> >
> > Change-Id: Ib80c23fe1ba4453f7c3cb43b65f93c5ea0deb709
> > Bug: skia:11854
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396757
> > Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
> > Commit-Queue: John Stiles <johnstiles@google.com>
>
> Bug: skia:11854, skia:11891
> Change-Id: I91363e31f34611d15ae350b52d6fc459feeace9c
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399076
> Auto-Submit: John Stiles <johnstiles@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>

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

Change-Id: I71a8cf31e8a013b7a2a0d10f0ad3bc3893ea07ea
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11854
Bug: skia:11891
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399499
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-22 13:45:00 +00:00
John Stiles
289da86e37 Revert "Add support for uniforms and layout(key)s to DSLCPPCodeGenerator."
This reverts commit f33b061e3b.

Reason for revert: Google3 roll and wasm build

Original change's description:
> Add support for uniforms and layout(key)s to DSLCPPCodeGenerator.
>
> Change-Id: I77c386e3d72fb4a5986e5efb8bc9d409200534d1
> Bug: skia:11854
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398457
> 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: I006ece639fa6051ff6ef1c496e648db9d5d0b30a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399498
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-22 13:43:20 +00:00
Chris Dalton
6ca9e18bf6 Update GrStrokeTessellator to make its own shader
Bug: skia:10419
Change-Id: I656e2508e95a47e03af431734ac06cbdb41232c6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398356
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-04-21 22:58:37 +00:00
Herb Derby
93250090c2 Reland "remove fAllocators from GrOpsTask"
This is a reland of f00d6a8efd

This change is significantly different from the original.

The lifetime of GrArenas on the GrSurfaceFillContext is from
first GrOpsTask creation to the completion of the first call
to GrOpsTask::onExecute. The overall lifetime of the GrArenas
is from first GrOpsTask creation until the last dtor of the
GrOpsTask.

There are checks in the GrArena to make sure that nothing is
allocated after it is removed from the GrSurfaceFillContext.

Original change's description:
> remove fAllocators from GrOpsTask
>
> Change-Id: I5901f005c2758a92692e5cd70ba46a2b5ad797fd
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393116
> Commit-Queue: Herb Derby <herb@google.com>
> Reviewed-by: Adlai Holler <adlai@google.com>
> Reviewed-by: Chris Dalton <csmartdalton@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

Change-Id: I9ca2ae09ddd3b3eb95981013f54ab4168b5c5b49
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397141
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-04-21 21:28:47 +00:00
John Stiles
f33b061e3b Add support for uniforms and layout(key)s to DSLCPPCodeGenerator.
Change-Id: I77c386e3d72fb4a5986e5efb8bc9d409200534d1
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398457
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-21 20:18:07 +00:00
John Stiles
c412688798 Reland "Implement statements and expressions in DSL C++ code generator."
This is a reland of 16cbfb41df

Tests now rely on `shaderDerivativeSupport` and `integerSupport` as
proxies to indicate ES3 support. The SwitchStatement test has been
adjusted to hopefully confuse fewer compilers.

Original change's description:
> Implement statements and expressions in DSL C++ code generator.
>
> This CL removes the bulk of the existing C++ code generator, especially
> all the complex format-string assembly code. It has been replaced with
> actual DSL code generation. Simple IR can now be successfully translated
> to a working DSL fragment processor.
>
> This CL also adds a simple test harness which is patterned after the
> existing SkSLTest; it renders a pixel, reads it back, and fails the test
> if the result isn't solid green (RGBA=0101).
>
> This CL doesn't implement every feature. Some obvious gaps include:
> - Sampling from children
> - Uniforms/inputs of any kind
> - Function calls of any kind
>
> Change-Id: Ib80c23fe1ba4453f7c3cb43b65f93c5ea0deb709
> Bug: skia:11854
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396757
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

Bug: skia:11854, skia:11891
Change-Id: I91363e31f34611d15ae350b52d6fc459feeace9c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399076
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-04-21 20:17:07 +00:00
Michael Ludwig
29c06bc82a Revert "Stop using copying SkPath::Iter for convexity and contains checks"
This reverts commit 3752760157.

Reason for revert: asan failures

Original change's description:
> Stop using copying SkPath::Iter for convexity and contains checks
>
> This also ensures that consecutive moveTos at the start and end of the
> path do not affect convexity, and updates AutoBoundsUpdate respects
> that as well.
>
> Bug: 1187385
> Change-Id: I9d9d7ab7f268003ff12e46873d7b98d993db47fe
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396056
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Mike Reed <reed@google.com>

TBR=csmartdalton@google.com,reed@google.com,michaelludwig@google.com

Change-Id: I46aaca9c709be7124fc3933f5d02f20f5d2b42ea
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1187385
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399376
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-04-21 19:43:18 +00:00
Michael Ludwig
3752760157 Stop using copying SkPath::Iter for convexity and contains checks
This also ensures that consecutive moveTos at the start and end of the
path do not affect convexity, and updates AutoBoundsUpdate respects
that as well.

Bug: 1187385
Change-Id: I9d9d7ab7f268003ff12e46873d7b98d993db47fe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396056
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-04-21 18:45:27 +00:00
Brian Osman
af4e2331d1 Add tests of the runtime effect stage factories
We were testing this with .rtcf and .rts files, but those don't go
through the MakeForXXX factories. This would have caught the bug fixed
in https://skia-review.googlesource.com/c/skia/+/398229

Change-Id: Id824e7bf32982c043978b2981cfd91dd7a9b2585
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398183
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-21 16:05:37 +00:00
John Stiles
8676ebe350 Demonstrate DSL for statements with multiple vardecls.
These now work, thanks to a combination of
http://review.skia.org/398221 and
http://review.skia.org/398017.

Change-Id: Ied1d6a39803c19dfa762a45e0ca4800820bb1c0a
Bug: skia:11868
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397219
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-04-21 15:03:37 +00:00
John Stiles
60191e0502 Revert "Implement statements and expressions in DSL C++ code generator."
This reverts commit 16cbfb41df.

Reason for revert: using ES3 features, breaks on ANGLE ES2 bots

Original change's description:
> Implement statements and expressions in DSL C++ code generator.
>
> This CL removes the bulk of the existing C++ code generator, especially
> all the complex format-string assembly code. It has been replaced with
> actual DSL code generation. Simple IR can now be successfully translated
> to a working DSL fragment processor.
>
> This CL also adds a simple test harness which is patterned after the
> existing SkSLTest; it renders a pixel, reads it back, and fails the test
> if the result isn't solid green (RGBA=0101).
>
> This CL doesn't implement every feature. Some obvious gaps include:
> - Sampling from children
> - Uniforms/inputs of any kind
> - Function calls of any kind
>
> Change-Id: Ib80c23fe1ba4453f7c3cb43b65f93c5ea0deb709
> Bug: skia:11854
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396757
> Reviewed-by: Ethan Nicholas <ethannicholas@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

Change-Id: I4f3e7667bf1e3a5539d0248b6c47d9ae2296aa88
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398739
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-20 19:59:37 +00:00
John Stiles
16cbfb41df Implement statements and expressions in DSL C++ code generator.
This CL removes the bulk of the existing C++ code generator, especially
all the complex format-string assembly code. It has been replaced with
actual DSL code generation. Simple IR can now be successfully translated
to a working DSL fragment processor.

This CL also adds a simple test harness which is patterned after the
existing SkSLTest; it renders a pixel, reads it back, and fails the test
if the result isn't solid green (RGBA=0101).

This CL doesn't implement every feature. Some obvious gaps include:
- Sampling from children
- Uniforms/inputs of any kind
- Function calls of any kind

Change-Id: Ib80c23fe1ba4453f7c3cb43b65f93c5ea0deb709
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396757
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-20 19:28:36 +00:00
Chris Dalton
f5b87f9b11 Make SkSurfaceProps non-optional for SDCs and SkSpecialImages
This ensures we don't lose the original SkSurfaceProps when creating
image filters, etc.

Bug: skia:11396
Change-Id: I6b412361c1005138278a1396faa7f7e069ec7eb2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397291
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-04-20 16:22:46 +00:00
John Stiles
49b409e680 Simplify for init-stmts at the IR level.
Most backends don't like init-stmts with multiple VarDeclarations inside
them, so we no longer emit IR that does this. This lets us avoid doing
backend-level fixups.

Change-Id: Ide839de18953a73e0f9c7a690df59a7bc3523f89
Bug: skia:11860
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398221
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-04-20 14:38:36 +00:00
Brian Osman
8f1dff6a9e Remove layout(marker) from runtime effect SkSL
This is another strange, experimental feature that clutters the
implementation and isn't used by anyone (to my knowledge).

Change-Id: I538b7eca0cd28aab32f4739b23459731ade9105e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398226
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-19 18:48:45 +00:00
Brian Osman
e49703faf2 Remove custom SkVertices data and runtime effect varying support
This was an experimental feature. It worked (but only the GPU backend).
It was never adopted or used by anyone, to my knowledge. It's a large
amount of code, and a strange corner of SkSL for users to stumble into.

Bug: skia:10680
Change-Id: I0dda0364bce7dbffa58c32de4c7801ec2a6bc42e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398222
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-19 17:49:25 +00:00
Chris Dalton
50f5e68b7c Use the word "precision" to describe "1/tolerance" for linearization
Bug: skia:10419
Change-Id: Ie01122ab8c9130367988fd2e264fcf4761862e89
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397656
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-04-19 17:38:35 +00:00
John Stiles
8e2a84be3d Fix for fuzzer-discovered error in SPIR-V compilation.
Unused InterfaceBlocks were not added to the ProgramUsage map. The
ProgramUsageVisitor now makes sure to account for them during its
initial scan.

Change-Id: If3afac8e954c5b685ddc6b63b0f771d8c0b8f207
Bug: oss-fuzz:33405
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398016
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-19 15:55:04 +00:00
Ethan Nicholas
db2326b46a Comma operator on DSL statements now creates unscoped blocks
Change-Id: I9eb85f25431b2d59b26e8cf8f4a73b9e45faa916
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398017
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-04-19 15:37:24 +00:00
Brian Osman
cc3d2d25c5 Runtime effects: Detect passthrough sample calls automatically
As explained, this is *very* conservative. It only works when the child
is sampled from within main, and using a direct reference to the coords
parameter. If that parameter is ever modified (even after being used),
the optimization doesn't happen. For most cases, this is fine.

Bug: skia:11869
Change-Id: Ia06181730a6d07e2a4fe2de4cc8e8c3402f0dc52
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397320
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-19 14:52:44 +00:00
Brian Salomon
d0f35c241c Reflatten YUVA image on each request.
It should now be rare to require a RGBA texture from a YUVA image (e.g.
in image filter)

Removes a thread-safety issue. A step towards allowing clients to pump
new data into the planes and be sure Skia wont draw the old contents.

Bug: skia:11873

Change-Id: I007cf28e477155f85ed9f1c6cc4547f9dbbb73fd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397319
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-04-19 14:52:04 +00:00
John Stiles
68072a4676 Perform the loop-exit test when continuing from inside a do-while.
SPIR-V would previously jump to the top of the do-while loop when
encountering a `continue`. This is not correct; it should jump to the
loop-exit test. We don't have any real shaders which test this case, and
it can't be checked from inside Runtime Effects since do-while is not
part of ES2.

Change-Id: Iac58e9e7ad0a94640e6418afea096b19ba50a2df
Bug: skia:11874
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397576
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-16 22:36:14 +00:00
Ethan Nicholas
a0f7654fbe SkSL For statement now enforces correct initializer type
Bug: skia:11870
Change-Id: I960800ac554e3c189d0b708fa6cabccf071fd020
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397460
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-16 20:48:03 +00:00
Ethan Nicholas
624a529fbd Added an API for creating RuntimeEffects using the SkSL DSL.
Change-Id: I305016d305455e2b90fe904d8da93cf7735cc38e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/389316
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-16 19:36:54 +00:00
Brian Osman
0962268099 Fix SampleUsage analysis for calls that use coords and color
Bug: skia:11867
Change-Id: I21e71c77518f0a942651f31061f43f80505090ea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397150
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-04-15 21:40:23 +00:00
Brian Osman
102d6e5a63 Add test case for sample() with color and various forms of coords
Demonstrates a bug that was introduced here:
  https://skia-review.googlesource.com/c/skia/+/396021

Bug: skia:11867
Change-Id: Iaa6521bdeb4c05b0b91f4df43505e9983106f964
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397148
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-15 20:34:42 +00:00
Brian Osman
6860db769b Insert newlines in generated FP constructors
Cleans up registerChild calls, which were all on one long line.

Change-Id: I2b665b033edb88cf1de5e4da433833c0be26c92b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397147
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-15 19:00:22 +00:00
Adlai Holler
b51dd577b9 Add GrResourceAllocator::reset
This is used in the fallback code when reordering produces
a DAG that goes over our memory budget.

Bug: skia:10877
Change-Id: I13772b30e270eb546957b88586ded1cf42d2dbeb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397136
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-04-15 17:04:10 +00:00
Herb Derby
0b1228d53e put an arena on GrRenderTargetProxy
This is a reland of 5a2de5e72f

This is part one of two CLs. In this CL, I put a
sk_sp<GrArenas> on GrRenderTargetProxy where GrArenas wraps
a SkArenaAlloc to add ref counting. Creating
a GrOpsTask shares the GrArenas with the ops task. When an
GrOpsTask is destroyed, it nulls out the fArenas sk_sp on
the GrRenderTargetProxy to limit the life span of the arenas.

New plumbing was added to GR_DRAW_OP_TEST_DEFINE to allow a
proper GrSurfaceDrawContext to be passed to GrAtlasTextOp's
GR_DRAW_OP_TEST_DEFINE so the arena will have a proper lifetime.

The second CL will work on replacing GrOpsTask's fAllocators
system with the shared arena.

Change-Id: Ieb568e4533c17e31b3b015e7781365d7d898c483
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396818
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-04-15 14:37:59 +00:00
Brian Osman
cbb60bd0b0 Add runtime color filter and shader modes to the SkSL compiler
These enforce stricter rules about the signature of main, and each one
uses a separate pre-include module. That prevents color filters from
being able to reference sk_FragCoord (or coords passed to main) at all.
It also limits the versions of sample() that are exposed.

In the new world, an effect created for a specific stage of the Skia
pipeline can only be used to create instances of that stage (SkShader or
SkColorFilter). For now, SkRuntimeEffect::Make uses kRuntimeEffect,
which continues to be more lenient and allow creation of either shaders
or color filters from a single effect. After we migrate all clients, we
can deprecate and then delete that mode.

Bug: skia:11813
Change-Id: I0afd79a72beeec84da42c86146e8fcd8d0e4c09f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395716
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-15 13:30:59 +00:00
John Stiles
f1ce6faf29 Fix for loops with multiple init-variables in GLSL.
When a Block is detected in the for loop's init-statement, we now
synthesize a scope and write the init-statement directly above the for
loop and leave the for loop's init-stmt section empty.

Change-Id: I3e89c6a4328a79e49b8a19faae7975629cd0e152
Bug: skia:11860
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396820
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-04-14 21:40:19 +00:00
Mike Klein
b91382ef3e remove SkNx::rsqrt()
The instructions used to implement it don't deliever
the same results across processors, even on the same
architecture.

Bug: skia:11861
Cq-Include-Trybots: luci.chromium.try:linux-blink-rel
Change-Id: I7831640fa6c0f01540619fce3f509c8969aaaaff
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396722
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-04-14 20:54:08 +00:00
John Stiles
a36fa6636b Fix for loops with multiple init-variables in Metal.
This is structured differently than the GLSL fix, due to the different
semantics of array-types in Metal.

Change-Id: I27ad11539bbbb96abb0686d5686b8fcd2f5dd6d1
Bug: skia:11860
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396916
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-04-14 20:47:48 +00:00
John Stiles
c5d860877e Add unit test for for-loop with multiple variables.
We lacked test coverage for this case, and this was broken when compound
VarDeclarations were split from one Statement into several.

Change-Id: I561b4d8acc0bfa01161d873a0c022ec58e316903
Bug: skia:11860
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396817
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-14 20:23:35 +00:00
Brian Salomon
5a32828e5e No VS specialization for identity or scale/trans in reduced shader mode
Modifies helpers on GrGLSLGeometryProcessor that insert, set, and make
keys for view/local matrix uniforms to not omit the uniform when
the matrix is identity or use a float4 when it is scale/trans. Always
uses a 3x3.

Bug: skia:11844
Change-Id: I0f25b60b46b8932d7e2cac4a50159d22b9cd84d2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395656
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-04-14 20:09:09 +00:00
Mike Klein
940ec1ca0e remove unused SkNx::invert()
The instructions used to implement it don't deliever
the same results across processors, even on the same
architecture.

Bug: skia:11861
Change-Id: Ifb87fc04a4ec866f84d7c2f2472c7f4b65661d28
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396721
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-04-14 19:27:38 +00:00
Brian Salomon
354147a23c Replace GrConstColorProcessor with a runtime FP
Change-Id: Ie36ea4d5186f6cca341efc6300b813ec8255bdbb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388457
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-04-14 18:40:18 +00:00
Brian Osman
cdee120180 Cache runtime color filter alpha-unchanged flag on the effect
This reuses the work we're already doing to compute the one-at-a-time
program, and lets us share the result across color filter instances
created from the same effect.

When we added caching of the flag to filter creation, pinpoint found a
performance regression. I expect this to resolve that.

Bug: chromium:1187432
Change-Id: Ie4f8551fa432d298ce950cba8642b9de28f19b81
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396758
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2021-04-14 14:35:28 +00:00
John Stiles
0a0a50ae97 Use .dsl.cpp suffix for DSL C++ instead of _dsl.cpp.
This requires the GN processing to be slightly more complex, as GN has
no native support for more than one extension on a file.
Context: https://groups.google.com/a/chromium.org/g/gn-dev/c/RdEpjeYtb-4

Change-Id: I630511fca9eb291f0e414481ef439f18a8e1b72f
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396197
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-04-14 13:49:53 +00:00
John Stiles
82ab3409f7 Fork CPPCodeGenerator into a DSL-based version.
The long term goal is for the DSLCPPCodeGenerator to replace the
CPPCodeGenerator entirely, but we will need both to coexist while DSL is
still under development.

Currently, the DSLCPPCodeGenerator is cloned from CPPCodeGenerator and
emits almost exactly the same code (it adds a comment at the top to
distinguish its output). Its output will change in followup CLs.

This CL also allows skslc to recognize the `_dsl.cpp` output suffix and
generate code using DSLCPPCodeGenerator instead of CPPCodeGenerator.
This allows test DSL FPs to be created for inspection.

Change-Id: If5136279c307ea53a9df3a292caa18344c1eb259
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396096
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-13 22:01:09 +00:00
Brian Osman
debcbbf6a8 Flip the arguments to sample() when passing both coords and a color
A subset of these signatures will be available to public SkSL, and
structured in a way that really pushes the coords as the primary
argument (and color as an optional one). In any case, I find this
ordering more natural.

Change-Id: I7b3bc962c5b305b9eeed1ae11ae1dc2ce7269364
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396021
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-13 19:06:07 +00:00
Brian Salomon
71283238d1 Reland "Remove code to push pixmaps to backend textures from GrGpu classes"
This is a reland of 45889d1269

Original change's description:
> Remove code to push pixmaps to backend textures from GrGpu classes
>
> Replace GrGpu::updateBackendTexture with narrower method that clears
> a backend texture.
>
> Creation of data for a solid color compressed texture is lifted up to
> GrDirectContext and goes through updateCompressedBackendTexture.
>
> Bug: skia:11786
> Change-Id: I1d617623df5e65686f30e57c361a64f78d77f7bd
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392836
> Reviewed-by: Jim Van Verth <jvanverth@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

Bug: skia:11786
Change-Id: Ibf85794a33e68acb17f0fb704f6815cd6460b3f2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396098
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-04-13 17:35:37 +00:00
Chris Dalton
2517ce39ca Add usesMSAASurface to GrMeshDrawOp::Target
Also switches GrFillRRectOp to call usesMSAASurface.

Bug: skia:11396
Change-Id: I66d0ee2c6dc76819efc0f3283f6e1a0af11f23f7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395136
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-04-13 16:50:00 +00:00
Brian Salomon
34012d7eee Revert "Remove code to push pixmaps to backend textures from GrGpu classes"
This reverts commit 45889d1269.

Reason for revert: compressed texture assertion on D3D bot

Original change's description:
> Remove code to push pixmaps to backend textures from GrGpu classes
>
> Replace GrGpu::updateBackendTexture with narrower method that clears
> a backend texture.
>
> Creation of data for a solid color compressed texture is lifted up to
> GrDirectContext and goes through updateCompressedBackendTexture.
>
> Bug: skia:11786
> Change-Id: I1d617623df5e65686f30e57c361a64f78d77f7bd
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392836
> Reviewed-by: Jim Van Verth <jvanverth@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

TBR=egdaniel@google.com,jvanverth@google.com,bsalomon@google.com

Change-Id: Ie58f52245c44c77f09742b0cb590cc97b97e6e37
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11786
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396097
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-04-13 16:17:42 +00:00