Commit Graph

8820 Commits

Author SHA1 Message Date
Mike Reed
52130b0909 Pass samplingoptions to GrArgs
Also, add control over kMedium mapping

Seems like a loss that GrInterpret throws away the cubic coefficients...

A step towards https://skia-review.googlesource.com/c/skia/+/347022

Bug: skia:11105, skia:7650
Change-Id: I2564c29b0eeffd4df92c0baa78e2c04f6348d7d7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347636
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-12-28 21:19:21 +00:00
Ben Wagner
f73a029506 Make onCreateScalerContext return unique_ptr.
Change SkTypeface::onCreateScalerContext to return std::unique_ptr
instead of a bare pointer. The public SkTypeface::createScalerContext
implementation already returns std::unique_ptr, so this is an internal
change only.

Move SkTypeface::createScalerContext implementation from
SkScalerContext.cpp to SkTypeface.cpp for consistency.

Also change the return type of SkScalerContext::MakeEmptyContext to
std::unique_ptr and rename to SkScalerContext::MakeEmpty.

Change-Id: I965308e8f9c78b887811e428f0de873dc6196479
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346658
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Auto-Submit: Ben Wagner <bungeman@google.com>
2020-12-28 17:31:09 +00:00
John Stiles
f94348fdd5 Detect and report numeric overflows in the SkSL parser.
Previously, some types of overflow were detected, but most would assert
or silently generate invalid code. Now, the parser will properly report
an error if it encounters any integer that exceeds UINT_MAX or any float
that exceeds FLT_MAX.

This fixes test OverflowUintLiteral.sksl. Added a test for floats as
well, OverflowFloatLiteral.sksl.

OverflowIntLiteral.sksl does not fail yet, because its values are larger
than INT_MAX, not UINT_MAX. These are legal from the perspective of the
parser. This must be caught later at IR generation time.

Change-Id: Ia5a904d01427cdc9f2ab5f4174154418737835e6
Bug: skia:10932
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347176
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-28 16:39:19 +00:00
Brian Osman
0247e9ea1c Fix SPIRV bug constructing a constant vector from another vector
This fix is overly conservative in some situations (identity conversions
among vectors with the same component type), but fixes errors in two
existing unit test cases.

Bug: skia:11116
Change-Id: If852f8591fb26817528fdc37191c49129e17d6b3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347053
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-12-23 21:14:48 +00:00
Brian Osman
4d3bfc511d Make all fragmentProcessors implicitly nullable in SkSL
This feature had devolved to just an assert, and one that isn't really
necessary - all of Ganesh is built to handle any child processor being
null. The next step is to remove nullable types entirely -- a large
amount of code.

Change-Id: I612a5867f8690400b405aa1f5c929e76cf5918fd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347050
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-12-23 20:22:18 +00:00
John Stiles
e64855fbfa Fix fuzzer-discovered crash with negated swizzles.
This CL updates `compareConstant` to fail gracefully instead of
aborting if the passed-in types don't match. This lets us call
`compareConstant` without checking types first.

Change-Id: Id2acdbdf700e64bcb24825cdad2c0e000992e8cb
Bug: oss-fuzz:28904
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347038
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-12-23 18:52:47 +00:00
Brian Osman
20fad32064 SkSL: Hide most integral types from runtime effects
'int' is the only integral type that exists in GLSL ES 1.0 (and it's not
really guaranteed to be an integer). This enforces the same restriction
on runtime effects - no unsigned integers, and no short or byte types.

Bug: skia:11093
Change-Id: I938f1e0e125dc8347507f428b46b51c66033c752
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347046
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-12-23 18:28:17 +00:00
Mike Reed
dc607e35e1 Use bitmap.asImage()
Change-Id: Ie16194937530d7cd75f84d9af66c31b77875ef83
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347043
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-23 17:41:47 +00:00
Mike Reed
839eef3e9a Work on hiding filter-quality
SkPaintPriv methods are just an internal stopgap

