Commit Graph

9394 Commits

Author SHA1 Message Date
John Stiles
3738ef531b Move code generators to codegen/ directory.
We are up to having seven distinct types of codegen, and will soon have
an 8th (DSL C++).

Change-Id: I6758328390c234ba1d5c30c118199dbc820af52a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395817
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-04-13 15:34:24 +00:00
John Stiles
7134646ebd Migrate SkSLExternalFunction to the ir/ directory.
Change-Id: I8ca4fbba551624c61a4ebe7a4716750fe0b48196
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395818
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>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-13 14:17:16 +00:00
Brian Salomon
45889d1269 Remove code to push pixmaps to backend textures from GrGpu classes
Replace GrGpu::updateBackendTexture with narrower method that clears
a backend texture.

Creation of data for a solid color compressed texture is lifted up to
GrDirectContext and goes through updateCompressedBackendTexture.

Bug: skia:11786
Change-Id: I1d617623df5e65686f30e57c361a64f78d77f7bd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392836
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-04-13 13:32:44 +00:00
Mike Reed
e58231ae8f Removed unused SkInterpolator
Bug: skia:11852
Change-Id: I7a9eb2e0594bc1bdf6e7ba5355b6f00cc177253f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395476
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2021-04-13 00:50:11 +00:00
Ethan Nicholas
8455893840 SkSL DSL matrix support
Change-Id: I9d43346df1a7611726f69ea54b4236e32d11d20c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395696
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-12 22:03:31 +00:00
Brian Osman
962e6140ac Add ivec GLSL type aliases to runtime effects
Also add unit test of all GLSL type aliases.

Bug: skia:10679
Change-Id: I93e21621c11adfe3f114d0c55fb8043518e62696
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395718
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-12 16:55:41 +00:00
John Stiles
d02615698e Fix assertion when performing type-coercion with enums.
In http://review.skia.org/393397, I replaced a Constructor::Convert call
with a call directly to ConstructorCompoundCast::Make.

This worked fine if the input expression was actually a compound, but
if it was not, the code would assert/crash. The fuzzer detected this
error right away. (Enums are not considered to be a scalar, a vector or
a matrix in SkSL.)

Change-Id: Ie0df4c5771ff4f4d8f5251d4703e9c3516b6baad
Bug: oss-fuzz:33113
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395720
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-12 16:40:31 +00:00
Ethan Nicholas
ee49efcc91 Added DSL fragmentProcessor and Sample function
Change-Id: I76348d151fbf27454a6f60e4f5f7e1774731e61b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395216
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-04-12 14:29:51 +00:00
John Stiles
97186dc957 Fix various fuzzer-generated tests.
Two of the tests are now (correctly) detected as invalid code, but were
previously checked into /shared/ because they compiled when the fuzzer
first reported them (that is, after the crash was fixed). These have
been moved into the /errors/ test folder.

One of the tests was only generating an error because its main function
was named `a` instead of `main`, so I renamed it to `main`.

Change-Id: I1a2346fb16e304b0c66ff377a3f9bf7e7ee89ba9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/394899
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-12 13:44:59 +00:00
Adlai Holler
cd2f96dd68 Add GrResourceAllocator::makeBudgetHeadroom
This allows the caller to decide whether a plan is feasible before
committing to it. In this CL the drawing manager doesn't actually
call it, but we test it. We'll call it in a follow-up CL

Bug: skia:10877
Change-Id: Ie3a6c14a0196f595c522a0c961aba7b10c980711
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/394157
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-04-09 22:52:07 +00:00
Adlai Holler
ee2837ba09 Split GrResourceAllocator::assign into two methods
A follow-up CL allows the user to check the budget headroom
in between these two steps.

Bug: skia:10877
Change-Id: Ie0e6f23029065158b2eadb0dc26caf32f54433e1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/394999
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-04-09 21:40:27 +00:00
John Stiles
d3a1df8da7 Remove sk_Height and sk_Width.
These builtins have been obsolete for a long time; they were only
implemented on the GLSL backend. These values are provided in
u_skRTHeight and u_skRTWidth instead. (See GrGLSLProgramBuilder's
addRTHeightUniform and addRTWidthUniform.)

Change-Id: I8cceca348cbf9071939618f913693c316d35dbc6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395001
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-09 21:01:27 +00:00
John Stiles
392d829798 Fix SPIR-V error when creating non-square diagonal matrices.
The code which assembled a uniform-scale matrix (aka
`ConstructorDiagonalMatrix`) accidentally looped over columns instead of
rows when assembling the matrix.

Change-Id: Iefb9ae645a7a85f61443e6e96b752ba729f40c9c
Bug: skia:11278
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/394997
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-09 19:15:07 +00:00
John Stiles
2de947e780 Fix broken Enum unit test.
This test fell into disrepair when constant propagation was removed; it
assumed that @if and @switch would work on all unchanging variables, not
just those with the `const` modifier.

Change-Id: Ie9c1816f9c0852fdea998e4e156047e4cca9ad5b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395000
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-09 19:07:27 +00:00
Adlai Holler
3cffe81f0d Improve GrResourceAllocator test infrastructure
Adding new tests in an upcoming CL. This sets the stage for that.

I also outlined the Register ctor so that the diff in the next CL is
more readable.

