Commit Graph

9813 Commits

Author SHA1 Message Date
Greg Daniel
1a3f4ab490 Fix texture barriers on DMSAA
Bug: skia:11396
Change-Id: Iad74958c05ed086fe85656b9dc5418d5ab4589e7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419838
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-06-23 19:30:38 +00:00
Ethan Nicholas
d0f4d0d5d4 Switched more DSL APIs over to skstd::string_view
Change-Id: I87defa005fab8b1be92a700bf38c91b92c0ab8a7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420616
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-23 18:59:16 +00:00
Brian Salomon
b149700e01 Avoid non-indexed quad draws on PowerVR Rogue and 54x
Bug: chromium:1203652
Change-Id: Id83ac81c40eda2653e97a7c8ae9326c273f0f00b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420537
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-06-23 18:11:18 +00:00
Ethan Nicholas
b4f8b7a9f2 Cleaned up DSL error handling
This unifies various chunks of error handling code and makes the DSL
more gracefully handle failed object construction.

Change-Id: I4edc581c9eba276ce2ee2a17125ea7bd6057134a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420237
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-06-23 15:22:35 +00:00
John Stiles
e2c4e7e62d Add comparison operators to skstd::optional.
This involves a significant number of overloads, as optionals can be
compared against other optionals, or nullopt, or a value; either side
can mix and match as desired.

Change-Id: I26b8420e417300d32569fc76a55bcfd8e01eb322
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420576
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-06-22 21:11:15 +00:00
John Stiles
e53cf99728 Add nullopt to skstd::optional.
Change-Id: Ie0ed256fce79e2a03fcd468c820f468dc8bf25b5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420536
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-06-22 17:19:55 +00:00
Brian Osman
5946589e58 Replace GrOverrideInputFragmentProcessor with a runtime FP
Change-Id: Ife4dcd5627851b2dac1ed05b38c551d5d258e39c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419797
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-06-22 14:21:48 +00:00
Michael Ludwig
9f73b04b43 Fix use of fLastMoveToIndex in computeConvexity
Convexity is determined with a two pass algorithm, first by a sign
measure and then by a winding measure. Convexity also is meant to not be
affected by leading moveTos (other than the last leading moveTo before
real verbs) and not affected by trailing moveTos (since no additional
contour has actually started).

The old code would incorrectly reduce pointCount when the last moveTo
index was greater than 0, so the BySign pass was skipped or calculated
on an incomplete set of points. When a path (as the one added in this
CL's new test) is convex by winding but not by sign, it would be
incorrectly identified as convex. This led to further cascading issues
during rasterization.

However, the old code also had the effect of correctly ignoring any
last trailing moveTo from being included in the BySign test. Without
the new loop decrementing pointCount, trailing moveTo locations
would incorrectly create concave paths (and would in fact be concave
if the verb was anything other than a move).

I also realized that if the last moveTo index is not at the end of the
initial leading block, or at the end of the path entirely, then it
means the path must have multiple contours, at which point the path
cannot be convex, so we take the early out.

TBR: reed@google.com, bsalomon@google.com

Bug: skia:1220754
Change-Id: I9bd38f2eaaa3dbee135c190ade46fce0bd20257a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420238
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-06-22 00:34:28 +00:00
Chris Dalton
685e09b31a Reland "Purge ccpr"
This is a reland of 7bf6bc0d06

Original change's description:
> Purge ccpr
>
> Now that the clip atlas has been successfully migrated to
> tessellation, we don't need this code anymore!
>
> Change-Id: Ic97f50cff7c4ee59f4476f8410f0b30a32df4e90
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419857
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Chris Dalton <csmartdalton@google.com>

Change-Id: If0be86902e7cc4755eba91a89be1ec1a6a4b54b2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419720
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-06-19 18:42:38 +00:00
Brian Osman
fe83ab6706 Revert "Purge ccpr"
This reverts commit 7bf6bc0d06.

Reason for revert: Android build references kCoverageCounting

Original change's description:
> Purge ccpr
>
> Now that the clip atlas has been successfully migrated to
> tessellation, we don't need this code anymore!
>
> Change-Id: Ic97f50cff7c4ee59f4476f8410f0b30a32df4e90
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419857
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Chris Dalton <csmartdalton@google.com>

TBR=robertphillips@google.com,brianosman@google.com,csmartdalton@google.com,michaelludwig@google.com

Change-Id: I01d99287978f848eb8bf900c07cba90ceb3b6edc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419898
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-06-19 15:13:19 +00:00
Chris Dalton
7bf6bc0d06 Purge ccpr
Now that the clip atlas has been successfully migrated to
tessellation, we don't need this code anymore!

Change-Id: Ic97f50cff7c4ee59f4476f8410f0b30a32df4e90
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419857
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-06-18 21:46:36 +00:00
Mike Reed
12923c4696 Move more virtuals into ...Base to hide them from public api
Bug: skia:12111

Change-Id: I35601e0504e8e1186314e19bf53f01274bfc0ae0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419357
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-06-18 20:20:06 +00:00
John Stiles
9a2aa9708f Implement SkBlender support in SkVM.
A lot of the SkVM-related setup was already hooked up in
http://review.skia.org/416916. This CL finishes the job by hooking up
the SkPaint's SkBlender field to SkVM, and adds various checks
throughout Skia's software drawing code that can detect the presence of
an SkBlender.

Since only SkVM knows how to render an SkBlender correctly, we now need
to avoid the legacy blitter and RasterPipeline blitter whenever an
SkBlender is present on the paint. This CL fixes the cases that I've
found so far, while testing rendering with ovals and images. I'm sure
there are more cases lurking; these will be uncovered and dealt with in
future CLs.

Change-Id: I1a7b3d6625352b3cba8e4f8d4c61129d08ac6ae7
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419576
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-18 15:33:38 +00:00
John Stiles
9b170c6d3f Implement SkBlender support in Ganesh.
SkBlenderBase::asFragmentProcessor now returns a working runtime-blender
FP. This FP is appended to the end of the paintFP chain by
skpaint_to_grpaint_impl when an SkPaint contains an SkBlender, and the
GrPaint's XferProcessor factory is set to kSrc.

Unit tests have been added to verify basic functionality is working as
expected; more thorough drawing tests will be added once the CPU side is
running as well (since we don't want GMs that render differently on CPU
and GPU).

Change-Id: I255abd057fa75d638a9f2612c1a353be4de9e24c
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419358
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-06-18 15:13:18 +00:00
Robert Phillips
71143950f4 Switch GrMeshDrawOp::Target to be the stand alone GrMeshDrawTarget class
The Tessellator classes will survive in the NGA and they use
GrMeshDrawOp::Target - but GrMeshDrawOp will not survive.

This is a prelude to making all the remaining GrOp-derived classes OGA-only.

Bug: skia:11837
Change-Id: I62dc92e5f42d672342113f12dcedf3435fab993f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419198
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-06-17 19:57:43 +00:00
Robert Phillips
294723d690 Move GrOp::VisitProxyFunc to GrTypesPriv.h GrVisitProxyFunc
This is almost purely a query/replace CL (% the #include juggling).
The VisitProxyFunc is used by more than just the Ops and will probably
still be required in the NGA.

This is a prelude to making all the remaining GrOp-derived classes OGA-only.

Bug: skia:11837
Change-Id: If1c127e5c126c676be529ed2a61dd7953abb03d0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419162
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-06-17 17:23:35 +00:00
Brian Osman
171fba72bf Add OptFlags support to GrSkSLFP
Constant output for constant input is determined automatically from the
SkSL. The other two flags are trickier, so we just let the caller
specify them. This will be a key part of migrating .fp files to runtime
FPs.

Restored the preserves-opaque-input flag for color FPs when the color is
opaque (an optimization that was lost when this was initially converted
to a runtime FP).

Change-Id: I6d649ebc23257e2514f42373e51e22d8a65109a0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419161
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-06-17 17:16:53 +00:00
Brian Osman
cc2d073020 Remove SkPaint::getHash
This was a particularly bad hash (A == B didn't imply
hash(A) == hash(B)). It was also entirely unused.

Change-Id: Id923bf1035effce04e12b1cc01d1c6aa4d11fdb6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419336
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-06-17 14:59:23 +00:00
Brian Osman
b2cb817d23 Add the concept of an "input" FP to GrSkSLFP
FPs are used to represent effects with varying semantics. In particular,
shaders (that generate colors with no real input), and color filters
(that always have a "primary" input color on which they operate).

Even FPs that are not directly tied to a particular SkShader or
SkColorFilter tend to fall into these two categories. GrSkSLFP was
tailored to the shader semantics. It always supported having child FPs,
but these weren't considered "special" in any way - there could be
multiple, and each one could be sampled in whatever way the SkSL wanted.

This CL adds a dedicated "input" FP slot, so that color filters (and FPs
that resemble color filters) can naturally map better. Previously, we
had to inject an additional FP to do composition of the input and the
SkSL. That worked fine - this change is really about cutting down on
allocations and extra CPU work for that extra FP in the tree.

Change-Id: Ic37457b31f8ed7b4aa8d814a5e78806caa19e1c5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/418739
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-06-17 14:06:23 +00:00
John Stiles
491282486e Reland "Add SkRuntimeBlender class."
This is a reland of 6034941cc2

Original change's description:
> Add SkRuntimeBlender class.
>
> This class is returned by SkRuntimeEffect::makeBlender when a runtime
> blend is returned. SkRuntimeBlendBuilder is also added as a convenience
> class to simplify creation and uniform setup.
>
> Our ability to add tests is limited in this CL because the SkPaint does
> not contain an SkBlender yet. We do have one test which builds an
> SkBlender, but there's not much we can do with it. Testing will be
> bulked up in the next CL.
>
> Change-Id: Ib2d7d04186690ec0d2238fc990a19d9e6b786ce3
> Bug: skia:12080
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417006
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: skia:12080
Change-Id: Ie41be141ba3787452f9d5c72946ebc748a5d6176
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419160
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-17 12:54:01 +00:00
Kevin Lubick
be03ef1565 Remove ableist language
Change-Id: Ie9ef50a14906c9350adbe16720291dca944ad7fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/418738
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Jorge Betancourt <jmbetancourt@google.com>
2021-06-16 21:37:21 +00:00
Mike Reed
5837aad590 Expose bounds for maskfilters
Bug: skia:12094
Change-Id: Ia0dfa15fef2cd2f5fe7e024e085e56880c12224b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419098
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-06-16 21:24:30 +00:00
Brian Osman
3e4ef49890 Remove SkBlendMode from SkSL
We've lived without this for a long time. It bloats sksl_gpu (inhibits
some inlining!), and if things go according to plan, we'll be removing
enum support from SkSL entirely soon.

Change-Id: If844bbe5fdae41df7930d5c8ea9b832f9dd1b922
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419099
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-06-16 21:01:30 +00:00
John Stiles
c804b740b8 Revert "Add SkRuntimeBlender class."
This reverts commit 6034941cc2.

Reason for revert: breaking MSVC build 

Original change's description:
> Add SkRuntimeBlender class.
>
> This class is returned by SkRuntimeEffect::makeBlender when a runtime
> blend is returned. SkRuntimeBlendBuilder is also added as a convenience
> class to simplify creation and uniform setup.
>
> Our ability to add tests is limited in this CL because the SkPaint does
> not contain an SkBlender yet. We do have one test which builds an
> SkBlender, but there's not much we can do with it. Testing will be
> bulked up in the next CL.
>
> Change-Id: Ib2d7d04186690ec0d2238fc990a19d9e6b786ce3
> Bug: skia:12080
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417006
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

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

Change-Id: Id916f7458b827cbfdbc951c8f02aed16e2f44935
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419159
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-06-16 20:59:42 +00:00
John Stiles
6034941cc2 Add SkRuntimeBlender class.
This class is returned by SkRuntimeEffect::makeBlender when a runtime
blend is returned. SkRuntimeBlendBuilder is also added as a convenience
class to simplify creation and uniform setup.

Our ability to add tests is limited in this CL because the SkPaint does
not contain an SkBlender yet. We do have one test which builds an
SkBlender, but there's not much we can do with it. Testing will be
bulked up in the next CL.

Change-Id: Ib2d7d04186690ec0d2238fc990a19d9e6b786ce3
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417006
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-16 20:34:50 +00:00
Chris Dalton
e8f6663287 Disable tessellation instead of CCPR in GrClipStack_SWMask
Change-Id: Ide987cebc40e7175d581c96977eea6acd76b5cff
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419076
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-06-16 18:49:10 +00:00
John Stiles
9300391a77 Add Make functions for runtime blends.
This does basic plumbing work, but lacks a real implementation for the
custom blend subclass. That subclass is added in the followup CL of this
CL chain.

Change-Id: I8db0eb42737a739b49741ffd6f4a283a2c0a9d62
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417005
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-06-16 18:19:57 +00:00
Robert Phillips
3674f589ee Make GrPathRenderer and all derived class be OGA-only
Bug: skia:11837
Change-Id: I92aacf8b412d0158036a5f27aa767590e426bd5c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417657
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-06-16 17:09:37 +00:00
Brian Osman
70ae91f5b2 Support specializing uniforms in runtime FPs
http://go/rteffect-uniform-enhancements

Change-Id: Icb69b87049488a3baf234d45fe1e6a3c96a16d5e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417856
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-06-15 18:49:19 +00:00
Ethan Nicholas
4f3e6a261b Moved DSLWriter::ReleaseProgram into DSLCore.
This makes the API accessible from the upcoming DSLParser.

Change-Id: I0ee31c7648e35dfeaa50285cf93dcdb9dd4872bd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417678
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-06-15 14:08:07 +00:00
Robert Phillips
1ca0da4b91 Make GrClipStack, GrClipStackClip, and GrReducedClip OGA-only
GrStencilClip and GrStencilMaskHelper just come along for the ride

Bug: skia:11837
Change-Id: I7cfa2dd620b7457e6b6be4abf91b1ecd415d9b73
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417680
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-06-15 12:48:34 +00:00
Michael Ludwig
9d1cc05100 Add scratch-only version of performDeferredCleanup
Change-Id: I5707d1da1b69ab1ffaa77d7a391a187ac3e8eba1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417267
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-06-10 18:13:23 +00:00
Ethan Nicholas
962dec40cb Removed StringFragment alias in favor of skstd::string_view
Change-Id: I026a8a6b452d4cb8adce4d5d4908aaf2e71f2555
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417516
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-06-10 18:07:03 +00:00
John Stiles
9c19b9f1ff Fix for fuzzer-discovered out-of-bounds array access.
Change-Id: I4280b5710dd8749ba766ba74d7a8886bc4e024bb
Bug: oss-fuzz:35124
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417200
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-06-10 14:32:10 +00:00
John Stiles
50d0d097c3 Add dest-color support to the Pipeline stage.
Previously, when converting a program, the pipeline stage could assume
that an input to main() of type half4/float4 was always the input color.
This was a good assumption since the only possible inputs were
coordinates, or the input color.

This CL now recognizes that when a second float4 is passed to the main()
function, it should be a SK_DEST_COLOR_BUILTIN. This will let blend
functions pass in two colors.

ProgramToSkVM now takes a dest-color argument as well, but existing call
sites won't reference it (since they aren't for blend functions). I've
just passed the input-color a second time, since the value will never
actually be accessed.

