1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
4 *
5 * Copyright (c) 2016 The Khronos Group Inc.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief Synchronization tests
22 *//*--------------------------------------------------------------------*/
23
24 #include "vktSynchronizationTests.hpp"
25 #include "vktTestGroupUtil.hpp"
26 #include "vktSynchronizationSmokeTests.hpp"
27 #include "vktSynchronizationBasicFenceTests.hpp"
28 #include "vktSynchronizationBasicSemaphoreTests.hpp"
29 #include "vktSynchronizationBasicEventTests.hpp"
30 #include "vktSynchronizationOperationSingleQueueTests.hpp"
31 #include "vktSynchronizationOperationMultiQueueTests.hpp"
32 #include "vktSynchronizationInternallySynchronizedObjectsTests.hpp"
33 #include "vktSynchronizationCrossInstanceSharingTests.hpp"
34 #include "vktSynchronizationSignalOrderTests.hpp"
35 #include "vktSynchronizationTimelineSemaphoreTests.hpp"
36 #include "vktSynchronizationWin32KeyedMutexTests.hpp"
37 #include "vktSynchronizationNoneStageTests.hpp"
38 #include "vktSynchronizationUtil.hpp"
39 #include "vktSynchronizationImageLayoutTransitionTests.hpp"
40 #include "vktGlobalPriorityQueueTests.hpp"
41
42 #include "deUniquePtr.hpp"
43
44 namespace vkt
45 {
46 namespace synchronization
47 {
48
49 namespace
50 {
51
createBasicTests(tcu::TestContext & testCtx,SynchronizationType type,VideoCodecOperationFlags videoCodecOperation)52 tcu::TestCaseGroup* createBasicTests (tcu::TestContext& testCtx, SynchronizationType type, VideoCodecOperationFlags videoCodecOperation)
53 {
54 de::MovePtr<tcu::TestCaseGroup> group(new tcu::TestCaseGroup(testCtx, "basic"));
55
56 if (type == SynchronizationType::LEGACY)
57 {
58 group->addChild(createBasicEventTests(testCtx, videoCodecOperation));
59 group->addChild(createBasicFenceTests(testCtx, videoCodecOperation));
60 }
61 else
62 {
63 group->addChild(createSynchronization2BasicEventTests(testCtx, videoCodecOperation));
64 }
65
66 group->addChild(createBasicBinarySemaphoreTests (testCtx, type, videoCodecOperation));
67 group->addChild(createBasicTimelineSemaphoreTests (testCtx, type, videoCodecOperation));
68
69 return group.release();
70 }
71
72 class OperationTests : public tcu::TestCaseGroup
73 {
74 public:
OperationTests(tcu::TestContext & testCtx,SynchronizationType type)75 OperationTests (tcu::TestContext& testCtx, SynchronizationType type)
76 : tcu::TestCaseGroup(testCtx, "op")
77 , m_type(type)
78 {
79 }
80
init(void)81 void init (void)
82 {
83 addChild(createSynchronizedOperationSingleQueueTests(m_testCtx, m_type, m_pipelineCacheData));
84 addChild(createSynchronizedOperationMultiQueueTests (m_testCtx, m_type, m_pipelineCacheData));
85 }
86
87 private:
88 SynchronizationType m_type;
89
90 // synchronization.op tests share pipeline cache data to speed up test execution.
91 PipelineCacheData m_pipelineCacheData;
92 };
93
getGroupName(SynchronizationType type,const std::string & name,VideoCodecOperationFlags videoCodecOperation)94 const std::pair<std::string, std::string> getGroupName (SynchronizationType type, const std::string& name, VideoCodecOperationFlags videoCodecOperation)
95 {
96 if (videoCodecOperation == 0)
97 {
98 const bool isSynchronization2 (type == SynchronizationType::SYNCHRONIZATION2);
99 const char* groupDescription[] { "Synchronization tests", "VK_KHR_synchronization2 tests" };
100
101 return std::pair<std::string, std::string>(name, groupDescription[isSynchronization2]);
102 }
103
104 #ifndef CTS_USES_VULKANSC
105 return std::pair<std::string, std::string>(name, "");
106 #else
107 TCU_THROW(InternalError, "Video support is not implemented in Vulkan SC");
108 #endif
109 }
110
createTestsInternal(tcu::TestContext & testCtx,SynchronizationType type,const std::string & name,VideoCodecOperationFlags videoCodecOperation)111 tcu::TestCaseGroup* createTestsInternal (tcu::TestContext& testCtx, SynchronizationType type, const std::string& name, VideoCodecOperationFlags videoCodecOperation)
112 {
113 const bool isSynchronization2 (type == SynchronizationType::SYNCHRONIZATION2);
114 const std::pair<std::string, std::string> groupName = getGroupName(type, name, videoCodecOperation);
115
116 de::MovePtr<tcu::TestCaseGroup> testGroup(new tcu::TestCaseGroup(testCtx, groupName.first.c_str()));
117
118 if (videoCodecOperation == 0)
119 {
120 if (isSynchronization2)
121 {
122 testGroup->addChild(createSynchronization2SmokeTests(testCtx));
123 testGroup->addChild(createSynchronization2TimelineSemaphoreTests(testCtx));
124 #ifndef CTS_USES_VULKANSC
125 testGroup->addChild(createNoneStageTests(testCtx));
126 #endif // CTS_USES_VULKANSC
127 testGroup->addChild(createImageLayoutTransitionTests(testCtx));
128 }
129 else // legacy synchronization
130 {
131 testGroup->addChild(createSmokeTests(testCtx));
132 testGroup->addChild(createTimelineSemaphoreTests(testCtx));
133
134 testGroup->addChild(createInternallySynchronizedObjects(testCtx));
135 #ifndef CTS_USES_VULKANSC
136 testGroup->addChild(createWin32KeyedMutexTest(testCtx));
137 testGroup->addChild(createGlobalPriorityQueueTests(testCtx));
138 #endif // CTS_USES_VULKANSC
139 }
140 }
141
142 testGroup->addChild(createBasicTests(testCtx, type, videoCodecOperation));
143
144 if (videoCodecOperation == 0)
145 {
146 testGroup->addChild(new OperationTests(testCtx, type));
147 #ifndef CTS_USES_VULKANSC
148 testGroup->addChild(createCrossInstanceSharingTest(testCtx, type));
149 testGroup->addChild(createSignalOrderTests(testCtx, type));
150 #endif // CTS_USES_VULKANSC
151 }
152
153 return testGroup.release();
154 }
155 } // anonymous
156
157 } // synchronization
158
createSynchronizationTests(tcu::TestContext & testCtx,const std::string & name)159 tcu::TestCaseGroup* createSynchronizationTests(tcu::TestContext& testCtx, const std::string& name)
160 {
161 return createSynchronizationTests(testCtx, name, 0u);
162 }
163
createSynchronization2Tests(tcu::TestContext & testCtx,const std::string & name)164 tcu::TestCaseGroup* createSynchronization2Tests(tcu::TestContext& testCtx, const std::string& name)
165 {
166 return createSynchronization2Tests(testCtx, name, 0u);
167 }
168
createSynchronizationTests(tcu::TestContext & testCtx,const std::string & name,synchronization::VideoCodecOperationFlags videoCodecOperation)169 tcu::TestCaseGroup* createSynchronizationTests (tcu::TestContext& testCtx, const std::string& name, synchronization::VideoCodecOperationFlags videoCodecOperation)
170 {
171 using namespace synchronization;
172
173 de::MovePtr<tcu::TestCaseGroup> testGroup (createTestsInternal(testCtx, SynchronizationType::LEGACY, name, videoCodecOperation));
174
175 return testGroup.release();
176 }
177
createSynchronization2Tests(tcu::TestContext & testCtx,const std::string & name,synchronization::VideoCodecOperationFlags videoCodecOperation)178 tcu::TestCaseGroup* createSynchronization2Tests (tcu::TestContext& testCtx, const std::string& name, synchronization::VideoCodecOperationFlags videoCodecOperation)
179 {
180 using namespace synchronization;
181
182 de::MovePtr<tcu::TestCaseGroup> testGroup(createTestsInternal(testCtx, SynchronizationType::SYNCHRONIZATION2, name, videoCodecOperation));
183
184 return testGroup.release();
185 }
186
187 } // vkt
188