bdcdbb9b522b76000a31c3336cd6683e5c0051d3
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / synchronization / vktSynchronizationTests.cpp
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
52 tcu::TestCaseGroup* createBasicTests (tcu::TestContext& testCtx, SynchronizationType type)
53 {
54         de::MovePtr<tcu::TestCaseGroup> group(new tcu::TestCaseGroup(testCtx, "basic", ""));
55
56         if (type == SynchronizationType::LEGACY)
57         {
58                 group->addChild(createBasicEventTests(testCtx));
59                 group->addChild(createBasicFenceTests(testCtx));
60         }
61         else
62         {
63                 group->addChild(createSynchronization2BasicEventTests(testCtx));
64         }
65
66         group->addChild(createBasicBinarySemaphoreTests         (testCtx, type));
67         group->addChild(createBasicTimelineSemaphoreTests       (testCtx, type));
68
69         return group.release();
70 }
71
72 class OperationTests : public tcu::TestCaseGroup
73 {
74 public:
75         OperationTests (tcu::TestContext& testCtx, SynchronizationType type)
76                 : tcu::TestCaseGroup(testCtx, "op", "Synchronization of a memory-modifying operation")
77                 , m_type(type)
78         {
79         }
80
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
94 tcu::TestCaseGroup* createTestsInternal (tcu::TestContext& testCtx, SynchronizationType type)
95 {
96         const bool              isSynchronization2      (type == SynchronizationType::SYNCHRONIZATION2);
97         const char*             groupName[]                     { "synchronization",            "synchronization2" };
98         const char*             groupDescription[]      { "Synchronization tests",      "VK_KHR_synchronization2 tests" };
99
100         de::MovePtr<tcu::TestCaseGroup> testGroup(new tcu::TestCaseGroup(testCtx, groupName[isSynchronization2], groupDescription[isSynchronization2]));
101
102         if (isSynchronization2)
103         {
104                 testGroup->addChild(createSynchronization2SmokeTests(testCtx));
105                 testGroup->addChild(createSynchronization2TimelineSemaphoreTests(testCtx));
106 #ifndef CTS_USES_VULKANSC
107                 testGroup->addChild(createNoneStageTests(testCtx));
108 #endif // CTS_USES_VULKANSC
109                 testGroup->addChild(createImageLayoutTransitionTests(testCtx));
110         }
111         else // legacy synchronization
112         {
113                 testGroup->addChild(createSmokeTests(testCtx));
114                 testGroup->addChild(createTimelineSemaphoreTests(testCtx));
115
116                 testGroup->addChild(createInternallySynchronizedObjects(testCtx));
117 #ifndef CTS_USES_VULKANSC
118                 testGroup->addChild(createWin32KeyedMutexTest(testCtx));
119                 testGroup->addChild(createGlobalPriorityQueueTests(testCtx));
120 #endif // CTS_USES_VULKANSC
121         }
122
123         testGroup->addChild(createBasicTests(testCtx, type));
124         testGroup->addChild(new OperationTests(testCtx, type));
125 #ifndef CTS_USES_VULKANSC
126         testGroup->addChild(createCrossInstanceSharingTest(testCtx, type));
127         testGroup->addChild(createSignalOrderTests(testCtx, type));
128 #endif // CTS_USES_VULKANSC
129
130         return testGroup.release();
131 }
132
133 } // anonymous
134
135 } // synchronization
136
137 tcu::TestCaseGroup* createSynchronizationTests (tcu::TestContext& testCtx)
138 {
139         using namespace synchronization;
140         return createTestsInternal(testCtx, SynchronizationType::LEGACY);
141 }
142
143 tcu::TestCaseGroup* createSynchronization2Tests(tcu::TestContext& testCtx)
144 {
145         using namespace synchronization;
146         return createTestsInternal(testCtx, SynchronizationType::SYNCHRONIZATION2);
147 }
148
149 } // vkt