Commit Graph

8426 Commits

Author SHA1 Message Date
Brian Osman
8e2ef02855 Support variables in the intrinsic map, clone them into Programs
As a first step, convert sksl_pipeline.sksl to an IntrinsicMap (rather
than inherited element list). This makes the new code operate on
sk_FragCoord (which was previously being shared by all runtime effect
programs).

The new unit test angered TSAN, and now runs without complaint.

Also finish converting the .fp intrinsics over, so those don't need an
inherited element list either. And while doing that, refactor that
parsing to match all of the others. FP was uniquely implementing
processIncludeFile itself, rather than reusing the pattern of other
pre-include parsing.

The meat of the CL is the subtle changes in Compiler, and the logic in
cloneBuiltinVariables. Note that we need to clone the global variable
declaration element (because one of the goals is to get rid of shared
and inherited program elements), but also the variable itself (and the
new copy needs to live in the program's symbol table).

Bug: skia:10589
Bug: skia:10679
Bug: skia:10680
Change-Id: Ied352f8434dac2b8eacb4e515b014b6af7b57d20
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319023
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-10-01 20:30:33 +00:00
Greg Daniel
0eca74cd2c Move bytesPerPixel query off of GrCaps and add bytesPerBlock query.
Part of this change is to move some of this static format information
off of GrCaps since it is not cap dependent in anyway. This allows us
to the need for caps in many places. Also changes the low level format
query to be based off of bytes per block so it can be shared for
compressed and non compressed formats.

This change will also make it easier to add stencil/depth formats in
follow on change since we don't have to fill in a whole caps
FormatInfo block just so we can get the bytesPerPixel which is all
they need.

Bug: skia:10727
Change-Id: I2e6fdabf3ed699b4145ef9e6f0a73078d32a0444
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/321463
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2020-10-01 20:10:12 +00:00
Brian Salomon
8e0aa441a5 Get GrBackendRenderTarget's sample count from MtlTexture.
Instead of being passed separately.

Check sample count in various onWrap methods in GrMtlGpu.

Bug: skia:9832


Cq-Include-Trybots: luci.skia.skia.primary:Test-iOS-Clang-iPhone8-GPU-AppleA11-arm64-Release-All-Metal,Test-iOS-Clang-iPhone7-GPU-PowerVRGT7600-arm64-Release-All-Metal,Test-iOS-Clang-iPadPro-GPU-PowerVRGT7800-arm64-Release-All-Metal,Test-iOS-Clang-iPhone11-GPU-AppleA13-arm64-Release-All-Metal,Test-iOS-Clang-iPhone6-GPU-PowerVRGX6450-arm64-Release-All-Metal,Test-Mac10.15-Clang-MacBookAir7.2-GPU-IntelHD6000-x86_64-Release-All-Metal
Change-Id: If5813db95b07f5d272e80920486f461cc5a587fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320956
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-09-30 20:40:33 +00:00
John Stiles
80ccdbd869 Inline trivial single-argument constructors directly.
We don't need to create a temporary variable for expressions like
`half3(x)`.

Change-Id: Ie0fa6a6dfb3d77d4372f96c676d3081f7e278852
Bug: skia:10786
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320960
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-09-30 17:06:14 +00:00
Robert Phillips
aac5728a82 Make GrRRectBlurEffect use the thread-safe uniquely-keyed view cache (take 2)
This yields a ~8% performance improvement on OOP-R/DDL-like rendering of the simpleblurroundrect GM.

Bug: 1108408
Change-Id: I710c75b73a395b2280abf0c5af528e0f6731326d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/311720
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320917
2020-09-30 15:54:43 +00:00
John Stiles
20e4b9de76 Add unit test for inlining trivial arguments.
Change-Id: I71cefc1ffacd671ede810d9133dfce75cb9f42b4
Bug: skia:10786
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320958
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>
2020-09-30 15:20:13 +00:00
John Stiles
44733aa1e2 Avoid creating temporary variables for nested trivial cases.
For instance, `foo[0].x` is now considered trivial to inline. It
combines two trivial cases: array-indexing by an int literal, and a
swizzle.

Change-Id: Ibb3ca1f324bbee0e9b3556e66644923fc9e0cf45
Bug: skia:10786
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320768
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-09-30 13:31:37 +00:00
Brian Osman
55b69f543c Revert "Make GrRRectBlurEffect use the thread-safe uniquely-keyed view cache"
This reverts commit 4cf00a814f.

Reason for revert: ANGLE and Mali 400 unhappy.

Original change's description:
> Make GrRRectBlurEffect use the thread-safe uniquely-keyed view cache
>
> This yields a ~8% performance improvement on OOP-R/DDL-like rendering of the simpleblurroundrect GM.
>
> Bug: 1108408
> Change-Id: I1ec9477dffe870e5973f8a334a65b1013a4ca3dd
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/311720
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>

TBR=egdaniel@google.com,robertphillips@google.com,adlai@google.com

Change-Id: Ib7135a2244b956d1a5d06c12a2b4c2ce398b9db2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1108408
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320817
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-09-30 11:23:00 +00:00
John Stiles
f201af8b00 Allow more types of expressions to be directly inlined.
The following types of expression are hoisted directly into the
inlined code:

- Struct field access: `myStruct.myField`
- Swizzles: `myVector.xzy`
- Simple array indexes: `myArray[0]`

This significantly reduces the number of temporary variables generated
by the inliner.

Change-Id: Ifed226ecc87b096ec1e38752c0c38ae32bd31578
Bug: skia:10737, skia:10786
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319919
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-09-30 00:36:40 +00:00
Robert Phillips
4cf00a814f Make GrRRectBlurEffect use the thread-safe uniquely-keyed view cache
This yields a ~8% performance improvement on OOP-R/DDL-like rendering of the simpleblurroundrect GM.

Bug: 1108408
Change-Id: I1ec9477dffe870e5973f8a334a65b1013a4ca3dd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/311720
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-09-29 23:41:18 +00:00
Brian Osman
401a366eb1 Fix swizzle-of-swizzle lvalues in ByteCodeGenerator
Bug: skia:10785
Change-Id: I01708af63d7e2ffc160022074ea9ff2b3c69eab5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320638
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-09-29 20:34:58 +00:00
Brian Salomon
57fd923c20 Add sample count to GrVkImageInfo.
Pre-req for allowing rendering to an externally created MSSA VkImage.


Bug: skia:9832

Cq-Include-Trybots: luci.skia.skia.primary:Test-Debian10-Clang-NUC7i5BNK-GPU-IntelIris640-x86_64-Release-All-Vulkan,Test-Win10-Clang-NUC8i5BEK-GPU-IntelIris655-x86_64-Release-All-Vulkan,Test-Win10-Clang-ShuttleA-GPU-RadeonHD7770-x86_64-Release-All-Vulkan,Test-Android-Clang-GalaxyS9-GPU-MaliG72-arm64-Release-All-Android_Vulkan,Test-Android-Clang-GalaxyS7_G930FD-GPU-MaliT880-arm64-Release-All-Android_Vulkan,Test-Android-Clang-GalaxyS20-GPU-MaliG77-arm64-Release-All-Android_Vulkan,Test-Android-Clang-Pixel4XL-GPU-Adreno640-arm64-Release-All-Android_Vulkan,Test-Android-Clang-P30-GPU-MaliG76-arm64-Release-All-Android_Vulkan
Change-Id: Ibf41944c6946dda7e27bdcd509ecd04976fc9ade
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320262
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-09-29 18:36:58 +00:00
Herb Derby
80f6e4e558 air gap SkStrikeServer API from implementation
This is the second CL for isolating the Chrome
remote glyph cache API from the implementation.

See CL/320074 for the first CL, which handles
SkStrikeClient.

Pull out the rest of the tracing functionality.

Change-Id: I4d6aa4bf648a0d2d55cecedbe445a05c27e3a986
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320256
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2020-09-28 20:43:33 +00:00
John Stiles
3d921f1b2c Add unit test to demonstrate lack of SkSL swizzle optimization.
The right side of assignments will collapse redundant swizzles, but the
left side does not. Code like this can actually cause the ByteCode-
Generator to assert if it is run (it asserts in `swizzle_is_simple`
during code generation).

Change-Id: I891912fe0b5de2670dfa95f6702a86d5c42bb2ec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320296
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>
2020-09-28 19:02:03 +00:00
John Stiles
06febefd7e Add 'tricky' OutParams golden output.
This was adapted from a test in SkSLInterpreterOutParams and presents a
challenging double swizzle.

Change-Id: Icb7b3bbb18d4b3cfa0c26acb524c08812ba88096
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319920
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>
2020-09-28 18:52:13 +00:00
Herb Derby
f0b5644e6b introduce SkGlyphRect specialized for union & intersect
SkGlyphRect is a rectangle encoding specialized for
union and intersect. It will be used for calculating
the bounding boxes of glyph runs, and clipping glyphs
for GPU.

Change-Id: Icab826b51dc2254ee4006ada84f7fc09e112a933
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319697
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2020-09-28 18:31:33 +00:00
John Stiles
bc0c29ead3 Fix call counts for intrinsic functions.
This allows dead-stripping to properly optimize away unreferenced clones
of intrinsic functions, and allows the inliner to detect intrinsic
functions that are only called once (which can generally always be
inlined without penalty).

Change-Id: I0cf034d880ae5d52f4cc0f93de6e2c7aad34e975
Bug: skia:10776
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320258
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>
2020-09-28 18:04:34 +00:00
John Stiles
e41b4ee49e Reland "Support out parameters that use a swizzle."
This is a reland of 435b482638

inlineStatement now takes a `const Expression* resultExpr` instead of
`const Expression& resultExpr` because resultExpr will be null for a
void function.

Original change's description:
> Support out parameters that use a swizzle.
>
> This CL also removes the `VariableExpression` class that was briefly
> added in a prior CL. This class was intended to support cloning an
> expression while changing the refKind of a VariableReference inside of
> the expression, but it added state and complexity. In this CL, rather
> than track this via extra state, the inliner just recurses into the
> expression as needed to find its VariableReference. Since most relevant
> expressions are just a VariableReference anyway, this is inexpensive.
>
> Change-Id: Id4d926b7d7520b5e6ce455446c05a6d59ef62a84
> Bug: skia:10756
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319917
> Commit-Queue: John Stiles <johnstiles@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>

Bug: skia:10756
Change-Id: I35f76c21eccf0ba2ab47e4313e131f7aa26980fa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320223
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-09-28 17:34:03 +00:00
Robert Phillips
defd223d40 Add correctness checks to GrThreadSafeViewCache tests
Bug: 1108408
Change-Id: I8e815003808624fcd767e5e9a579d3f17e7ddb46
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319781
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-09-28 15:43:53 +00:00
Brian Osman
6bfa63fe39 Revert "Support out parameters that use a swizzle."
This reverts commit 435b482638.

Reason for revert: ASAN/UBSAN unhappy.

Original change's description:
> Support out parameters that use a swizzle.
>
> This CL also removes the `VariableExpression` class that was briefly
> added in a prior CL. This class was intended to support cloning an
> expression while changing the refKind of a VariableReference inside of
> the expression, but it added state and complexity. In this CL, rather
> than track this via extra state, the inliner just recurses into the
> expression as needed to find its VariableReference. Since most relevant
> expressions are just a VariableReference anyway, this is inexpensive.
>
> Change-Id: Id4d926b7d7520b5e6ce455446c05a6d59ef62a84
> Bug: skia:10756
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319917
> Commit-Queue: John Stiles <johnstiles@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>

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

Change-Id: Ibdda47607f9e6e7f3a7459915067cf5e20919993
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10756
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320220
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-09-28 15:36:35 +00:00
John Stiles
435b482638 Support out parameters that use a swizzle.
This CL also removes the `VariableExpression` class that was briefly
added in a prior CL. This class was intended to support cloning an
expression while changing the refKind of a VariableReference inside of
the expression, but it added state and complexity. In this CL, rather
than track this via extra state, the inliner just recurses into the
expression as needed to find its VariableReference. Since most relevant
expressions are just a VariableReference anyway, this is inexpensive.

Change-Id: Id4d926b7d7520b5e6ce455446c05a6d59ef62a84
Bug: skia:10756
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319917
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-09-28 15:04:33 +00:00
John Stiles
7a6935a528 Update OutParams unit test to demonstrate SkSL failure.
Swizzles in combination with out params are currently broken in SkSL.
They are fixed in the followup CL at http://review.skia.org/319917

Change-Id: I22d9436a15631e6ee2acf9fc312a8634cf3b5407
Bug: skia:10756
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319918
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>
2020-09-28 14:09:03 +00:00
Fredrik Söderqvist
766eeb2ac3 Return target rect for SkPictureImageFilter forward bounds mapping
When mapping bounds in the forward direction, return the target rect of
the picture (fCropRect). This matches the behavior of SkImageSource
which can be considered to be semantically similar.

Bug: skia:10744
Change-Id: Ief213a847041ea6b276b2e7493e49db01715eda9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319616
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-09-26 13:05:30 +00:00
John Stiles
68861e3913 Add unit tests for assignment and invalid field access.
Change-Id: I8b755ae0078d6353e24834cd15603091d681114c
Bug: skia:10766
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319698
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-09-25 21:42:22 +00:00
Mike Klein
cac130ffc1 to_foo() -> to_Foo()
This tweak makes these conversion functions' names
match the names of the types, e.g. to_F32() makes F32.

Change-Id: I4d71c9bd17d835d09375e3343ee4316082b02889
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319763
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-09-25 21:31:45 +00:00
Brian Salomon
4e48490717 Remove deprecated Vulkan GrBackendRenderTarget constructor
Change-Id: I3bda64f7c03245e751bb19520ec7ed07e5c1d59e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319780
Auto-Submit: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2020-09-25 21:28:40 +00:00
John Stiles
c14defb8bf Disallow assignment to unfoldable ternaries in SkSL.
GLSL does not support assigning to ternaries, and will fail to compile
and/or generate non-functional shaders if we pass in a shader that tries
to assign into a ternary expression.

If SkSL is able to completely eliminate the ternary (e.g. if it boils
down to a simple `true ? x : y` or `false ? x : y`), SkSL can strip out
the ternary entirely and generate valid GLSL. This case is harmless and
so it is still allowed.

Change-Id: I960f119fb9934f998697634e6c4e519cd77d3780
Bug: skia:10767
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319679
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-09-25 21:26:40 +00:00
John Stiles
3fabfc0bd1 Fail gracefully when Metal encounters a geometry shader.
Change-Id: I452e52a87d89cefb5c21a0d9d57e9771f3038d73
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319783
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>
2020-09-25 21:21:50 +00:00
Chris Dalton
1b6a43cf20 Move user stencil settings from GrPipeline to GrProgramInfo
Bug: skia:10419
Change-Id: If11d28f6d9348ba0011825f719123c09f0103603
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319481
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-09-25 21:12:50 +00:00
Fredrik Söderqvist
0ea0c5e3bd More conservative reverse mapping bounds for SkDisplacementMapEffect
When reverse mapping bounds through SkDisplacementMapEffect, we need to
consider both the color input and the displacement input because they
could both directly, or indirectly, reference the source.

Bug: chromium:1128962
Change-Id: I03489fd2391f2ea595945961bf7e940a0e200cab
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319656
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-09-25 20:37:30 +00:00
John Stiles
ba38588d88 Remove sk_ClipDistance.
This was unused and did not work on non-GLSL backends.

Change-Id: I6bd314d43cfefa64871b5c0e964b5ae52e494164
Bug: skia:10757
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319778
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
2020-09-25 20:29:10 +00:00
John Stiles
dce4d3e2b1 Migrate setRefKind assignability checker into SkSLAnalysis.
This will allow the inliner to use IsAssignable.

Change-Id: Ic94f71002779b53d0b3dc97f37fbe4bb98b026d8
Bug: skia:10756
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319414
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-09-25 19:48:39 +00:00
Ethan Nicholas
7bd6043029 moved SkSL Block's data into IRNode
Change-Id: Id1066c7c2aeffce47fcd6823cb01a58b52e450c2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319676
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-09-25 19:33:19 +00:00
John Stiles
aeae3a58e3 Add golden outputs for the Metal backend.
This CL also updates the blend tests to use sk_FragColor instead of
returning a half4, as the Metal backend assumes that a fragment
processor's `main` will return void and always synthesizes a
`return *_out;` at the end.

(context link:
https://osscs.corp.google.com/android/platform/superproject/+/master:external/skqp/src/sksl/SkSLMetalCodeGenerator.cpp;l=803;drc=842d31b14159626054e01dd32826563a8f4214bf )

BYPASS_INCLUSIVE_LANGUAGE_REASON=see http://b/168134166

Change-Id: I330a456bf25ee72d3a29c59cd624625378ae80a0
Bug: skia:10649, skia:10757, skia:10758, skia:10759, skia:10760, skia:10761, skia:10762
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319409
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2020-09-25 17:46:43 +00:00
Robert Phillips
3380be9588 Fix creation of gpu resources in GrThreadSafeViewCache tests
This CL implements and exercises the preference for gpu-generated content.

This CL also switches to drawing a rect (vs. an arrow) since drawing
a concave path on the gpu can be fraught.

Bug: 1108408
Change-Id: Ieec1619b5357ffb31aa74b471ea09c061bd8f74e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319416
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-09-25 17:32:23 +00:00
John Stiles
ab4ab20fcf Migrate most SkSL tests currently in /glsl/ to /shared/.
These tests will also be used for Metal and SPIR-V testing. A small
handful of GLSL-specific stragglers (#version-specific or type-precision
related) will remain in /glsl/.

Change-Id: I7f2b2bd92825c327922c8ce74e438d2daa440dff
Bug: skia:10649
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319408
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2020-09-25 17:13:53 +00:00
Mike Klein
6b72d3a03b q14 rethink
I've been thinking and rethinking and rethinking how best to use 16-bit
values like Q14 fixed-point in SkVM.  Here's some ways:

   A) don't... just use 32-bit values instead
   B) use 16x2-bit pairs to match the narrower 32-bit lane count
   C) double-pump 32-bit values to match the wider 16-bit lane count
   D) use native 16- and 32-bit values and let the backends sort it out

