Commit Graph

8552 Commits

Author SHA1 Message Date
John Stiles
71624de2c5 Allow constant propagation for negated constant-vectors and ints.
This CL improves on the previous fix for oss-fuzz:26789 by actually
propagating the negation from the PrefixExpression inside the
constructor, which unblocks further optimizations.

Interestingly, this fix also exposes a further missing optimization--we
optimize away comparisons of constant-vectors for floats, but fail to
do the same for ints.

Change-Id: I9d4cb92b10452a74db96ff264322cdc8a8f2a41f
Bug: oss-fuzz:26830, oss-fuzz:26789, skia:10908
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332263
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-11-05 17:39:48 +00:00
John Stiles
96c2165ce1 Revert "Add memsets to the GrBlockAllocator unit tests."
This reverts commit 87bc83eaa6.

Reason for revert: breaking some platforms on tree

Original change's description:
> Add memsets to the GrBlockAllocator unit tests.
>
> These will verify that our blocks are actually set up properly--if not,
> we'll stomp over a sentinel word and/or trip an ASAN poisoned byte,
> causing the test to fail.
>
> Change-Id: I2dcb5b913d00c408f70c71f2660c6ec6017b452c
> Bug: skia:10885
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332260
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>

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

Change-Id: I93abff1ead8430a233c18e9ff30c76192a090ab9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10885
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332545
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-11-05 16:17:44 +00:00
John Stiles
87bc83eaa6 Add memsets to the GrBlockAllocator unit tests.
These will verify that our blocks are actually set up properly--if not,
we'll stomp over a sentinel word and/or trip an ASAN poisoned byte,
causing the test to fail.

Change-Id: I2dcb5b913d00c408f70c71f2660c6ec6017b452c
Bug: skia:10885
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332260
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-11-05 14:57:22 +00:00
John Stiles
68dcf542b7 Migrate CrbugOssfuzz21688 to a golden-output test.
Change-Id: I2c077e723d123b01fbcc8fe841ee1f3d28dc152d
Bug: skia:10694
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332037
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-11-04 22:34:13 +00:00
Brian Osman
91292e9482 Runtime Effects: Support 'uniform shader' (vs. 'in shader')
The previous behavior leaked Skia-internal concepts into public SkSL.
Users coming from GLSL will expect that bindable/sampleable objects are
uniform (just like texture2D). This keeps the old support around (and
tested), but updates all of our examples to use 'uniform'.

Bug: skia:10679
Change-Id: I0c98162f5e21dad7014d9778ceb26143d2f6030e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332376
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-11-04 22:29:53 +00:00
John Stiles
95acbbc3c9 Fix crash when comparing against a negated constant vector.
This CL solves the fuzzer crash. Constant propagation of the negative
sign into the vector will be investigated in a followup CL.

This CL also adds a few cleanups into IRGenerator::constantFold.

Change-Id: If73a4fe2a5777265e7d43cc4f482653a38cb59af
Bug: oss-fuzz:26830, oss-fuzz:26789
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332261
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2020-11-04 22:17:53 +00:00
John Stiles
6c88ea1278 Create unit test for comparison against a negated constant vector.
Change-Id: Ibc1a8d3ebbf62cc55d013f7d9146f6b155d11da2
Bug: oss-fuzz:26830, oss-fuzz:26789
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332377
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-11-04 22:15:23 +00:00
Brian Osman
d7e7659cad Move GrShaderCaps from Program::Settings to Compiler
This ties the caps to the compiler instance, paving the way for
pre-optimizing the shared code. Most of the time, the compiler is
created and owned the GPU instance, so this is fine. For runtime
effects, we now use the shared (device-agnostic) compiler instance
for the first compile, even on GPU. It's configured with caps that
apply no workarounds. We pass the user's SkSL to the backend as
cleanly as possible, and then apply any workarounds once it's part
of the full program.