Change-Id: Ibe6e37c5871068d8cd67dc0948961444dfd2b62a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347041
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-23 17:05:17 +00:00
Brian Osman
21ee1c0200 SkSL: Remove all $gsamplerFoo types
These are GLSL-isms that weren't really implemented - each one was a
"generic" type that only resolved to a single underlying type. We've
got along just fine without them for years, so update our sample()
declarations to take the actual underlying type. (Note that we had
worked around this by declaring an integer version of sample where
necessary, so we can presumably keep doing that in the future).

Change-Id: I4c46a2fa0c1f19e6278298c8005a2760329e7abf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347040
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-12-23 16:57:07 +00:00
Brian Osman
33c64a4473 SkSL: Remove "null" as a type and literal value.
Nullable fragment processors still exist, but they're handled
transparently by sample() within C++, so there's no need for .fp files
to ever do these tests manually.

Change-Id: Idf2bc58505207560553066c0126a2a036c5d970b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347039
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-12-23 16:21:57 +00:00
Brian Salomon
8f7d95382e Remove public getter for GrSurfaceDrawContext on SkSCanvas.
Made it private and accessible internally via SkCanvasPriv.

Update SkGpuDevice methods/variables after rename of GrDrawSurfaceContext.

Cq-Include-Trybots: luci.skia.skia.primary:Canary-G3,Canary-Flutter,Canary-Android
Change-Id: I3da64cee1de03c201243ee6c7ccd4b4c44cad8c9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346498
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-12-23 16:13:07 +00:00
Mike Reed
ac9f0c9e27 Bitmap.asImage()
... and lots and lots of IWYU

Change-Id: Ie5157dcdd2e6d29b95c71b39153278ab48ef4eb3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346778
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-23 15:54:57 +00:00
John Stiles
65b4827f16 Code cleanup: Replace .foreach() loops with regular for loops.
Change-Id: I2d396907387de4a5f3407d81efb9d2cd80e430d1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346265
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-12-23 14:21:17 +00:00
Brian Salomon
6bba3d8a5a Remove pixel write/read tests.
I found myself updating these for another change and realized they
are very limited tests that are redundant with more thorough tests.

Change-Id: I935da4d1da7ff3825a4042556845a8eb659b6ba8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346856
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
2020-12-23 13:56:17 +00:00
John Stiles
3624aba91f Enforce additional restrictions on opaque types.
Opaque types can no longer be copied via assignment or construction, and
various restrictions originally applied to the "fragmentProcessor" type
have been extended to cover opaque types in general.

Change-Id: I55ab7aefd1e6ef277e56a9408b430e1de5ba12ca
Bug: skia:11027
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346264
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-12-22 22:24:24 +00:00
John Stiles
e7dc7cbe1f Implement bitCount intrinsic on SPIR-V and Metal.
This intrinsic was previously lacking a unit test, and wasn't actually
implemented in Metal or SPIR-V. Fortunately it's trivial to add.

Change-Id: I68bbdc58376b579c7f3f0ae5f49323b389c2b8c4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346263
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-12-22 21:46:54 +00:00
John Stiles
7df731bcfd Reland "Add support for range-based for loops to SkTHashSet/Map."
Updated Pair type in SkTHashMap to derive from std::pair to fix C++14
issues with structured bindings.

Original change's description:
> Add support for range-based for loops to SkTHashSet/Map.
>
> This allows loops over SkTHashes to break in the middle, and also
> removes the need to use lambda captures to bring variables inside the
> loop's scope.
>
> Change-Id: Ief55d776b2c57a44b24cfe1c94493a5d514791c8
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346496
> Reviewed-by: Mike Klein <mtklein@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

Change-Id: I2ac5b2c59e70ed0ec3b42b32e7994d6bcdf56b40
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346502
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-12-22 20:53:53 +00:00
Michael Ludwig
a18613d120 Add halfWidth/halfHeight functions to SkRectPriv
These effectively compute width/2 or height/2, but switch operations
around so that it's less likely to overflow on finite rects that would
have overflows in width or height.