A) is how things work today, and C) is how SkRasterPipeline's lowp mode
works.  Having tried out B) and C) both for a good fair shake, they were
both already awkward to work with after writing just a few functions.  I
would not give up on them entirely, but they're no longer my favorites.

D) is subtle and my new favorite.  It's easiest to program with SkVM
when the values we're holding represent single values and the backend
handles any parallelism for us.  That suggests we add a simple 16-bit
Q14 to the existing 32-bit I32 and F32 types, where they can be actively
converted between as normal, but not freely no-op bit punned.  D) says
we people shouldn't have to choose between A-C) up front... each backend
can handle it themselves.

Under strategy D), it's entirely the backend's job to decide how to
represent each value, and how to to vectorize them.  We don't need to
know as a user, and the backends can use the program itself to inform
how they vectorize.  16-bit values could live in xmm registers and
32-bit values in ymm, or the 16-bit values could go in the low half of a
ymm, or the even lanes of a ymm, or a full ymm and use two for 32-bit
values, etc. etc.  This all is a backend choice, not something we should
have to know about when writing a program using Q14/I32/F32.

My next steps are to get Q14 operations tested and plumbed through the
JIT again, and to build out a blitter and a few effects using Q14 color
channels.  Then, independently, we can look at each backend and how to
vectorize them.  Some ideas:

    1) keep running at current vectorization, with half rate 16-bit ops
    2) pump up to 2x wider vectorization unconditionally to favor 16-bit
    3) pump up to 2x wider vectorization only when any 16-bit op is used

