• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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", "Synchronization of a memory-modifying operation")
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,VideoCodecOperationFlags videoCodecOperation)94 const std::pair<std::string, std::string> getGroupName (SynchronizationType type, VideoCodecOperationFlags videoCodecOperation)
95 {
96 	if (videoCodecOperation == 0)
97 	{
98 		const bool	isSynchronization2	(type == SynchronizationType::SYNCHRONIZATION2);
99 		const char*	groupName[]			{ "synchronization",		"synchronization2" };
100 		const char*	groupDescription[]	{ "Synchronization tests",	"VK_KHR_synchronization2 tests" };
101 
102 		return std::pair<std::string, std::string>(groupName[isSynchronization2], groupDescription[isSynchronization2]);
103 	}
104 
105 #ifndef CTS_USES_VULKANSC
106 	switch (videoCodecOperation)
107 	{
108 		case vk::VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_EXT:	return std::pair<std::string, std::string>("encode_h264", "");
109 		case vk::VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_EXT:	return std::pair<std::string, std::string>("encode_h265", "");
110 		case vk::VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR:	return std::pair<std::string, std::string>("decode_h264", "");
111 		case vk::VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR:	return std::pair<std::string, std::string>("decode_h265", "");
112 		default:												TCU_THROW(InternalError, "Unknown codec operation");
113 	}
114 #else
115 	TCU_THROW(InternalError, "Video support is not implemented in Vulkan SC");
116 #endif
117 }
118 
createTestsInternal(tcu::TestContext & testCtx,SynchronizationType type,VideoCodecOperationFlags videoCodecOperation)119 tcu::TestCaseGroup* createTestsInternal (tcu::TestContext& testCtx, SynchronizationType type, VideoCodecOperationFlags videoCodecOperation)
120 {
121 	const bool									isSynchronization2	(type == SynchronizationType::SYNCHRONIZATION2);
122 	const std::pair<std::string, std::string>	groupName			= getGroupName(type, videoCodecOperation);
123 
124 	de::MovePtr<tcu::TestCaseGroup> testGroup(new tcu::TestCaseGroup(testCtx, groupName.first.c_str(), groupName.second.c_str()));
125 
126 	if (videoCodecOperation == 0)
127 	{
128 		if (isSynchronization2)
129 		{
130 			testGroup->addChild(createSynchronization2SmokeTests(testCtx));
131 			testGroup->addChild(createSynchronization2TimelineSemaphoreTests(testCtx));
132 #ifndef CTS_USES_VULKANSC
133 			testGroup->addChild(createNoneStageTests(testCtx));
134 #endif // CTS_USES_VULKANSC
135 			testGroup->addChild(createImageLayoutTransitionTests(testCtx));
136 		}
137 		else // legacy synchronization
138 		{
139 			testGroup->addChild(createSmokeTests(testCtx));
140 			testGroup->addChild(createTimelineSemaphoreTests(testCtx));
141 
142 			testGroup->addChild(createInternallySynchronizedObjects(testCtx));
143 #ifndef CTS_USES_VULKANSC
144 			testGroup->addChild(createWin32KeyedMutexTest(testCtx));
145 			testGroup->addChild(createGlobalPriorityQueueTests(testCtx));
146 #endif // CTS_USES_VULKANSC
147 		}
148 	}
149 
150 	testGroup->addChild(createBasicTests(testCtx, type, videoCodecOperation));
151 
152 	if (videoCodecOperation == 0)
153 	{
154 		testGroup->addChild(new OperationTests(testCtx, type));
155 #ifndef CTS_USES_VULKANSC
156 		testGroup->addChild(createCrossInstanceSharingTest(testCtx, type));
157 		testGroup->addChild(createSignalOrderTests(testCtx, type));
158 #endif // CTS_USES_VULKANSC
159 	}
160 
161 	return testGroup.release();
162 }
163 } // anonymous
164 
165 } // synchronization
166 
createSynchronizationTests(tcu::TestContext & testCtx,synchronization::VideoCodecOperationFlags videoCodecOperation)167 tcu::TestCaseGroup* createSynchronizationTests (tcu::TestContext& testCtx, synchronization::VideoCodecOperationFlags videoCodecOperation)
168 {
169 	using namespace synchronization;
170 
171 	de::MovePtr<tcu::TestCaseGroup> testGroup	(createTestsInternal(testCtx, SynchronizationType::LEGACY, videoCodecOperation));
172 
173 	return testGroup.release();
174 }
175 
createSynchronization2Tests(tcu::TestContext & testCtx,synchronization::VideoCodecOperationFlags videoCodecOperation)176 tcu::TestCaseGroup* createSynchronization2Tests (tcu::TestContext& testCtx, synchronization::VideoCodecOperationFlags videoCodecOperation)
177 {
178 	using namespace synchronization;
179 
180 	de::MovePtr<tcu::TestCaseGroup> testGroup(createTestsInternal(testCtx, SynchronizationType::SYNCHRONIZATION2, videoCodecOperation));
181 
182 	return testGroup.release();
183 }
184 
185 } // vkt
186