Bug: skia:1160678
Change-Id: Ic93ca0c1d12598163b3dd48a5e8ba0ac7903301f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344968
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-12-22 20:42:43 +00:00
John Stiles
c5ff48648a Elide return expression temp-var in vardecl-less blocks.
Previously, a return statement inside a scoped Block would always result
in the return expression being assigned to a temporary variable instead
of replacing the function-call-expression directly. This was done
because there might be variables inside the Block; these would have
fallen out of scope when the expression is migrated to the call site,
resulting in an invalid expression.

We aren't actually examining the return expression so we don't know if
it uses variables from an inner scope at all. (Inspecting the return
expression for variable usage is certainly possible! But it's a fair
amount of code and complexity for a small payoff.)

However, we can very easily get most of the benefit here without paying
for the complexity. In this CL we now look for variable declarations
inside of scoped Blocks. If the code doesn't add any vardecls into
scoped Blocks, there's no risk of scope problems, and we don't need to
use a temp-var to store our return expressions. If any vardecls are
added, we go back to using a temp-var as before.

Change-Id: I4c81400dad2f33db06a1c18eb671ba2140232006
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346499
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-12-22 19:33:12 +00:00
Brian Osman
c0f2b64342 SkSL: Hide non-square matrices from runtime effects
These don't exist in our minimum spec (GLSL ES 1.0)

Bug: skia:11093
Change-Id: Ia2d871199fff2a98dcd517c1eebe46decb0c2dfb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346657
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-12-22 19:31:42 +00:00
Brian Osman
f4a5e5d180 SkSL: Add $squareMat and $squareHMat
Also renamed $matH to $hmat, to match $hvec convention. Runtime effects
will only support square matrices (like ES2), so this lets us declare
intrinsics like matrixCompMult correctly (and differently) for public
vs. private usage.

Bug: skia:11093
Change-Id: I457d83e4c5e09f8e01e7b8acb116c39ff17e52c3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346656
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-12-22 18:40:52 +00:00
Brian Osman
977feec5d7 Add .rte -> .skvm unit test framework
Includes a handful of test cases to exercise the system

Change-Id: I98e73a8bca063f475d2ddb51778e395697392ddb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346637
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-12-22 17:59:42 +00:00
John Stiles
f2ce4e91a2 Test that the inliner uses a temp var for return statements.
We have a handful of tests that demonstrate this behavior indirectly,
but lacked a focused test.

Change-Id: I895cc4e3bebf30721ed649244e42bf170cc6ec06
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346497
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-12-22 17:52:49 +00:00
John Stiles
dd690af373 Revert "Add support for range-based for loops to SkTHashSet/Map."
This reverts commit 5d00e15625.

Reason for revert: tree breakage on Chromebook standard lib

Original change's description:
> Add support for range-based for loops to SkTHashSet/Map.
>
> This allows loops over SkTHashes to break in the middle, and also
> removes the need to use lambda captures to bring variables inside the
> loop's scope.
>
> Change-Id: Ief55d776b2c57a44b24cfe1c94493a5d514791c8
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346496
> Reviewed-by: Mike Klein <mtklein@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

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

Change-Id: I165872ac41f66f3b3255cf8970626392e5283412
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346500
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-12-22 15:35:03 +00:00
John Stiles
5d00e15625 Add support for range-based for loops to SkTHashSet/Map.
This allows loops over SkTHashes to break in the middle, and also
removes the need to use lambda captures to bring variables inside the
loop's scope.

Change-Id: Ief55d776b2c57a44b24cfe1c94493a5d514791c8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346496
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-12-22 15:10:42 +00:00
John Stiles
a60ac0c45c Fix for fuzzer-discovered crash with swizzles.
We need to rescan after optimizing away expressions that might exist
in the CFG/definition map, since we are rebuilding them from scratch and
not just stripping off excess parts from them.

