Commit Graph

8693 Commits

Author SHA1 Message Date
John Stiles
bc3c41b874 Enforce that layout(binding=...) is set on interface blocks in Metal.
Previously, we would emit an invalid [[buffer(-1)]] annotation on the
block, causing the Metal compilation to fail.

Change-Id: I68b2439c05db3163686e84c5dcc9a5c43870ff67
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340761
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-04 19:30:35 +00:00
John Stiles
2630ea3312 Disallow identifier names that overlap existing types.
It's not legal to use identifiers like "int" or "sampler" to name your
variables (or enums, or structs, etc.). SkSL will now report this as an
error instead of relying on the driver to catch this.

(Note that in some contexts, it might be legal by the spec to reuse a
name that you introduced yourself, depending on the scope. In practice,
this confuses Apple GLSL, so we shouldn't support it anyway.)

This caught several existing places in our code where we used the name
"sampler." These were never exposed to the driver (they were intrinsics
that we would replace during compilation) so they were harmless before.

Change-Id: Ia6dcfca8c500d02e1eb5f9427bed8727e114dfc2
Bug: skia:11036
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340758
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-04 16:52:01 +00:00
Mike Klein
b19518dcc7 add missing unit test for 128-bit ops
Change-Id: I233398bf34411231d44613d89aed28935fe30a28
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340796
Commit-Queue: Herb Derby <herb@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2020-12-03 22:25:10 +00:00
Chris Dalton
f2fb80f504 Add unaffectedByDstValue() to GrProcessorSet::Analysis
This will allow us to decide whether we need a stencil test when
drawing strokes.

Bug: skia:10419
Change-Id: Ie6aa0e4c4af6302c3ec28f9515cfae0e5c41a4ec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340517
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2020-12-03 20:24:41 +00:00
John Stiles
d39aec940d Remove multi-dimensional array support from the parser.
Previously, our AST structures would include a "sizeCount" for arrays,
which indicated the number of AST nodes associated with array
dimensions. Since GLSL only supports a single array dimension, this
field has been replaced with "isArray," a boolean indicating whether we
have a single AST node for array size. This allowed many array-size
based looping constructs to be replaced with simpler non-looping
equivalents.

This change flushed out a few places where the parser was not actually
enforcing its promised maximum array-dimensionality.

Also found some duplicated code in variable-declaration parsing,
related to parsing array-sizes and initializer expressions. This has
been de-duplicated by using a lambda. (This change was likely why this
CL was not net-negative for LOC, but it's simpler and cleaner.)

Change-Id: I7abed732d3a296edf02c0ec9813fceb5aae4a9a0
Bug: skia:11026
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340656
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-03 20:24:38 +00:00
Mike Klein
a7470df09c add load128/store128
This finishes up the existing SkVM ops on arm64.
I wish I had a unit test for this, but there's no diffs drawing RGBA F32.

Change-Id: I53725769fa2e7a1701f7360905205356e1ea18cb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340718
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-12-03 19:53:07 +00:00
Mike Klein
ec255636f2 add to_fp16/from_fp16
Nothing too tricky here.

Change-Id: I48e51c301e53efc63fc92c378fe45a0e5a2df7e6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340520
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-12-03 18:40:47 +00:00
Mike Klein
c7bca52b99 add load64
Much like store64, load64 really wants to use ld2.4s but that needs a
way to allocate adjacent registers.  So, just like store64, do it
manually, this time with uzp (unzip).

Change-Id: Ie10cc8d2df57390d1c6709bd7485bb5158375078
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340519
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-12-03 18:32:57 +00:00
Mike Reed
1a4140e598 deprecate getTotalMatrix
Change-Id: Iec7d67f4ec3fdf4d5280f3de3d6146a69a60c646
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339995
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-03 17:37:35 +00:00
Chris Dalton
2833ec6111 Plumb mixed samples through GrXPFactory::GetAnalysisProperties
Bug: skia:10419
Change-Id: I43898b0131231e2a4d1d6153e60530ba372b1c19
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340516
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2020-12-03 16:33:21 +00:00
John Stiles
9ea48e3965 Disallow multi-dimensional arrays in SkSL.
GLSL only allows one-dimensional arrays. This CL lowers SkSL's array
dimensionality limit from eight to one, and fixes all the tests that
this breaks. The rest of the code still technically supports
arbitrarily-deep array dimensionality; there are many opportunities for
code cleanup and simplification in followup CLs.

Change-Id: I0fc31e4626649ec69d40c5f5597b3924de298df0
Bug: skia:11026
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340339
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-03 16:28:19 +00:00
John Stiles
076e9a2f34 Disallow returning array types in SkSL.
This is illegal in older versions of GLSL and in Metal. We now fail at
SkSL compilation time and properly report the error.

Change-Id: I6ddaeabff5386a1ed6ca3eb8703a6035476ec77a
Bug: skia:11021
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339298
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-03 16:27:39 +00:00
John Stiles
3dba3ee465 Fix various codegen issues for Metal array types.
This CL fixes cases where array dimensions could be placed on the type
instead of the variable (`float[2] x` instead of `float x[2]`). It also
reports errors in cases where arrays aren't syntactically valid in
Metal, rather than emitting unusable Metal code. (Some of these cases
are actually invalid GLSL as well! But those fixes are coming in
followup CLs.)

Change-Id: I22279127c8a9aa2f22bf5ea3d225e563c2e254f2
Bug: skia:10926, skia:10760, skia:10761
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340137
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-03 16:20:39 +00:00
Mike Klein
f5097db452 add store64
Ideally we'd use st2.4s here but that needs its inputs in adjacent
registers, and I don't have a mechanism for that (yet).  So instead
interlace manually using zip1/zip2.

Tested by SkVM_64bit.

Change-Id: I7b05fcd1f4398012755fc4f0d4e39743d0c69a94
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340518
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-12-03 16:12:19 +00:00
Robert Phillips
4b10d58fc9 Fix bug in GrClearOp combining and remove some asserts (take 2)
The buffer combining code path was combining the ops but never
telling the external system that the second op could be removed.

Bug: skia:10963
Change-Id: I887ebda91673d37139ebc7fc427e80a55b9d9bd1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340101
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-12-03 13:40:05 +00:00
Mike Klein
5334e8976d Revert "restore murmur3 for older iOS devices"
This reverts commit 3c161467f0.

Reason for revert: need to keep iOS simulator (Build-Mac-Clang-x64-Release-iOS) in mind

Original change's description:
> restore murmur3 for older iOS devices
>
> For reference, the relative costs are roughly,
>    - our hash with CRC32c instructions    1x
>    - Murmur3                             11x
>    - our hash with CRC32c fallback       23x
>
> So this should be a ~2x speedup for those
> older iOS devices not using an arm64e slice.
>
> Bug: skia:11001
> Cq-Include-Trybots: luci.skia.skia.primary:Test-iOS-Clang-iPadPro-GPU-PowerVRGT7800-arm64-Debug-All,Test-iOS-Clang-iPhone11-GPU-AppleA13-arm64-Debug-All,Test-iOS-Clang-iPhone6-GPU-PowerVRGX6450-arm64-Debug-All,Test-iOS-Clang-iPhone7-GPU-PowerVRGT7600-arm64-Debug-All,Test-iOS-Clang-iPhone8-GPU-AppleA11-arm64-Debug-All
> Change-Id: Ib56195ddc0c522380d263d56e767331d9f635728
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340178
> Commit-Queue: Mike Klein <mtklein@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

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

Change-Id: I0e3b23e63c33910e482031d7475feb624bd6e1f6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11001
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340396
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-12-02 22:39:01 +00:00
Leon Scroggins III
469d67e7d9 Expose more info in SkCodec::FrameInfo
Bug: b/160984428

Add more fields to SkCodec::FrameInfo, which describes the properties of
an individual frame in an animated image. This allows a client that
wishes to seek to determine frame dependencies so that they can decode
an arbitrary frame, which in turn will allow SkCodec to remove
SkCodec::FrameInfo::fRequiredFrame. Currently, SkCodec seeks through the
stream to determine frame dependencies, but this is unnecessary work
(and storage) for a client that does not want to seek.

These fields also support the proposed APIs in go/animated-ndk.

Move SkCodecAnimation::Blend from SkCodecAnimationPriv (and delete that
file) into SkCodecAnimation.h. Rename its values to be more clear.

Merge common code for populating SkCodec::FrameInfo.

Add a test for a GIF with offsets outside the range of the image. Note
that libwebp rejects such an image.

Update libgifcodec.

Change-Id: Ie27e0531e7d62eaae153eccb3105bf2121b5aac4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339857
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Nigel Tao <nigeltao@google.com>
2020-12-02 22:37:20 +00:00
Tyler Denniston
4be95c541c Add test for quadratic Wang's formula
Just verify that the max error on any of the intervals after splitting
is less than the specified tolerance. Looks like we're running into
some FP precision issues with large coord values, so I'm limiting the
max multiplier to 2^15 in this test.

Bug: skia:10419
Change-Id: I39e76dca5f77389833ba3c94930e6b67c2b1bc97
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340116
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Tyler Denniston <tdenniston@google.com>
2020-12-02 20:50:27 +00:00
Mike Klein
3c161467f0 restore murmur3 for older iOS devices
For reference, the relative costs are roughly,
   - our hash with CRC32c instructions    1x
   - Murmur3                             11x
   - our hash with CRC32c fallback       23x

So this should be a ~2x speedup for those
older iOS devices not using an arm64e slice.

Bug: skia:11001
Cq-Include-Trybots: luci.skia.skia.primary:Test-iOS-Clang-iPadPro-GPU-PowerVRGT7800-arm64-Debug-All,Test-iOS-Clang-iPhone11-GPU-AppleA13-arm64-Debug-All,Test-iOS-Clang-iPhone6-GPU-PowerVRGX6450-arm64-Debug-All,Test-iOS-Clang-iPhone7-GPU-PowerVRGT7600-arm64-Debug-All,Test-iOS-Clang-iPhone8-GPU-AppleA11-arm64-Debug-All
Change-Id: Ib56195ddc0c522380d263d56e767331d9f635728
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340178
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-12-02 20:17:26 +00:00
John Stiles
6bef6a7858 Fix flipped array dimensions in SkSL.
The proper approach for creating multi-dimensional array types is
complicated, so I added a function in SymbolTable which does it the
right way (addArrayDimensions). I found all the places in SkSL which
created arrays from base types and size arrays, and refactored them to
call addArrayDimensions instead of doing it manually.

I believe that this approach fixes a bunch of minor issues with multi-
dimensional array types; some are visible in the current codegen output,
and others are latent bugs. e.g. in some instances, a Variable's type()
was silently holding flipped array dimensions, but this never led to
a visible bug because we ended up using the VarDeclaration's baseType()
plus sizes() everywhere that the type was used. (In particular, this
caused debugging headaches in http://review.skia.org/340137 where I'd
use a Variable's type and suddenly its array dimensions would be wrong.)

Change-Id: Idd6a86aa5d1dce8918d02a53bcc2f7d7886e3ac5
Bug: skia:11016, skia:10924
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339860
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-02 20:07:57 +00:00
Robert Phillips
9443d58af2 Revert "Fix bug in GrClearOp combining and remove some asserts"
This reverts commit 35f1b20840.

Reason for revert: ANGLE failures

Original change's description:
> Fix bug in GrClearOp combining and remove some asserts
>
> The buffer combining code path was combining the ops but never
> telling the external system that the second op could be removed.
>
> Bug: skia:10963
> Change-Id: If015d877ffbbb75964aae9ca92ea760d7041372a
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339203
> Commit-Queue: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>

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

Change-Id: Ie188190e7ecf2c39ec067296af20a9794636a226
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10963
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340177
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-12-02 18:21:08 +00:00
John Stiles
799b32e25d Disable inliner on Functions.sksl.
This reintroduces the flipped-array-dimensions bug in skia:10924. It
will be fixed in followup CLs.

Change-Id: I24ec687209b397f5fd0cf44194d0e21fe30dc32c
Bug: skia:10924
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339797
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-12-02 17:48:36 +00:00
Mike Reed
387826f6f6 Remove unused SkRWBuffer
Bug: skia:10980
Change-Id: Ibbb62edcbf5a8c1bc341416aef225cae3cf1a256
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/336960
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Thiabaud Engelbrecht <thiabaud@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-12-02 15:29:06 +00:00
Robert Phillips
35f1b20840 Fix bug in GrClearOp combining and remove some asserts
The buffer combining code path was combining the ops but never
telling the external system that the second op could be removed.

Bug: skia:10963
Change-Id: If015d877ffbbb75964aae9ca92ea760d7041372a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339203
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2020-12-02 13:17:26 +00:00
John Stiles
986c7fb8ca Fix codegen errors with Metal return statements.
The Metal return type from main() diverges from the SkSL source, so we
patch it in the Metal code generator. This CL improves the patching
process in multiple ways:

- A `return` statement from a fragment processor main() is rewritten to:
    return *_out;

- A `return` statement from a vertex processor main() is rewritten to:
    return (_out->sk_Position.y = -_out->sk_Position.y, *_out);

- We avoid emitting a duplicate `return *_out;` statement if we can
  determine that main() already ends in a return statement. This is
  harmless either way so it doesn't necessarily catch everything. (e.g.
  it doesn't detect an if/else which returns at the end of both blocks.)

Also added a unit test which returns from the middle of a vertex shader,
since we didn't test this anywhere and we need to verify that
sk_Position.y will be negated. (This didn't work properly before.)

Change-Id: I14cf18375894fc712fa6c6466df3888ebaeba7c8
Bug: skia:10903
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339636
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-01 21:28:05 +00:00
John Stiles
842b3599c8 Enforce layout(location=...) on Metal out variables.
Previously, this would generate invalid code such as `[[user(locn-1)]]`.
We now generate a more-useful error at SkSL compilation time.

Change-Id: Ifbe335ec6d4abcbdfe89b892ba51063c94d22b11
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339397
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2020-12-01 20:41:15 +00:00
John Stiles
7bd7033072 Disallow global variables containing arrays of opaque types.
GLSL only supports arrays of samplers in very limited ways; they aren't
supported at all by SkSL. We now detect arrays of opaque objects and
reject the code.

We have several paths through the IR generator that create and process
array types; the unit test covers global and local variables, and array
on the type versus array on the variable.

Change-Id: I5b45e88e31cf4005723c3bf35561622d65321f7b
Bug: skia:11008
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339317
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-01 20:04:14 +00:00
Mike Klein
5ec9c4e763 disambiguate skvm::bit_cast()
Change-Id: If22eabb68b9293f5bc1d275535135d9760fe1ae5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339578
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-12-01 17:31:52 +00:00
Mike Klein
42d67a67f5 remove "half" term from SkVM
fp16 is a more precise name, given that there are things like bfloat16,
and this may free up the word "half" for the same sort of more nebulous
format as we use it in SkSL.

Change-Id: I55c39f3670f2c300b9306c92a86c4ec7a2e7b5d7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339577
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-12-01 17:08:32 +00:00
Chris Dalton
356cef301b Simplify grvx::approx_angle_between_vectors signature
Rather than taking the x and y values separately (ax, ay, bx, by),
simply take two vec<N*2>'s (a, b), where the x's are in a.lo and the
y's in a.hi.

Bug: skia:10419
Change-Id: I21d659c79247ccb625351c20b93c550d0afffe79
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339458
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2020-12-01 16:16:42 +00:00
Ben Wagner
831a5a10f4 Fix DWrite axis design parameters.
DWrite makes up a bunch of axes that don't exist, so non-variable axes
are ignored. However, the actual index of the non-variable axes was not
being updated. Update it.

Bug: skia:10928
Change-Id: Iedce5d0dd58f447821b403c38f033d214b457e9f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338602
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2020-12-01 15:00:33 +00:00
Ben Wagner
416fe32ce1 Ensure variable font from data created at default.
If font data is used to create an SkTypeface and the font data describes
a variable font and no variation parameters are specified, the
SkTypeface created should have the default values for all axes. This is
particularaly interesting with DirectWrite since it makes this not
straight forward.

Bug: skia:10929
Cq-Include-Trybots: luci.skia.skia.primary:Test-Win10-Clang-NUC5i7RYH-CPU-AVX2-x86_64-Debug-All-NativeFonts
Change-Id: I4620deebf52142bbdffa1a283343b503cd1e6981
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338604
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2020-12-01 00:30:22 +00:00
Brian Salomon
70fe17e12f Remove GrRenderTargetContextPriv and GrSurfaceContextPriv
I think this is vestigial from some time in the past where RTC was
public.

Also just expose the methods that add ops rather than have so many
friends + testingOnly versions.

Change-Id: I60d9fdff23b2d67039a7b37815da7ff9e73d8999
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339158
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-11-30 20:13:25 +00:00
Mike Reed
6affa2c2e3 move SkMipmapBuilder to private
Change-Id: I77f57b175984a5e373fae951a270a883e7e4c5d3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339216
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-11-30 20:13:15 +00:00
John Stiles
5b589fd273 Add test for returning arrays from functions.
Just filling in a gap in our tests. The output is a little strange as it
exposes a missed opportunity to constant-fold array accesses, but it
seems fine otherwise.

Change-Id: I6df13e0f9a49455015ceb47d7802bb5e1bbdaa1a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339217
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-11-30 19:38:05 +00:00
John Stiles
d7cc093f1f Fix ASAN error when inlining array constructor expressions.
Constructors such as `float[2](0, 0)` add a type to the symbol table;
this type needs to be copied into the new symbol table if the
constructor is cloned by the inliner.

Change-Id: Ifa8d2dec87103c6223ce493e2201a904c14c2137
Bug: oss-fuzz:28050
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339168
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-11-30 18:37:05 +00:00
Robert Phillips
c4fbc8d6cf Stop overflow of windows rects in GrClipStack
Bug: skia:10989
Change-Id: I512ccbd3d95178756ae436f7c67ed53d46105ae7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339165
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-11-30 18:12:24 +00:00
John Stiles
fd41d878b1 Fix SPIR-V and Metal support for enum types.
SPIR-V previously didn't know what to think when it encountered a Type
with a typeKind of kEnum, and would abort. These are now treated as
32-bit signed integers.

Metal previously emitted the SkSL enum typename, which is meaningless to
Metal since we do not emit the enum itself anywhere. Metal now emits
"int" for an enum-typed variable.

(GLSL already correctly emits "int" for enum types.)

Change-Id: I05975a2a399f9c4a22c00c90be0dccacd99d793b
Bug: skia:11003
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338856
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-11-30 18:05:48 +00:00
John Stiles
21f5f450a4 Fix SPIR-V compilation error with arrays of samplers.
This CL addresses the root cause of the fuzzer issue, by checking for
LayoutIsSupported before getting the MemoryLayout of a type. However,
this array ought to be detected as an error everywhere, as samplers are
opaque types; at present, this code compiles without error in GLSL and
Metal. This is an issue for followup CLs.

GLSL's actual support for arrays of samplers is interesting and probably
too nuanced for us to try to emulate:

https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Opaque_arrays

"Under GLSL version 3.30, Sampler arrays (the only opaque type 3.30
provides) can be declared, but they can only be accessed by compile-time
integral Constant Expressions. So you cannot loop over an array of
samplers, no matter what the array initializer, offset and comparison
expressions are.

Under GLSL 4.00 and above, array indices leading to an opaque value can
be accessed by non-compile-time constants, but these index values must
be dynamically uniform. The value of those indices must be the same
value, in the same execution order, regardless of any non-uniform
parameter values, for all shader invocations in the invocation group."

Change-Id: Ib382f5c3b563f996b3c8f1eb6b021b6d31fa9ce7
Bug: oss-fuzz:28107
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339159
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-11-30 17:28:14 +00:00
John Stiles
dc75a97b80 Add global struct definitions to SkSL.
Previously, GLSL and Metal code generators would emit a struct wherever
the type was first used in the code, regardless of where it was
originally defined or what scope the type needs to live in. This CL adds
a ProgramElement for struct definitions, so that structs will now appear
at the top-level as they were originally defined. In the case of Metal,
some special handling is also needed to handle the Globals struct
properly.

Not yet fully supported:
- No special handling for structs declared inside functions yet
- No support for structs in separate scopes with overlapping names
The severity of the remaining issues depends mostly on whether we want
to support structs inside functions in Runtime Effects.

Change-Id: Ia95d4529506cb3fa6da63f5cb548199a93e1c0c5
Bug: skia:10922, skia:10923, skia:10925, skia:10926
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338600
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-11-30 15:26:14 +00:00
John Stiles
ade695ea4a Add unit test for function dead-stripping.
This test verifies that dead-stripping works on both built-in and user
functions, if their function call is optimized away.

Change-Id: I3125a34640c69de43c383343cd00d97e5a32ac60
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338836
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-11-30 15:16:44 +00:00
John Stiles
712fd6bbb9 Add support for enums in Metal code generator.
Enums are an SkSL-only concept--when we output code, we emit plain
IntLiterals--so the fix is simply to ignore the Enum program element
when we encounter it. This is what GLSLCodeGen does as well.

Also added a unit test to confirm that enums work normally, and that
enums are subject to optimization and static-comparison checks just as
ints would be.

Change-Id: Ic4f8da7a27983add9eb41b936d46f6638d22bd4b
Bug: skia:11003
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338800
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-11-30 15:14:34 +00:00
John Stiles
ba067aa72b Migrate dedicated SPIR-V tests to golden outputs.
There were a surprisingly small number of dedicated SPIR-V tests.
SkSLSPIRVBadOffset was the only test that didn't already exist in the
golden outputs, although it actually contained two tests.

The SPIRVTest.cpp file has been converted to SPIRVTestbed.cpp, which can
be used for local debugging of SPIR-V issues via dm (like GLSLTestbed
and MetalTestbed).

Change-Id: I978d8a7cf5735af7f537113d2b9411ce42cfcf88
Bug: skia:10694
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338756
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2020-11-30 15:05:54 +00:00
John Stiles
d6449e9291 Remove ^^ operator from Metal codegen.
^^ is not an operator in Metal. != can be used for the same purpose.

Change-Id: If75b000076ebe0aa81d0ab354a8ae33e6ed52101
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339156
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-11-30 14:57:54 +00:00
Mike Klein
8d78da910e more arm64 ops
- easy: ceil, floor, sqrt
  - index is our first arm64 instruction to need a temporary,
    but other than that is pretty simple, just N - iota as usual.

With Op::index now supported, `viewer  --slide GM_runtime_shader`
frame time drops from ~1ms to ~0.24ms.

I accidentally swapped in a float-subtract for an int-subtract and
everything worked fine.  o_O

Change-Id: I44c51506a6a9014b398d6943bb0e3712e4e52445
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338661
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-11-25 22:49:07 +00:00
Mike Reed
420a9ba7b5 Switch to m44 for the rest of canvas virtuals
Guard flag has been added to clients

Change-Id: Ib61a48781f5dbd52279c8f4257ba3e22fb2704e0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338596
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-11-25 21:50:37 +00:00
Mike Klein
8b16beeaf4 remove SkVM uniform8/16
Uniforms in practice are always pointers or 32-bit ints or floats, so
these are essentially dead code. The change to SkVMBlitter.cpp is the
only interesting change, and I think it makes more sense now than
before.  The program will need float coverage in the end, so might as
well feed it one directly.

Change-Id: I7f1e77731cf10ccc35595012a6df4f9e54a0dad8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338631
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-11-25 21:44:47 +00:00
Mike Klein
8212fa5f84 remove SkVM Q14 support
Now that I've been reminded that half-float compute is real and no
longer just a dream, Q14 kind of pales in comparison, and just gets in
my way when working on SkVM.

As usual I've left in assembler support and unit tests for those
instructions.  The instructions are all pretty easy to keep working and
tested and don't get in the way, unlike the real "let's do Q14" stuff.

None of this Q14 code was hooked up to anything but unit tests, so no
capability lost here, and no diffs.  As always, it'll be easy to restore
should we ever want to by looking at this CL.

Change-Id: Ia42a96652b381267a7c3ec563b5978efcfc717a7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338630
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-11-25 21:08:17 +00:00
Mike Klein
b76f884220 clean up unused SkVM debug features
I'm not using any of these, so nice to move them aside.

Change-Id: Id43c1606c2f9e6bba0d8f6bd7d2f8f5e02d5b762
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338629
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-11-25 21:06:47 +00:00
Michael Ludwig
f2efb80bc3 Clamp really big recording bounds to safe ints
Bug: skia:10997
Change-Id: Ic6da0cbe6dd68009d888bc3174de913852559de7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338598
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-11-25 20:07:57 +00:00