Bug: skia:10905
Bug: skia:10868
Change-Id: Ifcf8d7ebda5d43ad8e180f06700a261811da83de
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331493
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-11-04 19:38:33 +00:00
Leon Scroggins
f12d05d125 Implement SkPathBuilder(SkPathFillType)
Bug: skia:9000

This constructor is already declared; provide a definition.
Add a test.

Change-Id: Ic54ccffe0b1adf7c8c411e19a3fc9d825a5c9619
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331799
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-11-04 18:17:23 +00:00
Greg Daniel
007d97d699 Allow creating SkSurfaceCharacterizations directly for vk secondary CB context.
Bug: chromium:1144921
Change-Id: I9ca905eb9f2542aafbde25e0baa5430640277699
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331877
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-11-04 16:43:42 +00:00
John Stiles
6e7cfaff18 Fix bad FP codegen when sample() calls are inlined.
Previously, temp variables created by sample() calls were named after
the offset of the sample() call within the code. This was
straightforward but would fail if the sample() call were duplicated via
inlining of helper functions.

FP sample() temp variables are now named using a counter, starting from
zero and counting upwards.

Change-Id: I16f9a3426117677c0df13d15772320def99cc0d6
Bug: skia:10858
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331415
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-11-03 19:54:45 +00:00
John Stiles
569249be6c Improve support for function prototypes in SkSL.
Previously, when a prototype was parsed, this added a function
declaration to the symbol table, but the prototype itself was not
re-emitted during code generation. This meant that the final code might
not be valid, since the absence of prototypes meant that the code might
attempt to invoke a function before its declaration. Now, prototypes are
stored in the ProgramElement list and re-emitted during code generation
for GLSL/Metal/CPP. (SPIR-V doesn't name its functions at all.)

Change-Id: I76446c796000eb0b56f964d82457122182c28b87
Bug: skia:10872
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331136
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-11-03 19:09:25 +00:00
John Stiles
7d3f089e58 Fix use-after-free error discovered by the fuzzer.
When eliminating a CFG node, we now flag its exit nodes; if our
optimization pass reaches one of those flagged nodes, we stop the
current optimization process in its tracks and initiate a rescan.

We do NOT recursively mark the exits of the exit nodes, so this fix is
reliant on the CFG being ordered in a non-chaotic fashion, but in
practice this seems to be sufficient for the CFGs we generate today.

Change-Id: I892805361c5f4297e02146f37a759dfda83f5488
Bug: oss-fuzz:26942
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331597
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-11-03 17:59:02 +00:00
Brian Osman
b047b5ddf4 Disable "any" function workaround in standalone/non-GPU caps
Change-Id: Ief57d9c102b3c7658738920cdf54ccd4d21c5c5e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331656
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-11-03 17:36:43 +00:00
John Stiles
e103f941fc Create test case for oss-fuzz:26942.
Change-Id: I19a9564ac4d52b709b8fdd757b99222372c626f4
Bug: oss-fuzz:26942
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331598
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-11-03 17:19:22 +00:00
Chris Dalton
6bacd9ff2f Fix the grvx_approx_angle_between_vectors test
This method is only valid in the range 2^(+/-30) due to fp32 overflow.
Adds a comment to the function and updates its test.

TBR=bsalomon@google.com
Change-Id: Ifa2fc0ed4a7f9123f0bebaa02c666c61e06e62a6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331481
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2020-11-03 00:27:54 +00:00
Chris Dalton
2882e70ef3 Add GrPathUtils::findCubicConvex180Chops
This method finds the locations a cubic needs to be chopped at before
it can be passed to the stroke tessellation shader. It's an integral
part of CPU stroke preparation and therefore extremely perf sensitive.

Bug: skia:10419
Change-Id: Ib23c2583b8cfc78814ce52425f7af2c8b2f8b420
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330314
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2020-11-02 20:33:54 +00:00
Chris Dalton
4195bcc25a Use uint4 instead if int4 in grvx test
Change-Id: Ic0a4c433d1d78592613b8a2fc10098ea74ee250e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331368
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-11-02 20:04:24 +00:00
Chris Dalton
c3cb099556 Add GrVx.h
Adds grvx, Ganesh's addendum to skvx. Here we introduce familiar names
and operations from GPU languages, as well as functions that are
approximate and/or have LSB differences from platform to platform.

The initial implementation has: fast_fma, fast_acos, and
fast_angle_between_vectors. When a function is approximate, its error
range is well documented and tested.

Also establishes GrWangsFormula as the first user of grvx.

Bug: skia:10419
Change-Id: Id0682599cf9c0303eff386095afc3ef9f3a7fa1b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330119
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-11-02 18:33:54 +00:00
John Stiles
bfad3e2a4a Add test cases to function-prototype golden outputs.
- Prototypes for never-declared functions
- Prototype before use
- Prototype after use
- A variety of inputs and outputs on the prototyped functions.
- Calling declared-but-undefined functions

Currently, the prototypes are not actually emitted in the generated GLSL
or Metal output at all. This CL is demonstrates our baseline before
proper prototype support is added.

Change-Id: I6112e0a89ab9bbecefccaca9fba985bb8011fff1
Bug: skia:10872
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331376
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-11-02 17:17:23 +00:00
Chris Dalton
4dd3c8cbef Fix Wang's formula for cubics
We finally have a reference and derivation of Wang's formula, thanks to
tdenniston@. And it turns out that the formula we had been using for
cubics wasn't quite right. It was overly conservative for certain types
of curves.

This CL fixes the incorrect cubic formulas and adds a citation to the
"Pyramid Algorithms" book. We should now be getting by with fewer linear
segments.

Bug: skia:10419
Change-Id: Ib850c7b4d17b8d9f9abed800cc7cb5f074df6e17
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331156
Reviewed-by: Tyler Denniston <tdenniston@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2020-11-02 16:36:43 +00:00
John Stiles
47ee0caa10 Split Texture test into separate 1D and 2D tests.
This improves the test output for Metal. Previously, the Metal output
was just an error message, since 1D textures were unsupported. Now we
have a valid golden output for the 2D case in Metal. (1D is still
unsupported and is likely to remain unsupported; Skia currently has no
use case for 1D textures.)

Change-Id: I91977712030f08e371cc6bfb2afa578940ca00b7
Bug: skia:10797
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330940
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-11-02 14:39:31 +00:00
Robert Phillips
67e58cb909 Add callback to thread-safe cache to resolve vertexData collisions
The triangulating path renderer can generate multiple triangulations of
the same path at different levels of precision. As previously
implemented the more precise triangulations would steal the unique
key from prior triangulations. This new callback will allow us to
replicate this behavior in the thread-safe cache.

Bug: 1108408
Change-Id: I8b445ca1e503b2fd78727a23d9376a2cf77f291c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330562
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-11-02 14:30:21 +00:00
Mike Reed
b21c1f2d44 test lineTo after addRect
Motivated by investigating
https://skia-review.googlesource.com/c/skia/+/330696

This CL does not fix anything, but is meant to better document
the current behavior.

Change-Id: I62b8cbfb39e05404f0f5303f024e1f56fc32b7e5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330937
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Tyler Denniston <tdenniston@google.com>
2020-10-31 15:10:48 +00:00
John Stiles
869cdefdd1 Fix unknown-identifier issue discovered by fuzzer.
This error was caused by an unbalanced symbol table push. This could
occur when an interface block encountered an error while parsing its
var-decls.

Change-Id: I910a980ac92fac7c0786c48b8dc3003ee3e75e5b
Bug: oss-fuzz:26700
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330896
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2020-10-30 19:11:31 +00:00
John Stiles
d5e6368fff Add initializer_list support to SkTArray.
Also added unit tests for each of SkTArray's various constructors, and
added `SkTArray::value_type` which allows calling code to refer to the
array's value-type. These unit tests exposed some preexisting strict-
aliasing issues in SkSTArray when compiled on GCC 6+ with optimizations
enabled, which are being investigated separately at skia:10891.

Change-Id: Ia0fb18830cfbbdcb1545fe7f7ac51d8e768a3f94
Bug: skia:10891
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330279
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-10-30 18:35:41 +00:00
John Stiles
09479909d1 Add unit test for error discovered by fuzzer.
Before http://review.skia.org/330743 was submitted, this caused an
assertion during CFG generation: http://screen/95ZaTYzon4bMVtE

Change-Id: Icf93472394de3d17425ad1258a68b263cab88eb1
Bug: oss-fuzz:26759
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330816
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2020-10-30 18:18:31 +00:00
John Stiles
4691b0f82b Fix crash when compiling FP files containing the modulo operator.
Change-Id: Idfbe128978575ab84b54485bffe2d82570ee099f
Bug: skia:10870
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330620
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-10-29 22:55:28 +00:00
John Stiles
8bc1a72cba Add unit test to demonstrate error with modulo in FP files.
(This CL also adds modulo to the IntFolding shared test, since this was
absent from the test. It's implemented and working properly already.)

Change-Id: I24a947ab38754bff2624cd5b58cf7a39553ca888
Bug: skia:10870
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330596
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-10-29 20:46:08 +00:00
Nigel Tao
f933e4fb56 Have SkWuffsCodec speak kRGB_565_SkColorType
This takes the "one pass" code path more often, using less memory, as it
does not have to allocate an intermediate width*height pixel buffer.

Wuffs v0.2 did not support RGB 565 color but Wuffs v0.3 does.

The Codec_AnimatedTransparentGif test passes with skia_use_wuffs true or
false.

Change-Id: Id569fc0bf62e614fa881cb235a9a6a1ca340dcb0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329916
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
2020-10-29 14:10:33 +00:00
Robert Phillips
83c38a8fd6 Allow uniqueKey invalidation messages to reach the thread safe cache
With the addition of vertex data to the thread safe cache we also have
to handle the case where a given SkPath becomes inaccessible and
proactively invalidate the matching entry.

Bug: 1108408
Change-Id: Id11ce2aa10517f7c0772a253634d3c0d13e13460
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330261
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-10-29 12:36:13 +00:00
Herb Derby
e25c30034a use SkArenaAlloc for combineIfPossible
Now that GrOps no longer needs a GrMemoryPool to be
deleted, just pass down the the SkArenaAlloc instead
of both the GrMemoryPool and SkArenaAlloc.

The alloc is only used for two ops, but we pass it
to all the ops most of which don't use it.

Change-Id: I873efcdfe44b446f2ac5089ea8425dff257e318c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330118
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2020-10-28 19:10:01 +00:00
Mike Klein
71f1266664 Revert "SkPathView for ownerless (can live on stack) SkPaths"
This reverts commit 375721d7bb.
Some manual edits needed due to time elapsed.

Bug: chromium:1141332, skia:10566
Change-Id: Iadb15d3f5334d9eed4e7053e9c19d75a0bbeb9de
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330196
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-10-28 15:25:41 +00:00
Herb Derby
e32e1aba34 replace GrOpMemoryPool with GrMemoryPool
Change-Id: I93fdeaa3ea6be73619f82859bb53aa88fae3262b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329962
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2020-10-27 16:15:11 +00:00
John Stiles
fdf6148102 Pass function arguments using SkSpan instead of count + ptr.
There's no functional change here; it's just using a slightly higher-
level abstraction to pass the same payload.

Change-Id: Ife7efa038db5d6dbde5decae2be79ad9db877aba
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329782
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-10-27 14:41:04 +00:00
John Stiles
890363ae34 Prototype helper functions from FP files before use.
GLSL requires that functions are declared before first use. In most
cases, we avoid the requirement for explicit prototypes by this by
strategically ordering our functions within the emitted code, but an FP
file might reference its helper functions in any order or have helper
functions that cross-invoke each other, so prototypes should be emitted.

Change-Id: I3b9e9c9ec4bd5be90b4f71f8165af45364facf30
Bug: skia:10872
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329781
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-10-27 14:33:00 +00:00
John Stiles
6b58a33c16 Mangle function names as a separate step before emitting func-bodies.
This is necessary to support function calls in FP files properly; in
some cases, functions can be referenced before they have been emitted,
and we need to be able to name them.

This CL resolves the remaining errors in GrRecursion.cpp. There are
still additional errors in GrNestedCall.cpp that will be fixed in
followup CLs.

Change-Id: Iec98ef02ea6a98a9945a4e0e3cfa3537dff01305
Bug: skia:10684, skia:10872
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329676
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-10-27 14:22:10 +00:00
Mike Klein
40f8107eab remove absl experiment
We've given up on Abseil, and these warnings are annoying:

    ... libtool: warning same member name (libabsl.escaping.o) ...

Bug: skia:10165
Change-Id: I144573206174cbe9b48fce8e86ed22eb4a4e29b3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329937
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-10-27 13:45:10 +00:00
Chris Dalton
81b270a659 Optimize SkChopCubicAt to chop at two points at once
Adds an SkChopCubicAt overload that performs two chops at once in
SIMD. Also updates SkChopCubicAt to accept T values of 0 and 1. This
has been the source of bugs in the past.

Bug: skia:10419
Change-Id: Ic8a482a69192fb1685f3766411cbdceed830f9b7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/327436
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2020-10-26 21:36:25 +00:00
Robert Phillips
3ac83b2f91 Add additional GrThreadSafeCache test case
and flush out some non-substantive changes; namely:
  whitespace changes
  tweak what is stored in TessInfo
  change createMesh to be CreateMesh

Bug: 1108408
Change-Id: Ife9a0e500b9f51db597350b0257b20efece03bdc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329633
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-10-26 19:42:15 +00:00
Herb Derby
c76d4096af add API for Op creation
Introduce three calls on GrOp: Make, MakeWithExtraMemory,
and MakeWithProcessorSet. Instead of returning
unique_ptr<GrOp>, they return a type of GrOp::OpOwner.
GrOp::OpOwner safely deletes the op when it goes out
of scope for either new/delete or GrOpMemoryPool
allocations.

In order to make the code easier to refactor, I
eliminated MakeArg from the helpers.

Change-Id: Icfd697906f3147a8734575d08bd7195e7517383a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/323778
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2020-10-26 18:51:15 +00:00
John Stiles
d2a3a5b3b4 Add support for fFormatArgs in .fp-file inner functions.
Previously, we'd just emit functions with `%s` in their function bodies.
Also, the fFormatArgs wouldn't get cleaned up, so subsequent code would
fill in the wrong format arguments in each place.

There are still problems with function calls (`sample` is broken;
function names are accessed before they've been declared or initialized)
but this is a step in the right direction.

Bug: skia:10684
Change-Id: I7399a71d44ebba5049703484ec9933dffbe8e2b9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329417
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-10-26 16:15:33 +00:00
Robert Phillips
375e1f6a64 Add unit tests for vertexData in the thread-safe cache
Bug: 1108408
Change-Id: Ia984324d559bb33bfe668a44ee93c6e39fc47685
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329419
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-10-23 23:21:56 +00:00
John Stiles
8744a5c820 Add unit test for nested function calls in FP files.
`func1` and `func2` emit bad code, `return %s()`, and because they don't
consume their `%s` format argument. This leaves the format argument list
unbalanced and all future args are wrong.

Another serious problem is that we don't actually know the names of the
functions that they need to call, because we haven't emitted them yet.

`func3` is not emitted at all. Sampling from a fragment processor
apparently fails in this context.

This is a more general case repro for skia:10684--it turns out that
recursion in particular wasn't the issue, but nested function calls just
don't work properly at all in FP files. This wasn't an issue in practice
because we don't have any existing FP files which nest function calls,
and the inliner also tends to aggressively flatten everything out if we
don't explicitly disable it.

Change-Id: Iff029c459c7d90be566f9b4c9be0e3150e459866
Bug: skia:10684
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329367
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-10-23 21:07:36 +00:00
John Stiles
80f240a3d3 Revive SkSLFPTestbed for basic verification of CPP/H codegen.
This brings back the basics from SkSLFPTest.cpp. This file was removed
entirely in http://review.skia.org/319029 but, in retrospect, it's still
a good idea for dm to verify that CPPCodeGen and HCodeGen can do their
jobs. And, like SkSLGLSLTestbed, this gives us a good place to attach
the debugger in dm for testing CPP/H-specific code generation bugs.

Change-Id: I514192bacd63021708dbd02a0276a3d55a43195f
Bug: skia:10684
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329370
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-10-23 20:32:35 +00:00
John Stiles
530933006d Add unit test demonstrating recursion codegen bug.
The generated code does not assign to sk_OutColor correctly; it assigns
into the `factorial` function name instead, which doesn't make sense.

Change-Id: Ibad1d47f2f9c4fbb410b5277cea6e1022daf8b9d
Bug: skia:10684
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329360
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-10-23 16:33:15 +00:00
John Stiles
9cef66fbf5 Fix use-after-free discovered by fuzzer.
In cases where multiple variables were declared on a single line, it is
legal for variable initialization-expressions to reference variables
declared earlier in the var-decl statement. It is NOT legal for the
inliner to move those references up to the previous statement, where the
variable doesn't exist yet.

This is mitigated by disabling the IRGenerator inliner for var-decls
past the first one in a var-decls statement. (The optimizer will still
pass over this code later and is able to inline it correctly, if it is
worth doing.)

Change-Id: I7a0d45eab20e30ed9f6b2f5c1251b6e0d8eeaea3
Bug: oss-fuzz:26167
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329357
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2020-10-23 16:10:15 +00:00
John Stiles
15d8174fc9 Add unit test for self-referential initializer expressions.
These don't compile in GLSL, so they shouldn't compile in SkSL either--
and fortunately, they do not.

(In C++, and consequently in Metal, these expressions are considered
legal by the grammar and do compile, but generate garbage output.)

Change-Id: I6c7bea70b3d91677ccd8fcbad1eba123d655e856
Bug: skia:10694
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329359
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-10-23 14:36:05 +00:00
Michael Ludwig
e267464b89 Make small epsilons more rigorous for gpu gaussian blurs
This also has several other bug fixes and refactorings within it that
I realized were possible while updating every where that had checked
sigma > 0 to be sigma > kEffectivelyZeroSigma.

The big things are that SkBlurPriv.h goes away and its functions are
just moved into SkGpuBlurUtils since they were only used by the GPU.
The implementations of those functions are also collected into
SkGpuBlurUtils.cpp.  I removed the GrMatrixConvolution::MakeGaussian,
in favor of SkGpuBlurUtils filling in the kernel itself and then calling
the regular Make. This let me consolidate two different 1D kernel
computing functions, and remove the 1D fallback code from the 2D kernel
calculation because GaussianBlur() can detect that earlier.

The new GM, BlurSigmaSmall, originally drew incorrectly on the GPU
backend because it's small but non-zero sigma would trick the sigma > 0
checks in various places so we'd do a full 2 pass X/Y blur. However,
when the sigma was too small, the kernel was just filled with 0s so the
Y pass would effectively clear everything. While I could have just fixed
that to be a [0, 1, 0] kernel, updating the blur pipeline to compare
against integer radii seems more robust.

Change-Id: I3c41e0235a27615a9056b25e627ffedd995264bd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328797
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-10-21 17:37:12 +00:00
Brian Osman
2d2f82c00a Always declare sk_FragColor in GLSL, even if unused
PLS and discard-only shaders are the only time this has an impact,
and it doesn't seem like a problem to have the declaration?

Removes one use of variable reference counts, which are going to be
refactored.

Change-Id: Idb8d06087eed56070252ee02dcf907bf0d24c5a1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328796
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-10-20 21:13:31 +00:00