Bug: skia:10877
Change-Id: I604f1ce811cddf1d1105716f114e27ce12bf8249
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/394998
Commit-Queue: Adlai Holler <adlai@google.com>
Auto-Submit: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-04-09 18:31:27 +00:00
Ethan Nicholas
80f6235688 Fixed an issue with passing DSLVar as a DSL function parameter
DSLVar is normally implicitly converted to DSLExpression wherever it is
used, but the naively template-ized nature of DSLFunction::operator()
meant that it was accepting DSLVar parameters directly. Since DSLVar is
non-copyable, this meant DSLVar couldn't be passed directly to a DSL
function.

The smarter templates in this change are able to pass DSLVar by
reference.

Change-Id: Id04531f909cefd29b377c46e37fc4525bb29953c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/394161
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-09 17:13:27 +00:00
John Stiles
3509210622 Implement array == and != on SPIR-V.
GLSL (post-ES2) allows array comparison: http://screen/8gryPvb9T7gndyb

Unfortunately, because ES2 does not support array comparisons, we can't
add this test to the dm test suite.

Change-Id: I06b71683e49b2631669cff801dc647951a81a299
Bug: skia:11849
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/394162
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-09 15:33:57 +00:00
John Stiles
781496ffe5 Add unit test for array of zero or negative size.
Change-Id: Icc710e414388e4026a5e9819a53b8dac8ee0a2d1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/394896
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-09 14:38:47 +00:00
John Stiles
d47330feed Add support for struct constructors to SkSL.
This is allowed in OpenGL ES2, and its absence in SkSL has been a pain
point for new users adopting Runtime Effects.

Change-Id: Id2ed78261a2cd2b14b49ad22cb74cdc9e0905f8a
Bug: skia:11368
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393418
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-04-09 13:54:16 +00:00
Ethan Nicholas
b14e6b9055 Added _Type suffix to DSL Type enum
No functionality changes, just making the naming consistent with our
other enums.

Change-Id: Ic9bc4a89f8373e4dc1060067a41468fb626e5fa1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/394160
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-08 21:55:05 +00:00
Adlai Holler
e1c8a38794 Add GrResourceCache::purgeToMakeHeadroom
This function will be used by the resource allocator to figure out
whether an allocation plan is feasible without committing to it.

Bug: skia:10877
Change-Id: I135b7b80d53d9c3541d2fa0313d91d14a1d54eb2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/394156
Commit-Queue: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Auto-Submit: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-04-08 20:20:35 +00:00
Herb Derby
022636b15a add RSXForm to SkGlyphRun
RSXForm is not stored directly in the glyph run. The Tx and
Ty portions are stored in the positions, and the scos, and ssin
portions in a span of SkVector.

This CL just adds the space for the extra information, but does
not utilize it yet.

Change-Id: I93e2140fb28a6638a57b6d811ed6dc823e8de6ae
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/394217
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-04-08 19:50:45 +00:00
John Stiles
bc5c2a0ab9 Implement struct == and != on SPIR-V.
OpenGL ES2 allows structs to be compared: http://screen/6KnX4ZfkdLtqDWv
This already worked in GLSL, Metal and SkVM.

Change-Id: Iaf7029c0c1ea9d447348c8280a2788f0d36befad
Bug: skia:11846
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393598
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-04-08 17:17:34 +00:00
Adlai Holler
ca1137b1d1 Give GrResourceAllocator a GrDirectContext
This allows it to access the resource cache as well as the provider,
and paves the way for memory budgeting inside the resource allocator.

Bug: skia:10877
Change-Id: I01e9c02e445494ac431b288f41006ae7360ff791
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/394116
Auto-Submit: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-04-08 17:16:54 +00:00
Chris Dalton
a655a33264 Rename glrt::fRTFBOID -> fMultisampleFBOID
As part of this we also create two fbos now for
multisampled_render_to_texture: one msaa and one not.

Bug: skia:11396
Change-Id: If519b52ec79de4b2abeac2c5658f766f1c7e8d9c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392746
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-04-08 16:03:04 +00:00
Brian Salomon
75ee737770 remove prepForSampling from GrSurfaceContext::writePixels.
We believe with advent of  GrBackendSurfaceMutableState that this is
only needed for inline atlas uploads. Those call GrGpu directly.

Bug: 1191058
Change-Id: Iad851ebc9f5b7df21d16064a84caa9575da98634
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393082
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-04-07 13:33:28 +00:00
Brian Osman
5c62582874 Require that runtime effect child variables are 'uniform'
Bug: skia:11374
Change-Id: I63d605eabbe514a0469d00d8a671969874f3edd4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393081
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-07 13:16:28 +00:00
Herb Derby
27ce7df013 Revert "put an arena on GrSurfaceDrawContext"
This reverts commit 5a2de5e72f.

Reason for revert: Upon further investigation this still leaks

Original change's description:
> put an arena on GrSurfaceDrawContext
>
> This is part one of two CLs. In this CL, I put a
> sk_sp<GrArenas> on GrSurfaceFillContext where GrArenas wraps
> a SkArenaAlloc to add ref counting. Creating
> a GrOpsTask shares the GrArenas with the ops task. New plumbing
> was added to GR_DRAW_OP_TEST_DEFINE to allow a proper
> GrSurfaceDrawContext to be passed to GrAtlasTextOp's
> GR_DRAW_OP_TEST_DEFINE so the arena will have a proper lifetime.
>
> The second CL will work on replacing GrOpsTask's fAllocators
> system with the shared arena.
>
> Change-Id: Ife3be0ab265441cbffab360f2808f5eed86db8b3
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392936
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