Change-Id: I4214586bda605c6d287aa25b1b099e6ef5ba15a4
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417261
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-09 22:09:21 +00:00
Brian Osman
03f1d12b64 Allow image filters to require a translation-only layer transform
Will be used for first version of runtime image filters.

Bug: skia:12074
Change-Id: I2d7fc3af77d5df8182fd3f3d8da888e20ee05b34
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416778
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-06-09 21:34:44 +00:00
John Stiles
f7f36ae077 Add ProgramKind::kRuntimeBlend for Runtime Blend functions.
Runtime Blend effects always take two input colors--source and
destination--instead of one. This CL adds a new ProgramKind for blend
effects, a new program module (empty for now), and adds a test to
confirm that the signature for blend functions is checked. Currently
these are only accessible via skslc; there's no Runtime Effect API to
create one and the dest color isn't hooked up to anything.

Change-Id: I5272a811d2d76b878cfdf3429efa78c9c8b3fd97
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416798
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-08 19:34:39 +00:00
Brian Salomon
3650f6d9e5 Revert "Reland "Reland "Use SkImage_Raster's unique ID to cache textures."""
This reverts commit 10461f3a6a.

Reason for revert: perf regression for tiled draw bitmaps

Each tile gets wrapped in a temp SkImage_Raster. Because each tile is
created from a SkBitmap that represents a subset of a SkPixelRef
the SkImage always gets a new unique id instead of sharing the SkPixelRef's gen id. Thus, with this change we never get a cache
hit since we're using the image rather than the bitmap's id.

Bug: chromium:1216194

Original change's description:
> Reland "Reland "Use SkImage_Raster's unique ID to cache textures.""
>
> Bug: skia:11983
>
> Change-Id: Ib637af99f4abcd427570bd4dda31488fbcb14ab7
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414876
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: skia:11983
Change-Id: Icc7f38ff568908d439af9060e3b30e44463818c0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416796
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-06-08 18:07:47 +00:00
Chris Dalton
7ad3aa20c9 Fix DMSAA loads on ES/ANGLE
ES and ANGLE don't support framebuffer blits from single to
multisample. On these platforms we now perform a draw instead.

Bug: skia:12069
Bug: angleproject:6030
Change-Id: Ida0a5e9b556c4715fa63cb98aba185e64c72b28e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/415767
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-06-08 17:45:46 +00:00
Chris Dalton
89d460f27b Skip the SkRemoteGlyphCache_DrawTextAsDFT test if not supported
Change-Id: I4f4630e5b3af2531871028f75fa99e1e827dea29
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416762
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-06-08 17:36:06 +00:00
Chris Dalton
155c33c859 Add a workaround for "ldexp(..., -x)" on Mac/Radeon/GLSL
Bug: skia:12076
Change-Id: Ia7aabe2e048a05475d25811af657228ea39d75ba
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416561
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-06-08 01:39:38 +00:00
Ethan Nicholas
2c9a6ec3a0 Added skstd::string_view
Change-Id: Id02ed33b4fe60663327cc50d79db2bf876ad6df7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/415458
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-06-07 21:48:37 +00:00
Brian Osman
443b5da2d2 Remove GrRuntimeFPBuilder, SkRuntimeEffect::makeFP
All callsites moved to the new templated GrSkSLFP factory

Change-Id: If8d0419379c96b5a52b2576a5da1b0a3da8cccbf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/415916
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-06-07 18:50:47 +00:00
Brian Salomon
dc03537758 Reland "Limit ANGLE PBO workaround to blocking use of GL_UNPACK_ROW_LENGTH"
This is a reland of 7788b3a62f

Original change's description:
> Limit ANGLE PBO workaround to blocking use of GL_UNPACK_ROW_LENGTH
>
> Previously we blocked all PBO->texture transfers.
>
> Bug: angleproject:5542
>
> Change-Id: I1decfbc9293c03da125716c73e6d635e2ab9cb1d
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406997
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

Bug: angleproject:5542
Change-Id: Id2474a47bdab368d36ddfbed335a8c58d5567fad
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416477
Commit-Queue: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-06-07 18:23:17 +00:00
Robert Phillips
516405c5b0 Add option to switch between OGA and NGA SkGpuDevices
Bug: skia:11837
Change-Id: Id52f05a055c97cd2644bc70d600e9313766f6730
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/415796
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-06-07 15:23:40 +00:00
Chris Dalton
fc8cf91cee Revert "Limit ANGLE PBO workaround to blocking use of GL_UNPACK_ROW_LENGTH"
This reverts commit 7788b3a62f.

Reason for revert: May be the cause of TransferPixelsToTextureTest failures

Original change's description:
> Limit ANGLE PBO workaround to blocking use of GL_UNPACK_ROW_LENGTH
>
> Previously we blocked all PBO->texture transfers.
>
> Bug: angleproject:5542
>
> Change-Id: I1decfbc9293c03da125716c73e6d635e2ab9cb1d
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406997
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: angleproject:5542
Change-Id: I5f1047e110aebe36800a7f807dba832ba27a8b3d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416056
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-06-07 12:49:21 +00:00
John Stiles
0fbc6a3bcb Fix up names from RenderTargetContext to SurfaceDrawContext.
RenderTargetContext was renamed several months ago; this CL just fixes
up a few related names which hadn't yet updated yet.

Change-Id: I59a6ea92fc5d309a9b45a83e3aca6e49cb8d662e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/415745
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-06-04 19:37:14 +00:00
Brian Salomon
7788b3a62f Limit ANGLE PBO workaround to blocking use of GL_UNPACK_ROW_LENGTH
Previously we blocked all PBO->texture transfers.

Bug: angleproject:5542

Change-Id: I1decfbc9293c03da125716c73e6d635e2ab9cb1d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406997
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-06-04 16:40:54 +00:00
Robert Phillips
6dd19477c5 Make the SkGpuDevice factories return SkBaseGpuDevices
and make SkSurface_Gpu hold an SkBaseGpuDevice.

Bug: skia:11837
Change-Id: Ief3b78440bce95a6b95f26642130ba8e2f2f3193
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/415460
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-06-04 14:13:13 +00:00
Robert Phillips
fa8af0a545 Add methods to access the top device's render target proxy
While the SDC-accessing versions have to stick around due to their
usage in unit tests, they will return null when exercising the NGA.
The render-target-proxy versions will work in both the OGA and NGA
and should, thus, be prefered.

Bug: skia:11837
Change-Id: I36213472e46e9da3ae6561f80d413090ceb6ad3e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/415058
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-06-03 18:16:27 +00:00
Brian Salomon
3e2fe2b007 One function for computing rt-adjust uniform once flip is determined.
Add some comments explaining why different APIs flip the way they do.

Remove flip from Metal code generator and reverse the way flipping
occurs in Metal backend.

Change-Id: Ibec71e8d96c66d4b34b5ce6417056674090f979c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/413236
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-06-02 19:02:06 +00:00
Chris Dalton
e6f45318ef Make GrWangsFormula::conic take "precision" instead of "tolerance"
Rearranges the algebra to use "precision". This makes it consistent
with the other formulas and removes the need for the caller to think
about inverting its precision value.

Bug: skia:10419
Change-Id: I186d03393952983e86b0bef69e1f89f86cdbb423
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414616
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Tyler Denniston <tdenniston@google.com>
2021-06-02 18:58:06 +00:00
Brian Salomon
10461f3a6a Reland "Reland "Use SkImage_Raster's unique ID to cache textures.""
Bug: skia:11983

