As we've learned there's not much advantage to working directly in i32
ops over f32... it's the same size, kind of a wash speed-wise, and f32
supports all operations we want where i32 supports only a subset. If we
really want to go fast, we need to focus on i16 operations, which are
both significantly faster and operate on twice as much data at a time.
(This is the same split as SkRasterPipeline, highp f32 and lowp i16.)
For now port everything to f32, with i16 to follow, perhaps much later.
There's a little here we could spin off to land first (uniformF, better
unpremul) but I think it might be easiest to land all at once.
Cq-Include-Trybots: skia.primary:Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-SK_USE_SKVM_BLITTER
Change-Id: I6fa0fd2031a0de18456abf529cc5b0d8137ecbe0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/253704
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
This basically wraps up the old `uniforms` and `buf` params
into a new type that has push() and pushF() methods that return
a value you can pass directly to Builder::uniform32() and co.
I think this has uniforms about as streamlined as they can get.
Change-Id: I8f611f91b4a2d7cdb8f05ce0333669d2e3930be8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252937
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
It's clearer and more efficient to emit uniforms
as we use them. The pattern to look for is something like
skvm::I32 val = p->uniform32(uniforms, buf->bytes());
buf->push_back(fVal);
where fVal holds the actual uniform value, and val is its program
counterpart.
Switching to SkTDArray lets us use friendlier methods like bytes() and
append(N) in the effect code.
It's a lot easier to follow this way once you get used to it and much
less error-prone. No need to split the can-we-do-it logic up from the
uniform emission, and so no chance to write logic twice that
acccidentally disagrees.
Effects now always emit uniforms when you call program(), which means we
occasionally do that twice, once when building the Key to look up cached
programs, and once again when building the program if the cache misses.
That's not that big of a deal... it reuses the same memory exactly, and
I've added some notes around the code and assertions that everything
matches up exactly. It only happens on cache miss, so it's dwarfed by
the cost of building and JITing the program anwyay.
Change-Id: I55a9252b11b2c0cd5f7ab8ace6df5fef29342c10
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252837
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
- move some helpers to central spot
- add a color filter interface, the same as shader without (x,y)
- implement matrix color filter (pretty naively)
and color filter shader (pretty reasonably)
- extend GM to demonstrate
The new blitters with color filters are failing to JIT because they're
running out of registers. (They still work fine on the interpreter of
course.) I'm going to take a look to see whether there's something I
can do either in the effect program() code or in the optimizer to
rearrange to get it to fit and JIT.
Cq-Include-Trybots: skia.primary:Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-SK_USE_SKVM_BLITTER
Change-Id: Ibdc1a5e7b9e7a14778efba583b7821bcd4f3062a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252788
Reviewed-by: Mike Klein <mtklein@google.com>
By making uniforms() just append to the uniform vector, there's no more
need for two passes, no need for the blitter to ever even know how many
uniforms the effects use, and the effects now never need to deal with a
nullptr uniform buffer. Much simpler all around.
While we're refactoring, convert the uniform buffer de jure to
std::vector<uint32_t>, which is what we'd been treating the old
std::vector<uint8_t> as by convention, and switch the program() offset
parameter type to size_t as a reminder that it's measured in bytes.
Cq-Include-Trybots: skia.primary:Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-SK_USE_SKVM_BLITTER
Change-Id: I81d2c92aae37a650104f384f815df78c8a186270
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252776
Reviewed-by: Mike Klein <mtklein@google.com>
We can unify these similar functions to reduce the amount of work we do
and guarantee SkShaderBase::program() is never called with a null
skvm::Builder*. We now only call program() to do real work: one call to
get a shader key, and if no program is found in the cache, one more call
to build the blitter program. No null checks are needed any longer.
Cq-Include-Trybots: skia.primary:Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-SK_USE_SKVM_BLITTER
Change-Id: I6e73d9d264690f04ddcc92e6f7b3c42654f8a41c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252759
Reviewed-by: Mike Klein <mtklein@google.com>
Change-Id: Iea0f804b1b2fed9e663e45c33fb54a91b10fd07b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252652
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This should work, though I need to do a little more work to get programs
that use x to JIT. It shouldn't be bad, probably done tomorrow.
I've added a demo y-gradient to the SkVMBlitter GM.
We may not need an explicit CTM parameter, just effects that chain into
each other changing (x,y) as they go? I guess that depends on whether
we want to specialize blitters on the matrix type any more than how we
get the shader coordinates.
Cq-Include-Trybots: skia.primary:Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-SK_USE_SKVM_BLITTER
Change-Id: Iae28d169f611605ca6fbb8bcbcca6b67b103171c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252620
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This means we can share programs with color shaders
whether they come through as a paint color or shader.
The GM now only ever JITs one program.
Change-Id: If61f9e7b79aa6b8fd1de7c16ff52f78bfd7dc4ec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252079
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
It's not drawing anything earthshattering, but it does act as an easy
way to exercise some interesting code paths in SkVMBlitter, here first
program caching based on shader program and not shader identity.
With today's shader caching patches, this makes 2 calls to
skvm::Builder::done(), JITing the program, while if you patched this in
at head you'd see 3. I'd like it to get down to 1 by converting paint
colors to color shaders.
Change-Id: I042f4d44a792b46e5543794c853e4ef0d95b11ec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252029
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>