skia2/resources
Mike Klein d48488b5ea reorder to minimize register pressure
Rewrite program instructions so that each value becomes available as
late as possible, just before it's used by another instruction.  This
reorders blocks of instructions to reduce them number of temporary
registers in flight.

Take this example of the sort of program that we naturally write,
noting the registers needed as we progress down the right:

    src = load32 ...          (1)
    sr = extract src ...      (2)
    sg = extract src ...      (3)
    sb = extract src ...      (4)
    sa = extract src ...      (4, src dies)

    dst = load32 ...          (5)
    dr = extract dst ...      (6)
    dg = extract dst ...      (7)
    db = extract dst ...      (8)
    da = extract dst ...      (8, dst dies)

    r = add sr dr             (7, sr and dr die)
    g = add sg dg             (6, sg and dg die)
    b = add sb db             (5, sb and db die)
    a = add sa da             (4, sa and da die)

    rg   = pack r g ...       (3, r and g die)
    ba   = pack b a ...       (2, b and a die)
    rgba = pack rg ba ...     (1, rg and ba die)
    store32 rgba ...          (0, rgba dies)

That original ordering of the code needs 8 registers (perhaps with a
temporary 9th, but we'll ignore that here).  This CL will rewrite the
program to something more like this by recursively issuing inputs only
once needed:

    src = load32 ...       (1)
    sr  = extract src ...  (2)
    dst = load32 ...       (3)
    dr  = extract dst ...  (4)
     r  = add sr dr        (3, sr and dr die)

    sg  = extract src ...  (4)
    dg  = extract dst ...  (5)
     g  = add sg dg        (4, sg and dg die)

    rg  = pack r g         (3, r and g die)

    sb  = extract src ...  (4)
    db  = extract dst ...  (5)
     b  = add sb db        (4, sb and db die)

    sa  = extract src ...  (4, src dies)
    da  = extract dst ...  (4, dst dies)
     a  = add sa da        (3, sa and da die)

    ba  = pack b a         (2, b and a die)

    rgba = pack rg ba ...  (1, rg and ba die)
    store32 rgba  ...      (0)

That trims 3 registers off the example, just by reordering!
I've added the real version of this example to SkVMTest.cpp.
(Its 6th register comes from holding the 0xff byte mask used
by extract, in case you're curious).

I'll admit it's not exactly easy to work out how this reordering works
without a pen and paper or trial and error.  I've tried to make the
implementation preserve the original program's order as much as makes
sense (i.e. when order is an otherwise arbitrary choice) to keep it
somewhat sane to follow.

This reordering naturally skips dead code, so pour one out for ☠️ .
We lose our cute dead code emoji marker, but on the other hand all code
downstream of Builder::done() can assume every instruction is live.

Change-Id: Iceffcd10fd7465eae51a39ef8eec7a7189766ba2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/249999
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2019-10-22 21:49:05 +00:00
..
android_fonts Move lang to list in Android font manager. 2017-08-14 19:29:05 +00:00
empty_images Do not create an SkRawCodec with zero dimensions 2016-12-02 22:23:35 +00:00
fonts Add planet emoji font. 2019-03-19 17:49:22 +00:00
icc_profiles update ColorSpaceTest.cpp to remove MakeICC 2018-05-23 17:11:11 +00:00
images Initial version of rescaling async readback API 2019-05-17 16:39:10 +00:00
invalid_images Update piex and add test image 2018-02-22 21:32:48 +00:00
lua Update SampleLua and lua files. 2018-05-22 15:51:25 +00:00
nima skeletal animation support added to API and software backend 2018-06-29 19:34:28 +00:00
particles Particles: Fake 3D example 2019-10-17 20:10:05 +00:00
skottie [skottie] Shift Channels effect support 2019-10-22 20:36:01 +00:00
text Shaper Tests: make a macro, rename test resources. 2019-05-03 17:16:36 +00:00
Cowboy.svg Add animated cowboy sample from WebKit tests, and fix. 2017-09-25 21:14:09 +00:00
crbug769134.fil Avoid uninitialized memory in readByteArrayAsData 2017-09-28 19:51:32 +00:00
nov-talk-sequence.txt demo tweaks, scale up perlin, add call to flush for fps 2015-11-09 13:10:30 -08:00
pdf_command_stream.txt SkPDF/Bench: add bench for SkPDFSharedStream (deflate) 2016-02-24 15:17:20 -08:00
README Add animated cowboy sample from WebKit tests, and fix. 2017-09-25 21:14:09 +00:00
SkVMTest.expected reorder to minimize register pressure 2019-10-22 21:49:05 +00:00

The resources directory includes some third party content used by Skia.
Licenses for that code are included in this file.

Openclipart

Openclipart uses the Creative Commons Zero 1.0 Public Domain License every time
an artist uploads a piece of clipart to Openclipart to make it clear the artist
is releasing the creative work for anyone to use for any reason, even
commercially. This act of "sharing" is the foundation Openclipart is based upon.
More details on the license can be found at
https://creativecommons.org/publicdomain/zero/1.0/.

LGPL or compatible (as implied by inclusion in KDE SVN)
http://websvn.kde.org/trunk/tests/ksvgtests/custom/cowboy.svg