Change-Id: Ib637af99f4abcd427570bd4dda31488fbcb14ab7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414876
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-06-02 18:41:56 +00:00
John Stiles
52cb1d059d Rename GrXferProcessor::DstProxyView to GrDstProxyView.
At present, only Xfer processors allow reading back from the destination
image since they are in charge of blending. However, we'd like to expose
the destination color to fragment processors and Runtime Effects in the
future. To make this possible, the DstProxyView will need to be
accessible outside of Xfer processors.

This CL migrates DstProxyView to be a top-level Ganesh class and fixes
up the references to it throughout Skia. It's interesting to note that
several call sites were already using typedefs to hide the class
nesting anyway.

Change-Id: I93a294aa097f9319a968503c4f2f7e4f388ff033
Bug: skia:12066
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414899
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-06-02 18:00:47 +00:00
Chris Dalton
feb099c403 Delete GrStrokeIndirectTessellator
Bug: skia:10419
Change-Id: I3393dbdbe33967d03e31ced4d1612fa228fc7acc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414584
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-06-02 15:50:53 +00:00
Chris Dalton
3b412788fd Move tessellation shader files into a subdirectory
Also renames GrStrokeShader -> GrStrokeTessellationShader.

Bug: skia:10419
Change-Id: I75b09f794ef86a4cd8c467a1fd61cc87fe68091b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/413756
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-06-01 20:26:13 +00:00
John Stiles
d774558eb1 Implement compile-time optimization for mix().
mix() has many overloads:
$genType mix($genType x, $genType y, $genType a);
$genType mix($genType x, $genType y, float a);
$genHType mix($genHType x, $genHType y, $genHType a);
$genHType mix($genHType x, $genHType y, half a);
$genType mix($genType x, $genType y, $genBType a);
$genHType mix($genHType x, $genHType y, $genBType a);
$genIType mix($genIType x, $genIType y, $genBType a);
$genBType mix($genBType x, $genBType y, $genBType a);

The top half were simple to implement via `evaluate_3_way_intrinsic`.

The bottom half--`x, y, $genBType`--required adding basic support into
`evaluate_n_way_intrinsic_of_type` for mixed argument types, since `x`
and `y` could be of any numeric type, but `a` is always boolean.
Fortunately, this didn't require major changes.

Change-Id: I015471f053c90d5a5c3ac67cc230d0f90950ff60
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414443
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-06-01 19:36:05 +00:00
John Stiles
598c5e5b07 Implement compile-time optimization for matrixCompMult().
$mat matrixCompMult($mat x, $mat y);
$hmat matrixCompMult($hmat x, $hmat y);

This required some minor changes to `evaluate_n_way_intrinsic_of_type`
to allow the inputs to be matrices instead of vectors. Fortunately, most
of the moving parts were already generic/flexible enough that this just
worked, but some explicit checks for `x.isVector` needed to become
`!x.isScalar()`, and `columns` needed to become `slotCount`.

Change-Id: I1e22ecad37a7e187a7171e1f590a720f07cf9832
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414436
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-06-01 19:35:23 +00:00
Ethan Nicholas
8f73edeaf6 Added more SkTOptional APIs
This adds copy constructors / assignment operator, reset(), value(), and
has_value() to SkTOptional.

Change-Id: I564552a75a4c612685cdaa8e80e4359b394b64a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414338
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-06-01 18:54:13 +00:00
John Stiles
9df48c6ba6 Add test for literals that overflow int64.
This was handled properly, but lacked a test.

Change-Id: I84adc7cb3d37ab85eef945c1e38fc43c6cd8aa01
Bug: skia:10932
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414437
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-06-01 17:34:23 +00:00
John Stiles
b0d93ccc90 Detect out-of-range integer assignment.
Now that we know the minimum and maximum values of a given integer Type,
we can check for assigment statements or variable initial-values that
exceed those bounds and report it as an error. This check should work on
anything that can be optimized or folded down to an IntLiteral, but
isn't meant to be 100% exhaustive.

Change-Id: I4473b5b003e1b8e3385943ce60e303e95664e8ba
Bug: skia:10932
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/413437
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-06-01 15:53:43 +00:00
John Stiles
c43dc5e038 Implement compile-time optimization for cross().
We need to be careful to distinguish cross(vec3, vec3)--a real built-in
intrinsic--from cross(vec2, vec2)--an inline function in sksl_gpu, but
not actually a legitimate GLSL intrinsic.