Change-Id: I843a2ea3fc38428e7c0bd0e2bf7a7d41101345e3
Bug: oss-fuzz:28794
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344972
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-22 14:38:52 +00:00
Mike Klein
960bd2dbaa allow arbitrary Builder Features
Should allow us to test sksl->skvm portably using dump().

Change-Id: If55e8e144f04643c02bd65baa84158ac1bf441b5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346336
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-12-21 21:56:47 +00:00
Leon Scroggins III
e42716032b SkAnimatedImage: Always respect exif orientation
No known clients (CanvasKit, Android) want to ignore the exif
orientation in an animation.

A follow-on CL will deprecate SkAndroidCodec::ExifOrientation, leaving
it up to the client (e.g. SkAnimatedImage, hwui/ImageDecoder) to
handle the orientation. Add SkEncodedOriginSwapsWidthHeight to assist
clients to do so.

Update stoplight_animated_image GM. It previously showed using
SkAnimatedImage without respecting the orientation, which is no longer
supported. The new version replaces the left half of the image with the
right.

Remove assert that is no longer true. Originally, an SkAnimatedImage was
"simple" if it did not have a crop or postProcessor. This is no longer
true if has an exif orientation. Add a test that calls the simple
constructor and verifies it does not crash.

Change-Id: I421fd02700f220fb90458cd03c4431dee7daf399
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344762
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2020-12-21 16:39:12 +00:00
Mike Reed
6aea078802 Don't use sprite-blit if cubic sampling
Need this to land first: https://chromium-review.googlesource.com/c/chromium/src/+/2597643

Bug: skia:7650
Change-Id: Idebecfc8a5922a937fd46ccff1eea4df53f6b0cd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345170
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-21 16:10:42 +00:00
Ethan Nicholas
dcd2f869d3 Reland "Reland "Reland "Reland "Revert "Initial land of SkSL DSL."""""
This reverts commit 4129b6b65f.

Reason for revert: WASM breakage: https://task-driver.skia.org/td/UBRwnWYfbc5IwUWqtFMv

Original change's description:
> Revert "Reland "Reland "Reland "Revert "Initial land of SkSL DSL."""""
>
> This reverts commit 346dd53ac0.
>
> Change-Id: I93bb18438cc6c2ad43d058d6c3f95bcc65d0cea9
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/343916
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>

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

# Not skipping CQ checks because this is a reland.

Change-Id: If05145cf9d9c51f4c76fe523f6050a670b5da669
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345169
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-12-18 01:05:48 +00:00
John Stiles
74ebd7e6ce Add support for inlining switches with returns inside.
Because we use `continue` for flow control handling now, we can escape
from the middle of a switch statement. This wasn't possible when we used
`break`.

This unlocks some pretty stellar optimization opportunities if the
switch value can be determined at compile time; see BlendEnum for an
example.

