Commit Graph

3491 Commits

Author SHA1 Message Date
Chris Dalton
2fceb21cb7 [graphite] Add an IntersectionTree class
Implements a BSP tree with NEON/SSE optimizations that tracks
non-overlapping regions. This object can be used batch sets of paths
into non-overlapping draws. Performance on AppleM1 with our existing
benchmarks looks very promising:

    desk_motionmarkarcs.skp     1227 paths -> 69 draws    450us
    desk_motionmarksuits.skp    1417 paths -> 26 draws    201us
    desk_chalkboard.skp         1940 paths -> 11 draws     84us
    desk_ynevsvg.skp             859 paths -> 10 draws     31us
    desk_micrographygirl.skp     318 paths -> 29 draws     11us

Bug: skia:12466
Change-Id: I847a93ed726dea10cb403cb76e578bd81eb920d2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/460298
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2021-10-19 19:45:01 +00:00
Jim Van Verth
a2645f2f5f [graphite] Remove CapsTest
Bug: skia:12466
Change-Id: Ibb99647cf151fb45901aee340d60914611c2ba75
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/461096
Auto-Submit: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-10-19 17:36:59 +00:00
Jim Van Verth
f3f2e75820 [graphite] Add RenderPass setup and test
Bug: skia:12466
Change-Id: Ibbb4894c6a46dd8853909214da85314f9abc3959
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459880
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-10-19 17:34:03 +00:00
Ethan Nicholas
ab0a13d9d9 Removed the final remnants of IRGenerator
This completes the long process of moving all of IRGenerator's code and
data into better homes and finally kills the class altogether. There is
a lot of #include churn here due to poor header hygiene in the past;
IRGenerator.h included a ton of stuff and almost everything included
IRGenerator, allowing us to inadvertently be sloppy with our includes.

Change-Id: I70d854e57dec7bd9a311b72f9f72d978d354da98
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459936
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-10-19 13:17:01 +00:00
Robert Phillips
1f766792d5 [graphite] Copy UniformDataManager into Graphite and trim down
This attempts to salvage the reuseable portion of:

https://skia-review.googlesource.com/c/skia/+/440841 (New approach to GrProcessor uniforms)

It also removes the old code's Gr- dependencies.

Bug: skia:12466
Change-Id: I7f7f3a9f9b4f3e282af1caeb02d2b305e6756025
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/460556
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-10-18 23:58:59 +00:00
Chris Dalton
8fafb0f633 [graphite] Add setters to Rect
Bug: skia:12466
Change-Id: I69222b60d421d8deebcb977124ee0f5cb06f34dd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/460638
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-10-18 22:13:35 +00:00
Jim Van Verth
0c56bbaffe [graphite] Add command buffer test
Adds test of command buffer submission with GPU recording (if enabled).
Also adds programmatic GPU recording support.

Bug: skia:12466
Change-Id: I85aba9f7e5e09f62f2ddc7040d1ff84bb9b4ae09
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/460337
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2021-10-18 17:49:36 +00:00
John Stiles
319d75d6f6 Add error test for unary-negating and unary-plussing arrays.
At present, we only detect four errors here. We should detect six.

Change-Id: I226854ab930a273695c42cf2f7bdb1d5cd97e50b
Bug: oss-fuzz:39998
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459882
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-10-18 14:30:36 +00:00
Michael Ludwig
4021b947f7 [graphite] Add Transform that wraps matrix, inverse, type and scale factors
Transform.h is named Transform_graphite.h to avoid collision with
Transform.h in skottie/src

Bug: skia:12466
Change-Id: I017eee2bffe1a0aad605221e67540f732c2ee6b9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459719
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-10-16 00:06:32 +00:00
Chris Dalton
d0c7f63645 Move Wang's formula back into src/gpu/tessellate
We are making src/gpu/tessellate independent of v1, and more represent
math and types that just know how to tessellate, so this seems like the
right place again for this file.

Bug: skia:12524
Change-Id: I773de3c0f93a57ce7ee16b44480667013f32ebd5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459136
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-10-14 17:34:29 +00:00
John Stiles
c8a96076b1 Added four more reserved words to SkSL.
We now detect attribute, varying, precision and invariant as reserved.

Change-Id: I8c90655a70b1bad31bf6143c3fdcb2ce582320b1
Bug: skia:12484
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459479
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-10-14 16:29:32 +00:00
John Stiles
f7d2673643 Fix up samplerCube/textureCube for ES2 conformance.
`samplerCube` is a type which we don't support at all. It has been added
to the reserved-word list.

`textureCube` was in our list of built-in types, but was not actually
used in any way; it wasn't actually added to the root or private symbol
tables, and was totally unreferenced by the code. It's been deleted.

Change-Id: I4f79ce5d40ac6ebdb2a7067fa60cc79e316b01b6
Bug: skia:12484
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459123
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-10-14 15:21:31 +00:00
John Stiles
ee36412765 Add ES2 conformance test harness to dm.
This CL adds a few more exceptions to our ES2 test import, and adds the
dm code which actually runs the tests.

Change-Id: If6691dd35931f4f10262d3a1eff020c2c347ca59
Bug: skia:12484
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459124
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-10-14 14:50:06 +00:00
Ethan Nicholas
6cfe358193 Moved CheckModifiers out of IRGenerator
Change-Id: Ic9288665fd31bde986720cd259b132a5cb9d87a6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459178
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-10-14 14:30:01 +00:00
Kevin Lubick
f541ddf785 Move ToolUtils::make_big_path() to bench/
The ToolUtils file is getting a bit bloated, IMO. I noticed this when
working on Bazel includes.

Including non-header files is a small nuisance in Bazel, so it
is probably better to just make it its own compilation unit.

Change-Id: I06ca3808a37ebef6478f5afa3f14086429899590
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459197
Reviewed-by: Ben Wagner <bungeman@google.com>
2021-10-14 12:57:29 +00:00
John Stiles
21fe518fbb Revert "Disallow matrix ctors which overflow a column."
This reverts commit eb68973c2f.

Reason for revert: ES2 conformance test checks this

Original change's description:
> Disallow matrix ctors which overflow a column.
>
> The GLSL spec allows matrix constructors containing vectors that would
> split between multiple columns of the matrix. However, in practice, this
> does not actually work well on a lot of GPUs!
>
> - "cast not allowed", "internal error":
> 	Tegra 3
> 	Quadro P400
> 	GTX 660
> 	GTX 960
> - Compiles, but generates wrong result:
> 	RadeonR9M470X
> 	RadeonHD7770
>
> Since this isn't a pattern we expect to see in user code, we now report
> it as an error at compile time. mat2(vec4) is treated as an exceptional
> case and still allowed.
>
> Change-Id: Id6925984a2d1ec948aec4defcc790a197a96cf86
> Bug: skia:12443
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449518
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>

Bug: skia:12443
Change-Id: I5a32744c88b9b830ad657488824c8c7dd0b0a652
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/458056
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
2021-10-14 01:30:08 +00:00
John Stiles
64c907c052 Mark private types as invalid in the public symbol table.
Previously, in public code, private types didn't exist anywhere in the
symbol table chain, and those names were free for the taking. Now, we
register them as invalid types in the public symbol table. This prevents
them from being used as variable names, and gives a more explicit error
if you try to use them as a type.

Change-Id: I9a943bf923639b72cbf36b1acf4b4fbe70982786
Bug: skia:12538
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459119
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-10-13 20:41:09 +00:00
Chris Dalton
1d910efd24 Delete TessTypes.h
The flags here are specific to v1 behavior. Move them into v1 only.

Bug: skia:12524
Change-Id: I27f06d0c153f95e1510bb11c8486d59e5242056a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/458997
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-10-13 18:54:35 +00:00
Greg Daniel
b9924539bb [graphite] Add Buffer and MtlBuffer classes.
Bug: skia:12466
Change-Id: I3252f36c3f78642c55f127379ceba99b4845822e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/458717
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-10-13 18:28:12 +00:00
Chris Dalton
0de8a96a72 Create an skgpu::tess namespace
This is just a bunch of renaming, and for now the tessellate/shaders
directory remains untouched. The next steps will be to clean up and
remove all Ganesh v1 dependencies from tessellation.

Bug: skia:12524
Change-Id: I8cc166c0c78f9fb160de807131fa53fcc0765818
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/458876
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-10-13 16:54:28 +00:00
Robert Phillips
297d096cfb [graphite] More testing infrastructure
With this CL we can run as:

     dm --src gm skp tests --config grmtl -v --nocpu --nogpu

and not get all the non-Graphite unit tests.

Bug: skia:12466
Change-Id: Ib3f04f315fe4b5731a54e4c72979a0c1e00baf24
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/457898
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-10-13 15:15:29 +00:00
John Stiles
980169a5b5 Allow non-trivial constant expressions for array sizes.
This fixes GLSL ES2 conformance test `array`.

Change-Id: I6ebee9253e1e8c394d9ddb6899e3a0940b7a38ef
Bug: skia:12495
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/458718
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-10-12 21:04:33 +00:00
Jim Van Verth
dc6a9e3e12 [graphite] Add command buffer submission and tracking
Bug: skia:12466
Change-Id: I965417fc1de471af33a31155abf2760d5d1b4f62
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/457317
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2021-10-12 20:04:29 +00:00
Chris Dalton
117596bc8a [graphite] Add a fast SIMD Rect type
Implements a Rect type whose standard operations use float4. The intent
of this class is to make calculations on draw bounds as fast as
possible.

Change-Id: I3bdb219b242bb7097809507c345b613670ff386e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/457136
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-10-12 18:42:07 +00:00
Brian Salomon
87a0078b89 Support building on clang with -std=c++14 but no C++17 extension warning.
Classes of issues addressed:

1. static constexpr class variables aren't automatically inline. Already handled in a separate CL

2. Lack of C++17 copy elision means classes of objects constructed at function return need a copy or move constructor even if RVO will mean it isn't called.

3. Nested braced init no longer allowed for base classes of subclasses without constructors.

4. template static constexpr var in template class throws error about redundant initialization. Adding inline and removing defn outside of class fixes it.

5. Some places that should have been including std headers now actually need to include them.

6. No auto template parameters.

7. No lambdas in constexpr funcs.


Bug: chromium:1257145
Change-Id: Icb24c6b4ed039287fb4cf27a21a1bb7dc9821728
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/457298
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-10-12 16:34:30 +00:00
John Stiles
732e4ebd20 Add test slide that mirrors the Chrome fillrect_gradient test.
This test page exercised some cases in our gradient code that were
not hit by any of our existing tests in Skia. (Specifically, simple
gradients with large numbers of redundant stops that can be optimized
away.)

Change-Id: If3309487ddc3d4057e2f160ae3bd319ea356669a
Bug: skia:8401
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/457658
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-10-12 00:43:58 +00:00
Michael Ludwig
6c8e2e832e Fix winding when splitting edges at out-of-bounds vertices
Add GM repros and up triangulation verb count to match chromium's define
The GMs draw incorrectly in (base->p2) with the updated verb count, but
would draw fine w/o the increased verb count because a different path
renderer would be chosen.

This fixes a latent bug that was in the edge splitting code of the
triangulator that was exposed by https://skia-review.googlesource.com/c/skia/+/432196
Before that CL, intersections of two lines would be clamped to one of the
4 vertices of the 2 segments. In the CL linked, the clamping was adjusted
to clamp X and Y axes separately, so it increased the chance that a
clamped intersection would have its X or Y coord equal to line's vertex
but differ along the other coord (when they both equaled, they were
considered coincident and splitting that edge did nothing).

Splitting an edge at its intersection was intended to split (p0 to p1)
into new lines (p0 to v) and (v to p1) where p0 < v < p1 according to the
vertical or horizontal sorting that was imposed on the mesh. For a given
line segment and a clamped vertex, there are 8 ways the intersection
could be clamped (4 edges and 4 corners). If the edge has a positive
non-zero slope, a zero slope, or an infinite slope, in all cases the
clamped intersection will be sorted correctly and satisfy p0 < v < p1.

However, if the edge has negative slope
  vertical: p0.y<p1.y and p0.x>p1.x,
  horizontal: p0.x<p1.x and p0.y<p1.y
then intersections snapped to the primary sorting axis will be out of
order and produce a split such that v < p0 < p1 or p0 < p1 < v. This
was already detected, but it didn't update the winding of the new edge
to preserve the original winding from p0 to p1.

In these out-of-order cases, the intersection point is the top of both
the new and old edge, or the bottom of both the new and old edge. This
means that winding "top to bottom" on the new edge would go in the
opposite direction as the original winding from p0 to p1. Flipping the
winding on the new edge preserves the intended winding of the contour
while still allowing the edges/vertices to be sorted consistently.

This showed up as large gradients in the AA triangulator because w/o the
winding adjustment, the winding flip at the new edge would confuse the
border extractor that was used to compute insets and outsets for the 1px
coverage ramp. It would then use edges that were normally unrelated to
each and declare their line intersections as the "interior" with full
coverage. Obviously these could be anywhere so the 1px coverage ramp
would get smeared across that shape.