Change-Id: I7e78c99dadfcbb637ae55a2503acfb7e591c932e
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/413440
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-06-01 15:51:53 +00:00
John Stiles
b069582d16 Add regression test for oss-fuzz:32156.
The fuzzer found that it could overflow an int via a properly-crafted
constant-fold expression, leading to a UBSAN error. Constant-fold
expressions now guard against overflow (http://review.skia.org/413138)
and UBSAN is no longer triggered.

Change-Id: I07dba41e87bb9ceed37b84ec6b8922defbdc6550
Bug: oss-fuzz:32156, skia:12050
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/413836
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-06-01 15:19:13 +00:00
John Stiles
e4ac484ac0 Implement compile-time optimization for atan().
This is one of the few compile-time constant functions with a variable
number of arguments, but it's otherwise pretty normal as intrinsics go.

$genType  atan($genType  y, $genType  x);
$genHType atan($genHType y, $genHType x);
$genType  atan($genType  y_over_x);
$genHType atan($genHType y_over_x);

Change-Id: Ie852e10f37d73d53f69e806550872bc015f802d6
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/413439
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-06-01 15:16:43 +00:00
John Stiles
7d341a37f7 Add unit test for Type::minimumValue and Type::maximumValue.
This test confirms that our logic to derive the min and max value of a
given integer type actually matches reality.

Change-Id: I1cb5fba6bfb9ffdcf4972d8feed79cf71e11d0ca
Bug: skia:10932
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/413376
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-27 20:45:57 +00:00
John Stiles
35981296a8 Prevent overflow of integral types during constant-folding.
Expressions which would overflow/wrap the result type are now left
as-is.

Change-Id: I6a942f337e6e5761823f5c9dcd214fa58227a626
Bug: skia:10932, skia:12050
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/413138
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-27 20:12:57 +00:00
Chris Dalton
6edc8d9617 Remove 'hasUserStencilSettings' from GrClip::apply
This doesn't seem necessary. Its only purpose was to disable analytic
clips when there were user stencil settings, which seems like a
de-optimization. The ops that use stencil all seem to properly handle
clip processors in their color pass, so it should be fine to remove
this.

Bug: skia:12047
Change-Id: Ide0ae1004548d62b2feb73c6950bcbcaf6716cfd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/413099
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-05-27 17:14:37 +00:00
John Stiles
b01c18625e Implement compile-time optimization for inverse().
$squareMat inverse($squareMat m);
$squareHMat inverse($squareHMat m);

Change-Id: I1a2b067dd276bb999107712c38d0124811b95e39
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412937
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-27 13:57:00 +00:00
John Stiles
afaddc959c Prevent overflow to infinity in constant-folding.
Expressions which would optimize to a non-finite value are now left
as-is.

Integer math still has problems with overflow, but that can be addressed
separately.

Change-Id: I363a2c42684989062f606186f48246b7ac5b585c
Bug: skia:12050
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412956
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-27 13:23:40 +00:00
John Stiles
b35fbdbb06 Add test demonstrating overflow error in SkSL.
Change-Id: Ic6a3ce722c607d4d3c47d37e5749a01ae5fb193f
Bug: skia:12050
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412668
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-26 21:52:31 +00:00
John Stiles
f47cfa8be5 Implement compile-time optimization for refract().
$genType refract($genType I, $genType N, float eta);
$genHType refract($genHType I, $genHType N, half eta);

The half form of refract was originally taking a `float eta` in our
headers, which seems wrong (and causes the DSL to break unless you add
casts). I've corrected the headers to use `half eta`.

Change-Id: I74b9ac330e0f7e99622d19cf7365aaa4cc910e57
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412664
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-26 19:55:39 +00:00
John Stiles
c3ff098020 Implement compile-time optimization for pow().
Change-Id: I1630cf6ecab6a1a18a7318c247f8263d87e2cda9
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412662
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-05-26 19:54:09 +00:00
John Stiles
4ceccaf053 Implement compile-time optimization for reflect().
$genType  reflect($genType  I, $genType  N);
$genHType reflect($genHType I, $genHType N);

Change-Id: I59889ad767829bf7e33838737d7b7f6d1cbc3ece
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412777
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-26 19:49:29 +00:00
John Stiles
7cfa1ce9db Implement compile-time optimization for faceforward().
This implementation leans heavily into DSL. I also reworked the
`normalize` intrinsic to use more DSL to shrink the implementation.

$genType faceforward($genType N, $genType I, $genType Nref);
$genHType faceforward($genHType N, $genHType I, $genHType Nref);

Change-Id: I73ab11d3fe449d2f2c0ae0d745fc39824fc64771
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412637
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-26 16:28:48 +00:00
John Stiles
3ef2c61c50 Implement compile-time optimization for normalize().
This one is structured a bit differently; it gets to length() value,
then divides the input by its length using a bit of DSL. Since all the
inputs are constant, the constant-folder will do the right thing.

$genType normalize($genType x);
$genHType normalize($genHType x);

Change-Id: I51e5c65fa9e33738cbe253fcc97ee2160c48cfdd
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412340
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-26 15:06:08 +00:00
John Stiles
419d2ced2d Implement compile-time optimization for dot().
float dot($genType x, $genType y);
half dot($genHType x, $genHType y);

Change-Id: Ia8b893eaddd8b4325c34143c80fb0ae05b111666
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412339
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-26 15:05:08 +00:00
John Stiles
e1c2beb3be Implement compile-time optimization for distance().
float distance($genType p0, $genType p1);
half distance($genHType p0, $genHType p1);

Change-Id: I492a90c0fe5c950c878752d45c3b2dc6f2cd866e
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412379
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-05-26 14:11:58 +00:00
John Stiles
9b2baac1d6 Implement compile-time optimization for length().
float length($genType x);
half length($genHType x);

Change-Id: I65b64fdba5f7bd53afba1d6f930217e3f1bd6f6e
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412377
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-26 00:58:53 +00:00
John Stiles
e5240a2498 Implement compile-time optimization for mod().
$genType mod($genType x, float y);
$genType mod($genType x, $genType y);
$genHType mod($genHType x, half y);
$genHType mod($genHType x, $genHType y);

Change-Id: I406eafbe824d7aa55012196521e6f10cac50ed19
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412376
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-25 22:07:53 +00:00
John Stiles
4987c4af49 Implement compile-time optimization for smoothstep().
$genType smoothstep($genType edge0, $genType edge1, $genType x);
$genType smoothstep(float edge0, float edge1, $genType x);
$genHType smoothstep($genHType edge0, $genHType edge1, $genHType x);
$genHType smoothstep(half edge0, half edge1, $genHType x);

Change-Id: Idf6a39fab8d5b81d4a3233444a8b381460cbde71
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412356
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 20:32:46 +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
0727a80885 Implement compile-time optimization for clamp().
$genType clamp($genType x, $genType minVal, $genType maxVal);
$genType clamp($genType x, float minVal, float maxVal);
$genHType clamp($genHType x, $genHType minVal, $genHType maxVal);
$genHType clamp($genHType x, half minVal, half maxVal);
$genIType clamp($genIType x, $genIType minVal, $genIType maxVal);
$genIType clamp($genIType x, int minVal, int maxVal);

Change-Id: I726270e84fca781825e59abed0c8c7d099ca7444
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411839
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 16:25:42 +00:00
Brian Osman
8cdf28fe2d Elide sample coords for GrSkSLFP if only used for pass-through sampling
If every use of the coords passed to main was for a call to sample that
was converted to pass-through sampling... We don't actually reference
the sample coords, so we can un-set the flag. This prevents the FP from
requesting an extra set of (unused) coords, which saves a varying
between the vertex and fragment shaders.

Bug: skia:11869
Change-Id: I4e15876031717b8bcf642e742bad8ae26d6bd020
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411871
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-05-25 15:35:56 +00:00
Brian Osman
70ae4c8ef0 Add test for runtime effects that don't need sample coords
As explained in the bug and comment - if the only reference to sample
coords is from a sample call that gets converted to pass-through, we
don't *actually* need the coords. We don't realize that with today's
analysis, so we end up generating a set of coords for the FP, which is
wasteful (adds an extra varying).

Bug: skia:11869
Change-Id: Iff818bb2c3deb96162a8cf107ccf4ecb35344bb1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411244
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-25 15:30:51 +00:00
John Stiles
7f17d36c2c Implement compile-time optimization for min() and max().
`evaluate_intrinsic_1_of_type` was rewritten and now supports up to
three arguments. The following APIs are now optimizable:

	$genType min($genType x, $genType y);
	$genType min($genType x, float y);
	$genHType min($genHType x, $genHType y);
	$genHType min($genHType x, half y);
	$genIType min($genIType x, $genIType y);
	$genIType min($genIType x, int y);
	$genType max($genType x, $genType y);
	$genType max($genType x, float y);
	$genHType max($genHType x, $genHType y);
	$genHType max($genHType x, half y);
	$genIType max($genIType x, $genIType y);
	$genIType max($genIType x, int y);

Change-Id: I0a6467fb60b008b61e8b6a7affaebfcb15f5f7a9
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412057
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-25 14:52:11 +00:00
Robert Phillips
5ccb4c1b1d Make SkSurface_Gpu::getDevice return a SkBaseGpuDevice
Change-Id: Ib678324849a15204c910df3361d7fd061cae1bb8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411900
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-05-25 14:47:51 +00:00
Ethan Nicholas
4ed2baa981 Added skstd::optional
This is needed by the upcoming DSLParser.

Change-Id: I54a0714e55feeb78894df766b14c795970f2c2d4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411308
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-25 14:10:11 +00:00
John Stiles
443fa19832 Implement compile-time optimization for sqrt(constant).
Change-Id: I3427fbaf57787c3051db95ec5882c9292d7985cf
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411312
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-25 04:43:10 +00:00
Robert Phillips
779125d7bc Cleanup SkGpuDevice factory functions a bit
This CL:
Clumps the proxy creation & device creation parameters together in the factories
Makes the raw SkGpuDevice factory take a "const SkSurfaceProps&"
Makes both the proxy-wrapping & raw factories call the SDC-based factory

Change-Id: I73fe88b639c015691fbbccdd9ff0acf2f0dad34c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410956
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-05-24 19:02:45 +00:00
Brian Salomon
e2078f1106 Make GrGpu pixel ops functions take SkIRect instead of LTRB params.
Change-Id: Ic4a8a32a434485b84284decbcc5a8f898197169a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408359
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-05-24 18:56:38 +00:00
John Stiles
639e812d9f Remove usage of sqrt() as an optimization barrier in tests.
In the majority of cases, a uniform is an equally good substitute, and
replacing `sqrt(N)` with `unknownInput` actually makes the test clearer.

Change-Id: I7bcb477571972d7aa2ce8c49b3674471f7310748
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411306
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-05-24 17:18:54 +00:00
John Stiles
f061c59792 Rewrite matrix comparisons to work around Adreno bug.
Change-Id: I2f245892e12416decd4f0aee491f16fb4040ffca
Bug: skia:11308
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411036
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-05-24 13:42:19 +00:00
Mike Reed
ec9d0e865d Move patheffect details to (private) base subclass
bug: skia:11957
Change-Id: Iceaa0ac1d7a3f049d2725629d78c755ad03a2862
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411302
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2021-05-22 01:55:43 +00:00
Chris Dalton
8447f13c6d Chop tessellated curves that don't fit in a patch
Previously we would completely disable hardware tessellation for a path
if there was any chance of a curve requiring more segments than
supported by the hardware. This CL updates the tessellators to simply
chop paths until they fit in patches, allowing us to finally draw any
path using hardware tessellation.

Bug: skia:10419
Change-Id: I5c9f78cda3e30b8810aff3cb908235965706f2d8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410977
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2021-05-21 23:01:43 +00:00
John Stiles
5ee369f623 Rename caps bit for matrix comparison rewrites.
This was originally designated for 2x2 matrices only, but this was not
right--all matrix comparisons actually need to be rewritten to fully
work around the bug.

Change-Id: I743d16a65bc55e93361a3dd8753653384583f063
Bug: skia:11308
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411416
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-21 22:31:53 +00:00
John Stiles
147cfda6d8 Allow function declarations to take (void).
This is allowed by GLSL, so we allow it too.

GLSL ES 1.0, Section 6.1: "The idiom “(void)” as a parameter list is
provided for convenience."

Change-Id: I551c505d3de518a75acd5e306f09f0f0767e43f2
Bug: skia:12025
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411300
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-21 19:21:23 +00:00
Brian Salomon
54593e7424 Revert "Reland "Use SkImage_Raster's unique ID to cache textures.""
This reverts commit 814c6db4c0.

Reason for revert: Pending investigatoin of what's going on with Chrome issue 1211203.

Original change's description:
> Reland "Use SkImage_Raster's unique ID to cache textures."
>
> This is a reland of 8005007e98
>
> Original change's description:
> > Use SkImage_Raster's unique ID to cache textures.
> >
> > SkImages can share SkBitmaps and have different unique IDs/mipmap
> > status. Currently we cache the texture version using the bitmap's
> > unique ID. Instead use the image's ID so different images produce
> > different textures (e.g. mipped and nonmipped).
> >
> > Bug: skia:11983
> > Change-Id: Ic37564186f675277e5a9de1bcf36b40a19c3a3de
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407356
> > Commit-Queue: Brian Salomon <bsalomon@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
>
> Bug: skia:11983
> Change-Id: I63e9d15ffdf6b6769c9b0b97d9aa30f353e1a3a3
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/409376
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: skia:11983
Change-Id: I4fb2875c2a62d409c3f6ddd41344e83f4e68a375
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411240
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-05-21 16:06:46 +00:00
Robert Phillips
7dd999696d Remove last two uses of SkGpuDevice's GrSurfaceDrawContext-based factory
Change-Id: Ib286933a1c2c82efbb87799016550086bcbc584f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410817
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-05-21 14:51:56 +00:00
John Stiles
36c5796f0b Add caps bit for 2x2 matrix comparison rewrites.
This will allow us to rewrite `mat == mat` on Adreno 5xx/6xx GPUs when
running in GLSL.

Change-Id: I621e918a545a49b7ecb9c944ae59b1e7a7594bae
Bug: skia:11308
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410996
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-05-20 23:19:05 +00:00
John Stiles
25be58e24b Reland "Eliminate unreachable code during optimization."
This is a reland of c6260f9742

Problematic DeadReturn.sksl test cases have been moved to DeadReturnES3.

Original change's description:
> Eliminate unreachable code during optimization.
>
> The Adreno 5xx and 6xx previously failed the SkSLStaticSwitchInline
> test; the driver struggled to interpret code with multiple return
> statements in a row. We now detect unreachable statements and eliminate
> them.
>
> Change-Id: I344d632f2488ca65b0635b37bebffe6e4fb607c5
> Bug: skia:12012
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410256
> Auto-Submit: John Stiles <johnstiles@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: skia:12012
Change-Id: I748e8761cbc71c811b5ad8fe49186f980261d8b9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410793
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-20 20:02:15 +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
Robert Phillips
54c878ef1c Retract GrSurfaceDrawContext when creating SkGpuDevices
This adds a new SkGpuDevice factory function that absorbs the
creation of the GrSurfaceDrawContext and updates a second factory
function to handle more cases.

Change-Id: If7bd33aa18d1ed5dd72288e7b4db3b97302640cf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410077
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-05-20 18:24:35 +00:00
John Stiles
6011bbcf48 Fix comma operator support with matrices in Metal.
MetalCodeGen would incorrectly identify `(someMatrix, someScalar)` as a
math operation between `someMatrix` and `someScalar` and attempt to
convert `someScalar` to a matrix. If `someScalar` was a Boolean type,
this would lead to an assertion.

The binary expression is now checked more thoroughly before converting
the scalar into a matrix.

Change-Id: Id7e104d5533d8c43375927d4815b83e1a3c36be1
Bug: skia:11125
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410682
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-20 18:08:35 +00:00
Brian Salomon
e72fd09ce1 Revert "Eliminate unreachable code during optimization."
This reverts commit c6260f9742.

Reason for revert: Nexus 7 is grumpy, fails SkSLDeadReturn_GPU
https://ci.chromium.org/raw/build/logs.chromium.org/skia/539fff50ff093c11/+/annotations


Original change's description:
> Eliminate unreachable code during optimization.
>
> The Adreno 5xx and 6xx previously failed the SkSLStaticSwitchInline
> test; the driver struggled to interpret code with multiple return
> statements in a row. We now detect unreachable statements and eliminate
> them.
>
> Change-Id: I344d632f2488ca65b0635b37bebffe6e4fb607c5
> Bug: skia:12012
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410256
> 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: Ia3db1f1b28417e479e2d71a4a6ed94a007e47cf9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12012
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410780
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-05-20 13:00:36 +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
c6260f9742 Eliminate unreachable code during optimization.
The Adreno 5xx and 6xx previously failed the SkSLStaticSwitchInline
test; the driver struggled to interpret code with multiple return
statements in a row. We now detect unreachable statements and eliminate
them.

Change-Id: I344d632f2488ca65b0635b37bebffe6e4fb607c5
Bug: skia:12012
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410256
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-19 23:03:23 +00:00
Brian Salomon
814c6db4c0 Reland "Use SkImage_Raster's unique ID to cache textures."
This is a reland of 8005007e98

Original change's description:
> Use SkImage_Raster's unique ID to cache textures.
>
> SkImages can share SkBitmaps and have different unique IDs/mipmap
> status. Currently we cache the texture version using the bitmap's
> unique ID. Instead use the image's ID so different images produce
> different textures (e.g. mipped and nonmipped).
>
> Bug: skia:11983
> Change-Id: Ic37564186f675277e5a9de1bcf36b40a19c3a3de
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407356
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

Bug: skia:11983
Change-Id: I63e9d15ffdf6b6769c9b0b97d9aa30f353e1a3a3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/409376
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-05-19 15:42:25 +00:00
John Stiles
3c74a5357a Add GLSL workaround for 4x2 diagonal matrix bug.
GLSL now emits 4x2 diagonal matrices as:
	`(mat4x2(1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0) * n)`
instead of
	`mat4x2(n)`.

This works around a long-standing GLSL bug in both Mesa and glslang that
affects several drivers:
https://github.com/KhronosGroup/glslang/issues/2645

Change-Id: If529d5cd150ce720f436cb3634a2fd3423919278
Bug: skia:12003
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410137
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-18 22:50:19 +00:00
Brian Osman
fa6a127310 Large simplification of the CType mapper logic in SkSL
- Arrays were unused
- Each ctype was used with exactly one mapper - remove the SkSL type
  list
- After that, the mapper was just a key + value, so make it just a value
  and use a map (rather than vector)

Change-Id: Ibc150ecc9ac9724ecd1e7056614ca5836ce99d5b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/409998
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-18 21:40:14 +00:00
Jim Van Verth
a655f0d8d4 Direct3D: implement transfer methods
Change-Id: Id41287668971d464e517e28757736d7d3b019666
Bug: skia:11977
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406356
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2021-05-18 20:48:14 +00:00
Brian Osman
c23386ca39 Remove layout(override_coverage)
This was only used in the context of sk_SampleMask, which was removed
recently.

Change-Id: Id70d7af8b3a100ff157c2984bad4131f1b92f317
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410056
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-18 19:39:54 +00:00
Brian Osman
3adc091af8 Remove layout(tracked) from SkSL
Change-Id: I6019418526def09c6c9f4b22567a2c76542d043c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/409876
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-18 17:44:54 +00:00
Ethan Nicholas
55a63afc5f Make it possible to use the DSL from within the compiler itself
The DSL would not previously function within the compiler, because it
expected to be in charge of everything itself. The compiler and DSL also
disagreed about how to handle some things, such as the DSL not
respecting the compiler's override flags.

This CL moves responsibility for much of the setup process into
DSL::Start(), which the compiler now invokes. DSL::Start() now also
takes a ProgramSettings instead of DSL-specific flags, and the
externalFunctions vector has been moved into ProgramSettings.

Change-Id: I283ed8366e25d67f02c43833743c5f8afdedaefc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408136
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-18 15:10:53 +00:00
Chris Dalton
e73c070911 Refactor stroke tessellation shaders
Splits the instanced and tessellation implementations into their own
separate files and merges their common code into a shared base class.
Renames GrStrokeTessellateShader to GrStrokeShader.

Bug: skia:10419
Change-Id: Ia731509858e682a605ee65c9ced1fd163e4c03f3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/409036
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Tyler Denniston <tdenniston@google.com>
2021-05-17 23:18:10 +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
Brian Salomon
6bddf46375 Revert "Use SkImage_Raster's unique ID to cache textures."
This reverts commit 8005007e98.

Reason for revert: text drop outs on D3D???
https://gold.skia.org/diff?test=xfermodes&left=1521937fb71ceb0615e8d369096ac180&right=b262b21be69db7b55b46106c0f60e9d7

Original change's description:
> Use SkImage_Raster's unique ID to cache textures.
>
> SkImages can share SkBitmaps and have different unique IDs/mipmap
> status. Currently we cache the texture version using the bitmap's
> unique ID. Instead use the image's ID so different images produce
> different textures (e.g. mipped and nonmipped).
>
> Bug: skia:11983
> Change-Id: Ic37564186f675277e5a9de1bcf36b40a19c3a3de
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407356
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

TBR=bsalomon@google.com,robertphillips@google.com

Change-Id: I39422295840ecdf363d3541380e7a25ab91a198b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11983
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/409298
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-05-17 16:24:11 +00:00
John Stiles
bdf3bb7b5f Add support for componentwise matrix divide in SPIR-V.
All the pieces of the puzzle were already here to support componentwise
addition and subtraction of matrices. Division was just a forgotten gap
in the implementation and is now patched up to match + and -.

NOTE: if you read the SPIR-V output very closely, you may be surprised
that there are fewer FDiv operations than you'd expect from reading the
input SkSL. As it turns out, a preexisting optimization is rewriting
`mat / 4` into `mat * 0.25` (see line 2689), and this rewritten form can
use the dedicated MatrixTimesScalar op. So we only get componentwise
FDivs for the `4 / mat` lines in the source.

Change-Id: I011c859f5b3a031fbb95a2956f1194a5f3b3794b
Bug: skia:11985
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408639
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-05-17 16:01:10 +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
Brian Salomon
8005007e98 Use SkImage_Raster's unique ID to cache textures.
SkImages can share SkBitmaps and have different unique IDs/mipmap
status. Currently we cache the texture version using the bitmap's
unique ID. Instead use the image's ID so different images produce
different textures (e.g. mipped and nonmipped).

Bug: skia:11983
Change-Id: Ic37564186f675277e5a9de1bcf36b40a19c3a3de
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407356
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-05-17 14:55:50 +00:00
John Stiles
a91bf055ea Add support for matrix-scalar operations in SPIR-V.
Multiplication is handled just as before. Ops other than multiplication
are handled by splatting the scalar into a matrix, then performing the
op as a componentwise matrix-op-matrix binary expression.

Change-Id: I654715c45bf5c91b8e9660fdf1c1c6d6818b621a
Bug: skia:11985
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408637
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-05-17 14:19:10 +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
Chris Dalton
0638df13a3 Cull tessellated strokes that don't intersect the viewport
When a stroke is zoomed in, it can require an exponential number of
chops. This CL updates the tessellators to stop recursing once a curve
is no longer in the viewport.

Bug: skia:10419
Bug: skia:11268
Bug: skia:9795
Change-Id: I6aad5355618462e88ce6ccccb57c500ae6310f22
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408576
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-05-14 23:03:53 +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
259553c942 Perform basic pass-fail checks in MatricesNonsquare.
Previously, it was structured like Matrices.sksl and had no verification
of its results. Now it double-checks that its outputs match our
expectations. The test is still quite simple for now, however.

Change-Id: Iaa45fe58beb497a63801833f8ba5a493a61139d9
Bug: skia:11985, skia:12003
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408646
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>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-14 19:39:43 +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
Robert Phillips
c650cc05f8 Revert "Vectorize scalars in SPIR-V using ConstructorSplat."
This reverts commit 5d61cc2f87.

Reason for revert: break Vk bots

Original change's description:
> Vectorize scalars in SPIR-V using ConstructorSplat.
>
> This avoids redundant code, and has a small side benefit of
> deduplicating constant vectors which appear more than once in the code,
> since `writeConstructorSplat` already supports this.
>
> Change-Id: I2972ee922ac92adeb40bc765da3b490a59b957b3
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408360
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

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

Change-Id: I9fc0b896c0cfccc348d510a02df47d5ad74a0e90
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408644
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-05-14 14:29:33 +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
6831635373 Cleanup TODO for constant-expression handling.
Support for constant-expression function calls in SkSL now exists, and
support for abs() was added at http://review.skia.org/405676.

Change-Id: I3144af993db93a3d640971734d4cb03e0cfb8589
Bug: skia:10835
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408642
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:36:33 +00:00
John Stiles
5d61cc2f87 Vectorize scalars in SPIR-V using ConstructorSplat.
This avoids redundant code, and has a small side benefit of
deduplicating constant vectors which appear more than once in the code,
since `writeConstructorSplat` already supports this.

Change-Id: I2972ee922ac92adeb40bc765da3b490a59b957b3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408360
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-05-14 13:01:02 +00:00
John Stiles
29b44fc226 Add SPIR-V test for matrix-op-scalar math.
This is a clone of the Metal test. (This can be moved into shared/ and
enabled as a real test once the codegen is fixed.)

At present, this test generates broken code; everything is writing an
SpvOpMatrixTimesScalar opcode regardless of the actual operation being
performed.

Change-Id: If06b4196e7d9be36e41c5c60c006b2a713cc25d8
Bug: skia:11985
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408297
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-14 12:52:02 +00:00
Brian Osman
58134e1408 Fix const globals in Metal
We were emitting this at global scope (not in Globals). That would lead
to errors about the variable needing to be in the constant address
space. (You can see the result in ConstArray.metal - the old code was
invalid). Also, we were already making references use _globals, so the
code was double-wrong (or half-right, depending on your perspective).

After the core change, writeVarDeclaration was only used for local
scope, and writeModifiers never used the 'globalContext' parameter.

The removal of finishLine() changed every test output, unfortunately.

Change-Id: Icc1356ba2cc3c339b2f5759b3d18523fd39395bc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408356
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-13 21:11:10 +00:00
Michael Ludwig
6529990763 Fix overdraw from unstable perspective math
There were two issues leading to the corruption seen in the linked
chromium issue.

1. The draw's bounds were calculated based on the quad being clipped
to w>= epsilon, which is what happens when the AA inset/outset is done.
But for non-aa quads, the fillrect and texture ops did no clipping,
assuming that the GPU would be sufficient. However, this can produce
non-aa draws that exceed the calculated bounds, misleading the clip
stack into incorrectly removing the scissor, etc.
2. Precision issues within CropToRect meant some perspective quads'
barycentric coordinates would become degenerate and compute to (0,0,1),
making it appear as if the render target/scissor were contained within
it. This meant we'd turn it into a rectangular clear.

These changes appear to address the corruption on Linux and Windows, but
there are still rendering artifacts from poor aa inset/outset
calculations. These artifacts are at least limited to the clip properly.
A better rendering method that does not rely on line intersections
will address these artifacts, but this CL is a reasonable temporary
mitigation.

Bug: chromium:1204347
Change-Id: I3c67d4efe70313ae7c98abc0a57b5b047c83890d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407821
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-05-13 19:37:53 +00:00
John Stiles
c985e149ea Add support for matrix division to Metal codegen.
This CL adds a polyfill for componentwise matrix/matrix division to
Metal, as well as matrix/=matrix. Matrix/scalar and scalar/matrix
division work by splatting the scalar out to a matrix (handled in the
prior CL, http://review.skia.org/407616) and then performing
componentwise matrix/matrix division.

Working demonstration (copy-pasted from the Metal output file):
http://screen/BrqyPcbPrB7Dy4m

Change-Id: I6a8b97783be3485f7ffee551b669d14bc58e7568
Bug: skia:11125
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407796
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-13 19:28:53 +00:00
Chris Dalton
0cfe5e1628 Add a GrCullTest class
GrCullTest quickly determines whether a set of points will be visible
or not. It will be used to guard against exponential recursion when
chopping paths at an extreme zoom level.

Bug: skia:10419
Change-Id: I85183826d820bbca0349a1e794b0696f776b134b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407297
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2021-05-13 17:30:58 +00:00
John Stiles
465da15b16 Reland "The Matrices test now verifies its results."
This reverts commit 90508f02dc.

Reason for revert: avoiding driver bugs this time

Original change's description:
> Revert "The Matrices test now verifies its results."
>
> This reverts commit 86121f6c0e.
>
> Reason for revert: tree sad
>
> Original change's description:
> > The Matrices test now verifies its results.
> >
> > Previously, this test did a bunch of matrix math but never actually
> > checked its results for correctness.
> >
> > Change-Id: I353be58049286266c2d561b0939b3874d2684403
> > Bug: skia:11985
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407360
> > 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>
>
> TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com
>
> Change-Id: I1335f01c14ee955426e02efaa3c30421cd41aa34
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:11985
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407617
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

Bug: skia:11985
Change-Id: I214375d74977f324973da72c440d7ff5ff179016
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408157
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-05-13 17:25:53 +00:00
John Stiles
6b13129c30 Add support for matrix + scalar to Metal codegen.
The Metal code generator will now detect matrix-op-scalar expressions
and splat the scalar across a matrix. This allows a scalar to be added
to, or subtracted from, a matrix. (It does not fix division because
Metal also does not natively support componentwise division on
matrices.)

Change-Id: I7d5b0c5bd35393475c524e34cad789bf4f72a103
Bug: skia:11125
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407616
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-05-13 17:22:43 +00:00
Michael Ludwig
4e9d5e2bdf Use Wang's formula for quadratic and cubic point counts
- most of the small diffs are because I moved GrWangsFormula.h out
   of the tessellate/ directory and into the geometry/ directory since
   it's more general than HW tessellation.

The previous implementation was based on the heuristic that the distance
from the true curve to the line segment would be divided by 4 every time
the curve was recursively subdivided. This was a reasonable
approximation if the curve had balanced curvature on both sides of the
split. However, in the case of the new GM's curve, the left half was
already very linear and the right half had much higher curves.

This lead to the approximation reporting fewer points than required.
Theoretically, those few points that weren't utilized by the left half
of the curve could have been made available to the right half, but the
implementation of that would be tricky.

Instead, it now uses Wang's formula to compute the number of points.
Since recursive subdivision leads to linearly spaced samples assuming it
can't stop early, this point count represents a valid upper bound on
what's needed. It also then ensures both left and right halves of a
curve have the point counts they might need w/o updating the
generation implementations. However, since the recursive point
generation exits once each section has reached the error tolerance, in
scenarios where the prior approximation was reasonable, we'll end up
using fewer points than reported by Wang's. Hopefully that means there
is negligible performance regression since we won't be increasing
vertex counts by that much (except where needed for correctness).

Bug: skia:11886
Change-Id: Iba39dbe4de82011775524583efd461b10c9259fe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405197
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-05-12 18:33:33 +00:00
John Stiles
90508f02dc Revert "The Matrices test now verifies its results."
This reverts commit 86121f6c0e.

Reason for revert: tree sad

Original change's description:
> The Matrices test now verifies its results.
>
> Previously, this test did a bunch of matrix math but never actually
> checked its results for correctness.
>
> Change-Id: I353be58049286266c2d561b0939b3874d2684403
> Bug: skia:11985
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407360
> 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>

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

Change-Id: I1335f01c14ee955426e02efaa3c30421cd41aa34
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11985
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407617
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-05-12 18:15:04 +00:00
Ethan Nicholas
22dcb738b0 Revert "Revert "Added DSL flags""
This reverts commit 9eb0bb6256.

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

Change-Id: I685478018bf48e5c06a57e9ca5542501d41c2b27
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407458
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-05-12 17:50:22 +00:00
John Stiles
86121f6c0e The Matrices test now verifies its results.
Previously, this test did a bunch of matrix math but never actually
checked its results for correctness.

Change-Id: I353be58049286266c2d561b0939b3874d2684403
Bug: skia:11985
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407360
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-12 16:11:04 +00:00
Brian Osman
a5842bc903 Move SkSpan to include/, for use in public API
Change-Id: I674f038600afd6d49316c1ece515941ee5579068
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406939
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-12 13:19:32 +00:00
Brian Osman
9eb0bb6256 Revert "Added DSL flags"
This reverts commit 71430593f0.

Reason for revert: Clang-tidy bot unhappy. (Not sure how this slipped by).

Original change's description:
> Added DSL flags
>
> This adds some basic flags to the DSL initialization which allows us to
> toggle things like optimization and validation.
>
> Change-Id: I35b10526af1678c88901eaacd5a2c4a9f5cd21a7
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406896
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>

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

Change-Id: I7512b8bcc6e94707949904eec42c396faa7fdaf8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407176
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-11 22:04:10 +00:00
Ethan Nicholas
71430593f0 Added DSL flags
This adds some basic flags to the DSL initialization which allows us to
toggle things like optimization and validation.

Change-Id: I35b10526af1678c88901eaacd5a2c4a9f5cd21a7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406896
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-11 20:44:29 +00:00
Brian Osman
ae87bf1e49 Remove SkSpan class template deduction guides
This effectively reverts a80ce1a36d,
and goes back to using SkMakeSpan (which works in C++14).

Change-Id: Iaa63c86b5acaadbdd60588b0a5c703820e810770
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406938
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-11 20:06:29 +00:00
Ethan Nicholas
b22fcaf627 Added DSL layout() support
Change-Id: I698dd607ff4676b6fb29be0a718c6073b66dc7c7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406336
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-05-11 19:52:59 +00:00
Florin Malita
4882f97829 [svgcanvas] Add support for relative path encoding
- expand SkParsePath to support relative path encoding
 - introduce a new SkSVGCanvas flag for clients to opt into relative
   encoding

Bug: skia:11981
Change-Id: I2d6c63254df23311f1a86dee9481bde9531c3b61
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406876
Reviewed-by: Tyler Denniston <tdenniston@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
2021-05-11 17:44:59 +00:00
Michael Ludwig
4e1c1a77ad Implement computeFastBounds for PathEffects
Makes computeFastBounds not part of the public API, it's only accessible
to subclasses of SkPathEffect, GrStyle, and SkPaint. Subclasses can
invoke it other path effects using SkPathEffectPriv::ComputeFastBounds.

Changes the internal function to
  bool computeFastBounds(SkRect* bounds) const;

Subclasses of SkPathEffect must implement this, and can choose to return
false when fast bounds aren't computable.

Provides implementations of computeFastBounds() for path effects
bundled with Skia.

Bug: skia:11974
Change-Id: I545ccf99b4e669d3af9df13acfac28573306fab8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406140
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-05-11 17:01:59 +00:00
John Stiles
33ef30ec68 Optimize remaining simple 1-argument intrinsics.
Aside from sqrt() and normalize(), we now optimize all the intrinsics
which take a single argument as input, and return that argument with
each of its components permuted as output.

This CL also introduces a minor restriction--we no longer optimize
intrinsics which evaluate to inf or nan, such as `inversesqrt(-1)`.
These will be left in the source as-is.

Change-Id: I4919b3c18a2df81accd6daf2f650b9f587ff43fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406577
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-05-11 16:44:09 +00:00
John Stiles
7bb100ec04 Optimize not() intrinsic.
This is similar to the intrinsic optimization for any() and all(). Tests
for all three intrinsics have been bulked up a bit as well.

Change-Id: I262b9448e543b4709d1e7c8585f74a206c4b5abd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406576
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-05-11 14:08:39 +00:00
Leon Scroggins III
7c40b6761a SkAnimatedImage: consider exif orientation
Bug: skia:11968

In the simple constructor without an SkImageInfo, cropRect, etc, read
the orientation and swap the width and height if necessary. Although
SkAnimatedImage respects the orientation at decode time, initializing
with backwards width/height results in treating them as a scale.

Change-Id: I0500c3e9a99701c0ec2bba8994c356587a3c876c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406456
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2021-05-11 13:59:48 +00:00
Ethan Nicholas
614fb1ef9c Removed early_fragment_tests layout qualifier
This layout qualifier is not actually used anywhere.

Change-Id: I817c9affdd00e492c70f251eb52680644b7ff3f7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406141
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-10 23:21:34 +00:00
John Stiles
420c563ba1 Add support for uint types in DSL C++ code generation.
UInt support was added to DSL in http://review.skia.org/403601. We use
the UInt type in the DitherEffect fragment processor.

Change-Id: I2770eb0196177ee403b461134c9895d2e0b2e6db
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406139
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-10 18:43:52 +00:00
John Stiles
edac7716aa Evaluate single-argument generic intrinsics at compile time.
In particular, this optimizes abs() and sign() when all inputs are known
at compile time. This resolves a TODO on a test case in
`IllegalIndexing.rts`.

Change-Id: Ica310522a85b42dc7ae255bd25004a6629d04176
Bug: skia:10835
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405676
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-05-10 14:50:50 +00:00
John Stiles
dabb2891c4 Fold casts of known values at compile time.
A cast like `float(five)` or `int4(colorGreen)` will now detect const
variables and replace the expression with its compile-time constant
equivalent value. This can unblock further constant folding
opportunities.

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

Change-Id: If78a2091770777b0caaaec696fe15a0f55d88c24
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405683
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-05-07 22:04:48 +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
Herb Derby
88983f1a3a Fix enumerate to handle refs
The SkEnumerate was capturing elements by value instead of
by reference. This caused odd things to happen when the value
was used on the left side of an assignment.

Added a test to demonstrate this.

Change-Id: I14bbeee8041bcbaa4e5ca845d6510096558673b1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/341462
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-05-07 21:51:38 +00:00
Jim Van Verth
1c318eb4ce Direct3D: fix up tests
* Enable MipmappedTest
* Add didWriteToSurface calls to fix up MipmapInvalidation test
* Add flush & submit to fix DDLSkSurfaceFlush test

Change-Id: I9c3cad96b40491a54cab4edb8f56639d6cc16665
Bug: skia:10446
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405496
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2021-05-07 21:48:38 +00:00
Brian Salomon
c411429239 Convert GrGLDriver/Vendor/Renderer to enum classes
Reformat uses to de-yodaify and try to improve readabilty of
complicated conditionals.

Change-Id: Ifccb84836cbe4f5a01813795ceb287089984f8ae
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405685
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-05-07 18:28:48 +00:00
John Stiles
115645ee9b Evaluate various single-argument float intrinsics at compile time.
This CL only handles a subset of our intrinsics. In particular, it
avoids changing the behavior of `sqrt` as many of our tests use sqrt as
an optimization barrier.

The transcendental test inputs are intentionally kept very simple to
avoid putting numbers in the test outputs which could round differently
on various platforms and cause Housekeeper to complain.

Change-Id: I539f918294332310dcd6fe12fab163c0b6216f65
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405398
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-05-07 14:37:18 +00:00
Brian Salomon
6e0e7cbe89 remove RGB_888x pixel tests exceptions.
Should have been removed with
https://skia.googlesource.com/skia/+/974c821502042c0ab233affb0f38bf2b49f5ecfe

Bug: skia:8862
Change-Id: I3e6445a006165cc2d5713c4b21b23ed674c0a6fe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405399
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-05-07 14:15:18 +00:00
John Stiles
1dc2d0fe0f Allow compile-time intrinsic evaluation to read const variables.
Previously, the code neglected to resolve constant variables into
values. This meant that expressions like `lessThan(zero, one)` could not
be compile-time evaluated even when `zero` and `one` have known values.

Change-Id: I2f5ce303e3dcc682be14e4d2485e24dd7c59212e
Bug: skia:10835
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405536
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-05-07 13:36:08 +00:00
Michael Ludwig
97f85bb7fd Remove SkTextBlobDiffCanvas, use tracking device directly with base SkCanvas
Chromium has been updated to use makeAnalysisCanvas directly and there are
no more references to SkTextBlobDiffCanvas as a type in its code base.

Since the GlyphTrackingDevice extends SkNoPixelsDevice, any SkCanvas that
uses it is effectively a "no-draw" canvas. However, by returning a base
SkCanvas the text tracking now automatically happens in the context of
the base's AutoLayerForImageFilter handling it applies on every draw. This
means that drawing a text blob with an image filter that modifies the
transform state will now be analyzed in that context automatically
(simplifying code in chrome after this lands).

Another behavioral change is that all non-text draws will still go through
the base SkCanvas' virtuals and invoke the device function. Since it's an
SkNoPixelsDevice, it'll still be a no-op, it just happens a little later.
This won't really impact performance because oop-r already inspects their
operations and only plays back text and transform related ones to the
analysis canvas, so we shouldn't really see non-text draws being invoked
anyways.

Bug: chromium:1187246
Change-Id: I83f86571300751f385b3065dfe889f218fa1edc6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405196
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-05-06 16:11:57 +00:00
Ethan Nicholas
722cb67b09 Improved DSL APIs in preparation for DSLParser
This includes several new array variants of existing APIs, DSLBlock now
supporting SymbolTables, and a couple of other minor changes needed by
the upcoming DSLParser.

Change-Id: I71feb268feb27cf7ff453cc59046091779bffe06
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404779
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-06 15:46:47 +00:00
John Stiles
a5f1697d05 Optimize intrinsic vector comparisons of constants.
If every argument passed to lessThan/greaterThan/lessThanEqual/
greaterThanEqual/equal/notEqual() is a compile-time constant, we now
detect this and optimize away the function call entirely.

Change-Id: I3415d21be6ef51b38b682a792bd118fad51957f5
Bug: skia:10835
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404776
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-05-06 14:00:27 +00:00
John Stiles
28181e70ce Optimize away intrinsics any() and all() when their inputs are known.
If every argument passed to any() or all() is a compile-time constant,
we now detect this and optimize away the function call entirely.

Future CLs will perform a similar optimization on other intrinsic calls
which can be detected and eliminated at compile time, like lessThan().

Change-Id: Ie55aff538b1ccaf2b3bcf9a69573a85f081b7ade
Bug: skia:10835
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404417
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-06 12:43:57 +00:00
Brian Osman
c9125aa8f3 Reland "Better first-class shader & color filter support in runtime effects"
This is a reland of adadb95a9f
... adds a temporary workaround for some Android framework code.

Original change's description:
> Better first-class shader & color filter support in runtime effects
>
> This does a few things, because they're all intertwined:
>
> 1) SkRuntimeEffect's API now includes details about children (which Skia
>    stage was declared, not just the name). The factories verify that the
>    declared types in the SkSL match up with the C++ types being passed.
>    Today, we still only support adding children of the same type, so the
>    checks are simple. Once we allow mixing types, we'll be testing the
>    declared type against the actual C++ type supplied for each slot.
> 2) Adds sample variants that supply the input color to the child. This
>    is now the only way to invoke a colorFilter child. Internally, we
>    support passing a color when invoking a child shader, but I'm not
>    exposing that. It's not clearly part of the semantics of the Skia
>    pipeline, and is almost never useful. It also exposes users to
>    several inconsistencies (skbug.com/11942).
> 3) Because of #2, it's possible that we can't compute a reusable program
>    to filter individual colors. In that case, we don't set the constant
>    output for constant input optimization, and filterColor4f falls back
>    to the slower base-class implementation.
>
> Bug: skia:11813 skia:11942
> Change-Id: I06c41e1b35056e486f3163a72acf6b9535d7fed4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401917
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Mike Klein <mtklein@google.com>

