Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
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
- Loading branch information
1 parent
7b04dd3
commit b6d5fe6
Showing
24 changed files
with
9,017 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# cmake file for VkRunner | ||
|
||
include(CheckCCompilerFlag) | ||
|
||
foreach(FLAG -std=c99 -Wno-extra -Wno-pedantic -Wno-conversion -Wno-shadow) | ||
string(REGEX REPLACE "[=-]" "_" FLAG_VAR "${FLAG}") | ||
CHECK_C_COMPILER_FLAG("${FLAG}" HAVE_FLAG_${FLAG_VAR}) | ||
if(${HAVE_FLAG_${FLAG_VAR}}) | ||
add_definitions("${FLAG}") | ||
endif() | ||
endforeach() | ||
|
||
set(VULKAN_HEADER "\"vkDefs.h\"") | ||
add_definitions("-D_DEFAULT_SOURCE") | ||
include_directories(../../external/vulkancts/framework/vulkan/) | ||
add_subdirectory(src) |
117 changes: 117 additions & 0 deletions
117
external/vulkancts/data/vulkan/vkrunner/example/spirv.shader_test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
[vertex shader spirv] | ||
OpCapability Shader | ||
%1 = OpExtInstImport "GLSL.std.450" | ||
OpMemoryModel Logical GLSL450 | ||
OpEntryPoint Vertex %main "main" %_ %pos %norm_coord | ||
OpSource GLSL 430 | ||
OpName %main "main" | ||
OpName %gl_PerVertex "gl_PerVertex" | ||
OpMemberName %gl_PerVertex 0 "gl_Position" | ||
OpName %_ "" | ||
OpName %pos "pos" | ||
OpName %norm_coord "norm_coord" | ||
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position | ||
OpDecorate %gl_PerVertex Block | ||
OpDecorate %pos Location 0 | ||
OpDecorate %norm_coord Location 0 | ||
%void = OpTypeVoid | ||
%3 = OpTypeFunction %void | ||
%float = OpTypeFloat 32 | ||
%v4float = OpTypeVector %float 4 | ||
%uint = OpTypeInt 32 0 | ||
%uint_1 = OpConstant %uint 1 | ||
%_arr_float_uint_1 = OpTypeArray %float %uint_1 | ||
%gl_PerVertex = OpTypeStruct %v4float | ||
%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex | ||
%_ = OpVariable %_ptr_Output_gl_PerVertex Output | ||
%int = OpTypeInt 32 1 | ||
%int_0 = OpConstant %int 0 | ||
%_ptr_Input_v4float = OpTypePointer Input %v4float | ||
%pos = OpVariable %_ptr_Input_v4float Input | ||
%_ptr_Output_v4float = OpTypePointer Output %v4float | ||
%norm_coord = OpVariable %_ptr_Output_v4float Output | ||
%main = OpFunction %void None %3 | ||
%5 = OpLabel | ||
%18 = OpLoad %v4float %pos | ||
%20 = OpAccessChain %_ptr_Output_v4float %_ %int_0 | ||
OpStore %20 %18 | ||
OpStore %norm_coord %18 | ||
OpReturn | ||
OpFunctionEnd | ||
|
||
[fragment shader spirv] | ||
OpCapability Shader | ||
%1 = OpExtInstImport "GLSL.std.450" | ||
OpMemoryModel Logical GLSL450 | ||
OpEntryPoint Fragment %main "main" %color %norm_coord | ||
OpExecutionMode %main OriginUpperLeft | ||
OpSource GLSL 430 | ||
OpName %main "main" | ||
OpName %color "color" | ||
OpName %norm_coord "norm_coord" | ||
OpDecorate %color Location 0 | ||
OpDecorate %norm_coord Location 0 | ||
%void = OpTypeVoid | ||
%3 = OpTypeFunction %void | ||
%float = OpTypeFloat 32 | ||
%v4float = OpTypeVector %float 4 | ||
%_ptr_Output_v4float = OpTypePointer Output %v4float | ||
%color = OpVariable %_ptr_Output_v4float Output | ||
%v2float = OpTypeVector %float 2 | ||
%float_1 = OpConstant %float 1 | ||
%12 = OpConstantComposite %v2float %float_1 %float_1 | ||
%bool = OpTypeBool | ||
%_ptr_Input_v4float = OpTypePointer Input %v4float | ||
%norm_coord = OpVariable %_ptr_Input_v4float Input | ||
%uint = OpTypeInt 32 0 | ||
%uint_0 = OpConstant %uint 0 | ||
%_ptr_Input_float = OpTypePointer Input %float | ||
%float_0_1 = OpConstant %float 0.1 | ||
%uint_1 = OpConstant %uint 1 | ||
%float_0 = OpConstant %float 0 | ||
%38 = OpConstantComposite %v2float %float_0 %float_0 | ||
%main = OpFunction %void None %3 | ||
%5 = OpLabel | ||
%13 = OpLoad %v4float %color | ||
%14 = OpVectorShuffle %v4float %13 %12 4 1 2 5 | ||
OpStore %color %14 | ||
%21 = OpAccessChain %_ptr_Input_float %norm_coord %uint_0 | ||
%22 = OpLoad %float %21 | ||
%23 = OpExtInst %float %1 FAbs %22 | ||
%25 = OpFOrdLessThan %bool %23 %float_0_1 | ||
%26 = OpLogicalNot %bool %25 | ||
OpSelectionMerge %28 None | ||
OpBranchConditional %26 %27 %28 | ||
%27 = OpLabel | ||
%30 = OpAccessChain %_ptr_Input_float %norm_coord %uint_1 | ||
%31 = OpLoad %float %30 | ||
%32 = OpExtInst %float %1 FAbs %31 | ||
%33 = OpFOrdLessThan %bool %32 %float_0_1 | ||
OpBranch %28 | ||
%28 = OpLabel | ||
%34 = OpPhi %bool %25 %5 %33 %27 | ||
OpSelectionMerge %36 None | ||
OpBranchConditional %34 %35 %41 | ||
%35 = OpLabel | ||
%39 = OpLoad %v4float %color | ||
%40 = OpVectorShuffle %v4float %39 %38 0 4 5 3 | ||
OpStore %color %40 | ||
OpBranch %36 | ||
%41 = OpLabel | ||
%42 = OpLoad %v4float %color | ||
%43 = OpVectorShuffle %v4float %42 %12 0 4 5 3 | ||
OpStore %color %43 | ||
OpBranch %36 | ||
%36 = OpLabel | ||
OpReturn | ||
OpFunctionEnd | ||
|
||
[test] | ||
draw rect -1 -1 2 2 | ||
|
||
probe rect rgba (0, 0, 11, 11) (1, 1, 1, 1) | ||
probe rect rgba (138, 0, 112, 11) (1, 1, 1, 1) | ||
probe rect rgba (0, 138, 11, 112) (1, 1, 1, 1) | ||
probe rect rgba (138, 138, 112, 112) (1, 1, 1, 1) | ||
probe rect rgba (114, 0, 23, 250) (1, 0, 0, 1) | ||
probe rect rgba (0, 114, 250, 23) (1, 0, 0, 1) |
28 changes: 28 additions & 0 deletions
28
external/vulkancts/data/vulkan/vkrunner/example/sqrt.shader_test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[compute shader] | ||
#version 450 | ||
|
||
layout(std140, push_constant) uniform push_constants { | ||
float in_value; | ||
}; | ||
|
||
layout(std140, binding = 0) buffer ssbo { | ||
float out_value; | ||
}; | ||
|
||
void | ||
main() | ||
{ | ||
out_value = sqrt(in_value); | ||
} | ||
|
||
[test] | ||
# Allocate an ssbo big enough for a float at binding 0 | ||
ssbo 0 4 | ||
|
||
# Set the push constant as an input value | ||
uniform float 0 <INPUT> | ||
|
||
compute 1 1 1 | ||
|
||
# Probe that we got the expected value | ||
probe ssbo float 0 0 == <OUTPUT> |
54 changes: 54 additions & 0 deletions
54
external/vulkancts/data/vulkan/vkrunner/example/ubo.shader_test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
[vertex shader] | ||
#version 450 | ||
|
||
layout(location = 0) out vec4 color_out; | ||
layout(location = 0) in vec4 pos; | ||
|
||
layout(binding = 3, std140) uniform block { | ||
vec4 color_in; | ||
mat2 transform; | ||
float offsets[4]; | ||
}; | ||
|
||
void | ||
main() | ||
{ | ||
gl_Position = vec4(transform * pos.xy, 0.0, 1.0); | ||
color_out = color_in; | ||
|
||
for (int i = 0; i < offsets.length(); i++) | ||
color_out[i] += offsets[i]; | ||
} | ||
|
||
[fragment shader] | ||
#version 450 | ||
|
||
layout(location = 0) in vec4 color_in; | ||
layout(location = 0) out vec4 color_out; | ||
|
||
void | ||
main() | ||
{ | ||
color_out = color_in; | ||
} | ||
|
||
[test] | ||
clear | ||
|
||
uniform ubo 3 mat2 16 0.0 1.0 1.0 0.0 | ||
|
||
# Sets the offset array. Arrays can be specified by listing multiple values | ||
uniform ubo 3 float 48 0.1 0.2 0.3 0.4 | ||
|
||
# Note that we can’t update the ubo and then draw another square | ||
# without first probing because the command buffer isn’t flushed | ||
# until a probe. Otherwise it would end up just using the second | ||
# set of values in the ubo for both rectangles. | ||
|
||
uniform ubo 3 vec4 0 -0.1 0.8 -0.3 0.6 | ||
draw rect -1 -1 1 2 | ||
relative probe rect rgba (0.0, 0.0, 1.0, 0.5) (0.0, 1.0, 0.0, 1.0) | ||
|
||
uniform ubo 3 vec4 0 -0.1 0.6 -0.3 0.6 | ||
draw rect 0 -1 1 2 | ||
relative probe rect rgba (0.0, 0.5, 1.0, 0.5) (0.0, 0.8, 0.0, 1.0) |
68 changes: 68 additions & 0 deletions
68
external/vulkancts/data/vulkan/vkrunner/example/vertex-data.shader_test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
[vertex shader] | ||
#version 430 | ||
|
||
layout(location = 0) in vec4 position; | ||
layout(location = 1) in vec4 color_in; | ||
layout(location = 0) out vec4 color_out; | ||
|
||
void | ||
main() | ||
{ | ||
gl_Position = position; | ||
color_out = color_in; | ||
} | ||
|
||
[fragment shader] | ||
#version 430 | ||
|
||
layout(location = 0) in vec4 color_in; | ||
layout(location = 0) out vec4 color_out; | ||
|
||
void | ||
main() | ||
{ | ||
color_out = color_in; | ||
} | ||
|
||
[vertex data] | ||
# position color | ||
0/R32G32_SFLOAT 1/A8B8G8R8_UNORM_PACK32 | ||
|
||
# Top-left red | ||
-1 -1 0xff0000ff | ||
0 -1 0xff0000ff | ||
-1 0 0xff0000ff | ||
0 -1 0xff0000ff | ||
-1 0 0xff0000ff | ||
0 0 0xff0000ff | ||
# Top-right green | ||
0 -1 0xff00ff00 | ||
1 -1 0xff00ff00 | ||
0 0 0xff00ff00 | ||
1 -1 0xff00ff00 | ||
0 0 0xff00ff00 | ||
1 0 0xff00ff00 | ||
# Bottom-left blue | ||
-1 0 0xffff0000 | ||
0 0 0xffff0000 | ||
-1 1 0xffff0000 | ||
0 0 0xffff0000 | ||
-1 1 0xffff0000 | ||
0 1 0xffff0000 | ||
# Bottom-right purple | ||
0 0 0xff800080 | ||
1 0 0xff800080 | ||
0 1 0xff800080 | ||
1 0 0xff800080 | ||
0 1 0xff800080 | ||
1 1 0xff800080 | ||
|
||
[test] | ||
clear | ||
|
||
draw arrays TRIANGLE_LIST 0 24 | ||
|
||
relative probe rect rgb (0, 0, 0.5, 0.5) (1, 0, 0) | ||
relative probe rect rgb (0.5, 0, 0.5, 0.5) (0, 1, 0) | ||
relative probe rect rgb (0, 0.5, 0.5, 0.5) (0, 0, 1) | ||
relative probe rect rgb (0.5, 0.5, 0.5, 0.5) (0.5, 0, 0.5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#ifndef _VKDEFS_H | ||
#define _VKDEFS_H | ||
/*------------------------------------------------------------------------- | ||
* Vulkan CTS Framework | ||
* -------------------- | ||
* | ||
* Copyright (c) 2018 Intel Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*//*! | ||
* \file | ||
* \brief Vulkan header for C files | ||
*//*--------------------------------------------------------------------*/ | ||
|
||
#include "deDefs.h" | ||
|
||
#if (DE_OS == DE_OS_ANDROID) && defined(__ARM_ARCH) && defined(__ARM_32BIT_STATE) | ||
# define VKAPI_ATTR __attribute__((pcs("aapcs-vfp"))) | ||
#else | ||
# define VKAPI_ATTR | ||
#endif | ||
|
||
#if (DE_OS == DE_OS_WIN32) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)) | ||
# define VKAPI_CALL __stdcall | ||
# define VKAPI_PTR VKAPI_CALL | ||
#else | ||
# define VKAPI_CALL | ||
# define VKAPI_PTR VKAPI_ATTR | ||
#endif | ||
|
||
#include "vkVulkan_c.inl" | ||
|
||
#endif /* _VKDEFS_H */ |
Oops, something went wrong.