279ca2e10c
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> |
||
---|---|---|
animations | ||
bazel | ||
bench | ||
bin | ||
build/fuchsia | ||
build_overrides | ||
client_utils/android | ||
demos.skia.org | ||
dm | ||
docker | ||
docs/examples | ||
example | ||
experimental | ||
fuzz | ||
gm | ||
gn | ||
include | ||
infra | ||
modules | ||
platform_tools | ||
resources | ||
samplecode | ||
site | ||
specs | ||
src | ||
tests | ||
third_party | ||
tools | ||
.bazelignore | ||
.clang-format | ||
.clang-tidy | ||
.gitignore | ||
.gn | ||
AUTHORS | ||
BUILD.bazel | ||
BUILD.gn | ||
codereview.settings | ||
CONTRIBUTING | ||
CQ_COMMITTERS | ||
DEPS | ||
go.mod | ||
go.sum | ||
LICENSE | ||
OWNERS | ||
PRESUBMIT.py | ||
public.bzl | ||
README | ||
README.chromium | ||
RELEASE_NOTES.txt | ||
whitespace.txt | ||
WORKSPACE.bazel |
Skia is a complete 2D graphic library for drawing Text, Geometries, and Images. See full details, and build instructions, at https://skia.org.