Bug: skia:11813 skia:11942
Change-Id: I2c31b147ed86fa8c4dddefb7066bc1d07fe0d285
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404637
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-05 22:06:46 +00:00
Michael Ludwig
daa9b8e4d9 Add mapRect function and RectToRect constructor to SkM44
The SkM44::RectToRect function matches the semantics of
SkMatrix::RectToRect(kFill_ScaleToFit). No other ScaleToFit variants are
ported over to SkM44.

skottie uses some instances of kCenter_ScaleToFit so that functionality
may need to be added in the future (in SkM44 or in skottie). There are
no current usages of the kStart and kEnd_ScaleToFit semantics.

The SkM44::mapRect() function is implemented to correspond to the
SkMatrix::mapRect() that returns the mapped rect (instead of modifying a
pointer) and always has ApplyPerspectiveClip::kYes. This was chosen to
keep its behavior simple and because perspective clipping is almost
always the right thing to do. In the new implementation there is no
longer a performance cliff to worry about (see below). For the timebeing
mapRect is hidden behind SkMatrixPriv::MapRect().

Performance:
I added benchmarks for mapRect() on SkM44 and SkMatrix that use the same
matrices to get a fair comparison on their different specializations.
SkMatrix has a very efficient mapRect when it's scale+translate or
simpler, then another impl. for affine matrices, and then falls back to
SkPath clipping when there's perspective. On the other hand, SkM44 only
has 2 modes: affine and perspective.

