streamline SkVM test rebaselining

- keep expectations in resources/
  - overwrite automatically if needed
    so we can see the diff in Git

Change-Id: I2486b127ebcc7f40332fd0462e38b1af04d3e32b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218038
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Klein 2019-06-03 16:27:46 -05:00
parent 30e918d915
commit 267f50773c
2 changed files with 303 additions and 285 deletions

282
resources/SkVMTest.expected Normal file
View File

@ -0,0 +1,282 @@
A8 over A8
r0 = load8 arg(0)
r1 = splat 3B808081 (0.0039215689)
r0 = to_f32 r0
r0 = mul_f32 r1 r0
r2 = load8 arg(1)
r2 = to_f32 r2
r2 = mul_f32 r1 r2
r1 = splat 3F800000 (1)
r1 = sub_f32 r1 r0
r1 = mad_f32 r2 r1 r0
r2 = splat 437F0000 (255)
r0 = splat 3F000000 (0.5)
r0 = mad_f32 r1 r2 r0
r0 = to_i32 r0
store8 arg(1) r0
A8 over G8
r0 = splat 0 (0)
r1 = load8 arg(0)
r2 = splat 3B808081 (0.0039215689)
r1 = to_f32 r1
r1 = mul_f32 r2 r1
r3 = load8 arg(1)
r3 = to_f32 r3
r3 = mul_f32 r2 r3
r2 = splat 3F800000 (1)
r2 = sub_f32 r2 r1
r2 = mad_f32 r3 r2 r0
r3 = splat 3E59B3D0 (0.21259999)
r0 = splat 3F371759 (0.71520001)
r1 = splat 3D93DD98 (0.0722)
r1 = mul_f32 r2 r1
r1 = mad_f32 r2 r0 r1
r1 = mad_f32 r2 r3 r1
r3 = splat 437F0000 (255)
r2 = splat 3F000000 (0.5)
r2 = mad_f32 r1 r3 r2
r2 = to_i32 r2
store8 arg(1) r2
A8 over RGBA_8888
r0 = splat 0 (0)
r1 = load8 arg(0)
r2 = splat 3B808081 (0.0039215689)
r1 = to_f32 r1
r1 = mul_f32 r2 r1
r3 = load32 arg(1)
r4 = splat FF (3.5733111e-43)
r5 = bit_and r3 r4
r5 = to_f32 r5
r5 = mul_f32 r2 r5
r6 = shr r3 8 (1.1210388e-44)
r6 = bit_and r6 r4
r6 = to_f32 r6
r6 = mul_f32 r2 r6
r7 = shr r3 10 (2.2420775e-44)
r7 = bit_and r7 r4
r7 = to_f32 r7
r7 = mul_f32 r2 r7
r3 = shr r3 18 (3.3631163e-44)
r3 = to_f32 r3
r3 = mul_f32 r2 r3
r2 = splat 3F800000 (1)
r2 = sub_f32 r2 r1
r5 = mad_f32 r5 r2 r0
r6 = mad_f32 r6 r2 r0
r7 = mad_f32 r7 r2 r0
r2 = mad_f32 r3 r2 r1
r3 = splat 437F0000 (255)
r1 = splat 3F000000 (0.5)
r5 = mad_f32 r5 r3 r1
r5 = to_i32 r5
r6 = mad_f32 r6 r3 r1
r6 = to_i32 r6
r6 = shl r6 8 (1.1210388e-44)
r7 = mad_f32 r7 r3 r1
r7 = to_i32 r7
r7 = shl r7 10 (2.2420775e-44)
r1 = mad_f32 r2 r3 r1
r1 = to_i32 r1
r1 = shl r1 18 (3.3631163e-44)
r6 = bit_or r5 r6
r6 = bit_or r6 r7
r6 = bit_or r6 r1
store32 arg(1) r6
G8 over A8
r0 = splat 3B808081 (0.0039215689)
r1 = splat 3F800000 (1)
r2 = load8 arg(1)
r2 = to_f32 r2
r2 = mul_f32 r0 r2
r0 = sub_f32 r1 r1
r0 = mad_f32 r2 r0 r1
r2 = splat 437F0000 (255)
r1 = splat 3F000000 (0.5)
r1 = mad_f32 r0 r2 r1
r1 = to_i32 r1
store8 arg(1) r1
G8 over G8
r0 = load8 arg(0)
r1 = splat 3B808081 (0.0039215689)
r0 = to_f32 r0
r0 = mul_f32 r1 r0
r2 = splat 3F800000 (1)
r3 = load8 arg(1)
r3 = to_f32 r3
r3 = mul_f32 r1 r3
r2 = sub_f32 r2 r2
r2 = mad_f32 r3 r2 r0
r3 = splat 3E59B3D0 (0.21259999)
r0 = splat 3F371759 (0.71520001)
r1 = splat 3D93DD98 (0.0722)
r1 = mul_f32 r2 r1
r1 = mad_f32 r2 r0 r1
r1 = mad_f32 r2 r3 r1
r3 = splat 437F0000 (255)
r2 = splat 3F000000 (0.5)
r2 = mad_f32 r1 r3 r2
r2 = to_i32 r2
store8 arg(1) r2
G8 over RGBA_8888
r0 = load8 arg(0)
r1 = splat 3B808081 (0.0039215689)
r0 = to_f32 r0
r0 = mul_f32 r1 r0
r2 = splat 3F800000 (1)
r3 = load32 arg(1)
r4 = splat FF (3.5733111e-43)
r5 = bit_and r3 r4
r5 = to_f32 r5
r5 = mul_f32 r1 r5
r6 = shr r3 8 (1.1210388e-44)
r6 = bit_and r6 r4
r6 = to_f32 r6
r6 = mul_f32 r1 r6
r7 = shr r3 10 (2.2420775e-44)
r7 = bit_and r7 r4
r7 = to_f32 r7
r7 = mul_f32 r1 r7
r3 = shr r3 18 (3.3631163e-44)
r3 = to_f32 r3
r3 = mul_f32 r1 r3
r1 = sub_f32 r2 r2
r5 = mad_f32 r5 r1 r0
r6 = mad_f32 r6 r1 r0
r7 = mad_f32 r7 r1 r0
r1 = mad_f32 r3 r1 r2
r3 = splat 437F0000 (255)
r2 = splat 3F000000 (0.5)
r5 = mad_f32 r5 r3 r2
r5 = to_i32 r5
r6 = mad_f32 r6 r3 r2
r6 = to_i32 r6
r6 = shl r6 8 (1.1210388e-44)
r7 = mad_f32 r7 r3 r2
r7 = to_i32 r7
r7 = shl r7 10 (2.2420775e-44)
r2 = mad_f32 r1 r3 r2
r2 = to_i32 r2
r2 = shl r2 18 (3.3631163e-44)
r6 = bit_or r5 r6
r6 = bit_or r6 r7
r6 = bit_or r6 r2
store32 arg(1) r6
RGBA_8888 over A8
r0 = load32 arg(0)
r1 = splat 3B808081 (0.0039215689)
r0 = shr r0 18 (3.3631163e-44)
r0 = to_f32 r0
r0 = mul_f32 r1 r0
r2 = load8 arg(1)
r2 = to_f32 r2
r2 = mul_f32 r1 r2
r1 = splat 3F800000 (1)
r1 = sub_f32 r1 r0
r1 = mad_f32 r2 r1 r0
r2 = splat 437F0000 (255)
r0 = splat 3F000000 (0.5)
r0 = mad_f32 r1 r2 r0
r0 = to_i32 r0
store8 arg(1) r0
RGBA_8888 over G8
r0 = load32 arg(0)
r1 = splat FF (3.5733111e-43)
r2 = bit_and r0 r1
r3 = splat 3B808081 (0.0039215689)
r2 = to_f32 r2
r2 = mul_f32 r3 r2
r4 = shr r0 8 (1.1210388e-44)
r4 = bit_and r4 r1
r4 = to_f32 r4
r4 = mul_f32 r3 r4
r5 = shr r0 10 (2.2420775e-44)
r5 = bit_and r5 r1
r5 = to_f32 r5
r5 = mul_f32 r3 r5
r0 = shr r0 18 (3.3631163e-44)
r0 = to_f32 r0
r0 = mul_f32 r3 r0
r1 = load8 arg(1)
r1 = to_f32 r1
r1 = mul_f32 r3 r1
r3 = splat 3F800000 (1)
r3 = sub_f32 r3 r0
r2 = mad_f32 r1 r3 r2
r4 = mad_f32 r1 r3 r4
r3 = mad_f32 r1 r3 r5
r1 = splat 3E59B3D0 (0.21259999)
r5 = splat 3F371759 (0.71520001)
r0 = splat 3D93DD98 (0.0722)
r0 = mul_f32 r3 r0
r0 = mad_f32 r4 r5 r0
r0 = mad_f32 r2 r1 r0
r1 = splat 437F0000 (255)
r2 = splat 3F000000 (0.5)
r2 = mad_f32 r0 r1 r2
r2 = to_i32 r2
store8 arg(1) r2
RGBA_8888 over RGBA_8888
r0 = load32 arg(0)
r1 = splat FF (3.5733111e-43)
r2 = bit_and r0 r1
r3 = splat 3B808081 (0.0039215689)
r2 = to_f32 r2
r2 = mul_f32 r3 r2
r4 = shr r0 8 (1.1210388e-44)
r4 = bit_and r4 r1
r4 = to_f32 r4
r4 = mul_f32 r3 r4
r5 = shr r0 10 (2.2420775e-44)
r5 = bit_and r5 r1
r5 = to_f32 r5
r5 = mul_f32 r3 r5
r0 = shr r0 18 (3.3631163e-44)
r0 = to_f32 r0
r0 = mul_f32 r3 r0
r6 = load32 arg(1)
r7 = bit_and r6 r1
r7 = to_f32 r7
r7 = mul_f32 r3 r7
r8 = shr r6 8 (1.1210388e-44)
r8 = bit_and r8 r1
r8 = to_f32 r8
r8 = mul_f32 r3 r8
r9 = shr r6 10 (2.2420775e-44)
r9 = bit_and r9 r1
r9 = to_f32 r9
r9 = mul_f32 r3 r9
r6 = shr r6 18 (3.3631163e-44)
r6 = to_f32 r6
r6 = mul_f32 r3 r6
r3 = splat 3F800000 (1)
r3 = sub_f32 r3 r0
r7 = mad_f32 r7 r3 r2
r8 = mad_f32 r8 r3 r4
r9 = mad_f32 r9 r3 r5
r3 = mad_f32 r6 r3 r0
r6 = splat 437F0000 (255)
r0 = splat 3F000000 (0.5)
r7 = mad_f32 r7 r6 r0
r7 = to_i32 r7
r8 = mad_f32 r8 r6 r0
r8 = to_i32 r8
r8 = shl r8 8 (1.1210388e-44)
r9 = mad_f32 r9 r6 r0
r9 = to_i32 r9
r9 = shl r9 10 (2.2420775e-44)
r0 = mad_f32 r3 r6 r0
r0 = to_i32 r0
r0 = shl r0 18 (3.3631163e-44)
r8 = bit_or r7 r8
r8 = bit_or r8 r9
r8 = bit_or r8 r0
store32 arg(1) r8

