Commit Graph

26 Commits

Author SHA1 Message Date
John Stiles
2d8b835cad Add SkBlender class; thread into SkVMBlitter.
Like SkColorFilter, SkShader, etc., this has a public-facing component
(SkBlender) and a private subclass (SkBlenderBase) which can be
obtained via a helper function (as_BB). At present there are no public-
facing methods, but the type needs to be exposed to be usable by the
outside world.

These classes exist for SkRuntimeEffect to subclass. The blender base
provides a `program` method with the parameters that blending will use.

Change-Id: I75c772fd4108a9c21fbda84201a8b23d3750a0df
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416916
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-16 17:35:38 +00:00
John Stiles
af8047dbb8 Rename existing 'Blend' enums/names to 'BlendFilter'.
Change-Id: I17c624e9145d7152f65695ca3ce4592a11bb09a2
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/418637
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-15 22:51:40 +00:00
Ethan Nicholas
6823b50830 Revert "Revert "Switched SkSL parser APIs from char* + length to string_view""
This reverts commit 85ed605159.

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

Change-Id: I09a8a821ceb2b3d525cbca5e52af5cad96d1e2b5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/418617
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-06-15 16:45:17 +00:00
Jorge Betancourt
85ed605159 Revert "Switched SkSL parser APIs from char* + length to string_view"
This reverts commit 2705cbf9bd.

Reason for revert: blocking g3 autoroller

Original change's description:
> Switched SkSL parser APIs from char* + length to string_view
>
> Change-Id: I9f4378b622699d80bef449f9857117e9cc437956
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/418140
> Reviewed-by: Brian Osman <brianosman@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

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

Change-Id: I56fe1b306f2619227b8a2c10b3ab7de30de60bdf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/418536
Reviewed-by: Jorge Betancourt <jmbetancourt@google.com>
Commit-Queue: Jorge Betancourt <jmbetancourt@google.com>
2021-06-15 12:29:09 +00:00
Ethan Nicholas
2705cbf9bd Switched SkSL parser APIs from char* + length to string_view
Change-Id: I9f4378b622699d80bef449f9857117e9cc437956
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/418140
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-06-14 20:59:52 +00:00
John Stiles
f7f36ae077 Add ProgramKind::kRuntimeBlend for Runtime Blend functions.
Runtime Blend effects always take two input colors--source and
destination--instead of one. This CL adds a new ProgramKind for blend
effects, a new program module (empty for now), and adds a test to
confirm that the signature for blend functions is checked. Currently
these are only accessible via skslc; there's no Runtime Effect API to
create one and the dest color isn't hooked up to anything.

Change-Id: I5272a811d2d76b878cfdf3429efa78c9c8b3fd97
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416798
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-08 19:34:39 +00:00
Brian Osman
cbb60bd0b0 Add runtime color filter and shader modes to the SkSL compiler
These enforce stricter rules about the signature of main, and each one
uses a separate pre-include module. That prevents color filters from
being able to reference sk_FragCoord (or coords passed to main) at all.
It also limits the versions of sample() that are exposed.

In the new world, an effect created for a specific stage of the Skia
pipeline can only be used to create instances of that stage (SkShader or
SkColorFilter). For now, SkRuntimeEffect::Make uses kRuntimeEffect,
which continues to be more lenient and allow creation of either shaders
or color filters from a single effect. After we migrate all clients, we
can deprecate and then delete that mode.

Bug: skia:11813
Change-Id: I0afd79a72beeec84da42c86146e8fcd8d0e4c09f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395716
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-15 13:30:59 +00:00
John Stiles
d2702fa155 Update SkSL benchmark code to match actual Skia output.
Our benchmarks had drifted away from actual codegen in several ways, and
were no longer representative of actual output. In particular, every
function in the existing benchmarks used a scratch `_output` variable
which would make it ineligible for return-statement-only inlining.

Updated the tests to match modern codegen. `small` and `large` use the
same sources as before. The code from `medium` is older and had diverged
quite far from today's output; I could not find a representative code
snippet at all. It has been replaced with SkSL of roughly similar
complexity.

