Commit Graph

9813 Commits

Author SHA1 Message Date
John Stiles
0733d48428 Check for SkSL ES3 capabilities in GrShaderCaps.
This lets us set the minimum bar for SkSL ES3 support in one place,
rather than checking this set of bits in multiple spots.

Change-Id: Icba58d8b6a93626ce2ffbe3c4b846cad4749cab5
Bug: skia:12347
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440518
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-18 17:12:12 +00:00
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
John Stiles
1e45dcd12f Add compile-time optimization for transpose().
Change-Id: I9ddb80b8886827250e243dc9174bb3679e70df9b
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440262
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-18 13:49:04 +00:00
John Stiles
a7ea66372d Revert "Use generation() to detect ES3 support."
This reverts commit fdde20d3ec.

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

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

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

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

Change-Id: Id9c678699baa1d9867848459bf680cc40f29b4bd
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440257
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-17 20:57:40 +00:00
John Stiles
5e3c1f4f89 Improve testing of transpose() intrinsic.
This intrinsic uses non-square matrices, so it will be useful in
confirming that we can use ES3 types in sksl_public intrinsics. Bulking
up this test (which we don't run in SkSLTest today) is a good first
step.

Change-Id: I8178f13d5ca376d7cae3d1a4350b2bc0397efb1f
Bug: skia:12348
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440256
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-17 20:44:59 +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
John Stiles
823c504999 Include non-ES2 numeric types in the root symbol table.
Previously, we hid non-ES2 numeric types from Runtime Effect code by
only including them in the private symbol table. Now, they are present
in the root symbol table, but marked with a new flag that identifies
them as disallowed in ES2.

The IR generator now enforces that strict-ES2 code doesn't contain types
that aren't allowed. This has two benefits:
- Intrinsic functions in sksl_public can now reference these types
- Error reporting is nicer

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

Change-Id: I4b5a844cf3aabee6b6d2c562e78859a29efc36fc
Bug: skia:12347
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439937
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-17 17:09:50 +00:00
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
Brian Salomon
3dbd159d09 Fix a couple Wshadow warnings
Change-Id: I04da5871c668b1ed9ca8db7fdcbfe06a70ee227f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440079
Commit-Queue: Brian Salomon <bsalomon@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-08-17 15:09:14 +00:00
Robert Phillips
168296b5a2 Reroute SurfaceContext factories through RecordingContextPriv
Bug: skia:11837
Change-Id: Ib00ccc78d6394ad85781dc1de090c2fe0e83c01f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439736
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-17 13:36:57 +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
John Stiles
c18ee4e55a Honor component type in Metal matrix helper functions.
Right now, Metal forces types to full precision. The matrix helper
functions previously baked in that assumption by hard-coding "floatX".
Now, they honor the component type; if this->typeName() started
returning "half", our helper functions would be named with "halfX". This
would allow half-precision and full-precision helpers to coexist.

Change-Id: I1679e6e76d2cf3c27fd69c42a92fb24bff6b69ec
Bug: skia:12339
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439396
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-08-16 14:34:15 +00:00
Greg Daniel
e56d31fd56 Update LazySurfaceDesc to take a GrTextureType.
Bug: skia:12342
Change-Id: Ic57f3f30bc7d0a9d932eb4ac1c28b87b3b544ce4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439282
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-08-16 14:17:58 +00:00
Greg Daniel
0e9d34d33c Reland "Remove GrBackendFormat's textureType use from isFormatTexturable call."
This reverts commit d90777ada3.

Reason for revert: relanding with fix to GrBackendTexture

Original change's description:
> Revert "Remove GrBackendFormat's textureType use from isFormatTexturable call."
>
> This reverts commit 832c817bc8.
>
> Reason for revert: uninitialized value in GrBackendTexture
>
> Original change's description:
> > Remove GrBackendFormat's textureType use from isFormatTexturable call.
> >
> > The goal of this change was to remove the use of GrBackendFormat::textureType()
> > from GrCaps::isFormatTexturable call. Instead we will always pass in a
> > GrTextureType into this call.
> >
> > To do this a lot of plumbing of GrTextureType was added to various call
> > sites. However, this CL halts the plubming up at the proxy level where we
> > get it from the GrBackendFormat still. Future CLs will continue removing
> > these call sites and others that use GrBackendFormat::textureType().
> >
> > Bug: skia:12342
> > Change-Id: Ic0f02b9c7f7402405623b8aa31aa32a9a7c22297
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439277
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com
>
> Change-Id: I354bbbf00be7a86c480009f3e7b36a8777a6bf3a
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:12342
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439338
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>

# Not skipping CQ checks because this is a reland.

Bug: skia:12342
Change-Id: I151196f149f9e191d2975b8fe81334f4f8720744
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439339
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-08-13 22:37:13 +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
John Stiles
1049d82061 Add ES3 Angle and Trigonometry methods to sksl_public.
This adds sinh, cosh, tanh, asinh, acosh, and atanh. We now also support
compile-time optimization for the arc functions.

Change-Id: I688f579b50403db534622b82926aa20d1f445341
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439319
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-13 20:57:44 +00:00
Greg Daniel
d90777ada3 Revert "Remove GrBackendFormat's textureType use from isFormatTexturable call."
This reverts commit 832c817bc8.

Reason for revert: uninitialized value in GrBackendTexture

Original change's description:
> Remove GrBackendFormat's textureType use from isFormatTexturable call.
>
> The goal of this change was to remove the use of GrBackendFormat::textureType()
> from GrCaps::isFormatTexturable call. Instead we will always pass in a
> GrTextureType into this call.
>
> To do this a lot of plumbing of GrTextureType was added to various call
> sites. However, this CL halts the plubming up at the proxy level where we
> get it from the GrBackendFormat still. Future CLs will continue removing
> these call sites and others that use GrBackendFormat::textureType().
>
> Bug: skia:12342
> Change-Id: Ic0f02b9c7f7402405623b8aa31aa32a9a7c22297
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439277
> Commit-Queue: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

TBR=egdaniel@google.com,bsalomon@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: I354bbbf00be7a86c480009f3e7b36a8777a6bf3a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439338
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-08-13 20:05:32 +00:00
Greg Daniel
832c817bc8 Remove GrBackendFormat's textureType use from isFormatTexturable call.
The goal of this change was to remove the use of GrBackendFormat::textureType()
from GrCaps::isFormatTexturable call. Instead we will always pass in a
GrTextureType into this call.

To do this a lot of plumbing of GrTextureType was added to various call
sites. However, this CL halts the plubming up at the proxy level where we
get it from the GrBackendFormat still. Future CLs will continue removing
these call sites and others that use GrBackendFormat::textureType().

Bug: skia:12342
Change-Id: Ic0f02b9c7f7402405623b8aa31aa32a9a7c22297
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439277
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-08-13 19:03:21 +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
fa088a665c Fix additional cases of variable shadowing in /tests/.
If we manage to fix all the existing cases of variable shadowing, we
could enable -Wshadow.

Change-Id: Ia92c86a902acc6864f3252431faeb157628b509e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439156
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2021-08-13 16:13:27 +00:00
Michael Ludwig
68e4e20fae Add unit test to cover incorrect image filter layer bounds bug
Pulls the matrix and layer bounds from the captured skp that was
originally clipped, and asserts that both SkMatrix and SkM44's
separate mapRect functions don't regress.

Bug: skia:12335
Change-Id: I092d60b8a38fcd3cb70a8123802d730644cffda1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439276
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Florin Malita <fmalita@google.com>
2021-08-13 14:25:14 +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
John Stiles
b05f03db32 Increase baked-in offset of RTFlip in skslc.
The value of 32 was causing errors when other uniforms were present, as
the SPIR-V code generator would detect overlapping uniform offsets and
fail.

Change-Id: I7bb1cf1244e54c39596c3a39e9f6972c6a47899c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439059
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-12 21:04:45 +00:00
John Stiles
9765973380 Fix cases of variable shadowing in /tests/.
If we manage to fix all the existing cases of variable shadowing, we
could enable -Wshadow.

Change-Id: Ib8b92275c5da71c4ee48540d434f3afdc45f4067
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438819
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Florin Malita <fmalita@google.com>
2021-08-12 16:11:39 +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
Michael Ludwig
423990db1b Decrease w epsilon to avoid incorrect bounds calculations
Bug: skia:12335
Change-Id: I0106c30d875a7a88431a6e068a82d2d987fc62b9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438738
Commit-Queue: Florin Malita <fmalita@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Florin Malita <fmalita@google.com>
2021-08-12 13:19:39 +00:00
Brian Osman
50fe857dd3 Revert "In SkCanvas destructor, discard (rather than blit) unbalanced layers"
This reverts commit 879b2f2e6e.

Reason for revert: UAF

Original change's description:
> In SkCanvas destructor, discard (rather than blit) unbalanced layers
>
> Bug: skia:12267
> Change-Id: I6808f62b2385a3466b1a93db905041a6529f58cb
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433360
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Florin Malita <fmalita@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Mike Reed <reed@google.com>

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

Bug: skia:12267
Change-Id: I616e6c65c1eb3b6d3f67b2dde6be3db4de6db18a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438739
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-08-12 02:22:14 +00:00
John Stiles
b7f2215bbb Fix cases of variable shadowing in test code.
If we manage to fix all the existing cases of variable shadowing, we
could enable -Wshadow.

Change-Id: I571931e01b0b95d85a7b566fc785ac219e8e731f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438697
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Tyler Denniston <tdenniston@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-11 20:38:09 +00:00
John Stiles
8a412325c4 Split up Codec 'check' into multiple helper functions.
This function was already divided into several different tests, but each
part relied on various bits and pieces from the others. This CL splits
it apart into smaller functions which should be easier to reason about.

This CL also fixes a handful of variable shadowing issues in the code.

Change-Id: Icfe189ae5fdf29913c1d94a6b5df9432442d648c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438658
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
2021-08-11 20:04:43 +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
Brian Salomon
bab2d11891 Improve consistency of GP::ProgramImpl subclasses
Named "Impl" and nested in GP or makeProgramImpl definition.

Remove unused INHERITED typedefs.

Remove GenKey pattern.

Bug: skia:11358
Change-Id: Icb4d5a0844184f51d92135de6cee6f6e77f57a5e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438478
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-11 16:52:09 +00:00
Herb Derby
f0efa1d8e7 Reland "Reland "uniform Ptr (UPtr) is a sub class of Ptr""
This is a reland of ea17e2499d

Original change's description:
> Reland "uniform Ptr (UPtr) is a sub class of Ptr"
>
> This is a reland of cef047a490
>
> Fix strides in SkVMTest to be the right size.
>
> Original change's description:
> > uniform Ptr (UPtr) is a sub class of Ptr
> >
> > A pointer for a Uniform (UPtr) is a sub type of a Ptr. Everywhere you
> > can use a Ptr a UPtr will work, but you can't use Ptr where you need
> > a UPtr. All the UPtr instructions uniformF, gather32, etc are expected
> > to be hoisted and therefore loaded only once. While the varyings
> > instructions like load32, etc. are expected to remain in the body
> > of the loop, and be evaluated each time through the loop.
> >
> > Change-Id: I4fe6458c2a4614872ed67cda1e81b05ea8a9e69e
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436297
> > Commit-Queue: Herb Derby <herb@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> Change-Id: I858fa1224452ec801b6186fede353849edc895b5
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436564
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

Change-Id: I774e710724c99a41d0d160e88a2b723f66e03861
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436821
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2021-08-11 16:42:10 +00:00
Robert Phillips
643f481b15 Cruft leftover from GrSurfaceContext hierarchy v1/v2 split
Non-substantive changes that didn't fit any earlier CL in the chain.

Bug: skia:11837
Change-Id: Ic9b7c05c014b03ab5b30532098fb8cd2da846d9a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/428958
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-11 14:17:49 +00:00
Brian Salomon
b25560a1e1 Consistency among GrFP::ProgramImpl subclasses
Remove GL or GLSL from names of subclasses. Make nearly all subclasses
nested either in FP class or its onMakeProgramImpl() function.

Make onSetData private rather than protected.

Remove unused INHERITED typedefs.

Embrace idea that Impl is part of FP private implementation:
direct member access rather than getters and no GenKey pattern.

Other random consistency updates, modernatizations, stylistic changes.

Bug: skia:11358
Change-Id: I0d94e00a146abdd38e094ca550fc3b9608bd433d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438056
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-08-11 13:59:46 +00:00
John Stiles
adb3eac15c Add tests for array assignment with narrowing conversions.
An assignment like `mediump int a[2] = myHighpIntArray;` should succeed
now that the previous CLs have landed; originally, this would have
caused a type-mismatch error.

Change-Id: I86ffe6a21d0c7fbe289eef95aebc2605412566aa
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437740
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-11 12:56:40 +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
Ethan Nicholas
57709e14e2 Added prototypes for DSLFunction
Previously, there was no way to create a forward declaration for a DSL
function. To avoid introducing new API and make this work in an
intuitive fashion, we now create prototypes for all DSL functions and
remove them when the function is promptly defined.

Change-Id: Ief36164ceb303a3d76a57dc073f2e9b8409bb45f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436562
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-10 21:16:01 +00:00
John Stiles
82d4c12dd9 Reland "Fix array-of-matrix/struct comparisons in Metal."
This is a reland of 23d8f94535

Original change's description:
> Fix array-of-matrix/struct comparisons in Metal.
>
> Metal needs helper functions in order to compare arrays, structs, and
> matrices. Depending on the input code, it was possible for the
> array-comparison helper to be emitted before a matrix-comparison
> or struct-comparison helper. If this occurred, array comparisons of that
> matrix or struct type would fail, because the operator== for the array's
> inner type was defined after array==, and Metal (like C++) parses
> top-to-bottom and only considers functions declared above the current
> function.
>
> We now emit prototypes for all the array, struct and matrix helper
> function. These prototypes are emitted above any helper functions. This
> ensures visibility no matter how your comparisons are organized.
>
> Change-Id: Ib3d8828c301fd0fa6c209788f9ea60800371edbe
> Bug: skia:12326
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437739
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: skia:12326
Change-Id: Ife68020f6b01fae973b97f76099c6d5e8215636c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438296
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-08-10 21:05:20 +00:00
Mike Reed
879b2f2e6e In SkCanvas destructor, discard (rather than blit) unbalanced layers
Bug: skia:12267
Change-Id: I6808f62b2385a3466b1a93db905041a6529f58cb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433360
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-08-10 20:27:10 +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
John Stiles
e076c3803a Reland "Fix array-of-vector comparisons in Metal."
This reverts commit ef9a1b66d0.

Reason for revert: not broken after all

Original change's description:
> Revert "Fix array-of-vector comparisons in Metal."
>
> This reverts commit 130338c9e1.
>
> Reason for revert: SkSL_ArrayComparison test causes Adreno 630/640 to crash in Vulkan
>
> Original change's description:
> > Fix array-of-vector comparisons in Metal.
> >
> > Comparing `vec1 == vec2` returns a bvec in Metal, so the result must be
> > wrapped in `all()` in order to boil it down to a single boolean result.
> > Our array-comparison helper function did not do this. Fortunately,
> > `all(scalar)` is a no-op, so we can just wrap the result unilaterally.
> >
> > Change-Id: I4f1f09a6832164ae2e6577d53b317f561332d581
> > Bug: skia:12324
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437736
> > 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,skcq-be@skia-corp.google.com.iam.gserviceaccount.com
>
> Change-Id: Ic76a5527a8339c8201f52df08d43041d7dcbeb61
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:12324
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438077
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

# Not skipping CQ checks because this is a reland.

Bug: skia:12324
Change-Id: I3da699b8d1113800efb27e162d0c6315f0aeaa49
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438176
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-10 18:09:42 +00:00
John Stiles
7b2b858bef Avoid short/ushort in MSL code generator.
The Metal code generator has historically avoided low-precision types in
the final output in order to dodge a variety of type-coercion issues.
However, the workaround was only coded for half/float. Extended the
workaround to cover int/short and uint/ushort as well.

Change-Id: I16e3a387ba2baef1ef2de7742e1b0d27786fee0e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437688
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-10 18:08:25 +00:00
John Stiles
3c991fd72c Fix duplicated array types in SPIR-V.
Previously, SPIR-V would generate two separate SpvIds for array types if
they differed in SkSL, even if they matched in SPIR-V. For instance,
`half[10]` and `float[10]` are the same SPIR-V type, so they should
reuse the same SpvId. (The RelaxedPrecision decoration doesn't go on the
type.)

This is important because OpLoad and OpStore require the same SpvId on a
variable; you can't OpLoad from one type SpvId and OpStore to a
different type SpvId, even if the underlying type behind the SpvId is
the same.

(A slightly simpler fix exists at http://review.skia.org/437237, but
this triggered a memory pooling bug that I can't properly debug from
this machine.)

Change-Id: I7669a95a2c946dde1eeff73474a3a0fb9d180512
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437683
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-08-10 18:04:49 +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