View File

@ -9,6 +9,7 @@
#include "include/private/SkColorData.h"
#include "src/core/SkVM.h"
#include "tests/Test.h"
#include "tools/Resources.h"
enum Fmt { A8, G8, RGBA_8888 };
const char* fmt_name(Fmt fmt) {
@ -29,8 +30,8 @@ const char* fmt_name(Fmt fmt) {
//
// Some parts of this builder code are written less fluently than possible,
// to avoid any ambiguity of function argument evaluation order. This lets
// our golden tests (kExpected) work portably. In general there's no reason
// to fear nesting calls to Builder routines.
// our golden tests work portably. In general there's no reason to fear
// nesting calls to Builder routines.
struct SrcoverBuilder : public skvm::Builder {
SrcoverBuilder(Fmt srcFmt, Fmt dstFmt) {
@ -113,298 +114,33 @@ struct SrcoverBuilder : public skvm::Builder {
}
};
static const char* kExpected[] = {
R"(r0 = load8 arg(0)
r1 = splat 3B808081 (0.0039215689)
r0 = to_f32 r0
r0 = mul_f32 r1 r0
r2 = load8 arg(1)
r2 = to_f32 r2
r2 = mul_f32 r1 r2
r1 = splat 3F800000 (1)
r1 = sub_f32 r1 r0
r1 = mad_f32 r2 r1 r0
r2 = splat 437F0000 (255)
r0 = splat 3F000000 (0.5)
r0 = mad_f32 r1 r2 r0
r0 = to_i32 r0
store8 arg(1) r0
)",
R"(r0 = splat 0 (0)
r1 = load8 arg(0)
r2 = splat 3B808081 (0.0039215689)
r1 = to_f32 r1
r1 = mul_f32 r2 r1
r3 = load8 arg(1)
r3 = to_f32 r3
r3 = mul_f32 r2 r3
r2 = splat 3F800000 (1)
r2 = sub_f32 r2 r1
r2 = mad_f32 r3 r2 r0
r3 = splat 3E59B3D0 (0.21259999)
r0 = splat 3F371759 (0.71520001)
r1 = splat 3D93DD98 (0.0722)
r1 = mul_f32 r2 r1
r1 = mad_f32 r2 r0 r1
r1 = mad_f32 r2 r3 r1
r3 = splat 437F0000 (255)
r2 = splat 3F000000 (0.5)
r2 = mad_f32 r1 r3 r2
r2 = to_i32 r2
store8 arg(1) r2
)",
R"(r0 = splat 0 (0)
r1 = load8 arg(0)
r2 = splat 3B808081 (0.0039215689)
r1 = to_f32 r1
r1 = mul_f32 r2 r1
r3 = load32 arg(1)
r4 = splat FF (3.5733111e-43)
r5 = bit_and r3 r4
r5 = to_f32 r5
r5 = mul_f32 r2 r5
r6 = shr r3 8 (1.1210388e-44)
r6 = bit_and r6 r4
r6 = to_f32 r6
r6 = mul_f32 r2 r6
r7 = shr r3 10 (2.2420775e-44)
r7 = bit_and r7 r4
r7 = to_f32 r7
r7 = mul_f32 r2 r7
r3 = shr r3 18 (3.3631163e-44)
r3 = to_f32 r3
r3 = mul_f32 r2 r3
r2 = splat 3F800000 (1)
r2 = sub_f32 r2 r1
r5 = mad_f32 r5 r2 r0
r6 = mad_f32 r6 r2 r0
r7 = mad_f32 r7 r2 r0
r2 = mad_f32 r3 r2 r1
r3 = splat 437F0000 (255)
r1 = splat 3F000000 (0.5)
r5 = mad_f32 r5 r3 r1
r5 = to_i32 r5
r6 = mad_f32 r6 r3 r1
r6 = to_i32 r6
r6 = shl r6 8 (1.1210388e-44)
r7 = mad_f32 r7 r3 r1
r7 = to_i32 r7
r7 = shl r7 10 (2.2420775e-44)
r1 = mad_f32 r2 r3 r1
r1 = to_i32 r1
r1 = shl r1 18 (3.3631163e-44)
r6 = bit_or r5 r6
r6 = bit_or r6 r7
r6 = bit_or r6 r1
store32 arg(1) r6
)",
R"(r0 = splat 3B808081 (0.0039215689)
r1 = splat 3F800000 (1)
r2 = load8 arg(1)
r2 = to_f32 r2
r2 = mul_f32 r0 r2
r0 = sub_f32 r1 r1
r0 = mad_f32 r2 r0 r1
r2 = splat 437F0000 (255)
r1 = splat 3F000000 (0.5)
r1 = mad_f32 r0 r2 r1
r1 = to_i32 r1
store8 arg(1) r1
)",
R"(r0 = load8 arg(0)
r1 = splat 3B808081 (0.0039215689)
r0 = to_f32 r0
r0 = mul_f32 r1 r0
r2 = splat 3F800000 (1)
r3 = load8 arg(1)
r3 = to_f32 r3
r3 = mul_f32 r1 r3
r2 = sub_f32 r2 r2
r2 = mad_f32 r3 r2 r0
r3 = splat 3E59B3D0 (0.21259999)
r0 = splat 3F371759 (0.71520001)
r1 = splat 3D93DD98 (0.0722)
r1 = mul_f32 r2 r1
r1 = mad_f32 r2 r0 r1
r1 = mad_f32 r2 r3 r1
r3 = splat 437F0000 (255)
r2 = splat 3F000000 (0.5)
r2 = mad_f32 r1 r3 r2
r2 = to_i32 r2
store8 arg(1) r2
)",
R"(r0 = load8 arg(0)
r1 = splat 3B808081 (0.0039215689)
r0 = to_f32 r0
r0 = mul_f32 r1 r0
r2 = splat 3F800000 (1)
r3 = load32 arg(1)
r4 = splat FF (3.5733111e-43)
r5 = bit_and r3 r4
r5 = to_f32 r5
r5 = mul_f32 r1 r5
r6 = shr r3 8 (1.1210388e-44)
r6 = bit_and r6 r4
r6 = to_f32 r6
r6 = mul_f32 r1 r6
r7 = shr r3 10 (2.2420775e-44)
r7 = bit_and r7 r4
r7 = to_f32 r7
r7 = mul_f32 r1 r7
r3 = shr r3 18 (3.3631163e-44)
r3 = to_f32 r3
r3 = mul_f32 r1 r3
r1 = sub_f32 r2 r2
r5 = mad_f32 r5 r1 r0
r6 = mad_f32 r6 r1 r0
r7 = mad_f32 r7 r1 r0
r1 = mad_f32 r3 r1 r2
r3 = splat 437F0000 (255)
r2 = splat 3F000000 (0.5)
r5 = mad_f32 r5 r3 r2
r5 = to_i32 r5
r6 = mad_f32 r6 r3 r2
r6 = to_i32 r6
r6 = shl r6 8 (1.1210388e-44)
r7 = mad_f32 r7 r3 r2
r7 = to_i32 r7
r7 = shl r7 10 (2.2420775e-44)
r2 = mad_f32 r1 r3 r2
r2 = to_i32 r2
r2 = shl r2 18 (3.3631163e-44)
r6 = bit_or r5 r6
r6 = bit_or r6 r7
r6 = bit_or r6 r2
store32 arg(1) r6
)",
R"(r0 = load32 arg(0)
r1 = splat 3B808081 (0.0039215689)
r0 = shr r0 18 (3.3631163e-44)
r0 = to_f32 r0
r0 = mul_f32 r1 r0
r2 = load8 arg(1)
r2 = to_f32 r2
r2 = mul_f32 r1 r2
r1 = splat 3F800000 (1)
r1 = sub_f32 r1 r0
r1 = mad_f32 r2 r1 r0
r2 = splat 437F0000 (255)
r0 = splat 3F000000 (0.5)
r0 = mad_f32 r1 r2 r0
r0 = to_i32 r0
store8 arg(1) r0
)",
R"(r0 = load32 arg(0)
r1 = splat FF (3.5733111e-43)
r2 = bit_and r0 r1
r3 = splat 3B808081 (0.0039215689)
r2 = to_f32 r2
r2 = mul_f32 r3 r2
r4 = shr r0 8 (1.1210388e-44)
r4 = bit_and r4 r1
r4 = to_f32 r4
r4 = mul_f32 r3 r4
r5 = shr r0 10 (2.2420775e-44)
r5 = bit_and r5 r1
r5 = to_f32 r5
r5 = mul_f32 r3 r5
r0 = shr r0 18 (3.3631163e-44)
r0 = to_f32 r0
r0 = mul_f32 r3 r0
r1 = load8 arg(1)
r1 = to_f32 r1
r1 = mul_f32 r3 r1
r3 = splat 3F800000 (1)
r3 = sub_f32 r3 r0
r2 = mad_f32 r1 r3 r2
r4 = mad_f32 r1 r3 r4
r3 = mad_f32 r1 r3 r5
r1 = splat 3E59B3D0 (0.21259999)
r5 = splat 3F371759 (0.71520001)
r0 = splat 3D93DD98 (0.0722)
r0 = mul_f32 r3 r0
r0 = mad_f32 r4 r5 r0
r0 = mad_f32 r2 r1 r0
r1 = splat 437F0000 (255)
r2 = splat 3F000000 (0.5)
r2 = mad_f32 r0 r1 r2
r2 = to_i32 r2
store8 arg(1) r2
)",
R"(r0 = load32 arg(0)
r1 = splat FF (3.5733111e-43)
r2 = bit_and r0 r1
r3 = splat 3B808081 (0.0039215689)
r2 = to_f32 r2
r2 = mul_f32 r3 r2
r4 = shr r0 8 (1.1210388e-44)
r4 = bit_and r4 r1
r4 = to_f32 r4
r4 = mul_f32 r3 r4
r5 = shr r0 10 (2.2420775e-44)
r5 = bit_and r5 r1
r5 = to_f32 r5
r5 = mul_f32 r3 r5
r0 = shr r0 18 (3.3631163e-44)
r0 = to_f32 r0
r0 = mul_f32 r3 r0
r6 = load32 arg(1)
r7 = bit_and r6 r1
r7 = to_f32 r7
r7 = mul_f32 r3 r7
r8 = shr r6 8 (1.1210388e-44)
r8 = bit_and r8 r1
r8 = to_f32 r8
r8 = mul_f32 r3 r8
r9 = shr r6 10 (2.2420775e-44)
r9 = bit_and r9 r1
r9 = to_f32 r9
r9 = mul_f32 r3 r9
r6 = shr r6 18 (3.3631163e-44)
r6 = to_f32 r6
r6 = mul_f32 r3 r6
r3 = splat 3F800000 (1)
r3 = sub_f32 r3 r0
r7 = mad_f32 r7 r3 r2
r8 = mad_f32 r8 r3 r4
r9 = mad_f32 r9 r3 r5
r3 = mad_f32 r6 r3 r0
r6 = splat 437F0000 (255)
r0 = splat 3F000000 (0.5)
r7 = mad_f32 r7 r6 r0
r7 = to_i32 r7
r8 = mad_f32 r8 r6 r0
r8 = to_i32 r8
r8 = shl r8 8 (1.1210388e-44)
r9 = mad_f32 r9 r6 r0
r9 = to_i32 r9
r9 = shl r9 10 (2.2420775e-44)
r0 = mad_f32 r3 r6 r0
r0 = to_i32 r0
r0 = shl r0 18 (3.3631163e-44)
r8 = bit_or r7 r8
r8 = bit_or r8 r9
r8 = bit_or r8 r0
store32 arg(1) r8
)",
};
DEF_TEST(SkVM, r) {
SkDynamicMemoryWStream buf;
for (int s = 0; s < 3; s++)
for (int d = 0; d < 3; d++) {
auto srcFmt = (Fmt)s,
dstFmt = (Fmt)d;
skvm::Program program = SrcoverBuilder{srcFmt, dstFmt}.done();
SkDynamicMemoryWStream buf;
buf.writeText(fmt_name(srcFmt));
buf.writeText(" over ");
buf.writeText(fmt_name(dstFmt));
buf.writeText("\n");
program.dump(&buf);
sk_sp<SkData> blob = buf.detachAsData();
buf.writeText("\n");
}
bool train = false;
if (train) {
SkDebugf("R\"(%.*s)\",\n", blob->size(), blob->data());
} else if (0 != memcmp(kExpected[3*s+d], blob->data(), blob->size())) {
ERRORF(r, "SkVMTest needs retraining.\n");
sk_sp<SkData> blob = buf.detachAsData();
{
sk_sp<SkData> expected = GetResourceAsData("SkVMTest.expected");
REPORTER_ASSERT(r, expected
&& blob->size() == expected->size()
&& 0 == memcmp(blob->data(), expected->data(), blob->size()));
SkFILEWStream out(GetResourcePath("SkVMTest.expected").c_str());
if (out.isValid()) {
out.write(blob->data(), blob->size());
}
}