On my desktop, with a Ryzen 9 3900X, here are the times for 100,000 calls
to mapRect for different types of matrices:
                         SkMatrix    SkM44
scale+translate           0.35 ms    0.42 ms
rotate                    1.70 ms    0.42 ms
perspective              63.90 ms    0.66 ms
clipped-perspective      138.0 ms    0.96 ms

To summarize, the SkM44::mapRect is almost as fast as the s+t specialization
in SkMatrix, but for all non-perspective matrices. For perspective matrices
it's only 2x slower than that specialization when no vertices are clipped,
and still almost 2x faster than the affine specialization when vertices are
clipped (and 100x faster than falling back to SkPath).

Given that, there's the open question of whether or not keeping an affine
specialization is worth it for SkM44's code size.

Bug: skia:11720
Change-Id: I6771956729ed64f3b287a9de503513375c9f42a0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402957
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
2021-05-05 19:57:26 +00:00
John Stiles
98378352be Optimize splat constructors containing const vars.
A constructor like `float3(five)` is not a compile-time constant, so we
miss optimization opportunities like folding. Constant variables inside
splat constructors are now replaced when optimization is on, so this
would optimize down to `float3(5.0)` and be eligible for folding.

Change-Id: I4bf6f52a48ef733e6b24791d02687081194ef488
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404676
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-05-05 17:44:06 +00:00
John Stiles
8c9ccc8ad1 Optimize compound constructors containing constant vars.
A constructor like `float2(one, two)` is not a compile-time constant, so
we miss optimization opportunities like folding. Constant variables
inside compound constructors are now replaced when optimization is on,
so this would optimize down to `float2(1.0, 2.0)` and be eligible for
folding.

