Change-Id: Ifd7883a4b327aae9fc0a984f08755d6d6f57f72e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/351018
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Change-Id: If6b23d03b02028b51f96e97080cbd7d34cc33b8f
Bug: skia:10931
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/351503
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>
This will flatten out expressions such as `!false` or `!true`. We
already had a similar fix-up at IR generation time which handled simple
cases, but this will catch more complicated ones like `!sk_Caps.xxxxx`
(since caps bits are only flattened out at constant propagation time).
Change-Id: I04282809d9a784266a64dbcafd097f3b0662806c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/351497
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>
Same basic deal as skcms.
This new GM tests our treatment of color spaces as sources is consistent
with our treatment of color spaces as destinations. It looks good to me
now, and I have tested that this GM catches a "well-placed typo" in each
of the three implementations modified here.
Bug: chromium:1144260
Change-Id: I3eabc93bbd65855c60006751f68c171ccdce9d94
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/351336
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
I've made y an F32 instead of an F32a to remind us that it's
usually best to multiply instead of divide by a constant.
Change-Id: I15c9ab50e51f5011eca977908168ed27f1de25b0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/351337
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This reverts commit 75887a2321.
Reason for revert: Flutter crash
Original change's description:
> Move GrTriangulator internal struct definitions to the .h file
>
> This makes them reusable for the edge-AA code when we move it.
>
> Bug: skia:10419
> Change-Id: I20042a419617717214535d45fc92a8cae986fb33
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/349356
> Reviewed-by: Jim Van Verth <jvanverth@google.com>
> Commit-Queue: Chris Dalton <csmartdalton@google.com>
TBR=jvanverth@google.com,robertphillips@google.com,csmartdalton@google.com
Change-Id: I7e317b01883afc9eab494f1a0846ece9e3272ec5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10419
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/351477
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
This is not actually necessary now that constantPropagate can fully
flatten out unary negation into its constant operands. The compilation
results don't change at all.
Change-Id: I7ab55bd3720413609d799dd866e1703973cb2626
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/351202
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>
Currently this doesn't actually handle going over the memory
budget, but it does carve out space to do that later. This algorithm
can't handle everything yet but I want to get it landed for
more iteration as long as it's disabled.
Bug: skia:10877
Change-Id: I37942172345e8cfd6fc2c591a3788a10652377da
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345168
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Auto-Submit: Adlai Holler <adlai@google.com>
Previously, we used a union of (int64, float) to store the cached value.
However, the union-based code turned out to be more complex than just
type-punning the float's bits to an int via memcpy (which we needed to
do anyway). The union-based approach was also likely to be UB by the
letter of the law--we were creating float keys by storing into fFloat,
then checking the map by comparing equality on fInt.
Change-Id: I62c7ff4b5fab8bb1be8836c23f746ef254053b6f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350957
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
This fixes SPIR-V code generation when encountering nested constructors
like `float3 v4 = float3(float2(1), 1.0);` as featured in our unit test
VectorConstructors.sksl.
Change-Id: I3a0c4b466b3cb17ba50bd264f899e59c55c768ed
Bug: skia:11141
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350032
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Like getIVecComponent or getFVecComponent, this retrieves the n'th
element of a Boolean compile-time constant vector. This will be used in
followup CLs.
Change-Id: Ib41c9c89cb773251e4c0d6cdcaea0437d8074e48
Bug: skia:11141
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350918
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This reverts commit b05571f0b8.
Reason for revert: Android crash
Original change's description:
> Disable tessellation when we don't have indirect draw support
>
> Avoids the polyfill that uses looping instanced draws. This has led to
> perf regressions on android.
>
> Bug: skia:11138 skia:11139 chromium:1163441
> Change-Id: I129bf96c6d8a3eaadc79bfca496c7d50189f737e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350738
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Chris Dalton <csmartdalton@google.com>
TBR=bsalomon@google.com,csmartdalton@google.com
Change-Id: Iebb473211ff618c1988aa5b7306e3e39efa353f5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11138 skia:11139 chromium:1163441
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/351216
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
This will be used in a followup CL to implement getBVecComponent. At
present it's not called.
Change-Id: Idd6f18314d0835af3946ea7458e6650384f505ea
Bug: skia:11141
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350703
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Previously ExternalValues were flexible, and could be used as raw values
(with the ability to chain access via dot notation), or they could be
callable. The only non-test use-case has been for functions (in
particles) for a long time. With the push towards SkVM, limiting
ourselves to this interface simplifies things: external functions are
basically custom intrinsics (and with the SkVM backend, they'll just get
access to the builder, and be able to do any math, as well as
loads/stores, etc).
By narrowing the feature set, we can rename everything to reflect that,
and it's overall clearer (the SkSL types now mirror FunctionReference
and FunctionCall directly, particularly in how they're handled by the
CFG and inliner).
Change-Id: Ib5dd34158ff85aae6c297408a92ace5485a08190
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350704
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
This reverts commit bef02dca9d.
Reason for revert: PreAbandonGpuContext failing on tree
Original change's description:
> Fix GPU improved noise impl and add to perlinnoise GM.
>
> GPU was recently busted when switching alpha-color type swizzles from
> aaaa to 000a.
>
> There was no GM that exercised SkPerlinNoiseShader::MakeImprovedNoise.
>
> It draws wrong before and after this change with the CPU backend.
>
> Bug: skia:10536
> Change-Id: I514e304d022fcccae80699a99facafa8ce947e9f
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350916
> Auto-Submit: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com
Change-Id: Iac635028b402e6008e3a8050bdfa66052d94fd10
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10536
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350956
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
GPU was recently busted when switching alpha-color type swizzles from
aaaa to 000a.
There was no GM that exercised SkPerlinNoiseShader::MakeImprovedNoise.
It draws wrong before and after this change with the CPU backend.
Bug: skia:10536
Change-Id: I514e304d022fcccae80699a99facafa8ce947e9f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350916
Auto-Submit: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Continue to test everything with the ByteCode interpreter, and run most
tests with the new SkSL-to-SkVM utilities, as well. A few tests rely on
features that aren't yet implemented (function calls, looping), and some
of the bespoke tests (that don't use the test() helpers) use even more
exotic features that need to be implemented or disallowed in the IR
generator. This is getting us closer to not needing ByteCode at all,
though.
Refactored a bunch of the helper code to reduce copy-paste among the
many different 'test' functions.
Change-Id: I138d4a24266f2d862742245c5ee895d86c01018e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350560
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Bug: skia:11134
Change-Id: I0b0a3f530452d5bb5c08da7f247728298c234dd7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350583
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Avoids the polyfill that uses looping instanced draws. This has led to
perf regressions on android.
Bug: skia:11138 skia:11139 chromium:1163441
Change-Id: I129bf96c6d8a3eaadc79bfca496c7d50189f737e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350738
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
We've been assuming that all Ops with the same arguments produce the
same value and deduplicating them, which results in a simple common
subexpression eliminator.
But we can't soundly dedup two identical loads with a store between;
that store could change the memory those loads read, producing different
values, as demonstrated by the first new unit test.
Then, by similar reasoning, it may first seem fine to deduplicate
stores, e.g.
store32 arg(0), v1
store32 arg(0), v1
That second store certainly does look redundant. But if we slot a
different store between, it's no longer redundant:
store32 arg(0), v1
store32 arg(0), v2
store32 arg(0), v1
If we dedup those two v1 stores, we'll skip the second and be left with
v2 in our buffer instead of v1. This is the second new unit test.
Now, uniform32 and gather ops also touch memory... are they safe to
dedup? Surprisingly, yes! Uniforms are easy: they're read-only. No
way to store to uniforms, so no intervening store can invalidate them.
Gathers are a little fuzzier, in that the buffer we gather from is
uniform in practice, but not strictly required to be... it's not
impossible to construct a program that gathers from a buffer that the
program also stores to, but you'd have to go out of your way to do it,
and it's not a pattern we use today, and SkVM does not provide the
synchronization primitives you'd need to make attempting that even
vaguely sensible. So gathers in practice can also be deduplicated.
In general it's safe to dedup an operation unless it touches _varying
memory_, i.e. loads and stores. uniform32 and gathers touch
non-varying memory, so they're safe, and while index is varying, it
doesn't touch memory.
Change-Id: Ia275f0ab2708d3f71e783164b419436b90f103a9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350608
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
I noticed is_always_varying() is a little wrong, and this new test demos
how. This isn't terribly important: in most practical situations
gathers will indeed be varying.
Change-Id: I456d4c7287147726c49ebb5af5af347c65cd21d4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350602
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Many of our shaders generate the same vector constant dozens of times,
e.g. Gaussian blur uses float4(1) repeatedly. This change avoids
re-emitting redundant vector constants.
Change-Id: I22a71cd8b2783fb997f52d485b49031f64ca6d96
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350701
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This was needed (transitively) by Dawn previously, but no longer
Cq-Include-Trybots: luci.skia.skia.primary:Build-Debian10-Clang-x86_64-Debug-Dawn,Test-Win10-Clang-Golo-GPU-QuadroP400-x86_64-Debug-All-Dawn
Change-Id: I15089298a295be41d7564fe53779e3fafd01229c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350702
Reviewed-by: Eric Boren <borenet@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Also explicitly default all special methods of SkStrikeCache to get
nicer warnings.
Change-Id: I8856a905c6075ca52d4ad900ccd0dacc581cd485
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350637
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
This makes them reusable for the edge-AA code when we move it.
Bug: skia:10419
Change-Id: I20042a419617717214535d45fc92a8cae986fb33
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/349356
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
and update GrGLGpu::flushScissorRect's signature to match it.
Change-Id: I9082003934168306833f86d310b942a8d7527384
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350612
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Previously, we had constant-value deduplication, based on the SkSL type
of the constant. However, we were still generating redundant constants,
because we would emit a separate constant for Float(n) and Half(n), or
Int(n) and Short(n), even though we generate the exact same instruction
for these constants. We now deduplicate based on the type's number-kind,
separating constant literals into three categories: floats, signed ints,
and unsigned ints. This better matches our type-handling in
getActualType.
Change-Id: I5777d4b3d567839b7aa72dc8de76908c18fc387e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350031
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
This CL adds additional variants of some IRGenerator functions to enable
them to be more easily called from upcoming DSL code. This should not
change functionality (other than a slightly different error message in
one case).
Change-Id: Ic727c194fca5111d4283007f4ec23653598a853b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350017
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
I plan to add at least one more gr_* class, so I figure it makes sense
to just keep all this similar things in one place.
Bug: skia:11136
Change-Id: I96d24dd094731e9694201e012fec37926cce564d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350639
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
The pattern appears to be that the variable that stores the uploaded
value has a "Prev" suffix.
Change-Id: I78ea449d75f5fd091c113cf08af919331467eb8d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350638
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Bug: skia:10979
Change-Id: I81b8692b0bb1582b60a9324492a782d04a09538f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344963
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
IntLiteral and FloatLiteral each had a pair of public constructors: one
which takes a Type (what type of Int/Float is this?), and another
constructor which takes a Context (assume the generic Float/Int type).
BoolLiteral had a public Context-based constructor, but its Type-based
constructor was private. The Type-based constructor is now public to
match its siblings. This allows us to create Booleans without needing
a Context&, if we have an fBool_Type, and fixes make_unique (which
doesn't like private constructors).
Change-Id: Iffb4980947a73b3a89aa1452cc90dce63620bd67
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350636
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>
Change-Id: Ia4a1c38161046b94dc56a1a76704766f1e14aab7
Bug: skia:11131
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350019
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Previously, the IR generator had code which could simplify conversion
constructors like `int(1.23)`. Separately, the optimizer's constant
propagation pass had its own separate implementation of these
simplifications as well.
This CL unifies the two implementations. Previously, the constant-
propagation pass version of the code only supported integer literals, so
this change also improves our code generation slightly.
Change-Id: I32c70a5f2aed210d03bef3166b1178a2d40cdabd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350024
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
new unit tests is crashing like many others.
Bug: skia:10869
Change-Id: Ic9418468cb4720a52aebf2486cc359dc456c9983
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350558
Commit-Queue: Brian Salomon <bsalomon@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>