TBR=bsalomon@google.com,herb@google.com

Change-Id: I9ca5c8b1e16b468003788cd3126eda1d40ff93ed
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393177
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-04-06 20:16:08 +00:00
Herb Derby
220dd695bb Revert "remove fAllocators from GrOpsTask"
This reverts commit f00d6a8efd.

Reason for revert: In the long run, it seems like this might leak.

Original change's description:
> remove fAllocators from GrOpsTask
>
> Change-Id: I5901f005c2758a92692e5cd70ba46a2b5ad797fd
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393116
> Commit-Queue: Herb Derby <herb@google.com>
> Reviewed-by: Adlai Holler <adlai@google.com>
> Reviewed-by: Chris Dalton <csmartdalton@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

TBR=herb@google.com,robertphillips@google.com,csmartdalton@google.com,adlai@google.com

Change-Id: I895e47c999c6961fa14c356d6d5bde80dd86b63e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393176
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-04-06 19:57:47 +00:00
Brian Osman
601abfacc7 Move 'shader' usage tests to an SkSL golden file
Also adds tests of non-uniform shader declarations. These are currently
allowed, but will be detected as an error in the next CL.

Bug: skia:11374
Change-Id: I3fee0a0c97ae590f7bc6952cb367f7e94436b891
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393080
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-06 19:20:16 +00:00
John Stiles
5abb9e1426 Represent matrix resizes as a dedicated expression type.
This shook out a long-standing bug; constant folding would treat a
matrix resize as if the cells not covered by the original matrix were
all zero. This is wrong; GLSL populates the unknown cells with an
identity matrix. We actually tested for the wrong behavior, so the tests
were updated to match the correct behavior, and an equivalent test was
added that does not constant-fold (to verify that our constant folder
matches reality).

Change-Id: I03df10ce646fbef0a36e9c1a841a7637182de122
Bug: skia:11032
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392916
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-06 18:35:06 +00:00
Herb Derby
f00d6a8efd remove fAllocators from GrOpsTask
Change-Id: I5901f005c2758a92692e5cd70ba46a2b5ad797fd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393116
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-04-06 18:22:46 +00:00
Chris Dalton
b21bfc8de5 Rename glrt->textureFBOID() -> singleSampleFBOID()
Bug: skia:11396
Change-Id: I02fdb4acd368a54e585891ef3c38f6b0c79a5d17
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392718
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-04-06 18:14:35 +00:00
Herb Derby
5a2de5e72f put an arena on GrSurfaceDrawContext
This is part one of two CLs. In this CL, I put a
sk_sp<GrArenas> on GrSurfaceFillContext where GrArenas wraps
a SkArenaAlloc to add ref counting. Creating
a GrOpsTask shares the GrArenas with the ops task. New plumbing
was added to GR_DRAW_OP_TEST_DEFINE to allow a proper
GrSurfaceDrawContext to be passed to GrAtlasTextOp's
GR_DRAW_OP_TEST_DEFINE so the arena will have a proper lifetime.

The second CL will work on replacing GrOpsTask's fAllocators
system with the shared arena.

Change-Id: Ife3be0ab265441cbffab360f2808f5eed86db8b3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392936
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-04-06 15:15:46 +00:00
John Stiles
9267183cf4 Fix matrix resizing in SPIR-V.
When growing a matrix, the new cells should contain the identity matrix.
`writeMatrixCopy` was populating every cell with zeros instead.
Also, `writeMatrixCopy` had some code for handling int matrices, but
we don't support this in SkSL anywhere else; replaced with an assert
that the component type is float.

Change-Id: Icb80ae711d5c4f1417b62168b203a661f52e8d7d
Bug: skia:11835
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393037
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-04-06 14:55:45 +00:00
Brian Salomon
b3479cea80 Limit texture attached to FBO workaround on Adreno 4xxx by driver ver.
Bug: skia:11834
Change-Id: I50e3a0ae87e7039376a6a8a3a6e0be24bf6f40fe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393036
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-04-06 14:52:45 +00:00
Brian Salomon
974c821502 Reland "Make RGB_888x pixel operations work."
This is a reland of 8ce24b1d11

Original change's description:
> Make RGB_888x pixel operations work.
>
> Also remove vulkan-specific conversions in GrVkGpu and rely
> on higher level SurfaceContext to convert correctly.
>
> Bug: skia:8862
> Change-Id: Ib8b0541c8c5831148b7129c4bbed3f925660116e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392378
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

Bug: skia:8862
Change-Id: I5d085e47398a4a2947228ee67f867552fa93123a
Cq-Include-Trybots: luci.skia.skia.primary:Test-Debian10-Clang-NUC5PPYH-GPU-IntelHD405-x86_64-Debug-All-Vulkan
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392842
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-04-05 21:18:46 +00:00
John Stiles
0a12b85f16 Add regression test for oss-fuzz finding.
The actual fix happened at prior CL http://review.skia.org/392197, which
reworked how vector-cast constructors function.

Change-Id: Ifb71ec913b349e65d38458dc615441e7a73efddc
Bug: oss-fuzz:32851
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392841
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-05 19:39:16 +00:00
Robert Phillips
8faa34089c Limit GrClipStackClip tests to only exist when relevant
As part of the new architecture I envision not compiling in stuff like
the GrClipStackClip when in NGA-mode. This ran/runs into trouble with
the unit tests.

