Skip to content

Commit b6d5fe6

Browse files
bpeelalegal-arm
authored andcommitted
Add tests using VkRunner, precompiling the scripts
This is an alternative version of change 2660 that precompiles the GLSL or SPIR-V assembly in the VkRunner test scripts to SPIR-V binary during the build phase so that they can be executed faster and without any external glslang or spirv-tools dependencies. This adds VkRunner as an external dependency and then adds some example test cases to use it. VkRunner is a tool designed to make it easier to create shader tests for Vulkan by using a simple scripting language which combines the shaders used for a pipeline along with a description of the inputs and expected outputs. VkRunner is fetched from an external repository so the fetch_sources script needs to be run after merging the patch. VkRunner tests can be added to any group, the tests need to be a child class of the VkRunnerTestCase class. Some VkRunner tests are provided as example, but they are excluded from the mustpass: dEQP-VK.vkrunner-example.* Shader test files are under external/vulkancts/data/vulkan/vkrunner/ path. The example shader_test files are under example/ subfolder. VK-GL-CTS: 1147 Change-Id: I1c5fc5f672a360800bfe10afbf96ca8fd07b38e6
1 parent 7b04dd3 commit b6d5fe6

24 files changed

Lines changed: 9017 additions & 0 deletions

AndroidGen.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ LOCAL_SRC_FILES := \
355355
external/vulkancts/modules/vulkan/ubo/vktUniformBlockTests.cpp \
356356
external/vulkancts/modules/vulkan/util/vktDrawUtil.cpp \
357357
external/vulkancts/modules/vulkan/util/vktExternalMemoryUtil.cpp \
358+
external/vulkancts/modules/vulkan/vkrunner/vktVkRunnerExampleTests.cpp \
359+
external/vulkancts/modules/vulkan/vkrunner/vktVkRunnerTestCase.cpp \
358360
external/vulkancts/modules/vulkan/vktInfoTests.cpp \
359361
external/vulkancts/modules/vulkan/vktShaderLibrary.cpp \
360362
external/vulkancts/modules/vulkan/vktTestCase.cpp \
@@ -1094,6 +1096,7 @@ LOCAL_C_INCLUDES := \
10941096
$(deqp_dir)/external/vulkancts/modules/vulkan/texture \
10951097
$(deqp_dir)/external/vulkancts/modules/vulkan/ubo \
10961098
$(deqp_dir)/external/vulkancts/modules/vulkan/util \
1099+
$(deqp_dir)/external/vulkancts/modules/vulkan/vkrunner \
10971100
$(deqp_dir)/external/vulkancts/modules/vulkan/wsi \
10981101
$(deqp_dir)/external/vulkancts/modules/vulkan/ycbcr \
10991102
$(deqp_dir)/framework/common \

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ add_subdirectory(external/glslang)
8888
# spirv-tools
8989
add_subdirectory(external/spirv-tools)
9090

91+
# VkRunner
92+
add_subdirectory(external/vkrunner)
93+
include_directories(external/vkrunner/src)
94+
9195
# spirv-headers
9296
set(SPIRV_INCLUDE_PATH "${PROJECT_SOURCE_DIR}/external/spirv-headers/src/include")
9397
if (NOT EXISTS ${SPIRV_INCLUDE_PATH})

android/cts/master/src/vk-excluded-tests.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ dEQP-VK.wsi.android.shared_presentable_image.scale_down.*
6464

6565
# Issue: b/67022169
6666
dEQP-VK.wsi.android.incremental_present.scale_down.*
67+
68+
# Excluded VkRunner example tests
69+
dEQP-VK.vkrunner-example.*

external/fetch_sources.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,11 @@ def postExtractLibpng (path):
328328
None,
329329
"17da9f8231f78cf519b4958c2229463a63ead9e2",
330330
"spirv-headers"),
331+
GitRepo(
332+
"https://github.com/Igalia/vkrunner.git",
333+
None,
334+
"bc4bd2bc11da08697143fdc23e4047c8c269bf50",
335+
"vkrunner"),
331336
]
332337