Change-Id: Id29be92c343c10fd604683a80c5d5bd2bd070cb0
Bug: skia:11097
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345419
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2020-12-18 00:14:48 +00:00
Ethan Nicholas
4129b6b65f Revert "Reland "Reland "Reland "Revert "Initial land of SkSL DSL."""""
This reverts commit 346dd53ac0.

Change-Id: I93bb18438cc6c2ad43d058d6c3f95bcc65d0cea9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/343916
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-12-17 21:47:16 +00:00
Mike Klein
0047afffb0 remove very oldest SkVM testing
None of these earliest testing tools are useful anymore
now that we can do useful work with SkVM and SkVMBlitter.

Change-Id: I8b25ef6ddd101c4ff8617c6742343dedb4764922
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345456
Commit-Queue: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-12-17 21:17:46 +00:00
John Stiles
77702f1704 Eliminate inliner temporary variables for top-level-exit functions.
When we determine that a function only contains a single return
statement and it is at the top level (i.e. not inside any scopes),
there is no need to create a temporary variable and store the
result expression into a variable. Instead, we can directly replace
the function-call expression with the return-statement's expression.

Unlike my previous solution, this does not require variable
declarations to be rewritten. The no-scopes limitation makes it
slightly less effective in theory, but in practice we still get
almost all of the benefit. The no-scope limitation bites us on
structures like

@if (true) {
    return x;
} else {
    return y;
}

Which will optimize away the if, but leave the scope:

{
    return x;
}

However, this is not a big deal; the biggest wins are single-line
helper functions like `guarded_divide` and `unpremul` which retain
the full benefit.

Change-Id: I7fbb725e65db021b9795c04c816819669815578f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345167
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2020-12-17 20:37:21 +00:00
John Stiles
fa9a08369e Remove unnecessary Blocks from the inliner.
If we aren't wrapping the inlined function body in a loop, there's no
need to add a scopeless Block; we've already got one. This doesn't
affect the final output meaningfully--it just suppresses a newline--but
it's one fewer IRNode allocation.

Change-Id: Ib7b0014e908586d8acfcf6c23520873fad31d0b7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345163
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-17 19:35:35 +00:00
John Stiles
7b920446a8 Replace inliner do-while loops with for loops.
do-while loops aren't compatible with GLSL ES2. For-loops which run
only one time should work exactly the same for our purposes. We expect
such a loop to be unrolled by every driver, so it shouldn't come at any
performance cost.

Change-Id: Ia8de5fcab8128c34da97eaeaf81f91ad1ac36ce4
Bug: skia:11097
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345159
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-17 19:23:47 +00:00
John Stiles
a07338f56b Add support for outerProduct in SPIR-V.
Fortunately, this had an existing opcode, so it was easy to add to our
intrinsics list, and the rest automatically worked.

Change-Id: Idcd5a2c46d6bf10c05c702faba4280a270c54929
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345398
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-12-17 19:05:05 +00:00
John Stiles
8298f6d885 Fix 4x4 outerProduct, and add unit tests.
We are still missing an implementation for Metal and SPIR-V, but at
least it's correct on GLSL now.

Change-Id: I5b365384eaefacb00faf6af7bda9b690cba00de5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345397
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-12-17 18:23:55 +00:00
Jim Van Verth
a8682204dc Fix shadow directional light bounds.
The shadowRec bounds code didn't handle directional lights, that's now
fixed. Also fixes normalization of the light direction -- it was only
using two components, it should use all three.

Bug: skia:10781
Change-Id: Ia7d39c5187f976627d017ac4abecbe1d1dc62712
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345126
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2020-12-17 18:04:15 +00:00
Brian Salomon
01ff5384bf Support luminance-alpha GL format for YUVA planes
Bug: skia:10632
Change-Id: Ic91510b55644c15ee4eb5f96e7c35193b5ce49df
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344761
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2020-12-17 14:54:25 +00:00
Brian Salomon
20f1b34628 Use ManagedBackendTexture in backend allocation tests
Change-Id: I96e598c989bea7d4ee08e12369fe1a5d83453ec3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344759
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-12-17 02:50:43 +00:00
Herb Derby
1d89532d59 extract fibonacci allocator block code
Extract the fibonacci progression block size calculation.
Simplify it by using a common array for the fibonacci number.
Add unit tests to check extreme limits.

Change-Id: I270a713881590f7e17be58dc9072ab7a79a7388d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345124
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2020-12-17 00:01:53 +00:00
Brian Osman
d6f2338ab1 SkSL IR normalization: Convert while loops to for loops
Bug: skia:11095
Change-Id: Icd69df40675e5ecde5004e04a7dcd78eedf8343c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344765
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-12-16 23:03:23 +00:00
Brian Salomon
04e3e506e7 Make backend allocation tests avoid alphatype conversions
Also use GrColorTypes wherever possible.

As a consequence, some cases now go through GrSurfaceContext rather
than SkSurface (because it uses GrColorType and allows kUnpremul).

Both changes make it easier to add testing for GL_LUMINANCE8_ALPHA8,
which is required to update Flutter on iOS/GL to use new YUVA
texture image api.

Bug: skia:11019
Bug: skia:10632
Change-Id: I0e8bef4af5aeb7fe58cc11ec7923ebb5029ce18b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344560
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345132
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-12-16 21:43:53 +00:00
Brian Salomon
590f567291 Add GrSurfaceFillContext
This is a new base class for GrSurfaceDrawContext. It allows any
alpha-type but is restricted to non-blending fills of irects using FPs,
clears,and discards.

Bug: skia:11019

Reviewed-on: https://skia-review.googlesource.com/c/skia/+/341680
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Change-Id: I696df3617719fcd8303faa73fb44b32b3fb4f71c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344896
2020-12-16 20:48:43 +00:00
John Stiles
6f31e27f1e Improve inliner variable name mangling.
Previously, multiple inliner passes in a row would each apply a
separate name mangling to variable names, so names like "_25_14_3_1_pos"
were not uncommon. This change demangles the name before re-mangling it,
so we would have just "_25_pos" instead.

It's not important, but it makes things easier to read.

Change-Id: I1257222dac2a68e337f431af230ce50730cedc9b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345116
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-16 20:46:43 +00:00
John Stiles
35fee4c079 Revert "Declare all inlined variables at the topmost scope possible."
This reverts commit e8e4aca955.

Reason for revert: can break ES2 for-loop rules

Original change's description:
> Declare all inlined variables at the topmost scope possible.
>
> By itself, this is uninteresting and even perhaps slightly
> counterproductive (as it separates vardecl from its initializer,
> increasing LOC). However, this enables a followup CL
> (http://review.skia.org/344665) which allows single-return functions to
> be inlined without the creation of a temporary variable at all. This
> applies to the majority of fragment processors in a typical Ganesh
> hierarchy. This change will greatly reduce the number of inliner-created
> temporary copies when compiling a typical tree of FPs.
>
> Change-Id: I03423a13cf35050637dabace4a32973a08a4ed0a
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344764
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

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

Change-Id: Ica01d6906bcb9cef1f49d22dda714fc9cbfa3885
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345121
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-12-16 18:26:21 +00:00
John Stiles
9e94812bef Revert "Eliminate inliner temporary variables for functions with a single exit."
This reverts commit 345d72124d.

Reason for revert: can break ES2 for-loop rules

Original change's description:
> Eliminate inliner temporary variables for functions with a single exit.
>
> When we determine that a function only contains a single return
> statement, there is no need to create a temporary variable and store the
> result expression into a variable. Instead, we can directly replace the
> function-call expression with the return-statement's expression.
>
> This dramatically simplifies the final optimized output from chains of
> very simple inlined functions, which is a very common pattern for trees
> of Skia fragment processors.
>
> Change-Id: I6789064a321daf43db2e1cef4915f25ed74d6131
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344665
> Commit-Queue: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>

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

Change-Id: I60845f22159605a06047b030e2686a769121a35a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345120
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-12-16 18:24:57 +00:00
Brian Osman
21a1afe7f8 Revert "Fix incorrect 'unreachable code' error in SkSL"
This reverts commit 67d2d73d06.

Reason for revert: Triggers errors in some shaders.

Original change's description:
> Fix incorrect 'unreachable code' error in SkSL
>
> This trades one error for another (a potential for incorrect use of
> unassigned variables). False-positives for unassigned variables are
> straightforward to workaround (and produce code that still looks
> reasonable). Working around unreachable code errors is tricky, and
> likely to produce non-idiomatic code. This change also makes the data
> flow analysis of all loop constructs more similar - for loops were
> behaving very differently from while loops.
>
> Note that this effectively a revert of:
>   https://skia-review.googlesource.com/c/skia/+/18121/
>
> Change-Id: Ib85d90b22cac8addfb106459c0a5f5616a89c3eb
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344957
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>

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

Change-Id: I84b93cc7f9309446dcc0e949e90908df31a1ff9c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345119
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-12-16 18:21:17 +00:00