Add .rte -> .skvm unit test framework
Includes a handful of test cases to exercise the system Change-Id: I98e73a8bca063f475d2ddb51778e395697392ddb Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346637 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
f2ce4e91a2
commit
977feec5d7
12
BUILD.gn
12
BUILD.gn
@ -783,6 +783,15 @@ if (skia_compile_sksl_tests) {
|
||||
lang = "--metal"
|
||||
settings = "--settings"
|
||||
}
|
||||
compile_sksl("skvm_tests") {
|
||||
sources = sksl_skvm_tests_sources
|
||||
outputPatterns = [ [
|
||||
"/golden",
|
||||
".skvm",
|
||||
] ]
|
||||
lang = "--skvm"
|
||||
settings = "--settings"
|
||||
}
|
||||
compile_sksl("spirv_tests") {
|
||||
sources = sksl_spirv_tests_sources
|
||||
outputPatterns = [ [
|
||||
@ -801,6 +810,8 @@ if (skia_compile_sksl_tests) {
|
||||
}
|
||||
group("compile_sksl_metal_tests") {
|
||||
}
|
||||
group("compile_sksl_skvm_tests") {
|
||||
}
|
||||
group("compile_sksl_spirv_tests") {
|
||||
}
|
||||
}
|
||||
@ -813,6 +824,7 @@ optional("gpu") {
|
||||
":compile_sksl_glsl_nosettings_tests",
|
||||
":compile_sksl_glsl_tests",
|
||||
":compile_sksl_metal_tests",
|
||||
":compile_sksl_skvm_tests",
|
||||
":compile_sksl_spirv_tests",
|
||||
":dehydrate_sksl",
|
||||
":run_sksllex",
|
||||
|
@ -63,8 +63,12 @@ for input in inputs:
|
||||
worklist.write(input + "\n")
|
||||
worklist.write(target + ".asm" + extensionForSpirvAsm(ext) + "\n")
|
||||
worklist.write(settings + "\n\n")
|
||||
elif lang == "--skvm":
|
||||
worklist.write(input + "\n")
|
||||
worklist.write(target + ".skvm\n")
|
||||
worklist.write(settings + "\n\n")
|
||||
else:
|
||||
sys.exit("### Expected one of: --fp --glsl --metal --spirv, got " + lang)
|
||||
sys.exit("### Expected one of: --fp --glsl --metal --spirv --skvm, got " + lang)
|
||||
|
||||
# Invoke skslc, passing in the worklist.
|
||||
worklist.close()
|
||||
|
@ -467,6 +467,19 @@ sksl_settings_tests = [
|
||||
"$_tests/sksl/workarounds/TernaryShortCircuit.sksl",
|
||||
]
|
||||
|
||||
sksl_rte_tests = [
|
||||
"$_tests/sksl/runtime/SampleWithConstantMatrix.rte",
|
||||
"$_tests/sksl/runtime/SampleWithExplicitCoord.rte",
|
||||
"$_tests/sksl/runtime/SampleWithUniformMatrix.rte",
|
||||
"$_tests/sksl/runtime/SampleWithVariableMatrix.rte",
|
||||
]
|
||||
|
||||
sksl_rte_error_tests = [
|
||||
"$_tests/sksl/errors/Discard.rte",
|
||||
"$_tests/sksl/errors/UnsupportedTypeSampler.rte",
|
||||
"$_tests/sksl/errors/UnsupportedTypeTexture.rte",
|
||||
]
|
||||
|
||||
# Tests in sksl_fp_tests_sources will be compiled with --settings on, and are expected to generate
|
||||
# a .cpp and a .h output file.
|
||||
sksl_fp_tests_sources = sksl_fp_error_tests + sksl_fp_tests
|
||||
@ -489,3 +502,7 @@ sksl_metal_tests_sources =
|
||||
# generate a .asm.(frag|vert|geom) output file.
|
||||
sksl_spirv_tests_sources =
|
||||
sksl_blend_tests + sksl_shared_tests + sksl_spirv_tests
|
||||
|
||||
## Tests in sksl_skvm_tests_sources will be compiled with --settings on, and are expected to
|
||||
## generate a .skvm output file.
|
||||
sksl_skvm_tests_sources = sksl_rte_tests + sksl_rte_error_tests
|
||||
|
@ -39,10 +39,6 @@ DEF_TEST(SkRuntimeEffectInvalid, r) {
|
||||
test("in bool Flag; layout(when=Flag) uniform float Input;" EMPTY_MAIN, "when");
|
||||
test("layout(tracked) uniform float Input;" EMPTY_MAIN, "tracked");
|
||||
|
||||
// GLSL types like sampler2D and texture2D are not allowed anywhere:
|
||||
test("uniform sampler2D s;" EMPTY_MAIN, "no type named 'sampler2D'");
|
||||
test("uniform texture2D s;" EMPTY_MAIN, "no type named 'texture2D'");
|
||||
|
||||
// Runtime SkSL supports a limited set of uniform types. No bool, or int, for example:
|
||||
test("uniform bool b;" EMPTY_MAIN, "uniform");
|
||||
test("uniform int i;" EMPTY_MAIN, "uniform");
|
||||
@ -58,9 +54,6 @@ DEF_TEST(SkRuntimeEffectInvalid, r) {
|
||||
|
||||
test("half4 missing(); half4 main() { return missing(); }", "undefined function");
|
||||
|
||||
// No use of 'discard' is permitted
|
||||
test("half4 main() { discard; }", "discard");
|
||||
|
||||
// Shouldn't be possible to create an SkRuntimeEffect without "main"
|
||||
test("", "main");
|
||||
|
||||
|
3
tests/sksl/errors/Discard.rte
Normal file
3
tests/sksl/errors/Discard.rte
Normal file
@ -0,0 +1,3 @@
|
||||
half4 main() {
|
||||
discard;
|
||||
}
|
5
tests/sksl/errors/UnsupportedTypeSampler.rte
Normal file
5
tests/sksl/errors/UnsupportedTypeSampler.rte
Normal file
@ -0,0 +1,5 @@
|
||||
uniform sampler2D s;
|
||||
|
||||
half4 main() {
|
||||
return half4(0);
|
||||
}
|
5
tests/sksl/errors/UnsupportedTypeTexture.rte
Normal file
5
tests/sksl/errors/UnsupportedTypeTexture.rte
Normal file
@ -0,0 +1,5 @@
|
||||
uniform texture2D s;
|
||||
|
||||
half4 main() {
|
||||
return half4(0);
|
||||
}
|
4
tests/sksl/errors/golden/Discard.skvm
Normal file
4
tests/sksl/errors/golden/Discard.skvm
Normal file
@ -0,0 +1,4 @@
|
||||
### Compilation failed:
|
||||
|
||||
error: 2: discard statement is only permitted in fragment shaders
|
||||
1 error
|
4
tests/sksl/errors/golden/UnsupportedTypeSampler.skvm
Normal file
4
tests/sksl/errors/golden/UnsupportedTypeSampler.skvm
Normal file
@ -0,0 +1,4 @@
|
||||
### Compilation failed:
|
||||
|
||||
error: 1: no type named 'sampler2D'
|
||||
1 error
|
4
tests/sksl/errors/golden/UnsupportedTypeTexture.skvm
Normal file
4
tests/sksl/errors/golden/UnsupportedTypeTexture.skvm
Normal file
@ -0,0 +1,4 @@
|
||||
### Compilation failed:
|
||||
|
||||
error: 1: no type named 'texture2D'
|
||||
1 error
|
6
tests/sksl/runtime/SampleWithConstantMatrix.rte
Normal file
6
tests/sksl/runtime/SampleWithConstantMatrix.rte
Normal file
@ -0,0 +1,6 @@
|
||||
uniform shader child;
|
||||
half4 main() {
|
||||
return sample(child, float3x3(2, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1));
|
||||
}
|
4
tests/sksl/runtime/SampleWithExplicitCoord.rte
Normal file
4
tests/sksl/runtime/SampleWithExplicitCoord.rte
Normal file
@ -0,0 +1,4 @@
|
||||
uniform shader child;
|
||||
half4 main(float2 p) {
|
||||
return sample(child, p.yx);
|
||||
}
|
5
tests/sksl/runtime/SampleWithUniformMatrix.rte
Normal file
5
tests/sksl/runtime/SampleWithUniformMatrix.rte
Normal file
@ -0,0 +1,5 @@
|
||||
uniform shader child;
|
||||
uniform float3x3 matrix;
|
||||
half4 main() {
|
||||
return sample(child, matrix);
|
||||
}
|
7
tests/sksl/runtime/SampleWithVariableMatrix.rte
Normal file
7
tests/sksl/runtime/SampleWithVariableMatrix.rte
Normal file
@ -0,0 +1,7 @@
|
||||
uniform shader child;
|
||||
half4 main() {
|
||||
float x = sqrt(1.0);
|
||||
return sample(child, float3x3(x, 0, 0,
|
||||
0, x, 0,
|
||||
0, 0, 1));
|
||||
}
|
37
tests/sksl/runtime/golden/SampleWithConstantMatrix.skvm
Normal file
37
tests/sksl/runtime/golden/SampleWithConstantMatrix.skvm
Normal file
@ -0,0 +1,37 @@
|
||||
12 registers, 35 instructions:
|
||||
0 r0 = splat 3 (4.2038954e-45)
|
||||
1 r1 = uniform32 arg(0) C
|
||||
2 r2 = splat 3F800000 (1)
|
||||
3 r3 = uniform32 arg(0) 0
|
||||
4 r4 = splat 0 (0)
|
||||
5 r5 = mul_f32 r4 r3
|
||||
6 r6 = splat 40000000 (2)
|
||||
7 r7 = splat 2 (2.8025969e-45)
|
||||
8 r8 = splat 1 (1.4012985e-45)
|
||||
loop:
|
||||
9 r9 = index
|
||||
10 r10 = mul_f32 r4 r9
|
||||
11 r11 = add_f32 r10 r5
|
||||
12 r11 = add_f32 r11 r2
|
||||
13 r11 = div_f32 r2 r11
|
||||
14 r10 = add_f32 r10 r3
|
||||
15 r10 = mul_f32 r10 r11
|
||||
16 r10 = trunc r10
|
||||
17 r10 = mul_i32 r10 r1
|
||||
18 r9 = mul_f32 r6 r9
|
||||
19 r9 = add_f32 r9 r5
|
||||
20 r11 = mul_f32 r9 r11
|
||||
21 r11 = trunc r11
|
||||
22 r10 = add_i32 r11 r10
|
||||
23 r10 = shl_i32 r10 2
|
||||
24 r11 = add_i32 r10 r0
|
||||
25 r11 = gather32 arg(0) 4 r11
|
||||
26 store32 arg(4) r11
|
||||
27 r11 = add_i32 r10 r7
|
||||
28 r11 = gather32 arg(0) 4 r11
|
||||
29 store32 arg(3) r11
|
||||
30 r11 = add_i32 r10 r8
|
||||
31 r11 = gather32 arg(0) 4 r11
|
||||
32 store32 arg(2) r11
|
||||
33 r10 = gather32 arg(0) 4 r10
|
||||
34 store32 arg(1) r10
|
24
tests/sksl/runtime/golden/SampleWithExplicitCoord.skvm
Normal file
24
tests/sksl/runtime/golden/SampleWithExplicitCoord.skvm
Normal file
@ -0,0 +1,24 @@
|
||||
7 registers, 22 instructions:
|
||||
0 r0 = splat 3 (4.2038954e-45)
|
||||
1 r1 = uniform32 arg(0) C
|
||||
2 r2 = uniform32 arg(0) 0
|
||||
3 r2 = trunc r2
|
||||
4 r3 = splat 2 (2.8025969e-45)
|
||||
5 r4 = splat 1 (1.4012985e-45)
|
||||
loop:
|
||||
6 r5 = index
|
||||
7 r5 = trunc r5
|
||||
8 r5 = mul_i32 r5 r1
|
||||
9 r5 = add_i32 r2 r5
|
||||
10 r5 = shl_i32 r5 2
|
||||
11 r6 = add_i32 r5 r0
|
||||
12 r6 = gather32 arg(0) 4 r6
|
||||
13 store32 arg(4) r6
|
||||
14 r6 = add_i32 r5 r3
|
||||
15 r6 = gather32 arg(0) 4 r6
|
||||
16 store32 arg(3) r6
|
||||
17 r6 = add_i32 r5 r4
|
||||
18 r6 = gather32 arg(0) 4 r6
|
||||
19 store32 arg(2) r6
|
||||
20 r5 = gather32 arg(0) 4 r5
|
||||
21 store32 arg(1) r5
|
49
tests/sksl/runtime/golden/SampleWithUniformMatrix.skvm
Normal file
49
tests/sksl/runtime/golden/SampleWithUniformMatrix.skvm
Normal file
@ -0,0 +1,49 @@
|
||||
17 registers, 47 instructions:
|
||||
0 r0 = splat 3 (4.2038954e-45)
|
||||
1 r1 = uniform32 arg(0) C
|
||||
2 r2 = uniform32 arg(0) 30
|
||||
3 r3 = uniform32 arg(0) 0
|
||||
4 r4 = uniform32 arg(0) 24
|
||||
5 r4 = mul_f32 r4 r3
|
||||
6 r5 = uniform32 arg(0) 18
|
||||
7 r6 = splat 3F800000 (1)
|
||||
8 r7 = uniform32 arg(0) 2C
|
||||
9 r8 = uniform32 arg(0) 20
|
||||
10 r8 = mul_f32 r8 r3
|
||||
11 r9 = uniform32 arg(0) 14
|
||||
12 r10 = uniform32 arg(0) 28
|
||||
13 r11 = uniform32 arg(0) 1C
|
||||
14 r3 = mul_f32 r11 r3
|
||||
15 r11 = uniform32 arg(0) 10
|
||||
16 r12 = splat 2 (2.8025969e-45)
|
||||
17 r13 = splat 1 (1.4012985e-45)
|
||||
loop:
|
||||
18 r14 = index
|
||||
19 r15 = mul_f32 r5 r14
|
||||
20 r15 = add_f32 r15 r4
|
||||
21 r15 = add_f32 r15 r2
|
||||
22 r15 = div_f32 r6 r15
|
||||
23 r16 = mul_f32 r9 r14
|
||||
24 r16 = add_f32 r16 r8
|
||||
25 r16 = add_f32 r16 r7
|
||||
26 r16 = mul_f32 r16 r15
|
||||
27 r16 = trunc r16
|
||||
28 r16 = mul_i32 r16 r1
|
||||
29 r14 = mul_f32 r11 r14
|
||||
30 r14 = add_f32 r14 r3
|
||||
31 r14 = add_f32 r14 r10
|
||||
32 r15 = mul_f32 r14 r15
|
||||
33 r15 = trunc r15
|
||||
34 r16 = add_i32 r15 r16
|
||||
35 r16 = shl_i32 r16 2
|
||||
36 r15 = add_i32 r16 r0
|
||||
37 r15 = gather32 arg(0) 4 r15
|
||||
38 store32 arg(4) r15
|
||||
39 r15 = add_i32 r16 r12
|
||||
40 r15 = gather32 arg(0) 4 r15
|
||||
41 store32 arg(3) r15
|
||||
42 r15 = add_i32 r16 r13
|
||||
43 r15 = gather32 arg(0) 4 r15
|
||||
44 store32 arg(2) r15
|
||||
45 r16 = gather32 arg(0) 4 r16
|
||||
46 store32 arg(1) r16
|
35
tests/sksl/runtime/golden/SampleWithVariableMatrix.skvm
Normal file
35
tests/sksl/runtime/golden/SampleWithVariableMatrix.skvm
Normal file
@ -0,0 +1,35 @@
|
||||
11 registers, 33 instructions:
|
||||
0 r0 = splat 3 (4.2038954e-45)
|
||||
1 r1 = uniform32 arg(0) C
|
||||
2 r2 = splat 3F800000 (1)
|
||||
3 r3 = uniform32 arg(0) 0
|
||||
4 r4 = splat 0 (0)
|
||||
5 r5 = mul_f32 r4 r3
|
||||
6 r6 = splat 2 (2.8025969e-45)
|
||||
7 r7 = splat 1 (1.4012985e-45)
|
||||
loop:
|
||||
8 r8 = index
|
||||
9 r9 = mul_f32 r4 r8
|
||||
10 r10 = add_f32 r9 r5
|
||||
11 r10 = add_f32 r10 r2
|
||||
12 r10 = div_f32 r2 r10
|
||||
13 r9 = add_f32 r9 r3
|
||||
14 r9 = mul_f32 r9 r10
|
||||
15 r9 = trunc r9
|
||||
16 r9 = mul_i32 r9 r1
|
||||
17 r8 = add_f32 r8 r5
|
||||
18 r10 = mul_f32 r8 r10
|
||||
19 r10 = trunc r10
|
||||
20 r9 = add_i32 r10 r9
|
||||
21 r9 = shl_i32 r9 2
|
||||
22 r10 = add_i32 r9 r0
|
||||
23 r10 = gather32 arg(0) 4 r10
|
||||
24 store32 arg(4) r10
|
||||
25 r10 = add_i32 r9 r6
|
||||
26 r10 = gather32 arg(0) 4 r10
|
||||
27 store32 arg(3) r10
|
||||
28 r10 = add_i32 r9 r7
|
||||
29 r10 = gather32 arg(0) 4 r10
|
||||
30 store32 arg(2) r10
|
||||
31 r9 = gather32 arg(0) 4 r9
|
||||
32 store32 arg(1) r9
|
Loading…
Reference in New Issue
Block a user