333338
def parseArgs ():

external/vkrunner/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src

external/vkrunner/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# cmake file for VkRunner
2+
3+
include(CheckCCompilerFlag)
4+
5+
foreach(FLAG -std=c99 -Wno-extra -Wno-pedantic -Wno-conversion -Wno-shadow)
6+
string(REGEX REPLACE "[=-]" "_" FLAG_VAR "${FLAG}")
7+
CHECK_C_COMPILER_FLAG("${FLAG}" HAVE_FLAG_${FLAG_VAR})
8+
if(${HAVE_FLAG_${FLAG_VAR}})
9+
add_definitions("${FLAG}")
10+
endif()
11+
endforeach()
12+
13+
set(VULKAN_HEADER "\"vkDefs.h\"")
14+
add_definitions("-D_DEFAULT_SOURCE")
15+
include_directories(../../external/vulkancts/framework/vulkan/)
16+
add_subdirectory(src)
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
[vertex shader spirv]
2+
OpCapability Shader
3+
%1 = OpExtInstImport "GLSL.std.450"
4+
OpMemoryModel Logical GLSL450
5+
OpEntryPoint Vertex %main "main" %_ %pos %norm_coord
6+
OpSource GLSL 430
7+
OpName %main "main"
8+
OpName %gl_PerVertex "gl_PerVertex"
9+
OpMemberName %gl_PerVertex 0 "gl_Position"
10+
OpName %_ ""
11+
OpName %pos "pos"
12+
OpName %norm_coord "norm_coord"
13+
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
14+
OpDecorate %gl_PerVertex Block
15+
OpDecorate %pos Location 0
16+
OpDecorate %norm_coord Location 0
17+
%void = OpTypeVoid
18+
%3 = OpTypeFunction %void
19+
%float = OpTypeFloat 32
20+
%v4float = OpTypeVector %float 4
21+
%uint = OpTypeInt 32 0
22+
%uint_1 = OpConstant %uint 1
23+
%_arr_float_uint_1 = OpTypeArray %float %uint_1
24+
%gl_PerVertex = OpTypeStruct %v4float
25+
%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
26+
%_ = OpVariable %_ptr_Output_gl_PerVertex Output
27+
%int = OpTypeInt 32 1
28+
%int_0 = OpConstant %int 0
29+
%_ptr_Input_v4float = OpTypePointer Input %v4float
30+
%pos = OpVariable %_ptr_Input_v4float Input
31+
%_ptr_Output_v4float = OpTypePointer Output %v4float
32+
%norm_coord = OpVariable %_ptr_Output_v4float Output
33+
%main = OpFunction %void None %3
34+
%5 = OpLabel
35+
%18 = OpLoad %v4float %pos
36+
%20 = OpAccessChain %_ptr_Output_v4float %_ %int_0
37+
OpStore %20 %18
38+
OpStore %norm_coord %18
39+
OpReturn
40+
OpFunctionEnd
41+
42+
[fragment shader spirv]
43+
OpCapability Shader
44+
%1 = OpExtInstImport "GLSL.std.450"
45+
OpMemoryModel Logical GLSL450
46+
OpEntryPoint Fragment %main "main" %color %norm_coord
47+
OpExecutionMode %main OriginUpperLeft
48+
OpSource GLSL 430
49+
OpName %main "main"
50+
OpName %color "color"
51+
OpName %norm_coord "norm_coord"
52+
OpDecorate %color Location 0
53+
OpDecorate %norm_coord Location 0
54+
%void = OpTypeVoid
55+
%3 = OpTypeFunction %void
56+
%float = OpTypeFloat 32
57+
%v4float = OpTypeVector %float 4
58+
%_ptr_Output_v4float = OpTypePointer Output %v4float
59+
%color = OpVariable %_ptr_Output_v4float Output
60+
%v2float = OpTypeVector %float 2
61+
%float_1 = OpConstant %float 1
62+
%12 = OpConstantComposite %v2float %float_1 %float_1
63+
%bool = OpTypeBool
64+
%_ptr_Input_v4float = OpTypePointer Input %v4float
65+
%norm_coord = OpVariable %_ptr_Input_v4float Input
66+
%uint = OpTypeInt 32 0
67+
%uint_0 = OpConstant %uint 0
68+
%_ptr_Input_float = OpTypePointer Input %float
69+
%float_0_1 = OpConstant %float 0.1
70+
%uint_1 = OpConstant %uint 1
71+
%float_0 = OpConstant %float 0
72+
%38 = OpConstantComposite %v2float %float_0 %float_0
73+
%main = OpFunction %void None %3
74+
%5 = OpLabel
75+
%13 = OpLoad %v4float %color
76+
%14 = OpVectorShuffle %v4float %13 %12 4 1 2 5
77+
OpStore %color %14
78+
%21 = OpAccessChain %_ptr_Input_float %norm_coord %uint_0
79+
%22 = OpLoad %float %21
80+
%23 = OpExtInst %float %1 FAbs %22
81+
%25 = OpFOrdLessThan %bool %23 %float_0_1
82+
%26 = OpLogicalNot %bool %25
83+
OpSelectionMerge %28 None
84+
OpBranchConditional %26 %27 %28
85+
%27 = OpLabel
86+
%30 = OpAccessChain %_ptr_Input_float %norm_coord %uint_1
87+
%31 = OpLoad %float %30
88+
%32 = OpExtInst %float %1 FAbs %31
89+
%33 = OpFOrdLessThan %bool %32 %float_0_1
90+
OpBranch %28
91+
%28 = OpLabel
92+
%34 = OpPhi %bool %25 %5 %33 %27
93+
OpSelectionMerge %36 None
94+
OpBranchConditional %34 %35 %41
95+
%35 = OpLabel
96+
%39 = OpLoad %v4float %color
97+
%40 = OpVectorShuffle %v4float %39 %38 0 4 5 3
98+
OpStore %color %40
99+
OpBranch %36
100+
%41 = OpLabel
101+
%42 = OpLoad %v4float %color
102+
%43 = OpVectorShuffle %v4float %42 %12 0 4 5 3
103+
OpStore %color %43
104+
OpBranch %36
105+
%36 = OpLabel
106+
OpReturn
107+
OpFunctionEnd
108+
109+
[test]
110+
draw rect -1 -1 2 2
111+
112+
probe rect rgba (0, 0, 11, 11) (1, 1, 1, 1)
113+
probe rect rgba (138, 0, 112, 11) (1, 1, 1, 1)
114+
probe rect rgba (0, 138, 11, 112) (1, 1, 1, 1)
115+
probe rect rgba (138, 138, 112, 112) (1, 1, 1, 1)
116+
probe rect rgba (114, 0, 23, 250) (1, 0, 0, 1)
117+
probe rect rgba (0, 114, 250, 23) (1, 0, 0, 1)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[compute shader]
2+
#version 450
3+
4+
layout(std140, push_constant) uniform push_constants {
5+
float in_value;
6+
};
7+
8+
layout(std140, binding = 0) buffer ssbo {
9+
float out_value;
10+
};
11+
12+
void
13+
main()
14+
{
15+
out_value = sqrt(in_value);
16+
}
17+
18+
[test]
19+
# Allocate an ssbo big enough for a float at binding 0
20+
ssbo 0 4
21+
22+
# Set the push constant as an input value
23+
uniform float 0 <INPUT>
24+
25+
compute 1 1 1
26+
27+
# Probe that we got the expected value
28+
probe ssbo float 0 0 == <OUTPUT>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[vertex shader]
2+
#version 450
3+
4+
layout(location = 0) out vec4 color_out;
5+
layout(location = 0) in vec4 pos;
6+
7+
layout(binding = 3, std140) uniform block {
8+
vec4 color_in;
9+
mat2 transform;
10+
float offsets[4];
11+
};
12+
13+
void
14+
main()
15+
{
16+
gl_Position = vec4(transform * pos.xy, 0.0, 1.0);
17+
color_out = color_in;
18+
19+
for (int i = 0; i < offsets.length(); i++)
20+
color_out[i] += offsets[i];
21+
}
22+
23+
[fragment shader]
24+
#version 450
25+
26+
layout(location = 0) in vec4 color_in;
27+
layout(location = 0) out vec4 color_out;
28+
29+
void
30+
main()
31+
{
32+
color_out = color_in;
33+
}
34+
35+
[test]
36+
clear
37+
38+
uniform ubo 3 mat2 16 0.0 1.0 1.0 0.0
39+
40+
# Sets the offset array. Arrays can be specified by listing multiple values
41+
uniform ubo 3 float 48 0.1 0.2 0.3 0.4
42+
43+
# Note that we can’t update the ubo and then draw another square
44+
# without first probing because the command buffer isn’t flushed
45+
# until a probe. Otherwise it would end up just using the second
46+
# set of values in the ubo for both rectangles.
47+
48+
uniform ubo 3 vec4 0 -0.1 0.8 -0.3 0.6
49+
draw rect -1 -1 1 2
50+
relative probe rect rgba (0.0, 0.0, 1.0, 0.5) (0.0, 1.0, 0.0, 1.0)
51+
52+
uniform ubo 3 vec4 0 -0.1 0.6 -0.3 0.6
53+
draw rect 0 -1 1 2
54+
relative probe rect rgba (0.0, 0.5, 1.0, 0.5) (0.0, 0.8, 0.0, 1.0)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
[vertex shader]
2+
#version 430
3+
4+
layout(location = 0) in vec4 position;
5+
layout(location = 1) in vec4 color_in;
6+
layout(location = 0) out vec4 color_out;
7+
8+
void
9+
main()
10+
{
11+
gl_Position = position;
12+
color_out = color_in;
13+
}
14+
15+
[fragment shader]
16+
#version 430
17+
18+
layout(location = 0) in vec4 color_in;
19+
layout(location = 0) out vec4 color_out;
20+
21+
void
22+
main()
23+
{
24+
color_out = color_in;
25+
}
26+
27+
[vertex data]
28+
# position color
29+
0/R32G32_SFLOAT 1/A8B8G8R8_UNORM_PACK32
30+
31+
# Top-left red
32+
-1 -1 0xff0000ff
33+
0 -1 0xff0000ff
34+
-1 0 0xff0000ff
35+
0 -1 0xff0000ff
36+
-1 0 0xff0000ff
37+
0 0 0xff0000ff
38+
# Top-right green
39+
0 -1 0xff00ff00
40+
1 -1 0xff00ff00
41+
0 0 0xff00ff00
42+
1 -1 0xff00ff00
43+
0 0 0xff00ff00
44+
1 0 0xff00ff00
45+
# Bottom-left blue
46+
-1 0 0xffff0000
47+
0 0 0xffff0000
48+
-1 1 0xffff0000
49+
0 0 0xffff0000
50+
-1 1 0xffff0000
51+
0 1 0xffff0000
52+
# Bottom-right purple
53+
0 0 0xff800080
54+
1 0 0xff800080
55+
0 1 0xff800080
56+
1 0 0xff800080
57+
0 1 0xff800080
58+
1 1 0xff800080
59+
60+
[test]
61+
clear
62+
63+
draw arrays TRIANGLE_LIST 0 24
64+
65+
relative probe rect rgb (0, 0, 0.5, 0.5) (1, 0, 0)
66+
relative probe rect rgb (0.5, 0, 0.5, 0.5) (0, 1, 0)
67+
relative probe rect rgb (0, 0.5, 0.5, 0.5) (0, 0, 1)
68+
relative probe rect rgb (0.5, 0.5, 0.5, 0.5) (0.5, 0, 0.5)

0 commit comments

Comments
 (0)