1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
4 *
5 * Copyright (c) 2019 Google LLC
6 * Copyright (c) 2019 The Khronos Group Inc.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 *//*!
21 * \file
22 * \brief Tests using only vertex shader in a graphics pipeline
23 *//*--------------------------------------------------------------------*/
24
25 #include <string>
26
27 #include "vktTestGroupUtil.hpp"
28 #include "vktAmberTestCase.hpp"
29 #include "vktPipelineMiscTests.hpp"
30
31 namespace vkt
32 {
33 namespace pipeline
34 {
35 namespace
36 {
37
38 enum AmberFeatureBits
39 {
40 AMBER_FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS = (1 << 0),
41 AMBER_FEATURE_TESSELATION_SHADER = (1 << 1),
42 AMBER_FEATURE_GEOMETRY_SHADER = (1 << 2),
43 };
44
45 using AmberFeatureFlags = deUint32;
46
getFeatureList(AmberFeatureFlags flags)47 std::vector<std::string> getFeatureList (AmberFeatureFlags flags)
48 {
49 std::vector<std::string> requirements;
50
51 if (flags & AMBER_FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS)
52 requirements.push_back("Features.vertexPipelineStoresAndAtomics");
53
54 if (flags & AMBER_FEATURE_TESSELATION_SHADER)
55 requirements.push_back("Features.tessellationShader");
56
57 if (flags & AMBER_FEATURE_GEOMETRY_SHADER)
58 requirements.push_back("Features.geometryShader");
59
60 return requirements;
61 }
62
addTests(tcu::TestCaseGroup * tests,const char * data_dir)63 void addTests (tcu::TestCaseGroup* tests, const char* data_dir)
64 {
65 tcu::TestContext& testCtx = tests->getTestContext();
66
67 // Shader test files are saved in <path>/external/vulkancts/data/vulkan/amber/<data_dir>/<basename>.amber
68 struct Case {
69 const char* basename;
70 const char* description;
71 AmberFeatureFlags flags;
72 };
73
74 const Case cases[] =
75 {
76 {
77 "position_to_ssbo",
78 "Write position data into ssbo using only the vertex shader in a pipeline",
79 (AMBER_FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS),
80 },
81 {
82 "primitive_id_from_tess",
83 "Read primitive id from tessellation shaders without a geometry shader",
84 (AMBER_FEATURE_TESSELATION_SHADER | AMBER_FEATURE_GEOMETRY_SHADER),
85 },
86 };
87
88 for (unsigned i = 0; i < DE_LENGTH_OF_ARRAY(cases) ; ++i)
89 {
90 std::string file = std::string(cases[i].basename) + ".amber";
91 std::vector<std::string> requirements = getFeatureList(cases[i].flags);
92 cts_amber::AmberTestCase *testCase = cts_amber::createAmberTestCase(testCtx, cases[i].basename, cases[i].description, data_dir, file, requirements);
93
94 tests->addChild(testCase);
95 }
96 }
97
98 } // anonymous
99
createMiscTests(tcu::TestContext & testCtx)100 tcu::TestCaseGroup* createMiscTests (tcu::TestContext& testCtx)
101 {
102 // Location of the Amber script files under the data/vulkan/amber source tree.
103 const char* data_dir = "pipeline";
104 return createTestGroup(testCtx, "misc", "Miscellaneous pipeline tests", addTests, data_dir);
105 }
106
107 } // SpirVAssembly
108 } // vkt
109