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
41 #include "deUniquePtr.hpp"
42
43 namespace vkt
44 {
45 namespace synchronization
46 {
47
48 namespace
49 {
50
createBasicTests(tcu::TestContext & testCtx,SynchronizationType type)51 tcu::TestCaseGroup* createBasicTests (tcu::TestContext& testCtx, SynchronizationType type)
52 {
53 de::MovePtr<tcu::TestCaseGroup> group(new tcu::TestCaseGroup(testCtx, "basic", ""));
54
55 if (type == SynchronizationType::LEGACY)
56 {
57 group->addChild(createBasicEventTests(testCtx));
58 group->addChild(createBasicFenceTests(testCtx));
59 }
60 else
61 {
62 group->addChild(createSynchronization2BasicEventTests(testCtx));
63 }
64
65 group->addChild(createBasicBinarySemaphoreTests (testCtx, type));
66 group->addChild(createBasicTimelineSemaphoreTests (testCtx, type));
67
68 return group.release();
69 }
70
71 class OperationTests : public tcu::TestCaseGroup
72 {
73 public:
OperationTests(tcu::TestContext & testCtx,SynchronizationType type)74 OperationTests (tcu::TestContext& testCtx, SynchronizationType type)
75 : tcu::TestCaseGroup(testCtx, "op", "Synchronization of a memory-modifying operation")
76 , m_type(type)
77 {
78 }
79
init(void)80 void init (void)
81 {
82 addChild(createSynchronizedOperationSingleQueueTests(m_testCtx, m_type, m_pipelineCacheData));
83 addChild(createSynchronizedOperationMultiQueueTests (m_testCtx, m_type, m_pipelineCacheData));
84 }
85
86 private:
87 SynchronizationType m_type;
88
89 // synchronization.op tests share pipeline cache data to speed up test execution.
90 PipelineCacheData m_pipelineCacheData;
91 };
92
createTestsInternal(tcu::TestContext & testCtx,SynchronizationType type)93 tcu::TestCaseGroup* createTestsInternal (tcu::TestContext& testCtx, SynchronizationType type)
94 {
95 const bool isSynchronization2 (type == SynchronizationType::SYNCHRONIZATION2);
96 const char* groupName[] { "synchronization", "synchronization2" };
97 const char* groupDescription[] { "Synchronization tests", "VK_KHR_synchronization2 tests" };
98
99 de::MovePtr<tcu::TestCaseGroup> testGroup(new tcu::TestCaseGroup(testCtx, groupName[isSynchronization2], groupDescription[isSynchronization2]));
100
101 if (isSynchronization2)
102 {
103 testGroup->addChild(createSynchronization2SmokeTests(testCtx));
104 testGroup->addChild(createSynchronization2TimelineSemaphoreTests(testCtx));
105 testGroup->addChild(createNoneStageTests(testCtx));
106 testGroup->addChild(createImageLayoutTransitionTests(testCtx));
107 }
108 else // legacy synchronization
109 {
110 testGroup->addChild(createSmokeTests(testCtx));
111 testGroup->addChild(createTimelineSemaphoreTests(testCtx));
112
113 testGroup->addChild(createInternallySynchronizedObjects(testCtx));
114 testGroup->addChild(createWin32KeyedMutexTest(testCtx));
115 }
116
117 testGroup->addChild(createBasicTests(testCtx, type));
118 testGroup->addChild(new OperationTests(testCtx, type));
119 testGroup->addChild(createCrossInstanceSharingTest(testCtx, type));
120 testGroup->addChild(createSignalOrderTests(testCtx, type));
121
122 return testGroup.release();
123 }
124
125 } // anonymous
126
127 } // synchronization
128
createSynchronizationTests(tcu::TestContext & testCtx)129 tcu::TestCaseGroup* createSynchronizationTests (tcu::TestContext& testCtx)
130 {
131 using namespace synchronization;
132 return createTestsInternal(testCtx, SynchronizationType::LEGACY);
133 }
134
createSynchronization2Tests(tcu::TestContext & testCtx)135 tcu::TestCaseGroup* createSynchronization2Tests(tcu::TestContext& testCtx)
136 {
137 using namespace synchronization;
138 return createTestsInternal(testCtx, SynchronizationType::SYNCHRONIZATION2);
139 }
140
141 } // vkt
142