Change-Id: I80dd421f61d4eed21278805e2dc26d198a678e52
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404657
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-05-05 16:42:56 +00:00
Ben Wagner
48faf7bd87 Improve typeface test assert information.
The Serialization_Typeface and FontMgr_AliasNames tests sometimes fail
on macOS 10.13 and 10.15.7 bots. This is likely fixed on macOS 11,
however in the interest of investigation there should be some attempt at
discovering if the retrieved fonts are actually different and which ones
were retrieved. Improve the reports with additional information about
the typefaces in question.

Change-Id: I0e4354eacf91be1ae98838569e4da9f964dc2ac8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404338
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2021-05-04 21:16:55 +00:00
Ethan Nicholas
371f6e18e5 Refactored SkSL function creation and error handling
This breaks up the giant IRGenerator::convertFunction method into more-
manageable chunks, moves the functionality into FunctionDeclaration,
and funnels the DSL through it so it receives the same error checking.

Change-Id: Icf2ac650ab3d5276d8c0134062a4e7e220f9bf32
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402778
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-04 19:25:25 +00:00
Ethan Nicholas
a1a0b92b04 Added DSLWrapper so DSL classes can be used in containers
This will be used by the upcoming DSLParser, which needs to be able to
put DSLExpression and DSLVar into containers such as std::vector and
std::optional.

Change-Id: I8d367cfd0b3a852a368c69a5b3be6c0eaa41d74a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404156
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-04 17:19:35 +00:00
Greg Daniel
c2cca5a8a0 Revert "Better first-class shader & color filter support in runtime effects"
This reverts commit adadb95a9f.

Reason for revert: breaking android

Original change's description:
> Better first-class shader & color filter support in runtime effects
>
> This does a few things, because they're all intertwined:
>
> 1) SkRuntimeEffect's API now includes details about children (which Skia
>    stage was declared, not just the name). The factories verify that the
>    declared types in the SkSL match up with the C++ types being passed.
>    Today, we still only support adding children of the same type, so the
>    checks are simple. Once we allow mixing types, we'll be testing the
>    declared type against the actual C++ type supplied for each slot.
> 2) Adds sample variants that supply the input color to the child. This
>    is now the only way to invoke a colorFilter child. Internally, we
>    support passing a color when invoking a child shader, but I'm not
>    exposing that. It's not clearly part of the semantics of the Skia
>    pipeline, and is almost never useful. It also exposes users to
>    several inconsistencies (skbug.com/11942).
> 3) Because of #2, it's possible that we can't compute a reusable program
>    to filter individual colors. In that case, we don't set the constant
>    output for constant input optimization, and filterColor4f falls back
>    to the slower base-class implementation.
>
> Bug: skia:11813 skia:11942
> Change-Id: I06c41e1b35056e486f3163a72acf6b9535d7fed4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401917
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Mike Klein <mtklein@google.com>

TBR=mtklein@google.com,bsalomon@google.com,brianosman@google.com

Change-Id: I94ba57e73305b2302f86fd0c1d76f667d4e45b92
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11813 skia:11942
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404117
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-05-04 13:36:26 +00:00
Ethan Nicholas
b83199e289 Added unsigned types and type query functions to DSL
Change-Id: I721825d1a38e9f6846b94f84d14cb8c85b7a7519
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/403601
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-05-04 13:14:15 +00:00
Brian Osman
adadb95a9f Better first-class shader & color filter support in runtime effects
This does a few things, because they're all intertwined:

1) SkRuntimeEffect's API now includes details about children (which Skia
   stage was declared, not just the name). The factories verify that the
   declared types in the SkSL match up with the C++ types being passed.
   Today, we still only support adding children of the same type, so the
   checks are simple. Once we allow mixing types, we'll be testing the
   declared type against the actual C++ type supplied for each slot.
2) Adds sample variants that supply the input color to the child. This
   is now the only way to invoke a colorFilter child. Internally, we
   support passing a color when invoking a child shader, but I'm not
   exposing that. It's not clearly part of the semantics of the Skia
   pipeline, and is almost never useful. It also exposes users to
   several inconsistencies (skbug.com/11942).
3) Because of #2, it's possible that we can't compute a reusable program
   to filter individual colors. In that case, we don't set the constant
   output for constant input optimization, and filterColor4f falls back
   to the slower base-class implementation.

Bug: skia:11813 skia:11942
Change-Id: I06c41e1b35056e486f3163a72acf6b9535d7fed4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401917
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2021-05-04 01:29:57 +00:00
Herb Derby
b6cce2d4c7 don't draw strings that have no glyphs
This string had several characters which resulted in zero
glyphs. Having zero glyphs bypassed the buffer sizing code,
and continued to process the glyph run list assuming it had
7 runs because the buffer sizing code also clears the run list.
This caused the code to process runs from a previous SkTextBlob,
which was already deleted.

If the there are no glyphs, call the buffer sizing code to
set up all the invariants. Exit if there are no runs produced.

Bug: oss-fuzz:33915

Change-Id: I9f3f38a58112c44ddd65265c68d982b3b0dcd79c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/403439
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-05-03 19:27:54 +00:00
John Stiles
7c59ab868d Honor static statements in DSL C++ codegen.
Change-Id: I06631e7f0db518f4de19a39bf1ed368afbd5d409
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/403076
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-30 18:40:08 +00:00
Ethan Nicholas
e9c2c5a4c3 Added support for DSL global variables
This adds an explicit DeclareGlobal call, which must now be called for
variables that were previously implicitly global.