Change-Id: I922dcf873c4bb1a3abfd2ce519f3dbf68e053770
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392839
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-04-05 18:46:46 +00:00
Brian Salomon
acd28fc509 Revert "Make RGB_888x pixel operations work."
This reverts commit 8ce24b1d11.

Reason for revert: https://ci.chromium.org/raw/build/logs.chromium.org/skia/52bc09f869c58a11/+/annotations

Original change's description:
> Make RGB_888x pixel operations work.
>
> Also remove vulkan-specific conversions in GrVkGpu and rely
> on higher level SurfaceContext to convert correctly.
>
> Bug: skia:8862
> Change-Id: Ib8b0541c8c5831148b7129c4bbed3f925660116e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392378
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>

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

Change-Id: I5358e0ba4d0f1dc24cc5c37dd86c401a3a6b6076
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:8862
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392840
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-04-05 18:42:57 +00:00
John Stiles
b14a819122 Represent vector-cast constructors with ConstructorVectorCast.
Making a VectorCast from a compile-time constant will perform the cast
at compile-time instead; previously, we did not apply this optimization.
This simplified a few test outputs in subtle ways. (In particular, the
SPIR-V codegen used to occasionally decorate OpConstantComposite of
constant numbers with RelaxedPrecision, and no longer appears to do
this. This should have no effect on results either way AFAICS.)

Because we don't return VectorCast constructors containing compile-time
constant values, we do not need to implement compareConstant for this
constructor; they only wrap non-compile-time-constant expressions.

Change-Id: I28c1f337f64d6f20fb86bc0f58e225af4bd7b26c
Bug: skia:11032
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392197
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-05 16:28:06 +00:00
Brian Salomon
8ce24b1d11 Make RGB_888x pixel operations work.
Also remove vulkan-specific conversions in GrVkGpu and rely
on higher level SurfaceContext to convert correctly.

Bug: skia:8862
Change-Id: Ib8b0541c8c5831148b7129c4bbed3f925660116e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392378
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-04-05 16:18:26 +00:00
Brian Osman
14d0096f1d Make 'shader' and 'colorFilter' first class types in SkSL
No functional change yet, but fragmentProcessor is no longer allowed in
runtime effect SkSL (and errors about 'shader' variables will no longer
refer to 'fragmentProcessor').

Bug: skia:11813
Change-Id: I5161f9adbe79090ec31ed3faf7dcef0e290842b7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392440
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-05 14:55:46 +00:00
Brian Osman
1f56479d6e Add test using 'fragmentProcessor' in runtime effects
Allowed today, will soon be an error.

Bug: skia:11813
Change-Id: I5c13de7657fa85f13fa6d80e1d890225d8a3e868
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392439
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-05 14:02:16 +00:00
Brian Salomon
2c673409ef Expose writing to mip levels via GrSurfaceContext::writePixels
Bug: skia:11786
Change-Id: Id17952db0aede56fa39845d9d371cf0a141f9dd7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/391836
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2021-04-02 19:16:15 +00:00
Chris Dalton
f8d75c687d Don't use the recordTimeAllocator in GrOpsTask
This is a stopgap for dealing with OOM issues.

Bug: b/182959903
Change-Id: I25855b6fc1c9d8d270c1cb3fcbdc1c7f93623214
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/391956
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-04-02 18:04:35 +00:00
Derek Sollenberger
396cd1dfab Revert "Lift atlas clip FP creation out of GrClip::apply"
This reverts commit 92b35673c5.

Reason for revert: breaking the android roll (see ag/14076257)

Original change's description:
> Lift atlas clip FP creation out of GrClip::apply
>
> Atlas clips always had a potential point of failure: If the SDC's
> opsTask ever got closed between GrClip::apply and
> GrOpsTask::addDrawOp, their mask would have gotten sent to the wrong
> opsTask. It didn't _look_ like this could happen with the current
> code, but it could have also been inadvertently changed quite easily.
>
> This CL adds a "pathsForClipAtlas" array for GrClip::apply to fill out
> instead of creating FPs. The SDC then generates the actual clip atlas
> FPs once it knows exactly which opsTask they will belong in.
>
> Bug: chromium:928984
> Change-Id: I507ab13b2b5e8c3c3c1916d97611297dbbd8a522
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/389926
> Commit-Queue: Chris Dalton <csmartdalton@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>

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

Change-Id: I9597d822a9f31b7070aee691ddf3a52f4f424a24
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:928984
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392339
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
2021-04-02 15:44:47 +00:00
Chris Dalton
92b35673c5 Lift atlas clip FP creation out of GrClip::apply
Atlas clips always had a potential point of failure: If the SDC's
opsTask ever got closed between GrClip::apply and
GrOpsTask::addDrawOp, their mask would have gotten sent to the wrong
opsTask. It didn't _look_ like this could happen with the current
code, but it could have also been inadvertently changed quite easily.

This CL adds a "pathsForClipAtlas" array for GrClip::apply to fill out
instead of creating FPs. The SDC then generates the actual clip atlas
FPs once it knows exactly which opsTask they will belong in.

