1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
4 *
5 * Copyright (c) 2020 Google Inc.
6 * Copyright (c) 2020 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 Fragment output location tests
23 *//*--------------------------------------------------------------------*/
24
25 #include "vktDrawOutputLocationTests.hpp"
26 #include "vktTestGroupUtil.hpp"
27 #include "amber/vktAmberTestCase.hpp"
28
29 #include "tcuTestCase.hpp"
30
31 #include <string>
32
33 namespace vkt
34 {
35 namespace Draw
36 {
37 namespace
38 {
39
checkSupport(Context & context,std::string testName)40 void checkSupport(Context &context, std::string testName)
41 {
42 if (context.isDeviceFunctionalitySupported("VK_KHR_portability_subset") &&
43 context.getPortabilitySubsetProperties().minVertexInputBindingStrideAlignment == 4 &&
44 (testName.find("r8g8") != std::string::npos || testName.find("inputs-outputs-mod") != std::string::npos))
45 {
46 TCU_THROW(NotSupportedError,
47 "VK_KHR_portability_subset: Stride is not a multiple of minVertexInputBindingStrideAlignment");
48 }
49 }
50
createTests(tcu::TestCaseGroup * testGroup)51 void createTests(tcu::TestCaseGroup *testGroup)
52 {
53 #ifndef CTS_USES_VULKANSC
54 tcu::TestContext &testCtx = testGroup->getTestContext();
55
56 // .Test output location array
57 {
58 tcu::TestCaseGroup *const array = new tcu::TestCaseGroup(testCtx, "array");
59 static const char dataDir[] = "draw/output_location/array";
60
61 static const std::string cases[] = {"b10g11r11-ufloat-pack32-highp",
62 "b10g11r11-ufloat-pack32-highp-output-float",
63 "b10g11r11-ufloat-pack32-highp-output-vec2",
64 "b10g11r11-ufloat-pack32-mediump",
65 "b10g11r11-ufloat-pack32-mediump-output-float",
66 "b10g11r11-ufloat-pack32-mediump-output-vec2",
67 "b8g8r8a8-unorm-highp",
68 "b8g8r8a8-unorm-highp-output-vec2",
69 "b8g8r8a8-unorm-highp-output-vec3",
70 "b8g8r8a8-unorm-mediump",
71 "b8g8r8a8-unorm-mediump-output-vec2",
72 "b8g8r8a8-unorm-mediump-output-vec3",
73 "r16g16-sfloat-highp",
74 "r16g16-sfloat-highp-output-float",
75 "r16g16-sfloat-mediump",
76 "r16g16-sfloat-mediump-output-float",
77 "r32g32b32a32-sfloat-highp",
78 "r32g32b32a32-sfloat-highp-output-vec2",
79 "r32g32b32a32-sfloat-highp-output-vec3",
80 "r32g32b32a32-sfloat-mediump",
81 "r32g32b32a32-sfloat-mediump-output-vec2",
82 "r32g32b32a32-sfloat-mediump-output-vec3",
83 "r32-sfloat-highp",
84 "r32-sfloat-mediump",
85 "r8g8-uint-highp",
86 "r8g8-uint-highp-output-uint",
87 "r8g8-uint-mediump",
88 "r8g8-uint-mediump-output-uint"};
89
90 testGroup->addChild(array);
91
92 for (int i = 0; i < DE_LENGTH_OF_ARRAY(cases); ++i)
93 {
94 const std::string fileName = cases[i] + ".amber";
95 cts_amber::AmberTestCase *testCase =
96 cts_amber::createAmberTestCase(testCtx, cases[i].c_str(), dataDir, fileName);
97
98 testCase->setCheckSupportCallback(checkSupport);
99 array->addChild(testCase);
100 }
101 }
102
103 // .Test output location shuffling
104 {
105 tcu::TestCaseGroup *const shuffle = new tcu::TestCaseGroup(testCtx, "shuffle");
106 static const char dataDir[] = "draw/output_location/shuffle";
107
108 static const std::string cases[] = {"inputs-outputs", "inputs-outputs-mod"};
109
110 testGroup->addChild(shuffle);
111 for (int i = 0; i < DE_LENGTH_OF_ARRAY(cases); ++i)
112 {
113 const std::string fileName = cases[i] + ".amber";
114 cts_amber::AmberTestCase *testCase =
115 cts_amber::createAmberTestCase(testCtx, cases[i].c_str(), dataDir, fileName);
116
117 shuffle->addChild(testCase);
118 }
119 }
120 #else
121 DE_UNREF(testGroup);
122 #endif
123 }
124
125 } // namespace
126
createOutputLocationTests(tcu::TestContext & testCtx)127 tcu::TestCaseGroup *createOutputLocationTests(tcu::TestContext &testCtx)
128 {
129 // Fragment output location tests
130 return createTestGroup(testCtx, "output_location", createTests);
131 }
132
133 } // namespace Draw
134 } // namespace vkt
135