Change-Id: Iaf838880d1033ee52aac9246e31e3bda9a3b36f0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402399
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-30 18:05:19 +00:00
Ethan Nicholas
8a6537d87e Added DSL support for static if & switch statements
Change-Id: If11443997ae29266bf46da77c1e4f9583fa3f5a5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402577
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-30 17:31:49 +00:00
Ethan Nicholas
a60cc3ea41 Fix DSL handling of doubles
Previously, "x = 1.0" (as opposed to 1.0f) would fail with an ambiguous
operator resolution.

Change-Id: I9bcb4115d209a2aadb3fc4c237b61c345b25ca00
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/400619
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-04-30 13:47:18 +00:00
John Stiles
18607b442c Reland "Optimize away swizzles of constant variables."
This is a reland of 7b253d34ee

http://review.skia.org/402781 must land first, to resolve the assertions
we were getting on the Android bots.

Original change's description:
> Optimize away swizzles of constant variables.
>
> Change-Id: I49807f18ea54e85c2b8f1419278c54aa2d6f8fac
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402581
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>

Change-Id: Ib4f494b16a89ff744d4384db95a8a86d9653c190
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402644
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-30 13:12:18 +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
a6cc82e3cf Revert "Optimize away swizzles of constant variables."
This reverts commit 7b253d34ee.

Reason for revert: asserting on some bots

Original change's description:
> Optimize away swizzles of constant variables.
>
> Change-Id: I49807f18ea54e85c2b8f1419278c54aa2d6f8fac
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402581
> Commit-Queue: John Stiles <johnstiles@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: I530e6923e3c56f503508c70258c25f160f8985bc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402640
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-29 17:41:08 +00:00
Brian Salomon
1c42fcfdd2 Don't pass NaN to SkChopQuadAt in SkChopQuadAtMaxCurvature.
Bug: chromium:1202417
Change-Id: Ie6a31b2a9999280c9771a3c8d8fa92d77c01cf03
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402259
Auto-Submit: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-04-29 16:40:09 +00:00
John Stiles
7b253d34ee Optimize away swizzles of constant variables.
Change-Id: I49807f18ea54e85c2b8f1419278c54aa2d6f8fac
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402581
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-04-29 16:04:42 +00:00
Brian Osman
552fcb9a1b Remove flexible runtime effects entirely
All internal usage has migrated to MakeFor..., this removes the old
program kind, and updates some tests.

Bug: skia:11813
Change-Id: I56733b071270e1ae3fab5d851e23acf6c02e3361
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402536
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-29 16:02:27 +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
Brian Osman
83dae92318 Remove SkSL sample-with-matrix implementation
Simplifies SampleUsage quite a bit (no need to track multiple kinds of
sampling, variable matrices don't exist any more, etc...).

Change-Id: I58b8de7218d00c4d882d2650672e5fe01892a062
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402177
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-29 12:46:57 +00:00
John Stiles
958a9395e6 Fix array-of-struct name mangling in Pipeline stage.
There aren't many cases where array-of-struct types are useful in
ES2, but it looks like function parameters are one such case:
http://screen/7Fnc7GhewAkUK3j

Change-Id: I23410a3824a3c202c12147d6939586cc0e55a9ce
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402397
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 21:02:36 +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 Salomon
27c4202f4b Remove GrBitmapTextureMaker.
Replace with two methods in SkGr.h that make cached/uncached texture
proxies from SkBitmap. Move code that makes a GrFP from the proxy
to SkImage_Raster::asFragmentProcessor.

Bug: skia:11877
Change-Id: I51a0ae687561be9b0e44b98ee50f171e42476d94
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401920
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-04-28 17:24:56 +00:00
Mike Klein
ffeef16664 use MakeFor...() when caching
and remove SkRuntimeEffectInvalidColorFilters.

Change-Id: I80753e635fb0b2e93637a8b2a7f2add66020e4c1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402196
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-28 16:16:06 +00:00
Brian Osman
bf3e9e9591 Remove sample-with-matrix from SkSL
This is completely unused - GrMatrixEffect is the only thing that deals
with matrix transforms on child sampling. Removing this makes everything
simpler to reason about.

Change-Id: I555a3fd937c064f2480b149a6d4d8e36f7ee69bc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402176
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-04-28 15:44:35 +00:00
Brian Osman
4f0098227e Make the generic SkRuntimeEffect::Make factories private
All clients have been moved to the stage-specific factories. The old
flexible factories are still used internally (for now), but this
prevents any new usage from creeping in accidentally.

Bug: skia:11813
Change-Id: I6c34dfd19b396541f9a0e2f9eab8a51591ed8b70
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402156
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-28 14:49:46 +00:00
John Stiles
c4e9588621 Improve DSL CPP support for global variables.
Global variables which can be calculated in C++ code are now written as
constant values in the DSL, instead of performing the same logic
redundantly in the shader.

In some cases this can be fairly significant, e.g. RectBlurEffect has
a global with the expression
    abs(rect.x) > 16000 || abs(rect.y) > 16000 ||
    abs(rect.z) > 16000 || abs(rect.w) > 16000

Change-Id: I84221f60a4986b3225afcf91ef95cdcfc941b4b7
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401437
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-27 21:59:41 +00:00
John Stiles
d6e1e0fb46 Use macros for sk_Caps again.
This undoes the change from http://review.skia.org/400541 and reworks
sk_Caps to use macros, exactly like the existing CPPCodeGenerator.

This compromise is necessary for when-expressions. Specifically, when-
expressions must be valid when parsed *either* as SkSL or as C++. We
want to support when-expressions that reference sk_Caps, like:

    layout(when=!sk_Caps.floatIs32Bits)

The macro approach allows this when-expression to work.

Change-Id: I346762fb14c0b2f0c10015497f902f037e3461a9
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401157
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-27 21:55:11 +00:00
John Stiles
ec871bf353 Fix global variables which call built-in functions.
When emitting a built-in function call, we need to honor the `fCPPMode`
state. Previously we were rewriting the call into a DSL call even in C++
mode.

We also now spell out Fract's complete namespace, to avoid a name
collision with MacTypes.h:

https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/MacTypes.h.auto.html
    typedef SInt32                          Fract;


Change-Id: I752b7816a64a9b2b2c79d92fe46cd774e1bab96a
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401678
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-27 21:54:31 +00:00
Adlai Holler
e9ea414ac0 Improve API for skipping render tasks
This lets the user query if a task is skippable, makes
the naming clearer, and only calls the virtual once.

Bug: skia:10877
Change-Id: Ia8a7e0e3014d447bd8b4e914edf4f705a2ea107b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401856
Commit-Queue: Adlai Holler <adlai@google.com>
Auto-Submit: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-04-27 21:01:55 +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
Brian Osman
4d5711192a Reland "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.

Reland changes the logic in GrSkSLFP slightly, to avoid turning all
samples into pass-through when a child is sampled with both pass-through
and explicit coordinates.

Bug: skia:11869
Change-Id: Iec18f059b4e78df0d2f53449aa0c2945c58a58f7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401677
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-04-27 17:44:31 +00:00
Brian Osman
00f3041414 Revert "Runtime effects: Detect passthrough sample calls automatically"
This reverts commit cc3d2d25c5.

Reason for revert: Subtle bug snuck past testing.

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

Bug: skia:11869
Change-Id: Icfc756cde745d450966eaa49f5067a73232635b1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401158
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-26 21:27:28 +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
119ad7329d Remove superfluous lines from DSL generated code.
The comma-warning issue has since been fixed, and we don't need to
use `(void) var;` when we have C++17's [[maybe_unused]] attribute.

Change-Id: I2078354f06801b024638e9c7d9ac699df20a8c48
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401116
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-26 16:40:48 +00:00
John Stiles
e3fa745a5a Add support for atan() to DSL.
Change-Id: I00cc1e89fd85fdc0ce0860fcb35ececd0eaec50a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/400540
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-04-26 15:18:18 +00:00
John Stiles
b9fc6e45c2 Support 'layout(when)' expressions in DSL C++.
This required some changes to how we name variables in DSL.
When-expressions are designed to expect a local C++ variable with the
same name as the layout key. This constraint means our DSLVar variables
CANNOT have the same name as the layout key. Now, all DSL variables are
given a prefix. We try to keep the code tidy by using just a leading
underscore as the prefix, where it's safe to do so. (The C++ naming
rules put some underscore-names out of bounds, but underscore followed
by a lowercase letter is safe.)

Change-Id: Iaa8878042329b9909096f05712d5cf636ea01822
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/400623
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-26 15:17:38 +00:00
Brian Osman
56ed7daeca Use MakeForShader/ColorFilter in runtime effect tests
Bug: skia:11813
Change-Id: I9748a2806fe4636111fbb5740a3ebdb0814cfc35
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401018
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-26 14:44:38 +00:00
John Stiles
08771b00eb Add DSLVar::swap method.
This gives DSLVar the ability to be set up after initial construction.
To do this, we create a plain empty Var, then swap it with the actual
Var we want afterwards. This allows DSL to support Vars which are
`uniform half4` in some cases and `const half4` (or entirely unused) in
other cases.

This technique was adapted from similar code in Ethan's parser CL.

Change-Id: Ic54d037a0102fda77b25d4755caf77a291eaa8c6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/400716
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-26 14:28:48 +00:00
John Stiles
08c6608907 Append f suffix to float literals in DSL C++.
This prevents some ambiguous-expression errors (since we were passing a
`double` typed value into places that only took an `int` or `float`).

(The ambiguous-expression errors were later fixed in
http://review.skia.org/400619, but it's still the right thing to do for
DSL C++ to emit floats.)

Change-Id: I052c9919a9f00cb427dd152722d2f7c370f3f3b4
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/400616
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-04-23 23:15:54 +00:00
John Stiles
1dcf46359c Fix sk_Caps support in DSL C++ code generator.
This was almost right, but was missing the trailing () to make a
function call.

Change-Id: I1215a97bb0ac39aceca8ff6bea70af8ff572ef84
Bug: skia:11854
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/400541
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-04-23 22:20:13 +00:00
Michael Ludwig
48f106501c Reland "Stop using copying SkPath::Iter for convexity and contains checks"
This reverts commit 29c06bc82a.

Reason for revert: Convexicator::BySign did not handle count <= 3, which
it previously never encountered because a path with leading moveTos
would actually turn into a sequence of moveTo+close by the forceClose
SkPath::Iter so it'd never actually skip anything.

I updated the code so that BySign checks for count <= 3 after we've
skipped leading moveTos. This means computeConvexity's logic can get
a little simpler, just checking isFinite(), calling into BySign, and
then going into the second pass. Previously, it skipped the first pass
if pointCount <= 3 (using the pointCount before leading moveTos were
skipped).

Lastly, I removed SkPathPriv::IsConvex. It was the other user of
BySign but it was only used in PathTest. I figured it's best to have
a single source of convexity definition rather than having two code
paths that both need to implement the same two-pass behavior.

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

# Not skipping CQ checks because this is a reland.

Bug: 1187385
Change-Id: I21159915839911225440c2f65da9bbbd22b77ab3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399377
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-04-23 20:44:33 +00:00
Chris Dalton
e0fe23a65e Add a second stencil attachment to GrRenderTarget for dmsaa
As we move toward dmsaa, we need stencil attachments on the single and
multisample attachments both. This is only a temporary solution until
the new surface world is finished.

Bug: skia:11396
Change-Id: I48928343e1fc9fd2e00362a534be9eb3ade92656
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399838
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2021-04-23 20:01:03 +00:00
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