These choices can be made independently for each backend (JIT, LLVM,
interp), and I wouldn't be surprised to find that we'll want to do them
differently.  For instance, the interpreter is already running at 32x
vectorization... might be pumping it higher won't help anything.

Change-Id: Ib8ad2b1bf790e8c4e3acfb4818d4032f7628e8f8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319321
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-09-24 20:02:58 +00:00
Brian Osman
32d53550c8 Remove unsafe compiler methods related to external values
We don't want to be polluting the global namespace with external values,
especially when the typical/recommended way to use the Compiler is with
a single long-lived instance. Force client code to manage ownership (the
only non-unit-test case was already doing this), and pass external
values to convertProgram, so they can be added to the Program's symbol
table.

Change-Id: If4c1db5e48a62e2cf4333b8d80420f2dfede27ab
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319125
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-09-24 14:12:08 +00:00
Chris Dalton
fc396a85e4 Make WangsFormula_* tests more tolerant of rsqrt approximation
TBR=michaelludwig@google.com

Change-Id: I01e9bd833b604628487a9f345d6fae8340f2848d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319197
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2020-09-24 03:36:27 +00:00
Herb Derby
5d9d837994 error on the side of safety for empty blobs
If the blob is empty, then try to regenerate it. Using
this method caused a slowdown in Skia perf, so we
added an extra check to allow some empty blobs through
for perf performance. The perf problem was caused by
SKPs generate empty blobs because of font mismatches.
Flutter has shown that scaling from very small to
normal size is not correctly handled by the existing
check. This CL favors correctness over optimizing empty
text blob and always regenerates empty blobs.