Change-Id: Iadd32cbb6725554355ddfe384ce538f3dc49aca3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/385160
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-03-16 13:59:23 +00:00
John Stiles
dbd4e6f0c0 Move ProgramKind and ProgramSettings types out of SkSL::Program.
This change will allow these types to be forward-declared; C++ doesn't
allow forward declaration of types declared inside a struct. Moving
these types out of Programs resulted in a large diff.

The Settings::Value helper class has been moved inside of the
IRGenerator. In practice, it was actually just an implementation detail
of how IRGenerator looks up caps-values by name. It seems very unlikely
that this will be necessary elsewhere going forward.

Change-Id: I6119417fae608f1c492a27de746d2b550ef8ca20
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/370836
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-16 19:30:48 +00:00
Brian Osman
9194675a3e SkSL: In the front-end, rename PipelineStage to RuntimeEffect
This maps to usage better, and makes some code simpler to understand.
Note that there is still a PipelineStage *back-end*, which is specific
to the runtime-effect FP. A kRuntimeEffect_Kind program can be used to
generate a PipelineStage (for the GPU backend), or an skvm program (for
the CPU backend).

Change-Id: Id3f535db93a239726c595225aafe9467f0d19817
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344969
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-12-21 21:23:17 +00:00
Brian Osman
5626998ac4 SkSL: Reduce default heap usage, improve heap benchmarks
We were always pre-loading the fragment and vertex modules, but deferred
loading all others. Those two take up about 300 KB of heap. Now, all
modules are deferred, so compiler instances that don't need them (like
the one used for runtime effects) are much smaller.

Now that we can get better fine-grained numbers, added two more
benchmarks, to track actual baseline usage, plus the usage in the two
most likely configurations.

Change-Id: Idfbcd52c8afee566ac42ab827c80c940f91c4ad7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337176
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-11-20 19:17:17 +00:00
Brian Osman
0006ad01ce Stop cloning builtin functions
Previously, any builtin functions would be optimized as a side-effect of
optimizing programs that used them. Now that shared elements aren't
being optimized in that way, we explicitly optimize any shared modules
when they are first created. We don't remove dead elements, but we
we do substitute settings, simplify, and inline.

Bug: skia:10905
Change-Id: I701b5e9f52fb880ef3e6f4c67694d08602f47e95
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/336440
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-11-20 15:02:54 +00:00
Ethan Nicholas
ba9a04fb8d Revert "Revert "Additional SkSL benches""
This reverts commit 1277971939.

Change-Id: I7985ef22ddd19adcab468acc684b330ce6978c8d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332738
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-11-06 15:10:10 +00:00
Ethan Nicholas
1277971939 Revert "Additional SkSL benches"
This reverts commit a2d6b31f66.

Reason for revert: breaking bots

Original change's description:
> Additional SkSL benches
>
> This adds additional benchmarks to give us better insight into how long
> the various compilation phases take. The four benches per size now
> cover just parsing, parsing + converting to IR, parsing + converting to
> IR + optimizing, and finally parsing + converting to IR + optimizing +
> generating GLSL.
>
> Change-Id: I7099a5a9f40ae5031e330dc4e1bb08c2a20ada63
> Bug: skia:10805
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332262
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>

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

Change-Id: Idb3e3082d11f72978131068b2229ce2578d645c3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10805
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332601
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-11-05 20:11:46 +00:00
Ethan Nicholas
a2d6b31f66 Additional SkSL benches
This adds additional benchmarks to give us better insight into how long
the various compilation phases take. The four benches per size now
cover just parsing, parsing + converting to IR, parsing + converting to
IR + optimizing, and finally parsing + converting to IR + optimizing +
generating GLSL.

Change-Id: I7099a5a9f40ae5031e330dc4e1bb08c2a20ada63
Bug: skia:10805
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332262
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-11-05 19:13:47 +00:00
Brian Osman
d7e7659cad Move GrShaderCaps from Program::Settings to Compiler
This ties the caps to the compiler instance, paving the way for
pre-optimizing the shared code. Most of the time, the compiler is
created and owned the GPU instance, so this is fine. For runtime
effects, we now use the shared (device-agnostic) compiler instance
for the first compile, even on GPU. It's configured with caps that
apply no workarounds. We pass the user's SkSL to the backend as
cleanly as possible, and then apply any workarounds once it's part
of the full program.