Bug: chromium:928984
Change-Id: I507ab13b2b5e8c3c3c1916d97611297dbbd8a522
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/389926
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-04-01 20:21:18 +00:00
Brian Osman
d18967c67d Add integer uniforms to runtime effects
Bug: skia:11803
Change-Id: I925f14be282b96355721986de6049090b35adf3d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/391856
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2021-04-01 17:20:03 +00:00
Brian Salomon
d8db5884de ComparePixels helper takes GrCPixmaps
Change-Id: I56d902b652663df7893626d19bc88d18f980c02c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/391301
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-03-31 20:38:22 +00:00
Chris Dalton
8ed7a8d1c6 Extract a GrVertexChunkArray class with a builder
This will be used by the new stroke tessellator. All the other
tessellators should start chopping and chunking too. That will allow us
to quit cropping paths if we are afraid they might need more segments
than are supported.

Bug: chromium:1172543
Change-Id: I30f0ebb581f56cac099d8c05e0e181c4657c3db8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/390096
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-03-31 17:27:52 +00:00
John Stiles
22a54543a8 Add support for constant-folded array inequality checks.
This isn't something I expect to occur often. However, we have always
reported that array-ctors with constant arguments are compile-time
constants, and `compareConstant` is supposed to be implemented for all
compile-time constants.

Change-Id: I0bbfe2a3f78c29c14f69c3b6faca71067a0e45c8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/391116
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-31 15:50:02 +00:00
John Stiles
8037c9e2ed Add test for folding of == and != for arrays.
We don't directly support this today at all. In practice, though, simple
constant arrays are detected as equal in the constant-folding pass
because they hit the `x == x` self-equality check (using
`IsSameExpressionTree`).

This does not work for our inequality tests, though, so those do not
fold.

Change-Id: I6730a9a2d1da9ac613ee58889d651f3ff65b1d2d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/391057
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-31 15:32:03 +00:00
Brian Salomon
5392c94fe8 GrConvertPixels takes pixmaps
Add GrCPixmap, a GrPixmap but with const void* instead of void*. Share
impl via template base class GrPixmapBase.

Change-Id: I7dfdf24a73c1bc8557ff7b90f93a9399da2f3f75
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350022
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2021-03-31 00:23:17 +00:00
Chris Dalton
9b5b7db793 Move GrStrokeTessellator into its own header file
Simple refactor to make things reusable for the next non-hardware stroke
tessellator.

Change-Id: I0898b54a616e60f0475ac74cbd6f518e8696e0e5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/390078
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-03-30 18:00:16 +00:00
Brian Salomon
1d2a26d0df Add more comprehensive test for GPU write pixels.
Similar to existing SurfaceContextReadPixels but for writes. Tries all
combinations of src/dst color type and alpha type for write pixels.
Always reads back pixels for verification using the ImageInfo of the
tested surface context.

Bug: skia:8862
Bug: skia:11130
Bug: skia:11786

Reviewed-on: https://skia-review.googlesource.com/c/skia/+/348886
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Change-Id: I22b38a99c8b4e5b506cd0b94ab9cac3d347f6b2e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388236
2021-03-30 15:50:36 +00:00
John Stiles
fabed8bb79 Fix fuzzer-discovered error with variable declarations.
As soon as a single VarDeclaration is successfully created, its Variable
is added to the current symbol table. However, if a variable-declaration
line declared several variables in a row, we would stop if ANY of the
declarations contained an error and discard the entire statement, but
would continue processing the rest of the program. This left us in a
position where some Variables existed in the SymbolTable with valid,
reachable names, but their corresponding VarDeclaration statement had
been thrown away as erroneous. Since Variables point back to
VarDeclarations for their initialValues, this gave us a stale pointer.
Any future reference to that variable name which could trigger an
access to its initialValue would read from this dead pointer.

This CL fixes the conversion of VarDeclarations so that we no longer
throw away any VarDeclarations associated with a successfully-parsed
Variable.

Change-Id: If8ec3c160933e48a0e1f36414234b3a849d8978c
Bug: oss-fuzz:32587
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/389636
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-29 14:35:09 +00:00
John Stiles
2396fb8be5 Convert division-by-literal in SPIR-V to multiplication.
This is particularly relevant for "vector / scalar" divides, as these
end up generating an extra OpFDiv to take the reciprocal of the scalar.
This meant we were generating code to calculate "literal 1 / literal N"
at runtime whenever dividing vector V against scalar N. This fix moves
the reciprocal calculation to compile-time. And of course, it's a valid
strength reduction in all cases.

Change-Id: I0986057e516120fe872e70135f1ac365155d5377
Bug: skia:11792
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/389156
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-26 02:30:54 +00:00
John Stiles
d94bfdd7d8 Fix codegen for integer vector-scalar arithmetic in SPIR-V.
Due to missing type-checks, we would emit `OpVectorTimesScalar` when
multiplying an ivec with an int, or an `OpFDiv` when dividing an ivec
against an int.

Change-Id: Idc214dbe0ec208cb44f28b22e585584ac2ab7dae
Bug: skia:11267, skia:11788
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388742
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-26 02:30:04 +00:00
John Stiles
2febb5b423 Add SkSL test for vector-scalar math.
We had constant-folding tests for vector-scalar arithmetic, but didn't
have an equivalent SkSL unit test for vector-scalar arithmetic that
actually needs to be computed at runtime.

This exposes two SPIR-V bugs: one was previously known, but the other
is a new discovery.

Change-Id: I28737128f20b445797c6c29872335d05f94cc95c
Bug: skia:11267, skia:11788
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388739
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-25 23:30:34 +00:00
John Stiles
0c9d888748 Run SkSL inliner tests as part of dm.
Previously, these tests were never actually executed, only read during
code review. They are now properly tested for correctness whenever dm
is run. Non-ES2 compliant statements (do/while/switch) are unfortunately
excluded here, as they are not compatible with Runtime Effects yet.