https://github.com/flutter/flutter/issues/64936

Change-Id: Ib18ecb684b0af5cf6dce274b6dc09a9c61b17c77
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319031
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2020-09-23 21:18:27 +00:00
John Stiles
978674a23e Fix crash with invalid out parameters.
Many calls to `setRefKind` failed to check the return value; if it's
false, an error has occurred and the program is in a bad state.
Specifically, there is an assignment to a variable that's not marked as
"written-to." If we continue processing the program, we're likely to
assert.

Change-Id: I2dd5d1f41aa5ca0d30f8d638f05fe2e838216d78
Bug: skia:10753
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319116
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-09-23 20:36:17 +00:00
Chris Dalton
e2067645ef Optimize GrWangsFormula
Adds various optimizations to GrWangsFormula as well as "pow4" variants
of the formula that are quicker than the standard and/or log2 versions.
Uses the pow4 variants in GrStrokePatchBuilder.

Bug: skia:10419
Change-Id: I8478582df5296b088d25808bcaeb93107ff20797
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/318954
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2020-09-23 20:35:47 +00:00
John Stiles
59b2a92c96 Add new unit tests for SkSL.
These cover:
- Properly configured out-params
- Invalid/non-lvalue out-params, which currently cause an SkSL crash
- Interactions between the inliner and variable swizzles