Bug: skia:10905
Bug: skia:10868
Change-Id: Ifcf8d7ebda5d43ad8e180f06700a261811da83de
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331493
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-11-04 19:38:33 +00:00
John Stiles
312535b47d Create sksl_small nanobench test.
This is the standard no-op shader that Viewer uses to blit the software
rasterizer's back-buffer to the screen. It modulates against white and
samples a texture using an identity matrix.

This gives us a realistic best-case-scenario test. `sksl_tiny` is too
small to be a realistic test (although it's a good data point to show
our ultimate speed-of-light).

Change-Id: Ic697cb1301752574ab63a9a0d7b07a0ff81c3a88
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329476
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-10-24 13:05:11 +00:00
John Stiles
7f88b721ab Update nanobench SkSL tests.
The "sksl_huge" test has been renamed to "sksl_medium."
Added a new "sksl_large" test which contains a dithered gradient shader.

Change-Id: Ia8488460022008ae4efecb5593f01db06c1c283f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320827
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-09-30 14:17:07 +00:00
Brian Osman
24c5d2447f Add a benchmark that measures SkSL::Compiler startup time
This is basically timing the rehydrator, but is helpful in conjunction
with heap usage if a client wants to decide to throw away a compiler
that they don't anticipate using for some amount of time.

Change-Id: Ie9b27d9a3b7667b5492d870f242cdafd00784708
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320617
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-09-29 20:25:21 +00:00
Ethan Nicholas
34b19c5750 SkSL optimization now happens in convertProgram rather than being a
separate step.

This ended up uncovering an optimization bug. SkSLNonConstantCase
started failing; it turns out that the optimizer was never being run on
this test, and so we hadn't noticed that it didn't actually work in the
presence of optimization.

Change-Id: Iff1d330be7534113b86f86b00c39f91282903ae3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/316568
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-09-14 16:34:47 +00:00
John Stiles
7571f9e490 Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'.
Mechanically updated via Xcode "Replace Regular Expression":

  typedef (.*) INHERITED;
    -->
  using INHERITED = $1;

The ClangTidy approach generated an even larger CL which would have
required a significant amount of hand-tweaking to be usable.

Change-Id: I671dc9d9efdf6d60151325c8d4d13fad7e10a15b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314999
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-09-03 03:41:26 +00:00
Brian Osman
24b8a8cd1a Switch back to mallinfo in SkSL memory benchmark
Early results from measuring RSS (via /proc or similar) shows results
that aren't very accurate or stable. From previous detailed testing, I
know that mallinfo gives a good answer. We only really need results
from ~one machine, so limiting to UNIX bots isn't a big deal.

Change-Id: I73af043720b1204e1da436e2e63b19766a97a9a2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301445
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-07-09 14:42:02 +00:00
Brian Osman
68870aa5d1 Add heap usage of SkSL::Compiler to nanobench output
This will let us track a new metric that measures the heap usage of
constructing a default compiler object. I anticipate adding similar
stats about the heap usage from compiling simple vs. complex SkSL.

Change-Id: Idb814c0b5d210d00a06ce5dc7147437aabcba1bb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301359
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-07-09 00:05:28 +00:00
Ethan Nicholas
1386366e01 renamed SkSL texture() and process() to sample()
Bug: skia:
Change-Id: I2ae0caf08f8434302cae8151ae1ea0fda8d56928
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230397
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-07-29 17:37:38 +00:00
Ethan Nicholas
fc9941665b Major rearchitecture of SkSL parsing, focused on improving performance.
Bug: skia:
Change-Id: I83e3a094d26085fc4d586e5d2581e0d61c55634e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/145080
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-06-06 14:33:32 +00:00
Ethan Nicholas
40679c3aa5 added SkSL bench
Bug: skia:
Change-Id: I8497ddbc5c5fef4e0fa87f3b9828034ba34284cc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217636
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-06-03 16:01:30 +00:00