Change-Id: I965c782baad6f8dd3961a400ae791fb2c1f844d3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/389296
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-25 22:58:54 +00:00
John Stiles
9e13fe86b1 Rewrite matrix * vector multiplication on ARM GPUs.
If sk_Caps.rewriteMatrixVectorMultiply is false, we generate the same
code as before.

If sk_Caps.rewriteMatrixVectorMultiply is true, and optimization is
enabled, medium-precision multiplication of `matrix * vector` is
rewritten in BinaryExpression as the sum of
(m[0]*v[0] + m[1]*v[1] + ... + m[N]*v[N]).

Change-Id: I9796158fd4203b5cd2278c0d0e9a2e8cda82b136
Bug: skia:11769
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388460
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-03-24 19:21:44 +00:00
John Stiles
85749c0b22 Add caps bit for RewriteMatrixVectorMultiply.
On ARM GPUs, the Vulkan driver does not honor relaxed precision when
evaluating SpvOpMatrixTimesVector. This leads to reduced performance
(compared to GLSL, where mediump matrices and floats do evaluate all
intermediate values at mediump).

This caps bit will be enabled on ARM GPUs and, in a followup CL, will
be used to toggle a workaround where `m*v` is rewritten as the sum of
(m[0]*v[0] + m[1]*v[1] + ... + m[N]*v[N]).

Change-Id: I310fa73639b6498552c9672e76860f2eded15d0a
Bug: skia:11769
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388459
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-03-23 22:40:02 +00:00
Ethan Nicholas
7f01588f15 Revert "Revert "Added more RelaxedPrecision decorations""
This reverts commit 7bba1f55e8.

Change-Id: I707a3c215f37376086e22eaa43916afeed6da4c7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388456
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-03-23 19:34:42 +00:00
Brian Osman
d1f3b97a64 Remove sk_SampleMask support from SkSL
Change-Id: I22837a4921238749664217e595d24d196503534d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388096
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-03-23 14:37:28 +00:00
Robert Phillips
f10535f6fa Fuse GrGLSLPrimitiveProcessor and GrGLSLGeometryProcessor ...
into a new GrGLSLGeometryProcessor. Since NVPR is no more this
distinction (between GLSL- Primitive and Geometry -Processor)
probably isn't needed/useful.

Bug: skia:11760
Change-Id: I75621725bd2b0ef3dbac2ea6449bd571551babab
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388036
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-23 14:30:18 +00:00
John Stiles
9d26af9a82 Fix testing of Runtime Effects with inlining enabled and disabled.
Previously, the act of painting a Runtime Effect was causing its helper
functions to get inlined, even if inlining was disabled during the
initial SkSL generation. This meant that the "NoInline" path was not
actually very effective.

Change-Id: If8e3933be61df4a49d2e11d916d7fff22876315e
Bug: skia:11362
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388099
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-23 14:23:28 +00:00
Chris Dalton
4ac0cbe769 Remove the scary raw pointer from GrCCClipProcessor into GrCCClipPath
This also allows us to rip out extra work ccpr was doing to maintain
the lifetimes of these objects.

Bug: chromium:928984
Change-Id: I094784235e23f00fb2ed10756a5eaa22a6028c2e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387356
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-03-22 21:45:17 +00:00
John Stiles
1b843bdcb7 Fix up outdated tests.
Removed error tests which no longer test anything:
- UseWithoutInitialize...: we no longer track variable use-before-init.
- InlineDivideByZero: we no longer constant-fold the result of an
  inlined function call into its parent statement.
- Unreachable: we no longer report unreachable statements.

And fixed some minor test-case issues:
- StaticSwitchConditionalBreak: we still check this, but the function
  was being dead-stripped before this check could run. Renamed to main.
- OssFuzzXxxxx: these cases no longer report errors, but they are still
  valuable as regression tests; moved to `shared/`.

Change-Id: Iade3cff821dc998cacfd02f62d3ac4625e48904c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387820
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-03-22 21:11:47 +00:00
Robert Phillips
787fd9d80a Fuse GrPrimitiveProcessor & GrGeometryProcessor into a new GrGeometryProcessor
With the removal of NVPR we no longer need this distinction.

Bug: skia:11760
Change-Id: I225a4feb764395fb72aca3ffc8b6d05396bf0b1e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386890
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-03-22 19:44:40 +00:00
Robert Phillips
22970175f7 Remove sample locations usage from GL backend
Bug: skia:8921

Change-Id: If9e65a78f9e1fddb5c5ad5afa5612294935122e5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386837
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-03-22 18:00:06 +00:00
John Stiles
f9e8551edf Mangle function names in SPIR-V.
SPIR-V doesn't seem to mind overlapping function names, since they're
not load-bearing in any way, but this keeps us consistent with the other
code generators.

Change-Id: Ifdb4cb17795da88eabc0db841af746fb76caf423
Bug: skia:10851
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387757
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-22 17:32:46 +00:00
John Stiles
e1068349fc Mangle function names in Metal.
Change-Id: Ib9a1a51f8a29b2d03792a3abd93b3a9a321b5464
Bug: skia:10851
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387756
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-22 17:23:21 +00:00
John Stiles
ece1d794b9 Mangle function names in GLSL.
This will be implemented in Metal and SPIR-V in followup CLs.