Bug: chromium:1257515
Change-Id: I015d6b4767db352e3eecfc53047958e74320268d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/458057
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-10-11 23:49:37 +00:00
Robert Phillips
3062759ffd [graphite] Set up unit testing system
Bug: skia:12466
Change-Id: I401a185d818a964327d323b9ebcd0850ec0b1c9b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/457318
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-10-11 16:18:05 +00:00
John Stiles
eafb39fc7e Create hardstop_gradients_many test slide.
This GM presents different gradients with an increasing number of
hardstops, from 1 to 100.

Change-Id: I1c279c6ea1a25f9785001aa29db632547a38ab68
Bug: skia:8401
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/457437
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-10-11 13:44:02 +00:00
Chris Dalton
1ab7ff6abf [graphite] Clean up bitwise operators for enum masks
* Rename TFlagsMask<> to Mask<>
* Make Mask<> implicitly convertible to bool
* Rename SKGPU_MAKE_BITFIELD_CLASS_OPS to SKGPU_MAKE_MASK_OPS
* Remove the macro for non-class enums

Change-Id: I86059335d731f34c9c9c20a4cd6d5491543aa3b1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456816
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-10-08 00:32:54 +00:00
Ethan Nicholas
c845272b4e Broke DSLWriter into two separate classes
As DSLWriter evolved, it ended up performing two unrelated duties:

1. Holding per-thread state which is referenced throughout SkSL
   (including non-DSL code)
2. DSL-specific utility functions