Change-Id: I4874101236084f273e704d8717149b431d813883
Bug: skia:10753
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319036
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-09-23 20:30:47 +00:00
Greg Daniel
1d3c8c1a8b Add optional param to setBackendTextureState to return previous state.
Bug: skia:10742
Change-Id: I334e7896d0a1509eb666c46d5731d2573a5c1aba
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/318698
Reviewed-by: Austin Eng <enga@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2020-09-23 19:54:59 +00:00
John Stiles
db62d088ef Bring back the harness from SkSLGLSLTest as a testbed for debugging.
The code here is resuscitated from the GLSL testing harness at
http://review.skia.org/317771 . Testing and debugging in dm is simpler
than debugging skslc when we encounter compiler issues.

Change-Id: I492dd0bbd2f0ee0b3b6a1b5253da54d72dc1eb3b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319032
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>
2020-09-23 18:44:47 +00:00
John Stiles
647a9bd7c2 Convert the remaining FP tests to golden outputs.
(Removed one test, SkSLFPSwitchWithMultipleReturnsInside, because it was
redundant with existing tests.)

Change-Id: I1bfc069babdb5eb0cc515f195c3a2e307bb5871a
Bug: skia:10694
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319029
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>
2020-09-23 16:21:58 +00:00
Robert Phillips
c2fe1644db Add time-based purging to the GrThreadSafeUniquelyKeyedProxyViewCache
Bug: 1108408
Change-Id: I7dd4a3b1b20f3267903dd7f303a2d639b562d84a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/318761
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-09-23 13:07:50 +00:00
Michael Ludwig
462bdfc06e Allow non-AA clip rects to be scissor only even on MSAA targets
This appears to fix the performance regressions seen on a number of webpage
SKPs for vkmsaa8 and glmsaa targets on devices that can't disable multisampling.

Bug: skia:10730
Change-Id: I2c10a78cfe864f987b7f17eb69eb2e1712ca0676
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317772
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-09-23 13:05:00 +00:00
John Stiles
d4867c94be Add rc accessor method to SkMatrix.
FP gencode reads back matrix values in its dumpInfo method using rc().
This worked for SkM44; now it will work for SkMatrix as well.

Change-Id: I4efc7018529bd3c84aacc073fad2bfca7e12c517
Bug: skia:10748
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/318756
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-09-22 21:32:20 +00:00
John Stiles
544a32ff23 Promote bool(k) to true/false during constant propagation.
Cleaned up some nearby code while implementing this fix as well.

Change-Id: Ic084451f0d9fc12169e1720a8889a290249eb5e9
Bug: skia:10750
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/318796
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>
2020-09-22 21:18:49 +00:00