Change-Id: I397b4db40b15dd54cf1d8a17f414c3fe184b48d2
Bug: skia:10851
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387638
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-22 17:18:26 +00:00
John Stiles
e67bd1371e Migrate VarDeclaration conversion out of IRGenerator.
Change-Id: If5fb4f99d327bb429f60e8d6c526720dd02b0928
Bug: skia:11342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386800
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-03-22 14:25:26 +00:00
Mike Reed
7db854c779 Hide getFilterQuality
Skia does not call set or get filter-quality any more
(except for legacy picture deserialization)

Change-Id: I504caf407ca68392481b771040e5d3280bf7da7f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387439
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-03-21 02:23:27 +00:00
Mike Reed
12a75588e7 GrFPArgs no longer needs sampling
Change-Id: I20fc4b4c3d6997f3ebc1d6d0049447b348f8a110
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387416
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-03-20 17:33:56 +00:00
Mike Reed
7cee3efb6b FilterQuality should no longer be needed.
Start to clean up.

Change-Id: I6dea9344d8a19010d6e22ee8d0cd2b795910a82c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386843
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-03-20 14:30:06 +00:00
Chris Dalton
bf9c63b760 Don't fail clip atlas instantiation when the access is out of bounds
This means the draw is entirely clipped out, so we just don't even
create the FP to begin with.

Change-Id: I6d8a2a2e18be07c8a1408437c4bcc3d9349b77a2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387057
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-03-20 01:35:04 +00:00
Adlai Holler
7df8d22c40 Do register allocation in GrResourceAllocator (take 2)
This lets us plan out the allocation of resources without
actually committing to the resulting plan. In the future,
the user will be able to do the register allocation, then
query the estimated memory cost, and either commit to
that allocation or try a different order of operations.

The difference between this and the original 286097 are that we sorted
fFinishedIntvls by increasing start instead of increasing end and we
use the GrUniqueKey.hash instead of the default crc hash.

Bug: skia:10877
Change-Id: Idc405e2b4532c4cd0ae4127210ba3b42de27bd46
Cq-Include-Trybots: luci.skia.skia.primary:Canary-Chromium,Test-Debian10-Clang-GCE-GPU-SwiftShader-x86_64-Debug-All-SwiftShader_MSAN
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386888
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
2021-03-19 20:05:52 +00:00
John Stiles
b66645830d Only run the inliner one time.
This saves a significant amount of CPU time and, now that the inliner
can handle nested expressions, still inlines almost everything.

Change-Id: I8f198630fa9627bc433ef8fb72f6bcf94595cdaa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386917
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-19 17:02:21 +00:00
John Stiles
708faba16b Allow multiple expressions on the same statement to be inlined.
This will allow the inliner to successfully do more work in a single
pass.

Change-Id: I26e8831737c10bdf9a35eebd94ea8b74f6487077
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386916
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-03-19 15:14:24 +00:00
John Stiles
049f0dfaba Reduce unnecessary scratch variables in Inliner.
Arguments without side-effects that aren't read from more than once can
be moved directly into the inlined function, and don't need a scratch
variable. This can allow functions like `guarded_divide` to inline
completely in more cases.

Change-Id: I0bfce35635cf9779f4af1bc0790da966ccfe4230
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386678
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-03-19 14:10:29 +00:00
Robert Phillips
31798c2796 Remove NVPR
Bug: skia:11760
Change-Id: Ie0fc1aaa3120b37b1d452fdc9a8b5cb91b6ffe1e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386559
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-03-19 12:26:38 +00:00
John Stiles
7bba1f55e8 Revert "Added more RelaxedPrecision decorations"
This reverts commit ab52d95634.

Reason for revert: didn't intend for this to submit, oops

Original change's description:
> Added more RelaxedPrecision decorations
>
> Change-Id: I3814e7144f22c8f838082df6ed1f41119efb2ec2
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385157
> Commit-Queue: John Stiles <johnstiles@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>

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

Change-Id: I8190069d8a428e541782cb2b47ec280f4c7e5686
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386956
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-03-19 03:01:50 +00:00
Ethan Nicholas
ab52d95634 Added more RelaxedPrecision decorations
Change-Id: I3814e7144f22c8f838082df6ed1f41119efb2ec2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385157
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-03-19 03:01:07 +00:00
Mike Reed
10a5ff2cac Must pass filtering to picture shader
Change-Id: I820867df80daa1594d6202cad5e8e95c060293fe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386838
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2021-03-18 22:18:47 +00:00
Adlai Holler
9f358825f9 Revert "Do register allocation in GrResourceAllocator"
This reverts commit c6f78ff55d.

Reason for revert: Broke Chrome roll and MSAN

Original change's description:
> Do register allocation in GrResourceAllocator
>
> This lets us plan out the allocation of resources without
> actually committing to the resulting plan. In the future,
> the user will be able to do the register allocation, then
> query the estimated memory cost, and either commit to
> that allocation or try a different order of operations.
>
> Bug: skia:10877
> Change-Id: I34f92b01986dc2a0dd72e85d42283fc438c5fc82
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386097
> Commit-Queue: Adlai Holler <adlai@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

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

Change-Id: I7492c12b8188ed22c3cd80fd4068da402d8d3543
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10877
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386856
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
2021-03-18 20:41:18 +00:00
Adlai Holler
c6f78ff55d Do register allocation in GrResourceAllocator
This lets us plan out the allocation of resources without
actually committing to the resulting plan. In the future,
the user will be able to do the register allocation, then
query the estimated memory cost, and either commit to
that allocation or try a different order of operations.