There's no reason for those to be contained in the same class, and
there's also no reason the per-thread state should be held in a
DSL-specific class. This breaks out an SkSL::ThreadContext class to hold
the state info, leaving the DSL utility functions behind in DSLWriter
(which should perhaps be renamed, but that's a job for a future CL).

Change-Id: Iccd45314bd9b37d4a1d3e27920e32a50c0b07d7c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456736
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-10-07 15:28:58 +00:00
Greg Daniel
e47c5d16aa [graphite] Add TextureProxy support.
With this change it should now be safe to start using Proxys and Textures
everywhere. There is no caching the Proxys/Textures will live as long as
someone holds a ref.

Bug: skia:12466
Change-Id: I3c657b65b44b9dca0a77a255d6a4fc89e3862124
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456916
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-10-07 14:56:25 +00:00
John Stiles
042a197ce2 Migrate compiler elimination passes to Transform.
Change-Id: Ibb8695917d0a8ff43467542ee7a7b36f573513f8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456798
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-10-07 13:50:07 +00:00
Michael Ludwig
2aff315093 [graphite] Add Shape variant over path, rect, rrect, convex poly
This is basically GrShape except that I removed some of the API that
GrStyledShape used. I also changed the set of types that Shape can
represent to be better match what I imagine our final set will be in
graphite: {empty,point,line,rect,rrect,path,arc}
       -> {empty,rect,rrect,path,convex-polygon}

The convex polygon is used to store points and lines as well. I also
imagine that it will subsume the need for migrating GrQuad over.

I'm doing this on its own in preparation for moving the ClipStack over
and consolidating the draw handling in Device/DrawList, all of which
get a lot easier if there is a single type that stores the geometry.

For the first milestone, actual rendering will still likely use
Shape::asPath() for the path renderer, but it's not a lot of extra work
to preserve the logical type at the high level, so may as well do that.

There are a few functions internal to Shape that still need to be
implemented (converting a path to a list of vertices, and doing point
containment), but those can come in a later CL.

Bug: skia:12466
Change-Id: I1040c54e3b8004f3bc1767d72ded60b572b39596
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456257
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-10-07 13:48:25 +00:00
John Stiles
2dfbf99edf Migrate IsConstantExpression out of SkSLAnalysis.
Change-Id: I08717dd9e9ad20a18a623e06f0c66a0f697effa4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456796
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-10-07 13:40:00 +00:00
John Stiles
2153a87064 Migrate GetLoopUnrollInfo out of SkSLAnalysis.
Change-Id: Ic0d1b04ee09a144dbb13cc98dff8e10409186a8e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456648
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-10-07 13:39:22 +00:00
John Stiles
8db7cd008d Migrate CanExitWithoutReturningValue out of SkSLAnalysis.
Change-Id: I0e59da9dda8917e2bc9d6959fdfeeaeae9372c3a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456647
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-10-07 13:24:26 +00:00
John Stiles
a7827d6ac1 Migrate EliminateDeadLocalVariables into Transform.
Change-Id: Idc0c51c0d293121fd306e7153b2e47f7e7dec222
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456646
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-10-06 21:09:23 +00:00
John Stiles
7176637442 Migrate EliminateUnreachableCode into Transform.
Change-Id: Ib32895a78a8de4c49ce1208f0c1b9b111d092b42
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456643
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-10-06 20:49:38 +00:00
John Stiles
da4bcb6891 Migrate ProgramUsage out of SkSLAnalysis.
Change-Id: I005eccfa262ed047409cce0417f50f93fb6341a3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456641
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-10-06 20:46:12 +00:00
John Stiles
a272914cbb Add SkSL prefix to SwitchCaseContainsExit filename.
Change-Id: Ia5bf3423fa75ac610fd34db252fee493d5a53877
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456644
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-10-06 20:44:24 +00:00
John Stiles
b691ce4151 Migrate CheckProgramUnrolledSize out of SkSLAnalysis.
Change-Id: I97c4d1b4c870367d6457f4dd851f48a6d2211e5d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456640
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-10-06 20:39:34 +00:00
John Stiles
a1b44b72eb Migrate SwitchCaseContainsExit out of SkSLAnalysis.
This CL also removes `SwitchCaseFallsThrough` entirely; it was
not referenced anywhere.

Change-Id: I58298bf2a603615e37f4cced9db6d2f4c2c54d5a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456473
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-10-06 18:50:59 +00:00
Robert Phillips
47da0ac577 [graphite] Add stub classes for Recorder, Recording and TaskGraph
Bug: skia:12466
Change-Id: I730c227a78040ea8747d11437032504527b3ee81
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456463
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-10-06 16:32:52 +00:00
Greg Daniel
fbc64be806 [graphite] Add Caps getters for default TextureInfos
Bug: skia:12466
Change-Id: I9165e5f49e4b897f4b315662221b944e362b7b41
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456456
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2021-10-06 15:11:29 +00:00
Greg Daniel
d4ca5e11a1 Add Texture creation to ResourceProvider.
The caller to ResourceProvider should be passing in the TextureInfo
they want. Thus we don't need all the specialized factores on
mtl::Texture.

Also removes UsageFlags from Texture which aren't needed.

Bug: skia:12466
Change-Id: Iad51a7da6efe481382a3f5fbaefc6d2504d1c013
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/456236
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-10-05 21:13:53 +00:00
Jim Van Verth
efdb1f0a3b [graphite] Add pipeline cache to ResourceProvider
Copied from GrMtlResourceProvider, and stripped down to the barest minimum.

Bug: skia:12466
Change-Id: I63cb52ee4bbc4c6ce5a1de16312bd4c69911d32c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455619
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-10-05 14:34:22 +00:00
Michael Ludwig
65e848d6b5 Reland "[graphite] SurfaceDrawContext -> DrawContext"
This reverts commit 9602a4fad0.

Reason for revert: fixed var ref

Original change's description:
> Revert "[graphite] SurfaceDrawContext -> DrawContext"
>
> This reverts commit a525fd141b.
>
> Reason for revert: missed updating sdc->dc in one spot
>
> Original change's description:
> > [graphite] SurfaceDrawContext -> DrawContext
> >
> > Bug: skia:12466
> > Change-Id: If4a06bc0ab8befab8a155276c316ba9378b90a48
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455658
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
>
> Bug: skia:12466
> Change-Id: I60e316225d44d7046bc82c80fe42345d8941f99e
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455662
> Auto-Submit: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>

Bug: skia:12466
Change-Id: I693b1e39fd65fe20cd5bb3f36bcc5f3da011c6b3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455663
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-10-04 21:43:52 +00:00
Michael Ludwig
9602a4fad0 Revert "[graphite] SurfaceDrawContext -> DrawContext"
This reverts commit a525fd141b.

Reason for revert: missed updating sdc->dc in one spot

Original change's description:
> [graphite] SurfaceDrawContext -> DrawContext
>
> Bug: skia:12466
> Change-Id: If4a06bc0ab8befab8a155276c316ba9378b90a48
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455658
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

Bug: skia:12466
Change-Id: I60e316225d44d7046bc82c80fe42345d8941f99e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455662
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2021-10-04 20:36:17 +00:00
Michael Ludwig
a525fd141b [graphite] SurfaceDrawContext -> DrawContext
Bug: skia:12466
Change-Id: If4a06bc0ab8befab8a155276c316ba9378b90a48
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455658
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-10-04 19:51:53 +00:00
John Stiles
a106472197 Reland "Disallow constructors of ES3 types in ES2 code."
This is a reland of 36f53ec7e1

Original change's description:
> Disallow constructors of ES3 types in ES2 code.
>
> The fuzzer found that we constructed TypeReferences without first
> checking for disallowed tyoes. (In fact, TypeReference creation had no
> error checking at all; it didn't even have Convert/Make functions.)
>
> Added proper Convert/Make to TypeReference, and used those calls to
> report errors or cause assertions if trying to make a TypeReference to a
> type that the program did not support.
>
> (While tracking down this bug, I added strict-ES2 type assertions to our
> constructor IR nodes as well. This helped pinpoint the error and seem
> reasonable to leave in, just in case.)
>
> Change-Id: I896b68ae9d3d9e1f30d7eba9fa594617ab851c74
> Bug: oss-fuzz:39540
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455498
> Commit-Queue: John Stiles <johnstiles@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: oss-fuzz:39540
Change-Id: Id8e323c22b18726214613b6061c08873048b7c69
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455617
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-10-04 17:51:00 +00:00
John Stiles
e03f1c101c Revert "Disallow constructors of ES3 types in ES2 code."
This reverts commit 36f53ec7e1.

Reason for revert: breaks DS3Types test

Original change's description:
> Disallow constructors of ES3 types in ES2 code.
>
> The fuzzer found that we constructed TypeReferences without first
> checking for disallowed tyoes. (In fact, TypeReference creation had no
> error checking at all; it didn't even have Convert/Make functions.)
>
> Added proper Convert/Make to TypeReference, and used those calls to
> report errors or cause assertions if trying to make a TypeReference to a
> type that the program did not support.
>
> (While tracking down this bug, I added strict-ES2 type assertions to our
> constructor IR nodes as well. This helped pinpoint the error and seem
> reasonable to leave in, just in case.)
>
> Change-Id: I896b68ae9d3d9e1f30d7eba9fa594617ab851c74
> Bug: oss-fuzz:39540
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455498
> Commit-Queue: John Stiles <johnstiles@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: oss-fuzz:39540
Change-Id: I1dc3ccca477fcb9fe3f39cfe8af1fd54dcb18d6b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455616
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2021-10-04 15:36:08 +00:00
John Stiles
36f53ec7e1 Disallow constructors of ES3 types in ES2 code.
The fuzzer found that we constructed TypeReferences without first
checking for disallowed tyoes. (In fact, TypeReference creation had no
error checking at all; it didn't even have Convert/Make functions.)

Added proper Convert/Make to TypeReference, and used those calls to
report errors or cause assertions if trying to make a TypeReference to a
type that the program did not support.

(While tracking down this bug, I added strict-ES2 type assertions to our
constructor IR nodes as well. This helped pinpoint the error and seem
reasonable to leave in, just in case.)

Change-Id: I896b68ae9d3d9e1f30d7eba9fa594617ab851c74
Bug: oss-fuzz:39540
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455498
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-10-04 15:02:24 +00:00
John Stiles
906e9eb538 Emit qualifiers in the GLSL ES-required order.
This should fix a failure in the ES2 conformance suite's "const_in_int".

Change-Id: I8b5487749291ef57712b8fe6c3949dc7c3e76883
Bug: skia:12499
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455157
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-10-01 19:09:43 +00:00
John Stiles
7e947ab4b6 Reland "Mark GLSL reserved names as reserved in SkSL grammar."
This reverts commit 5f15c695f9.

Reason for revert: landed http://ag/15959743 to fix Android roll

Original change's description:
> Revert "Mark GLSL reserved names as reserved in SkSL grammar."
>
> This reverts commit 57f3fc4cde.
>
> Reason for revert: breaking Android roll
>
> Original change's description:
> > Mark GLSL reserved names as reserved in SkSL grammar.
> >
> > We now reject every reserved name in the ES2 docs as an unexpected
> > token, except for the rule that all names beginning with `gl_` are
> > reserved. (Unfortunately, sksl_frag bends the rules by directly
> > declaring a builtin variable named `gl_SecondaryFragColorEXT`.)
> >
> > Change-Id: I5dcb40b754720ca97fe3d80e2f9072beaa39fcdb
> > Bug: skia:11115
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/454737
> > Auto-Submit: John Stiles <johnstiles@google.com>
> > Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> > Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
>
> Bug: skia:11115
> Change-Id: Ica56f48dc76ef1e52780acaf59b8ad9143637637
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/454860
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>

Bug: skia:11115
Change-Id: I012b8d4e03be7f9c888c26d912552412529b4fb6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455159
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-10-01 18:31:50 +00:00
Ethan Nicholas
5f15c695f9 Revert "Mark GLSL reserved names as reserved in SkSL grammar."
This reverts commit 57f3fc4cde.

Reason for revert: breaking Android roll

Original change's description:
> Mark GLSL reserved names as reserved in SkSL grammar.
>
> We now reject every reserved name in the ES2 docs as an unexpected
> token, except for the rule that all names beginning with `gl_` are
> reserved. (Unfortunately, sksl_frag bends the rules by directly
> declaring a builtin variable named `gl_SecondaryFragColorEXT`.)
>
> Change-Id: I5dcb40b754720ca97fe3d80e2f9072beaa39fcdb
> Bug: skia:11115
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/454737
> Auto-Submit: John Stiles <johnstiles@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>

Bug: skia:11115
Change-Id: Ica56f48dc76ef1e52780acaf59b8ad9143637637
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/454860
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-10-01 14:53:12 +00:00
Ethan Nicholas
1e6e919a7e Moved findAndDeclareBuiltinVariables out of IRGenerator
No functional changes, just continuing the process of moving code out
of IRGenerator in hopes of its eventual disappearance.

Change-Id: I3507b85c5493c61812869c9bae53de8af89ee129
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/453941
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-09-30 20:02:44 +00:00
John Stiles
57f3fc4cde Mark GLSL reserved names as reserved in SkSL grammar.
We now reject every reserved name in the ES2 docs as an unexpected
token, except for the rule that all names beginning with `gl_` are
reserved. (Unfortunately, sksl_frag bends the rules by directly
declaring a builtin variable named `gl_SecondaryFragColorEXT`.)

Change-Id: I5dcb40b754720ca97fe3d80e2f9072beaa39fcdb
Bug: skia:11115
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/454737
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-09-30 19:55:47 +00:00
Greg Daniel
f69f21e601 Add MtlTexture class.
Bug: skia:12466
Change-Id: I6207af8bb34ccab28265ced733e1930f42e2db8b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/454776
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-09-30 18:24:48 +00:00
Greg Daniel
b2d20e02e7 [graphite] Add basic Texture files.
Bug: skia:12466
Change-Id: If708d8a4bd00802e60a860215edcb64db179e573
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/454616
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2021-09-30 15:29:50 +00:00
Ethan Nicholas
58014fa9a6 Moved SkSL intrinsics from IRGenerator to Context
Moving stuff out of IRGenerator in preparation for its eventual
deletion.

Change-Id: Ib4290158670fecbca02bc71452b9bf4691094fe3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/453943
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-09-29 22:15:49 +00:00
Jim Van Verth
0f833ca8ae [graphite] Add Metal trampoline.
Adds the interface between C++ and Objective-C code so we can create
the Gpu.

Bug: skia:12466
Change-Id: I0c4b5d21ddaa119c21682105dc84d75769f069f6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/453952
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2021-09-29 22:12:20 +00:00
Greg Daniel
d73cff0e2d [graphite] Add TextureInfo class.
Also adds the Mtl subclass as well

Bug: skia:12466
Change-Id: Ia3a81f33a00374a96765fde3a3442c5e13188ad1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/453719
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-09-29 16:31:27 +00:00
Robert Phillips
e19164d9f4 [graphite] Move some basic include/gpu files over to Graphite
This is mainly to make make MtlBackendContext available.

GrTypes has to go to GraphiteTypes due to a name collision with Types.h in in sktext.

Bug: skia:12466
Change-Id: If073d5540c3dbf3fbfb404808d80deab42c40aa6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/453497
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2021-09-28 21:11:25 +00:00
Michael Ludwig
949aebff35 [graphite] Fix build for DrawPass
Bug: skia:12466
Change-Id: I2ba1f1541c273ba90032c93a92ed3770dc5b0080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/453756
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2021-09-28 20:38:18 +00:00
Jim Van Verth
47b6286e6e [graphite] Stub in more Metal classes
Bug: skia:12466
Change-Id: I83ebf7dbea0d67b3c121b011f62e7b729f5e5257
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/453577
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2021-09-28 17:46:28 +00:00
Ethan Nicholas
791c0d36a6 Remove ASTNode and SkSLParser
Now that DSLParser is used for everything we can get rid of this
unused code.

Change-Id: I7b586a7d7a51ac9df7d2c52baa1f525233f489b9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/443076
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-28 13:36:49 +00:00
Jim Van Verth
2045b981fb Graphite: Add stubs for Pipeline and PipelineDesc
Bug: skia:12466
Change-Id: Ie949a17166b3ab5c529b74a6762c8a6f8ca8052f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/453061
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2021-09-28 11:28:19 +00:00
John Stiles
085ee36d91 Delete runtime_effect_image test.
Change-Id: I1affffe2fbc2f38a99d43485ec112a4809b8cac4
Bug: skia:12482
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/453141
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-27 20:12:20 +00:00
John Stiles
26c93442b5 Re-re-reland "Rewrite switch statements in GLSL strict-ES2 mode."
This reverts commit 6f06bab632.

Reason for revert: glslGeneration is more trustworthy than GR_GL_VER

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

Bug: skia:12450
Change-Id: I4bac3a468ae20967fe6ec372561dd44f67c6b730
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452897
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-27 14:35:19 +00:00
Michael Ludwig
aeb5d4daed [graphite] Flesh out Device/SDC a bit more
Renames SDCTask -> RenderPassTask and adds comments describing its
purpose. Has SDC use a DrawList and expose similar drawing functions.
Stubs out all Device methods that will eventually need to be supported,
but groups them into in-scope and out-of-scope sections. Implements the
drawing functions in terms of drawPath() and has drawPath() invoke the
SDC functions (with untested support for path effects, hairline, etc.).

Bug: skia:12466
Change-Id: Id661fc987aeb35f0dfa536c0cb0b6210742cf32c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452233
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-09-25 17:51:42 +00:00
Brian Osman
6f06bab632 Revert "Re-reland "Rewrite switch statements in GLSL strict-ES2 mode."""
This reverts commit 64560c7cd5.

Reason for revert: Nexus5, also

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

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

Reason for revert: disabled offending tests

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

Bug: skia:12450
Change-Id: Ia0e23e20794ea707e54be50123b5323369354a03
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452721
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-24 20:50:20 +00:00
Jim Van Verth
8b85d7b429 Graphite: add ResourceProvider and CommandBuffer stubs
Bug: skia:12466
Change-Id: I30b53802d706406faf8045264c09a75ee3bf9126
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452232
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-09-24 20:30:16 +00:00
Michael Ludwig
397fdfdf18 Implement separate crop filter
Right now the crop image filter is hidden in src/ and is only used in
a new GM to test out its functionality. In later CLs the plan will be to
migrate individual filter effects away from the built-in crop rect to
composing themselves with this image filter.

Eventually, the crop filter will be made public as part of the
SkImageFilters factories so there can be independent control on input
and output cropping. Its features will also be expanded to support more
tile modes than just kDecal.

Once all other effects rely on this crop filter, the legacy system can
be deleted and the effects can be more easily updated to the rest of the
new image filter API. This crop filter is actually the first image
filter to be implemented only in terms of the new API (and skif coord
space types). This highlighted a few pain points that still exist in
terms of the API, where I have added comments to capture how they could
be improved. Unfortunately, they aren't addressable until the rest of
the implementations have been migrated.

Bug: skia:9296
Change-Id: I12e96b679c246a9ec4e1e61f640414a11f1b6bb5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/451597
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-09-24 20:18:36 +00:00
Brian Osman
c4c355940c Revert "Reland "Rewrite switch statements in GLSL strict-ES2 mode.""
This reverts commit c81edd0e8c.

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

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

Reason for revert: uses dedicated caps bit

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

Bug: skia:12450
Change-Id: I0d3b0969d2040dbb4ee808132146687767c97442
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452560
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-24 16:43:42 +00:00
Jim Van Verth
1e90b88e45 Graphite: Add stubs for Gpu and Caps
Bug: skia:12466
Change-Id: I1267d3a387e74dc510ee4d00925049a4e7ac9edd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452557
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2021-09-24 16:19:43 +00:00
Brian Osman
d26d0e6a47 Revert "Rewrite switch statements in GLSL strict-ES2 mode."
This reverts commit 45e3838006.

Reason for revert: Also need to rewrite them in actual ES2 mode.

Original change's description:
> Rewrite switch statements in GLSL strict-ES2 mode.
>
> Once this lands, switch statements will work everywhere--Metal, SPIR-V,
> GLSL, and SkVM.
>
> Change-Id: I2797d0a872de8be77bb9f7aa6acb93421d571d70
> Bug: skia:12450
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452356
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: skia:12450
Change-Id: I92656ed40289872405c0873f2c56a52b04e35b1d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452556
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2021-09-24 13:11:05 +00:00
John Stiles
45e3838006 Rewrite switch statements in GLSL strict-ES2 mode.
Once this lands, switch statements will work everywhere--Metal, SPIR-V,
GLSL, and SkVM.

Change-Id: I2797d0a872de8be77bb9f7aa6acb93421d571d70
Bug: skia:12450
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452356
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-23 21:22:09 +00:00
John Stiles
cb40008b43 Implement switch in SkVM.
SkVM implements switches as a pseudo-loop; breaks are handled with the
condition mask just like a for loop. Fallthrough is handled via a
scratch Value in a temporary slot. `writeStore` neeeded to be refactored
to support writing into slot(s) without an associated Variable.

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

Change-Id: I5507257246c42a35d2f46b4b9a89492a5ffeff9b
Bug: skia:12450
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/451421
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-09-23 19:58:55 +00:00
Robert Phillips
d6bf374c3c Graphite: Improve DM/Graphite connection
This makes "dm --config grgl --src gm skp" generate a lot of green pngs and adds a stub class for Image_Graphite.

Bug: skia:12466
Change-Id: Ia7cf891ad278434f473cf6c9c4673bf8fa085adf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/451740
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-09-22 21:34:09 +00:00
Michael Ludwig
01754ecf12 Graphite: Rough out DrawCommandList and BoundsManager
Device will own and manage a BoundsManager, which it will use to decide
the sort and test Z's that it passes to the DrawCommandList in its
draw() implementations.

DrawCommandList might end up being owned by the SDC, with the SDC
exposing a similar drawing API. There will need to be some mechanism to
end a DrawCommandList and start a new one (the list moves into an
SDCTask). This would either happen from an external flush call, or in
the rare case where the representable Z values are exhausted and we
have to insert a depth buffer clear and start a new task that depends
on the prior one.

Bug: skia:12466
Change-Id: I892b631037dc801eb94da2462683c9701afa281b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/451599
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-09-22 19:36:49 +00:00
Jerome Gaillard
6ee0018bfe Remove mssse3 flag of host builds for Android skia
This flag is not necessary, and it prevents users with CPUs that do not
support SSSE3 from using design tools in Android Studio.

Change-Id: Ia3b907c6f398e331f642256774116fbf720581da
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445937
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2021-09-22 18:36:20 +00:00
Robert Phillips
5a6f1606cc Add more stub classes
Bug: skia:12466
Change-Id: Iaa8431bf6fbe20c30b34a90a5a55f6f89723aa30
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/451257
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-09-22 15:59:54 +00:00
Jim Van Verth
5480677cfc Fix CMAKE build
Change-Id: I4471903f20b8167b71f81db91748794c7fbfb94b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/451576
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-09-22 14:16:40 +00:00
Robert Phillips
f15c3ff9d3 Add SkSurface_Graphite stub
and fix up the #include guards

Bug: skia:12466
Change-Id: I865ebb00827001b2cf0f7d871e872a7be0f36c22
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/451156
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2021-09-21 20:28:40 +00:00
John Stiles
1c5eb4b371 Disallow continue inside a switch.
This fails on several platforms in practice, and is of very limited
real-world utility.

Change-Id: Ib476396fc33cb51af6bbcf7fe822d30703ed995d
Bug: skia:12467
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450993
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-21 19:26:40 +00:00
John Stiles
35bd92638f Add tests for switch + loop constructs.
Change-Id: I17b5e21a28140b8e9313d87af9b1145674214fdb
Bug: skia:12450
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450989
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-21 17:23:47 +00:00
Robert Phillips
755e00edec Update sprint to graphite name
Change-Id: Ice0826af0b64fa8dd92975f879af8ab0f71740fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/451039
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-09-21 16:44:10 +00:00
John Stiles
e32309d771 Update switch-fallthrough test to run in dm.
Also, removed "switch containing dead code" test. This wasn't testing
anything meaningful. (When we had full CFG analysis, we could have
eliminated some of the assignments inside the switch body, but this is
not something we do anymore.)

Change-Id: Iaeb74ebee41a7f368113ede9a4e30c033b9de8ac
Bug: skia:12450
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450985
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-09-21 15:41:37 +00:00
Robert Phillips
1a4080add1 More beachhead
This should at least get something compiling.

Change-Id: I617fd4d6e4f0a3fdd6dedbe66f3a4448bb913b2c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450976
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-09-21 14:44:32 +00:00
John Stiles
b8f1651f9b Add workaround for switch() containing only a default case.
The Mac Radeon GLSL driver crashes when given a switch statement that
only contains a default case and returns a value. Adding a case works
around the crash, and doesn't affect the meaning of the switch.

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

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

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

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

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

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

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

Bug: skia:12450
Change-Id: If40c90023a64c608181285f6470b3e75303cc3cc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450756
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2021-09-20 21:57:09 +00:00
Greg Daniel
84261653c5 Reland "Add new GrSurfaceInfo class and related backend structs."
This is a reland of 6aac1193a7

Original change's description:
> Add new GrSurfaceInfo class and related backend structs.
>
> Bug: skia:12402
> Change-Id: I45b2f71dcfa5843e2a19a8de7d34196a4d552905
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445176
> Commit-Queue: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

Bug: skia:12402
Change-Id: Id540bea408d72ceba43ec4245c3748d630121926
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450277
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-09-20 20:44:53 +00:00
John Stiles
be056f4f62 Add switch statement support to PipelineStage.
This allows us to write SKSL_TEST_ES3 tests in SkSLTest and have them
run properly. Previously, such a test would assert inside the pipeline-
stage generator. In ES2 mode, we will rewrite switches as chained ifs,
but in ES3 mode we will want to continue emitting them as-is (they will
be faster than chained ifs on a modern GPU).

`writeSwitchStatement` is adapted from GLSLCodeGenerator.

Change-Id: I532ea5ed49869e7cdffced0cdcd0e353af8d4d79
Bug: skia:12450
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450478
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-20 18:55:09 +00:00
Ethan Nicholas
f62934b85a Fixed DSLParser error uncovered by ossfuzz
Missed one more case of Optional<Wrapper<Expression>>. This should be
the last one.

Bug: oss-fuzz:38944
Change-Id: Ic7f790cd99e2a3ee1c3874cc767a4702265d1723
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450476
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-09-20 17:57:14 +00:00
Jim Van Verth
14a9b089b6 Reland "Revert "New approach to GrProcessor uniforms.""
This reverts commit a59925fb1d.

Reason for revert: Speculative revert for https://crbug.com/1251070

Original change's description:
> Revert "Revert "New approach to GrProcessor uniforms.""
>
> This reverts commit ae59426ea6.
>
> Bug: skia:12182
> Change-Id: I591a0a89ffad1a3d5d867dd247ceeec71b6041a4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449516
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

Bug: skia:12182
Change-Id: I2f37c7e9675dd35194791340012e1b4135b076a1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450440
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2021-09-20 14:51:44 +00:00
Ethan Nicholas
c973d26854 Fixed DSLParser assertion error uncovered by fuzzer
Bug: oss-fuzz:38108
Change-Id: I0e055d837923f00b982bc395dbf29b6ff59a3b21
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448896
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-09-20 13:48:41 +00:00
Jim Van Verth
2f7ee02577 Revert "Add new GrSurfaceInfo class and related backend structs."
This reverts commit 6aac1193a7.

Reason for revert: Breaking Mac bots in Chromium roll. Looks like
they depend on getVkImageInfo for an unknown reason, and it's 
hidden behind SK_VULKAN.

Original change's description:
> Add new GrSurfaceInfo class and related backend structs.
>
> Bug: skia:12402
> Change-Id: I45b2f71dcfa5843e2a19a8de7d34196a4d552905
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445176
> Commit-Queue: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

Bug: skia:12402
Change-Id: I3c9642354dae8c955bc58d281700536393f84519
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/450199
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2021-09-18 16:35:38 +00:00
Greg Daniel
6aac1193a7 Add new GrSurfaceInfo class and related backend structs.
Bug: skia:12402
Change-Id: I45b2f71dcfa5843e2a19a8de7d34196a4d552905
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445176
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-09-18 00:41:07 +00:00
Ethan Nicholas
0dc1e0f797 Fixed DSLParser unary expression error handling
Missed a case when eliminating optional/wrapper in an earlier CL.

Change-Id: If7f80ea6e2172acadf7b0087fe1a05853ccae445
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449838
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-09-17 17:55:13 +00:00
Brian Salomon
a59925fb1d Revert "Revert "New approach to GrProcessor uniforms.""
This reverts commit ae59426ea6.

Bug: skia:12182
Change-Id: I591a0a89ffad1a3d5d867dd247ceeec71b6041a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449516
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-09-17 16:02:01 +00:00
John Stiles
eb68973c2f Disallow matrix ctors which overflow a column.
The GLSL spec allows matrix constructors containing vectors that would
split between multiple columns of the matrix. However, in practice, this
does not actually work well on a lot of GPUs!

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

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

Change-Id: Id6925984a2d1ec948aec4defcc790a197a96cf86
Bug: skia:12443
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449518
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-09-16 22:14:49 +00:00
Robert Phillips
ef80d7b50a Move more classes to skgpu::v1 namespace
Bug: skia:11837
Change-Id: Iaa0349749a5d79d7915fb37ef1b30b46f0aa58d6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448796
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-09-16 14:04:16 +00:00
John Stiles
a047e8bf4d Improve overflow checks in CheckProgramUnrolledSize.
The fuzzer discovered that it could overflow the program-size value.
Rewrote the logic to use SkSafeMath everywhere, and to early-exit as
soon as a statement manages to exceed the program size.

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

Bug: oss-fuzz:38726
Change-Id: I5270d4837ac982085d7baf5abd4b361f7bfb8562
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449062
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-09-15 15:41:49 +00:00
Robert Phillips
de60d7a64d Move more classes to skgpu::v1 namespace
Bug: skia:11837
Change-Id: If0bfb3009693b203b2080a1d43cc3b1865c3ab9e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448274
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-09-15 15:20:24 +00:00
Ethan Nicholas
fd1332f5a7 Reland "Fixed DSL assertion error on source files containing nulls"
This is a reland of db38ad7b14

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

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

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

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

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

Change-Id: Ie79242768966fcbe879ad73461d17b4fb8e55670
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448117
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-14 18:15:23 +00:00
Greg Daniel
2bc96d6771 Merge GrVkAttachment into GrVkImage.
Bug: skia:12402
Change-Id: I743724f66db8d7666d4d627d6945ce6bc3dc6bc3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448261
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-09-14 13:34:17 +00:00
John Stiles
7d19065eef Add test of off-kilter matrix constructors.
This exposes a bug in the Metal code generator which will be resolved
in a followup CL.

Change-Id: If073835dbee474ea9a805eb92b42dc1fca2afbd0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448378
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-09-14 13:01:26 +00:00
Brian Salomon
ae59426ea6 Revert "New approach to GrProcessor uniforms."
This reverts commit 10c9f36bdd.

Reason for revert:bad gms, maybe blocking chrome roll

Original change's description:
> New approach to GrProcessor uniforms.
>
> The important aspect is that it allows knowing the uniforms that will
> be used by a set of processors without having to create ProgramImpls.
>
> GrProcessor subclasses specify uniforms at creation time in a similar
> style to how GrGeometryProcessors already specify attributes. That is,
> they initialize a span of structs describing the uniform which may
> contain void uniforms that are skipped. Unlike attributes, the struct
> contains an offset into the processor where the data is stored.
>
> GrUniformAggregator is used to collect the uniforms from all processors
> that compose a draw and mangle their names. The ProgramImpl subclasses
> query the aggregator for their uniform names when emitting code.
>
> The old system for uniforms is left intact and only three processors,
> one GP, one FP, and one XP, are updated to use the new system.
>
> Some pieces that are missing before everything can be moved over:
> -support for uniforms not owned by GrProcessor (e.g. rt-adjust)
> -support for samplers
> -helpers for common patterns
>  (e.g. GrGeometryProcessor::ProgramImpl::setupUniformColor(),
>   and the various matrix helpers on ProgramImpl)
>
> Bug: skia:12182
>
> Change-Id: I21c1b7a8940eb9b8aad003f5a2569e43977a33d2
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440841
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

Bug: skia:12182
Change-Id: I6cc508900a599d27124f8ba48597593192d5d807
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448418
Auto-Submit: Brian Salomon <bsalomon@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2021-09-13 21:22:16 +00:00
Brian Salomon
10c9f36bdd New approach to GrProcessor uniforms.
The important aspect is that it allows knowing the uniforms that will
be used by a set of processors without having to create ProgramImpls.

GrProcessor subclasses specify uniforms at creation time in a similar
style to how GrGeometryProcessors already specify attributes. That is,
they initialize a span of structs describing the uniform which may
contain void uniforms that are skipped. Unlike attributes, the struct
contains an offset into the processor where the data is stored.

GrUniformAggregator is used to collect the uniforms from all processors
that compose a draw and mangle their names. The ProgramImpl subclasses
query the aggregator for their uniform names when emitting code.

The old system for uniforms is left intact and only three processors,
one GP, one FP, and one XP, are updated to use the new system.

Some pieces that are missing before everything can be moved over:
-support for uniforms not owned by GrProcessor (e.g. rt-adjust)
-support for samplers
-helpers for common patterns
 (e.g. GrGeometryProcessor::ProgramImpl::setupUniformColor(),
  and the various matrix helpers on ProgramImpl)

Bug: skia:12182

Change-Id: I21c1b7a8940eb9b8aad003f5a2569e43977a33d2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440841
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-09-13 19:55:06 +00:00
John Stiles
7591d4b5ef Replace trio of XxxxLiteral types with a single Literal type.
Throughout SkSL we've begun using doubles as a convenient way to store
any SkSL value (int, float, bool) in a single type. This idea has now
been extended to literals. Rather than having three expression kinds for
integers, floats and boolean literals, we can have just one. These can
be accessed in a type-specific way (`floatValue`, `intValue`, and
`boolValue` return the expected type, or assert if it's not the
matching type), or in a type-agnostic way (`value` will return a double
and works on any type of Literal).

This allows us to remove a complex template trick (Literal<T> is gone),
removes two redundant Expression types, and and lets us reduce our code
size in ConstantFolder, FunctionCall, etc.

Most of the conversion process was pretty straightforward:
* `IntLiteral::Make` becomes `Literal::MakeInt`
* `x.is<IntLiteral>()` becomes `x.isIntLiteral()`
* `x.as<IntLiteral>.value()` becomes `x.as<Literal>.intValue()`

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

Change-Id: I6e9d97c7c9ca969aba65e601bbcd9fe676105838
Bug: oss-fuzz:38560
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448116
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-13 13:34:48 +00:00
Michael Ludwig
47d824415e Revert "Fixed DSL assertion error on source files containing nulls"
This reverts commit db38ad7b14.

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

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

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

Change-Id: I3b80499e9b182c9ea046c479f35d7a965d548401
Bug: oss-fuzz:38107
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/447182
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-10 18:44:22 +00:00
Ethan Nicholas
c9d65f0b8a Fixed duplicate function definition error discovered by fuzzer
Bug: oss-fuzz:38140
Change-Id: I76a1b3ef8289b3089192d043d173677c00741a54
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445836
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-10 17:35:52 +00:00
Ethan Nicholas
bf4a7d5235 Fixed DSLParser crash with invalid swizzle
In response to a non-identifier token after a dot, DSLParser would
attempt to swizzle a zero-length field and fail an assertion.

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

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

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

Change-Id: I8b2f0411358aeb68c4edfeb0bd7a2814c4be1f40
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/447056
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-09-09 18:59:15 +00:00
Robert Phillips
769b4884a9 Move some more Ops to skgpu::v1 namespace
Bug: skia:11837
Change-Id: I522636c6dbf977929b0d368e18beb9c3a01fdeb1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/446184
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-09-08 15:41:04 +00:00
Ethan Nicholas
a2c76c77c4 Fixed illegal interface block reporting
DSL was improperly allowing interface blocks in runtime shaders, which
caused PipelineStageGenerator to get upset.

Bug: oss-fuzz:38131
Change-Id: I593e68f2cab3db9151d606e65e2826ffa9c494e2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/446324
Commit-Queue: Ravi Mistry <rmistry@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-09-07 20:18:00 +00:00
John Stiles
3ff77f4862 Fix inliner bug discovered by fuzzer.
Intrinsic-call optimization can be triggered during inlining. In this
case, inlining turned `normalize(x)` into `normalize(constant-value)`.

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

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

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

Change-Id: I6da98788d93749ffeb008c1f4c3f72b436e8ceeb
Bug: oss-fuzz:37994
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445956
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-09-07 13:29:37 +00:00
Brian Osman
3099f798e7 SkSL: Add support for method calls on effect objects
Includes .eval() as a new alternative syntax for sample/shade.

Bug: skia:12302
Change-Id: Ia921c141b3eeeba7e5309d921967b941f9cd055e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/444756
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-09-03 14:53:33 +00:00
John Stiles
2af4b13925 Reject programs which exceed 50 stack frames during size analysis.
Our program-size analysis pass needs to recurse into called functions;
depending on the exact order of functions in the program, this recursion
can hypothetically be as deep as the deepest function-call chain. Set an
upper bound on recursion here, so we don't overflow the stack while
trying to check the program size. In practice, 50 frames is far deeper
than a regular shader should ever go.

Change-Id: I733ee48dad6f8053facdfd9f6d8a2b9b2a4af188
Bug: skia:12396
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/445279
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-09-03 02:41:34 +00:00
John Stiles
61e5e202a5 Enforce an upper bound on Runtime Effect program size.
The fuzzer is currently learning to make unboundedly-large programs by
nesting medium-size loops repeatedly. SkVM doesn't have a mechanism to
limit the ensuing explosion of code and ends up making unreasonably deep
stacks and/or unreasonably large programs.

SkSL now enforces an upper bound of approximately 100,000 IR nodes on a
fully-flattened, fully-inlined strict-ES2 program. The limit is picked
out of thin air, but this should be enough to prevent SkVM from going
haywire while still being large enough to handle any reasonable program.
We can definitely tune this value if we find that it is too large
(admitting dangerous code) or too small (rejecting good code).

Change-Id: I11735636175721fbc79460b4e194d8e4b42dc47d
Bug: skia:12396, oss-fuzz:37827, oss-fuzz:37837
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/444358
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-02 14:44:34 +00:00
Robert Phillips
fbf021492e Move more Ops to skgpu::v1 namespace
GrFillRRectOp
GrFillRectOp

Bug: skia:11837
Change-Id: Icdecc2ccd9def659b0d9402910b2072e02577a66
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/444817
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-09-02 13:25:29 +00:00
Robert Phillips
46d7bd56f6 Move more Ops to skgpu::v1 namespace (take 2)
GrClearOp
GrDashOp

Bug: skia:11837
Change-Id: I9ada76c061154e769e7f486e7c57a93fd1d74907
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/444636
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-09-01 18:57:02 +00:00
Robert Phillips
d2f53f9e3e Move more Ops to skgpu::v1 namespace
Bug: skia:11837
Change-Id: Ia79f76c18587741000367edba303c5f7c0c1087d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/444178
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-09-01 16:50:16 +00:00
Robert Phillips
5fe828accb Revert "Move more Ops to skgpu::v1 namespace"
This reverts commit f3158abda3.

Reason for revert: Broke Flutter build

Original change's description:
> Move more Ops to skgpu::v1 namespace
>
> GrClearOp
> GrDashOp
>
> Bug: skia:11837
> Change-Id: Ib65418952e7d4fb1e419e4942223823f22302b34
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/443518
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>

TBR=robertphillips@google.com,michaelludwig@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: Ic181ced7f5f2a8ff834fdcfb4e5265b99eef1666
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11837
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/444365
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-09-01 14:44:46 +00:00
Robert Phillips
f3158abda3 Move more Ops to skgpu::v1 namespace
GrClearOp
GrDashOp

Bug: skia:11837
Change-Id: Ib65418952e7d4fb1e419e4942223823f22302b34
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/443518
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-09-01 14:03:55 +00:00
John Stiles
5cec187b36 Fix array timeout discovered by the fuzzer.
The fuzzer discovered that, when we attempt to verify that an array
doesn't contain any literal values that are out-of-range for its base
type, we pay a linear-time cost based on the size of the array. This
happens even when the array value isn't known at compile time; we still
iterate over its slot count and diligently discover that every single
constant-subexpression slot in the expression is "null".

We now have a helper function on Expression,
`allowsConstantSubexpressions`, which only returns true for expression
kinds that can contain constant subexpressions. We use this helper to
skip over this linear-per-subexpression check when the expression
cannot possibly contain a constant subexpression. In particular,
`AnyConstructor::compareConstant` and `Type::checkForOutOfRangeLiteral`
will now early-out for expressions that can't possibly contain a
constant subexpression.

Change-Id: Ia34e422afa67b478a8616acb0a0e9cd211b29698
Bug: oss-fuzz:37900
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/444136
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-31 19:55:45 +00:00
Greg Daniel
0e32aa8a3a Rename some GrD3DTypes* header files.
I want to free up GrD3DTypesPriv to actually be private types that
include real d3d objects.

Change-Id: Id38d6baae4fa68c19301b27d4f9d51eb1d9c5db0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/443676
Commit-Queue: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Auto-Submit: Greg Daniel <egdaniel@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-08-31 18:49:46 +00:00
Robert Phillips
cadd5dbded Move three Op-derived classes to the skgpu::v1 namespace
GrRegionOp
GrShadowRRectOp
GrStrokeRectOp

Bug: skia:11837
Change-Id: I0b573031acb13138e1549712c555337247e0a08e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442836
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-30 21:16:11 +00:00
John Stiles
f89a8122a4 Fix flaws in minus-prefix optimization.
We had a logic bug when attempting to optimize the following code:
    const vecN x = vecN(a, b, c);
    -x;

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

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

Change-Id: I10dd2460ab26ba3e820b0cff5db091368fb7e648
Bug: oss-fuzz:37764, oss-fuzz:37861
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/443407
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-30 20:40:17 +00:00
Robert Phillips
31f763190f Move GrAtlasTextOp to skgpu::v1 namespace
Bug: skia:11837
Change-Id: I3dde13940e57763d5a8224cb1a4b555e904351d7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442716
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-30 14:56:55 +00:00
Robert Phillips
2145390fbe Move GrTextureOp to skgpu::v1 namespace
Bug: skia:11837
Change-Id: Ie99b1c512885404351d6917bbea751d99a2ca23e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442797
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-30 14:14:14 +00:00
Brian Osman
99ddd2a98d Remove (unused) geometry shader support
Bug: skia:8451 skia:10827
Change-Id: I5b38a1d72cd4558f8e2a92aaf9b12f05efce0923
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442683
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-08-27 19:41:10 +00:00
John Stiles
8d13084535 Migrate function-body finalization out of IRGenerator.
This is a first step towards replacing `finalizeFunction` with a
`FunctionDefinition::Convert` method living outside of the IRGenerator.

Previously this code would assert that we had no early returns from a
vertex-program main() method; this has been turned into an error.
(The original assertion was also tied to fRTFlip, because the *problem*
with early-returns in main is tied to the lack of RTFlip fixups, but
we fundamentally don't allow early returns, so it makes more sense to
just universally disallow it.)

Change-Id: Iba0742f7ef3cbc83995ea130fec1eb1ef2556c44
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442691
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-27 18:51:52 +00:00
John Stiles
842ee5bd8d Fix assertion when calling a built-in function at global scope.
The fuzzer invented a much more elaborate example, but I was able to
winnow it down to a simple otherwise-normal test case. This also fixes
a latent DSL bug; DSL functions were not updating the list of referenced
intrinsics, so the compiler might emit finished programs that called
built-in functions that didn't exist in the code.

Change-Id: I095bb566b9db9f87cbe9460732c300b7973eb112
Bug: oss-fuzz:37659
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442325
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-27 17:05:21 +00:00
John Stiles
bb8cf5804c Fix invalid variable ref-kind discovered by fuzzer.
No-op arithmetic simplification will convert expressions like `x += 0`
to `x`. When making this simplification, we will also downgrade the ref-
kind of `x` from "write" to "read" since the new expression is no longer
an assignment.

The fuzzer discovered that the ref-kind downgrade was too aggressive,
and would also traverse into nested subexpressions and downgrade them
as well. That is, for `x[y=z] += 0` would convert both `x` and `y`
into "read" references, which is incorrect; `y` is still being written
to.

The fuzzer managed to turn this mistake into an assertion by leveraging
a separate optimization. It added a leading, side-effect-less comma
expression for us to detect as worthless and eliminate. In doing so, we
clone the expression with the busted ref-kind, triggering an assertion.

Change-Id: I42fc31f6932f679ae875e2b49db2ad2f4e89e2cb
Bug: oss-fuzz:37677
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442536
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-27 14:01:21 +00:00
Robert Phillips
fdafc0cbe4 Move GrAtlasRenderTask to gpu/ops and skgpu::v1 namespace
Bug: skia:11837
Change-Id: I29352c0e2c9e987b28be983c3d519a88b589baf1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442022
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-25 21:39:11 +00:00
John Stiles
fbb905e70f Remove nearly-unused ASTNode description code.
The entire ASTNode is probably going away soon, but this is a decent
place to start. Checking the fuzzer logs, we had 0% coverage in here,
which makes sense because it's unreachable by any normal means.

Change-Id: I396464e3e613d46e990b629c4fc991c11f6110fa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442000
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-25 20:58:13 +00:00
Robert Phillips
3e87a8eda9 Move GrOpsTask to gpu/ops and the the skgpu::v1 namespace
Bug: skia:11837
Change-Id: I9ee6343b5144b02e8f455df0ea01b8199a8f14e1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440837
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2021-08-25 18:32:17 +00:00
John Stiles
43ac7e6315 Fix parsing error with SPIR-V negating a uint.
Our SPIR-V code generator did not implement support for negating a uint.
However, this is something that GLSL allows (as does the rest of SkSL).
I checked glslang and it uses OpSNegate here. The SPIR-V docs indicate
that OpSNegate allows any type of integer, and the validator lets it
pass, so we now use OpSNegate here as well.

http://screen/33mkq92uxAT5Xu8
http://screen/4YBTh3gCWz8eZx7
http://screen/388HtXyytcN5vLZ

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

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

Change-Id: I42d7372ba77fa1528ae24eb8c29a2e5903784139
Bug: oss-fuzz:37622
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441878
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-25 17:26:54 +00:00
John Stiles
f95048cc4d Report intermediate expressions as errors in For next-exprs.
We weren't coercing the expression because we don't care about its type,
but that allowed intermediate-expressions to pass through without
reporting an error. Now we coerce the expression to its present type,
which will always fail if the type is disallowed and succeed otherwise.

Change-Id: Ic0de0d17f0f5d56360575efe992ce4d74dec2a5a
Bug: oss-fuzz:37620
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441876
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-25 17:26:21 +00:00
Michael Ludwig
c1ed11d909 Move GrBlockAllocator and GrTBlockList to src/core/
src/gpu/GrBlockAllocator -> src/core/SkBlockAllocator
src/gpu/GrTBlockList -> src/core/SkTBlockList

Tests and references also renamed.

Bug: skia:12330
Change-Id: I5fad05faa3dcecd89a0a478dcf30c090ea7589f5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441477
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-08-25 13:21:32 +00:00
Brian Osman
b5282f0112 Migrate runtime effect sample tests to golden files
Much easier to maintain, especially with an upcoming change to the
sampling syntax.

Change-Id: I378811b7be0afcce5b7e68a942e7b46d96568155
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441518
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-08-24 15:19:44 +00:00
John Stiles
d77dda5bd5 Fix inliner bug discovered by fuzzer.
The inliner contained a type error when attempting to inline a function
that takes an array as input. The scratch copy of the array was created
as `float[123] var;` instead of `float var[123];`. This led to an
assertion in VarDeclaration::Make.

Change-Id: I5128fe71462bb59a015a7b4e59c1a74800828b16
Bug: oss-fuzz:37466
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441576
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-24 14:44:43 +00:00
Ethan Nicholas
553239bc12 Added reportPendingErrors to SkSL code generation
This fixes an assertion failure uncovered by the fuzzer.

Bug: oss-fuzz:37469
Change-Id: I626c003cfa8a0bc65851899df3a7695dbe29200b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441311
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-08-23 20:54:40 +00:00
John Stiles
3f37322d71 Fix const function-parameter assertion discovered by fuzzer.
During constant-folding, we baked in an assertion stating that any
const-typed variable reference ought to have an initial value, because
you can't declare a const variable without assigning a value. However,
function parameters are an exception to this rule! They are variable
references and are allowed to be const, but will not have an initial
value. (In this case, `const` just means you can't alter the value.)

In this case, all we needed to do was remove the assertion; we already
treated this case defensively and with the appropriate care.

Change-Id: I61242c6d08c59886c6992898f195771e6334f2b4
Bug: oss-fuzz:37465
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441239
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-23 19:28:29 +00:00
John Stiles
7253a201a3 Improve error-checking during array-size conversion.
The fuzzer noticed insufficient guards in IndexExpression::Convert when
converting an array size from an IntLiteral to a SKSL_INT. We had code
in IRGenerator which did this properly, so I moved our array-size
conversion logic into SkSLType and had IndexExpression share it.

Also, a variety of tests around similar error conditions were added.

Change-Id: I51529dea25f9029f81ae236511610069d66be29f
Bug: oss-fuzz:37462
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441236
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-23 14:35:00 +00:00
John Stiles
8f633ef2b5 Fix assertion discovered by fuzzer.
We now stop processing a var-declaration if its array-size expression is
invalid. Previously, we'd pass a null array-size expression into
convertVar, which would assert (but would fail cleanly afterwards).

Change-Id: I976f3326e32afbc7045a86d73c0dcb28f418a6f4
Bug: oss-fuzz:37457
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441079
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-23 14:23:46 +00:00
Robert Phillips
e453fa063d Move some v1-only gpu/tessellate files to gpu/ops
This CL just moves the files and renames them. It doesn't move them into the skgpu::v1 namespace.

Bug: skia:11837
Change-Id: Iab322d0dc5b5d1cfd32436785081539dc85c18d3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440776
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
2021-08-19 19:56:46 +00:00
Robert Phillips
db0ec08127 Move GrPathRenderer and GrPathRendererChain to skgpu::v1 namespace
Bug: skia:11837
Change-Id: I42abcd3724ac1e2c71d3bd13ff6295a4683af5e0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440261
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-19 18:26:57 +00:00
Robert Phillips
43e70f1913 Move 2 path renderers to skgpu::v1 namespace
Bug: skia:11837
Change-Id: I71c8e5b7221e0eb84400e0ddc1a8126d820d24bb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440538
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2021-08-19 16:16:23 +00:00
Robert Phillips
832f3fbcae Move GrTessellationPathFlags to their own header (GrTessTypes.h)
Having this enum on GrTessellationPathRenderer forced it to be over-#included and was blocking making GrTessellationPathRenderer.h v1-only.

Bug: skia:11837
Change-Id: I80660ed659946d7aa555057c9f4fd1136b44cca0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440536
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-19 14:47:45 +00:00
Robert Phillips
9030a3b1f6 Move GrStencilMaskHelper and GrStencilClip to skgpu::v1 namespace
Bug: skia:11837
Change-Id: I6aee4b5fcdb39a669f1ce9adb143b4562c206e57
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440263
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-18 15:59:14 +00:00
Robert Phillips
74b943237e Move GrClipStack to skgpu::v1 namespace
Bug: skia:11837
Change-Id: I42dfaf795ec6afe9d648b0715457a3a38ef8c7a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439943
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-18 13:58:45 +00:00
Robert Phillips
db857ce628 Make GrSmallPathAtlasMgr and GrSmallPathShapeData v1-only files
This is part of making everything in the gpu/ops directory be v1-only.

Bug: skia:11837
Change-Id: I9709ffc140a77d4d68f3838e3d30374df0913889
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440156
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-17 23:42:26 +00:00
John Stiles
b0697081b5 Improve SPIR-V handling of RTFlip when running the fuzzer.
If the passed-in shader references RTFlip (i.e., sk_FragCoord is used),
the settings must contain RTFlip layout info; otherwise, an error
occurs. Originally, the fuzzer detected this as a problem because the
error was being delivered via SK_ABORT, but it's failing more cleanly
now that Ethan's new error handling code is in place (causing the fuzzer
to report that the bug was "fixed"). With this CL, the oss-fuzz shader
will actually compile successfully in SPIR-V instead of leading to an
error.

Change-Id: I3268e84bd8e01c95a25ed0845a37324e98033c4b
Bug: oss-fuzz:35916
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439779
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-17 22:31:10 +00:00
Robert Phillips
461c539a04 Move several more PathRenderers to skgpu::v1 namespace
Bug: skia:11837
Change-Id: Ifa1da88aafcaa96e0e885facaeb849cc9963bcfe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439938
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-17 22:19:11 +00:00
Robert Phillips
41ebbd71b1 Move triangulators and tessellators into gpu/geometry
This is the other half of making everything in gpu/ops be v1-only.

Bug: skia:11837
Change-Id: I5d77a499ef02eba69208d5bd634650433d02f6fb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440216
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-17 19:25:25 +00:00
Robert Phillips
17dc658f29 Move Software and Small PathRenderers to skgpu::v1 namespace
Bug: skia:11837
Change-Id: Ia34f1840aaa7360ea9a3ca40fef5cb96b68c6ca3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439781
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-17 16:52:47 +00:00
John Stiles
059798f40e Test that Runtime Effects cannot use non-ES2 types.
Surprisingly, we didn't actually have a preexisting test covering this.
Error reporting is lackluster in this CL but will be improved in the
followup.

Change-Id: I0b1cdb5a82f066af6b9d3fd9c39748080c2e18c0
Bug: skia:12348
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439996
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-17 15:10:02 +00:00
John Stiles
7d99ba2503 Enable variable-shadow warnings.
This will prevent us from reusing a variable name from an outer scope
within an inner scope; this is a common source of confusion or bugs.
There are two special cases where shadowing is still allowed.

- Constructor arguments that match class member variables, e.g.:

    MyCtor(int value) : value(value) {}

- Lambdas where the outside variable is not accessible in the inner
  scope, e.g.:

    void Fn(int x) {
        auto lambda = [] { int x = 123; };  /* outer x not captured */
    }

Change-Id: I073bdaf7c530fc958fc13ce68464cf345a2f5358
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439497
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-08-16 18:06:06 +00:00
Brian Osman
eb0f29dba2 SkSL: Allow invoking children (shaders, etc) like functions
Previously, you would declare child objects (shaders, colorFilters, etc.)
and "sample" them like this:

    uniform shader input;
    uniform colorFilter filter;
    half4 main(float2 coord) {
        half4 inColor = sample(input, coord);
        return sample(filter, inColor);
    }

With the new syntax, those child objects become directly callable,
reflecting the way that Skia assembles all parts of the paint (as functions)
in the overall fragment shader:

    uniform shader input;
    uniform colorFilter filter;
    half4 main(float2 coord) {
        half4 inColor = input(coord);
        return filter(inColor);
    }

Bug: skia:12302
Change-Id: Ia12351964dc5d2300660187933188e738671cd83
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436517
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-08-16 14:52:51 +00:00
Ethan Nicholas
da44b579f5 Removed missing file from sksl.gni
sksl.gni still had a reference to a now-deleted file, which is
presumably the cause of the current build failures.

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

Change-Id: I3a7d4514e338ca0810a21413e900248b1a2153e0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439283
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-13 23:49:25 +00:00
Ethan Nicholas
4a5e22a8c8 Further unified error handling between SkSL and DSL
This eliminates the SkSL ErrorReporter class and funnels everything
through the DSL ErrorHandler. Since the DSL error handler can be
changed, this required a number of updates to ensure that things work
properly in the face of custom error handlers. There is probably more
work to be done in that area, but this at least passes all existing
tests.

Change-Id: Iaee27b79fc4ed426c484ccab257c09d28619ead5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438116
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-08-13 22:26:10 +00:00
Robert Phillips
364ea352b0 Make remaining GrOp derived classes be skgpu::v1 only
I will follow up with a CL actually moving the newly V1-only files to their final homes and adding namespaces.

Bug: skia:11837
Change-Id: I0fed1a802ae93a4357c53cde2b665ad6ddb49a6f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/418996
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-13 20:21:15 +00:00
John Stiles
4e2494870d Allow derivatives in Runtime Effects when ES3 restrictions are off.
We can now add functions to sksl_public.sksl with an $es3 prefix. These
will be allowed in a Runtime Effect when strict-ES2 mode is disabled.
Note that the CPU backend still doesn't have support for these calls,
and will fail ungracefully (assertion, nonsense result) if these
intrinsics are used.

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

Change-Id: I9c911bc2b77f5051e80844607e7fd08ad386ee56
Bug: skia:12202, skia:12340
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439058
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-13 16:45:17 +00:00
John Stiles
efde90d973 Add $es3 modifier to SkSL.
This modifier is currently allowed on built-in functions only.

The presence of this modifier will be used to indicate intrinsics which
are ES3-specific (and therefore, not allowed in user code under typical
circumstances).

Change-Id: Ice6be8d9d1b2bf0c8f07f2a89f335bb2f90f6681
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439057
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-13 14:07:40 +00:00
Robert Phillips
06273bcb8a Prepare headers for making all ops V1-only
Basically, ensure all the headers about to become V1-only only appear in contexts that are currently or will soon be V1-only.

This is almost all fallout from retracting some of the moving headers from other headers i.e.:

GrMeshDrawOp.h from GrOpFlushState.h
GrDrawOp.h from GrOpsRenderPass.h
GrDrawOp.h from GrOpsTask.h
GrSimpleMeshDrawOpHelper.h from GrTessellationShader.h


Bug: skia:11837
Change-Id: I939f5c82c3042e9ab00571b5796ab82dbe968085
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438677
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-12 15:09:11 +00:00
Brian Salomon
4895946078 Move ProgramImpl definitions into Processor subclass headers.
Move ProgramImpl function definitions into Processor subclass cpp files.

Delete separate h/cpp files.

Modify GrGLSLVaryingHandler::addPassThroughAttribute to break #include
cycle. It now takes a ShaderVar rather than a GP::Attribute, making
it slightly more flexible as the input can be any variable defined
in the vertex shader.

Bug: skia:11358
Change-Id: I94ee8cd44d29e194216592ecae5fd28de785c975
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438596
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-08-11 19:45:56 +00:00
John Stiles
26487162fe Add support for array-cast syntax in SkSL.
Compiling a program with "allow narrowing conversions" actually fixes up
narrowing casts in the program by inserting casts wherever they would be
needed for type-correctness. For instance, compiling the statement
    `half h = myFloat;`
inserts an appropriate narrowing cast:
    `half h = half(myFloat);`.

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

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

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

Change-Id: Ia20933541c3bd4a946c1ea38209f93008acdb9cb
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437687
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-11 12:56:40 +00:00
Robert Phillips
53eaa64873 Rename GrSurfaceContext -> skgpu::SurfaceContext
Almost entirely mechanical.

Bug: skia:11837
Change-Id: I984339097fdeeae2eccb6c1d790d510020511961
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438177
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-10 19:24:53 +00:00
Michael Ludwig
b23630c509 Reland "Remove SkTLList"
This reverts commit 14b1d56a2b.

Reason for revert: fix emplace_back() usage

Original change's description:
> Revert "Remove SkTLList"
>
> This reverts commit e1d523d70f.
>
> Reason for revert: breaking old stdlib versions (< c17)
>
> Original change's description:
> > Remove SkTLList
> >
> > Change-Id: I198678b5cb298cf51872fbb8d4fd5d705a6b684e
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437339
> > Reviewed-by: Brian Osman <brianosman@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
>
> TBR=brianosman@google.com,michaelludwig@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com
>
> Change-Id: I8e02e4cd2f293e7530f842be783de10f69be2ef4
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438078
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

# Not skipping CQ checks because this is a reland.

Change-Id: Ied33ce81a8312963ff0713c4660cdb8541a02180
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438080
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-10 17:57:41 +00:00
Michael Ludwig
14b1d56a2b Revert "Remove SkTLList"
This reverts commit e1d523d70f.

Reason for revert: breaking old stdlib versions (< c17)

Original change's description:
> Remove SkTLList
>
> Change-Id: I198678b5cb298cf51872fbb8d4fd5d705a6b684e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437339
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

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

Change-Id: I8e02e4cd2f293e7530f842be783de10f69be2ef4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438078
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-08-10 14:53:52 +00:00
Michael Ludwig
e1d523d70f Remove SkTLList
Change-Id: I198678b5cb298cf51872fbb8d4fd5d705a6b684e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437339
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-08-10 14:36:07 +00:00
Michael Ludwig
e1d0040c54 Delete GrClipStackClip and GrReducedClip
Bug: skia:10205
Change-Id: Iafee804751d69e98241a7825664f3be04b20eb14
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436566
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-08-09 18:53:58 +00:00
Ben Wagner
51d83abcd2 Ease HarfBuzz API change with feature detection
Skia has been using the not entirely public HarfBuzz subsetting API.
This API is changing for public release. In order to make the transition
from old to new build flags were added, which would require build
changes as HarfBuzz is updated downstream. Instead detect the existence
of the old or new API and use whichever is present automatically.

Change-Id: I0727f97ad7d394dfb24553076d4b383570cf0002
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437121
Reviewed-by: Garret Rieger <grieger@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2021-08-06 17:22:22 +00:00
John Stiles
2195f94a0c Add unit test for array narrowing conversions.
Change-Id: Ibadda2a10e19984c7a0efb66fd3187f280666445
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436996
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-06 13:05:35 +00:00
John Stiles
e3f85e07fa Add improved regression test for oss-fuzz:36655.
Most of the code generated by the fuzzer is nonsense, but there is a
method to its madness. The crash is only triggered under specific
conditions:
- The runtime effect has enough helper functions to mostly fill up the
  call graph hash-map. It won't rehash until it gets close to capacity.
- There must be several calls to built-in functions, in order to add
  elements to the call graph to force a rehash.

The fuzzer-generated code manages to satisfy both these requirements.

Change-Id: I9a1d7535557fedd4e9bfece3930ac86ede291ffe
Bug: oss-fuzz:36655
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437118
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-06 13:03:32 +00:00
John Stiles
e3ae968f5f Enable comparison of arrays of different precision types.
GLSL allows an array of `lowp float` to be compared against `highp
float` seamlessly because the types are considered to be the same. SkSL,
however, treats these as different types, so we need to coerce the types
to allow this comparison to work.

In other words, these comparisons can cause an array to be implicitly
casted. The expression `myHalf2Array == float[2](a, b)` should be
allowed when narrowing conversions are enabled. To allow this to work,
we need a dedicated IR node representing this type coercion.

We now allow implicit coercion of array types when the array's component
types would be implicitly coercible, and have a new IR node representing
that implicit conversion.

This CL fixes array comparisons, but array assignment needs additional
fixes. It currently results in:
    "type mismatch: '=' cannot operate on (types)".

Bug: skia:12248
Change-Id: I99062486c081f748f65be4b36a3a52e95b559812
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436571
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-06 12:57:10 +00:00
Garret Rieger
66684b17b3 Roll HarfBuzz from 2.6.4 to 2.8.2-147
3a74ee5282..368e957887

Additionally adds a build option that switches to the new
harfbuzz subsetting api which is coming in the next version
of harfbuzz.

Change-Id: I924a7b4978412d636d4c8d19f5c6021ea3c73d21
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433737
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2021-08-06 02:54:40 +00:00
John Stiles
9ae6ea0711 Fix fuzzer-discovered error with swizzling matrices.
The optimization logic for swizzling a constructor assumed that every
argument to the constructor was a scalar or vector. When it was written,
this assumption was true. However, we recently added support for casting
mat2x2 to float4 which violates the assumption.

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

Change-Id: Ia2b297bd62dfdf4af56712164fbc80c29c9611eb
Bug: oss-fuzz:36852
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437017
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-05 21:59:23 +00:00
Robert Phillips
5ac7f33281 Add V2 SFC and SDC stubs
Bug: skia:11837
Change-Id: Id7aa117af3e026d71caeed3ee6489394e869eed1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436568
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-05 21:54:18 +00:00
John Stiles
ded41aafb2 Fix fuzzer-discovered error with SPIR-V interface arrays.
OSSFuzz discovered a minor variation of oss-fuzz:36770 which tickled a
different bug in SPIR-V RTFlip handling; we did not properly handle the
case where the InterfaceBlock is an array. SPIR-V does not support this
at all, but the IRGenerator allows it, and we don't detect it an an
error until later in the compilation process.

Change-Id: I80bd67a13dad878717dc122462132a2ed675532d
Bug: oss-fuzz:36850
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437018
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-05 21:44:16 +00:00
John Stiles
b806da4501 Honor lowp/mediump/highp precision qualifiers in IRGenerator.
This CL does not update the DSLParser to honor these precision
qualifiers; that will be done in a followup.

Change-Id: Ib629bc99c0e6c7afb550a381d4e3b6ccc26aa64e
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436337
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-04 21:29:10 +00:00
John Stiles
020143148f Add parser support for highp/mediump Tokens in vardecls.
These parse into new modifier bits; the IR generator does not yet
support these bits. That's coming in a followup CL.

Change-Id: I362e9227694f9b862eaad100f6afca45a9b62a01
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436336
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-04 21:11:14 +00:00
Robert Phillips
f3868628f9 Fission GrSurfaceFillContext into skgpu:: and skgpu::v1:: versions (take 2)
The only really interesting parts are:
  src/gpu/SurfaceFillContext.*
  src/gpu/v1/SurfaceFillContext.*

Everything else is mostly mechanical.

TBR=michaelludwig@google.com
Bug: skia:11837
Change-Id: Ia208e9a73d1529804c06d4f805d8ca3674851496
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436558
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-04 19:40:55 +00:00
John Stiles
9fdcc517b2 Write test demonstrating bug with array narrowing conversions.
We don't currently support this. There's no explicit syntax to cast an
array's type, but it can be implicitly required in some situations, like
`halfArray == floatArray` (when fAllowNarrowingConversions is on).

Change-Id: I00fe0ddd4f2682b2950e828dd78bb941d5f0430e
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436560
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-04 18:34:18 +00:00
Derek Sollenberger
40b82c6b5c Revert "Fission GrSurfaceFillContext into skgpu:: and skgpu::v1:: versions"
This reverts commit af844c79d5.

Reason for revert: breaking chrome roller

Original change's description:
> Fission GrSurfaceFillContext into skgpu:: and skgpu::v1:: versions
>
> The only really interesting parts are:
>   src/gpu/SurfaceFillContext.*
>   src/gpu/v1/SurfaceFillContext.*
>
> Everything else is mostly mechanical.
>
> Bug: skia:11837
> Change-Id: If2945f30dadd6ad0cccf6ff2b53e4a92b1dc6cbc
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436099
> Commit-Queue: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>

TBR=robertphillips@google.com,michaelludwig@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: I3b2d1d4a30e253a107f55dc3c5ecaaee5386e6e8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11837
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436557
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
2021-08-04 17:15:45 +00:00
Robert Phillips
af844c79d5 Fission GrSurfaceFillContext into skgpu:: and skgpu::v1:: versions
The only really interesting parts are:
  src/gpu/SurfaceFillContext.*
  src/gpu/v1/SurfaceFillContext.*

Everything else is mostly mechanical.

Bug: skia:11837
Change-Id: If2945f30dadd6ad0cccf6ff2b53e4a92b1dc6cbc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436099
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-04 14:30:10 +00:00
Leon Scroggins III
86b2c952ae Update gn_to_bp_utils to support python3
Python2 is going away, so update the script to run with python3.

Change-Id: I8c1aad12ecf8ae1bde67a1ad5486bf6feb1c04d1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436098
Reviewed-by: Ravi Mistry <rmistry@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2021-08-03 17:52:43 +00:00
Robert Phillips
46eb3ab80d Make v1/SurfaceDrawContext V1-only
The GrFillRectOp and GrTextureOp guards are temporary - just until they are made V1-only.

The SkGlyphRunPainter and GrTextBlob guards are going to linger since both will probably exist in both versions.

The GrTextBlob guards mainly hide the draw and makeAtlasTextOp methods.

Bug: skia:11837
Change-Id: Icc19d664bb4d93962bf63386dc59fe176cc61ea1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/434044
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-03 16:07:22 +00:00
John Stiles
e9dcbfdaa1 Add test for Runtime Effects and narrowing conversions.
This code intentionally mixes half4s and float4s everywhere. Before
http://review.skia.org/435916 landed, this resulted in a compile error.

Change-Id: I852fef6ee99a8b78623e0e9ddeee2ad84a8c0504
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436058
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-03 15:58:46 +00:00
Robert Phillips
a3f206e0b8 Non-substantive changes for making v1::SurfaceDrawContext V1-only
Bug: skia:11837
Change-Id: I60112e370c95e6f9d9bc12cb9b05d40dd2220bc9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/435279
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-02 19:22:58 +00:00
John Stiles
d7437eec2e Fix for fuzzer-discovered error in SPIR-V with RTFlip.
SPIR-V code generation synthesizes some extra variables that don't
actually exist in the Program. Checking the ProgramUsage of these
variables would fail; ProgramUsage::get doesn't know about these
variables, so it asserts (and would consider them as dead even if it
didn't assert). We now track our SPIR-V bonus variables in a separate
set, and always report them as live.

Change-Id: If2f681470654025abf7ca4b3ec8126de2eb01297
Bug: oss-fuzz:36770
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/435625
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-02 17:13:50 +00:00
John Stiles
68c9325263 Create test case to repro skia:12212.
Change-Id: I2dde12b262f51b00a95eb26f87b85c3f5a19b45b
Bug: skia:12212
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/428961
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-07-30 17:41:13 +00:00
Robert Phillips
1a2e7de8ea Update tests for a V1-only skgpu::v1::SurfaceDrawContext
Bug: skia:11837
Change-Id: If8dd864d6cd8bc5ab9569fbab40866e1810dbc27
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/434162
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-07-30 16:33:41 +00:00
John Stiles
131410a7d1 Add regression test for oss-fuzz:36655.
Change-Id: I7b53df1eae83a596c4d1f3620e7f9bd146f68af2
Bug: oss-fuzz:36655
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/434465
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-07-29 15:22:20 +00:00
Robert Phillips
4dca83162b Rename GrSurfaceDrawContext to skgpu::v1::SurfaceDrawContext
This CL is mostly mechanical. It:

replaces "src/gpu/GrSurfaceDrawContext.h" #includes with
         "src/gpu/v1/SurfaceDrawContext_v1.h" and reorders

replaces "class GrSurfaceDrawContext;" with
         "namespace skgpu { namespace v1 { class SurfaceDrawContext; }}"

replaces "GrSurfaceDrawContext*" with "auto" where possible
replaces "rtc" with "sdc"
replaces "surfaceDrawContext" with "sdc"
replaces GrSurfaceDrawContext with skgpu::v1::SurfaceDrawContext
reflows parameters as needed

This CL does not try to:

make skgpu::v1::SurfaceDrawContext V1-only
minimize the skgpu and/or skgpu::v1 prefixes

Those two tasks will be accomplished in follow up CLs. This CL is just trying to get the bulk of the mechanical changes comprehensibly landed.

Bug: skia:11837
Change-Id: I6fe59080249d585df8f5d27c6b67569cdc35842f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433156
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-07-28 20:12:10 +00:00
Herb Derby
5992f9eb43 draw vertices: fast triangles using a shader
Introduce a new call to SkShaderBase to return an
SkUpdatableShader. An SkUpdatableShader is both a SkShaderBase
and has an update() method.

If the onUpdatableShader call returns !nullptr, then the
shader's specialized updatable shader is used. Otherwise,
the shader is wrapped in a TexCoordShader.

This scheme allows Shaders to have specialized updaters,
but also adds updaters for shaders that don't need
specialization.

orig  this  bench
771µs 779µs verts_textures_colors
217µs 335µs verts_textures
275µs 380µs verts_textures_persp

Bug=skia:11822

Change-Id: I11ba344eba96188c5631228cd5e91c5d834ea3d6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/429417
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-07-28 18:08:35 +00:00
Brian Osman
310178c7b7 Microbench for canvas save/restore calls
Change-Id: I0dbf1af17c3a7ec70437e0479cd8b6b6269d155c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433476
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-27 21:08:11 +00:00
Chris Dalton
6966981ae0 Add a 'pathMatrix' to GrPathTessellator::prepare
The pathMatrix is applied on the CPU while the geometry is being
written out. It is a tool for batching, and is applied in addition to
the shader's on-GPU matrix. This CL also updates GrPathStencilCoverOp
do do all its path transformations with pathMatrix on the CPU side.
The next step will be for atlases to use the pathMatrix instead of
creating uber paths.

Bug: skia:12258
Change-Id: Ib924dfb06a2c0eed8f9045adc6ae9eefad510082
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433236
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-07-27 20:31:57 +00:00
Robert Phillips
400f52e691 Retract GrSurfaceDrawContext.h a bit
This CL just pulls GrSurfaceDrawContext.h out of headers and .cpp files where possible.

TBR=brianosman@google.com
Bug: skia:11837
Change-Id: Ib96f3619e3a50091516f81ae48f956fe83c05aff
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431384
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2021-07-26 18:28:04 +00:00
Jim Van Verth
6a54042bcd Add GrMtlRenderPipeline.
Creates a wrapper class just for id<MTLRenderPipelineState> so it can
be managed as a command buffer object.

Bug: skia:12253
Change-Id: Ibef833fda25d00e7b3110c17b59c5e760b523473
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431040
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2021-07-26 15:11:41 +00:00
Robert Phillips
04f22eacaa Feed all top-level GPU accessors through skgpu::BaseDevice (take 2)
This pulls the GPU-specific accessors off of SkCanvas and SkDevice - moving them all to skgpu::BaseDevice and SkCanvasPriv.

This will allow us to more easily change the gpu class hierarchy (esp. changing GrSurfaceDrawContext to skgpu::v1:SurfaceDrawContext) w/o churning the public API.

TBR=brianosman@google.com
Bug: skia:11837
Change-Id: Ib69a3ea27c840fa7758bc3318395a27228c7ae9d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431539
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-07-26 14:56:37 +00:00
John Stiles
bb2ef92d05 Add private blender type to SkSL built-in types.
This type will hold blender objects, similar to color filters and
shaders. Since the implementation is not yet complete, the type is
currently named `$blender` to indicate that it's private/inaccessible.
The $ will be removed once sampling is functional.

Many places which were conditioned on "is a color filter or shader" are
now conditioned on a helper method instead; if we ever add another
runtime effect type in the future, there should be less hunting for
places that need to be fixed.

Change-Id: I207219abf8764906c3612ce8896492c7a2af6ea1
Bug: skia:12257
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/432259
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-07-26 13:10:42 +00:00
Brian Osman
7da0657fda Explicitly detect static recursion in SkSL
This relaxes our rules to allow calls to declared (but not yet defined)
functions. With that rule change, we have to specifically detect static
recursion and produce an error.

Bug: skia:12137
Change-Id: I39cc281fcd73fb30014bc7b43043552623727e03
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431537
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-24 00:01:15 +00:00
Chris Dalton
c3176002bc Lift the tessellation atlas into its own path renderer
Creates a new path renderer, GrAtlasPathRenderer, that handles all the
atlasing. Managing the atlas in its own path renderer gives us more
control over when atlasing happens in the chain, will allow us to more
easily use the atlas in kCoverage mode, and makes the clipping code
cleaner.

Bug: skia:12258
Change-Id: Ie0b669974936c23895c8ab794e2d97206ed140f8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431896
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-07-23 23:02:58 +00:00
Robert Phillips
d91d2341b9 Revert "Feed all top-level GPU accessors through skgpu::BaseDevice"
This reverts commit 5de8b19504.

Reason for revert: blocking Android roll

Original change's description:
> Feed all top-level GPU accessors through skgpu::BaseDevice
>
> This pulls the GPU-specific accessors off of SkCanvas and SkDevice - moving them all to skgpu::BaseDevice and SkCanvasPriv.
>
> This will allow us to more easily change the gpu class hierarchy (esp. changing GrSurfaceDrawContext to skgpu::v1:SurfaceDrawContext) w/o churning the public API.
>
> Bug: skia:11837
> Change-Id: I4e205255706680ac58ffe40f714884c2ee7ac799
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431036
> Reviewed-by: Brian Osman <brianosman@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>

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

Change-Id: I8a015be4edbe21d63db09d5593af13cc89df4217
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11837
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431538
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-07-22 18:56:51 +00:00
Robert Phillips
5de8b19504 Feed all top-level GPU accessors through skgpu::BaseDevice
This pulls the GPU-specific accessors off of SkCanvas and SkDevice - moving them all to skgpu::BaseDevice and SkCanvasPriv.

This will allow us to more easily change the gpu class hierarchy (esp. changing GrSurfaceDrawContext to skgpu::v1:SurfaceDrawContext) w/o churning the public API.

Bug: skia:11837
Change-Id: I4e205255706680ac58ffe40f714884c2ee7ac799
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431036
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-07-22 16:47:30 +00:00
Brian Osman
fb212256ca Improve tests/comments, to prepare for calling functions before definition
Bug: skia:12137
Change-Id: I609dd2578bf39a30e036ea85281886f8c4554579
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431038
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-22 13:19:39 +00:00
Mike Reed
aebe248575 SkFilterQuality is gone.
Bug: skia:11235
Change-Id: Iefa0156f542f217e687299f053768ee5b87f84d7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/430977
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-07-22 12:41:49 +00:00
Robert Phillips
7a0d3c3f12 Revise GM infrastructure to not rely on GrSurfaceDrawContext
The SDC will soon be V1-only. Remove it from the generic testing infrastructure and require each V1-specific GM to explicitly retrieve it.

Bug: skia:11837
Change-Id: I4c904b7e333333382062bde4b17a1f9f81bee6a9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/430425
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-07-21 20:59:37 +00:00
John Stiles
b6a7319f21 Add tokens for highp/mediump/lowp.
At present, they aren't hooked up to anything. They will be made
functional in followup CLs.

Change-Id: I4bfc25eb4e19fce4c36ea0b55494bf37b2a9ee23
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/430637
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-07-21 15:41:20 +00:00
Herb Derby
a7a9443104 rename the VM blitter to SkVMBlitter
Change-Id: I71ae924d32dc2268cc4a3db1920c08287533f9ae
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/430697
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-07-21 15:32:19 +00:00
Robert Phillips
259b46894d Reduce GrOnFlushResourceProvider's functionality
The main goal of this CL was to remove GrOnFlushResourceProvider::makeSurfaceDrawContext (which was only being used in the OnFlushCallbackTest) to allow simpler modifications to GrSurfaceDrawContext. It looks like there was a lot more unused stuff here though.

Bug: skia:11837
Change-Id: Idbc4001c58a4e8456bffcf1bac32150f2452fb56
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/430043
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-07-20 20:47:34 +00:00
Ethan Nicholas
dd2fdea9c2 Initial land of DSLParser
The DSLParser is an alternative to the existing SkSLParser which goes
directly to IR code using the SkSL DSL. It is substantially faster and
simpler than the existing parser->IRGenerator pipeline, but not yet
feature complete nor fully tested.

Change-Id: Iee45e9b527a3b88faa2ea74fc512051c8a38c5d4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/400622
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-07-20 20:28:54 +00:00
Jim Van Verth
960a4f89bb Add GrMtlFrameBuffer.
Sets up creation of the framebuffer object from the current render
target and adds it to the OpsRenderPass.

Bug: skia:12186
Change-Id: I08984553bcef2afcf3003d3f59e40c2fa9e383a9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/430042
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2021-07-20 19:22:01 +00:00
Robert Phillips
e40495da3d Untangle GrSurfaceDrawContext.h, GrTextureOp.h and GrFillRectOp.h
The dependencies between these headers made modifying the SDC and Ops separately somewhat difficult.

Bug: skia:11837
Change-Id: I0c3ca118ce206bf8db5b6753be1ef46531ae1f58
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/430041
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-07-20 17:09:21 +00:00
Brian Osman
946a4cb8ac First pass at a no-SkSL CPU build
This just disables everything that depends on SkSL today:

- Color filters:
  - HighContrast
  - Lerp
  - Luma
  - Overdraw
- Skottie effects:
  - BlackAndWhite
  - BrightnessContrast
  - DisplacementMap
  - FractalNoise
  - Sphere
  - Threshold
  - GradientColorFilter (indirectly, this uses ColorFilters::Lerp)

Cq-Include-Trybots: luci.skia.skia.primary:Canary-Android,Canary-Chromium,Canary-Flutter,Canary-G3
Bug: skia:12197
Change-Id: I26269bd4423897142b8f2fdcc4ab1b274e767cba
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/427376
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2021-07-19 21:19:51 +00:00
Mike Reed
01e6273c46 rm flutter support for filterquality
Change-Id: Ibcae9d2378d136ce15e3284f679e71b42f1ba32d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/429337
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-07-17 14:39:38 +00:00
Mike Reed
11a20bbbf4 rm getblendmode flag for flutter
Change-Id: Id578c5dbf7f0f4274d43b3ae8a7cfb50d3563cc3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/429376
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-07-17 13:53:45 +00:00
John Stiles
f2de1b8b4d Fix crash when drawing a GPU-backed surface onto raster.
We now null-check the result of recordingContext() before using it.

Thanks cqjjjzr2@gmail.com for the initial discovery and suggested fix.

Change-Id: Iafcf306f8cd9deb7147ef9c5c71a21907eedc01f
Bug: skia:12214
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/429098
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-07-16 15:12:43 +00:00
John Stiles
0397ae4e15 Reland "Add unit test confirming Runtime Blends match native blends."
This is a reland of 0b62a05d9a

Original change's description:
> Add unit test confirming Runtime Blends match native blends.
>
> We perform the same draw operation twice--once with a `setBlendMode`
> based blend, and then once more with `setBlender` and passing SkSL which
> is equivalent to the native blend op. If this test fails, it would
> indicate that Runtime Blends aren't being applied appropriately (or
> perhaps that a GPU's built-in blending modes are cutting corners?).
>
> Change-Id: I4ca1f9ed600d9ec733687cc6de7d3e2eb6e765c9
> Bug: skia:12080
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/428318
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

Bug: skia:12080
Change-Id: Idf4297314b133e5bce689a25d53063bff8469fac
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/428676
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-07-15 15:19:14 +00:00
Mike Reed
0547b914f6 Revert "Add unit test confirming Runtime Blends match native blends."
This reverts commit 0b62a05d9a.

Reason for revert: GetRuntimeBlendForBlendMode not found in google3

Does the new file that contains that not appear in google3's build?

Original change's description:
> Add unit test confirming Runtime Blends match native blends.
>
> We perform the same draw operation twice--once with a `setBlendMode`
> based blend, and then once more with `setBlender` and passing SkSL which
> is equivalent to the native blend op. If this test fails, it would
> indicate that Runtime Blends aren't being applied appropriately (or
> perhaps that a GPU's built-in blending modes are cutting corners?).
>
> Change-Id: I4ca1f9ed600d9ec733687cc6de7d3e2eb6e765c9
> Bug: skia:12080
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/428318
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

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

Change-Id: Idd5ca97cfc4b642d3f97fdbd1fe9bd108b56e3a6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/428617
Reviewed-by: Mike Reed <reed@google.com>
2021-07-15 00:50:14 +00:00
John Stiles
0b62a05d9a Add unit test confirming Runtime Blends match native blends.
We perform the same draw operation twice--once with a `setBlendMode`
based blend, and then once more with `setBlender` and passing SkSL which
is equivalent to the native blend op. If this test fails, it would
indicate that Runtime Blends aren't being applied appropriately (or
perhaps that a GPU's built-in blending modes are cutting corners?).

Change-Id: I4ca1f9ed600d9ec733687cc6de7d3e2eb6e765c9
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/428318
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-07-14 21:51:03 +00:00
Robert Phillips
a92913e169 Make GrAuditTrail V1-only
This CL has some rough edges since some classes that use it (e.g., GrOpsTask) aren't yet V1-only. That said, the big CL has to be broken up somehow.

Bug: skia:11837
Change-Id: I41ed9982ca4664f893e447ba23c7aec59f42c964
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426416
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-07-13 13:56:53 +00:00
John Stiles
ce7cdcd7b4 Add test for SkSL vector-slice constructors.
SkSL does not support shrinking a vector via casting. Use a swizzle
instead.

Change-Id: Ieba78a05dad9c55f44c765924e28f0c7e1667a67
Bug: skia:12193
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/427198
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-07-12 20:33:44 +00:00
Mike Reed
5643e55f09 Add flag for filterquality in flutter
Change-Id: I8612d58efcfac82b7924c680fd8fa91b6d48614f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426956
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2021-07-12 20:09:30 +00:00
John Stiles
7f56b41fc0 Add scalar-swizzling tests for int and bool types.
Boolean scalar-swizzling is currently not working.

Change-Id: Icd965e4b64a12311d098168f65622110d5fb3437
Bug: skia:12195
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/427038
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-07-12 19:54:40 +00:00
John Stiles
49c417621b Shore up matrix/vector conversion tests.
The tests now check bool4-mat2 conversions, which fortunately do work,
and the vector-to-matrix tests include int and bool conversions as well.

Change-Id: I971271838a93081b9258deb7c1d13b7732fb2440
Bug: skia:12067
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426757
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-07-12 15:02:51 +00:00
John Stiles
f9ad6ec852 Add support for mat2-to-ivec4 conversions in SkSL.
The fuzzer quickly discovered that the newly introduced mat2-to-vec4
conversion code did not account for integer vectors. We now handle
`ivec4(mat2)` casts properly. This required some non-trivial
restructuring of the logic, but in the vast majority of cases, the types
will match and the end result will be identical.

Change-Id: If07c2fe4b4345bd767384b1802374910f65cd3f0
Bug: oss-fuzz:35998
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426756
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-07-12 14:09:18 +00:00
Mike Reed
c98dbc6410 Hide deprecated SkPaint::getBlendMode
Callers should use asBlendMode or getBlendMode_or

Bug: skia:12173
Change-Id: I8b62527a2ae11c9bf0c1473c4fffa53b38aa7017
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425756
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Yegor Jbanov <yjbanov@google.com>
2021-07-11 17:14:21 +00:00
Brian Osman
bc35495729 Fix python3 issue in compile_sksl_tests.py
Change-Id: I755364b84dabed40a3b54d2f0cc0bc5efde1451f
Bug: skia:12134
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426537
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-09 20:54:07 +00:00
John Stiles
9191e813a0 Enforce consistency in swizzle domains.
GLSL disallows mixing swizzle domains within a single swizzle:
http://screen/93eHNQDbx35hMdk
SkSL now disallows it as well.

Change-Id: Ied2e11ee04285b143a864e28cac30335f01aad0e
Bug: skia:10621
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426458
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-07-09 20:30:22 +00:00
John Stiles
6de2e1db03 Add support for matrix-to-vector conversions in SkSL.
GLSL supports casting vec4 into mat2 and vice versa, so SkSL should have
equivalent support. This CL allows the Compound constructor to take a
matrix as input, and fixes up backends to do the right thing when a
matrix shows up in the compound-constructor path.

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

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

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

Bug: skia:12067
Change-Id: I1379914ee39ce340f09b11b3754820db9c645378
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426058
Reviewed-by: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-07-08 23:28:22 +00:00
Chris Dalton
b1fd64e82e Extract a GrAtlasInstancedHelper subclass
This helper will allow other GPs that use instancing to also clip
against an atlas.

Bug: chromium:928984
Change-Id: I5a3bb221220bace46c6c9d799c2db68e2a2c67b7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425979
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-07-08 22:31:24 +00:00
John Stiles
f009db5b85 Revert "Add tests for matrix-vector conversions."
This reverts commit a89781215a.

Reason for revert: breakage on Windows 

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

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

Change-Id: I2563041f538b1b20074385f1b61af5fc506ffad5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12067
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426057
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-07-08 21:46:40 +00:00