Bug: skia:10877
Change-Id: I34f92b01986dc2a0dd72e85d42283fc438c5fc82
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386097
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-03-18 17:45:46 +00:00
Ethan Nicholas
8f352ce20c Revert "Revert "Refactored SPIR-V RelaxedPrecision handling""
This reverts commit a9c187e5cc.

Change-Id: Icbfb8abdfc67fc2e6428d97a6cdede2726fb56e4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385596
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-03-18 15:01:15 +00:00
John Stiles
3150839b59 Disable CommaSideEffects test on GPU.
This test causes the Adreno 330 driver to crash, and does not pass on
Quadro P400 in wasm. The CPU test confirms that we can get it right,
even if not all drivers do.

Change-Id: I5ffb72ac647a49dab7130ab2c6e94f587ded6cf9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386216
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-17 21:56:00 +00:00
Leon Scroggins
d5e94d90e8 Move skbug5883.gif to a better test
Bug: skia:11754

This image is invalid - SkCodec draws *something* but it's not
particularly meaningful. Remove it from our CodecSrc tests and add it to
BadImage tests so that we still verify we don't crash (etc) but we no
longer expect to be able to draw it using the platform generator.

Change-Id: I4781d645896d9f01afbd70fb0c5acfd262dd3169
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385880
Commit-Queue: Leon Scroggins <scroggo@google.com>
Auto-Submit: Leon Scroggins <scroggo@google.com>
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
2021-03-17 19:44:10 +00:00
John Stiles
bff24abab8 Disallow inlining a function with out-parameters.
It is difficult to do this both efficiently and correctly while honoring
GLSL semantics (which require the lvalues to be kept distinct, even when
they point to the same variable). We could make it work by making copies
of every out parameter in each direction (going in for inouts, and
coming out for outs and inouts).

However, this could be self-defeating if it makes it harder for the
driver to track variable lifetimes. Simply opting out of inlining these
functions entirely seems like the best tradeoff; let the driver optimize
them if it can, and we can enjoy reduced complexity in the SkSL inliner.

Change-Id: I62f7b4550cc181cfe789e4f2ff4e408ba1baf9cb
Bug: skia:11326
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/370257
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-03-17 18:04:00 +00:00
Ethan Nicholas
e0707b7075 No longer passing the results of OpAccessChain to function calls
It turns out it is not legal to pass the results of OpAccessChain as a
function argument, for... reasons. This CL switches us over to passing
the argument via a temp variable instead.

Bug: skia:11748
Change-Id: Ib5e86c1d000655ebd7bb62ceea6a27b823808645
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385936
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-03-17 16:37:00 +00:00
John Stiles
dc20847579 Disallow inlining functions containing early returns.
This allows us to remove 100 LOC from the inliner and is very unlikely
to affect any existing benchmark. We don't have any evidence to support
the idea that a one-iteration `for` loop with `continue`-based exits
will be any faster than a standard function call on any existing GPU.
Our fragment processors are generally written to avoid early returns,
in large part to avoid hitting this path.

This drastically impacts BlendEnum.sksl (which can no longer flatten out
a switch over every blend function in SkSL) but is otherwise a wash.

See: http://go/optimization-in-sksl-inliner suggestion 4(a)

Change-Id: I1f9c27bcd7a8de46cc4e8d0b9768d75957cf1c50
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385377
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-03-17 16:29:00 +00:00
John Stiles
2810beed23 Improve do-while test in CanExitWithoutReturningValue.
This put the coverage for do-while loops on par with for loops.

Change-Id: I53e0d733edd02a6a139792a8d74c68116453e5ff
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385500
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-03-17 14:50:56 +00:00
Ethan Nicholas
961d944648 SkSL DSL now uses node pooling
Change-Id: I6404cea5267b5da5a5948f0d6246688fef1fe4c4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/383758
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-03-16 21:18:55 +00:00
John Stiles
2654187396 Eliminate unused local variables during SkSL optimization.
This can eliminate const variables which have been completely folded
away, unnecessary synthetic variables created during codegen/inlining,
or code that simply didn't need to exist at all.

Change-Id: I37a65e455e6527a6a6c2f4dde918f48d84dc2638
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/383496
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-16 17:22:53 +00:00
John Stiles
f10eff363b Fix misdetection of dead global variables.
A global variable should be considered "dead" if it's never written and
never read. The previous code checked if it was never written OR never
read, which is not the same.

This would generate GLSL/Metal that didn't compile. In SPIR-V, it would
SkASSERT, then crash, during codegen. The fuzzer was able to detect the
SPIR-V issue, but it was wrong in all three cases.

Change-Id: Id59a2499eb5baa3839b93826bfbc24191bfd490b
Bug: oss-fuzz:32005
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385280
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-16 16:02:03 +00:00
Michael Ludwig
bf58add00e Revert "Only include header once in combined MSL shader."
This reverts commit e7a8f85e4f.

Reason for revert: must revert dependent CL

Original change's description:
> Only include header once in combined MSL shader.
>
> Bug: skia:11389
> Change-Id: I3e24dcaa2cfeddc7efd7985f9f42a59bfc8175f2
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385137
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: Jim Van Verth <jvanverth@google.com>

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

Change-Id: I7a886b6c57a666e54e65365e41dcb57bd9ab4ba6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11389
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385237
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-03-16 14:44:25 +00:00