• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2017 The Khronos Group Inc.
6  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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 Protected content copy image tests
23  *//*--------------------------------------------------------------------*/
24 
25 #include "vktProtectedMemCopyImageTests.hpp"
26 
27 #include "deRandom.hpp"
28 #include "tcuTestLog.hpp"
29 #include "tcuVector.hpp"
30 #include "tcuVectorUtil.hpp"
31 
32 #include "vkPrograms.hpp"
33 #include "vktTestCase.hpp"
34 #include "vktTestGroupUtil.hpp"
35 #include "vkTypeUtil.hpp"
36 #include "vkBuilderUtil.hpp"
37 #include "vkCmdUtil.hpp"
38 
39 #include "vktProtectedMemContext.hpp"
40 #include "vktProtectedMemUtils.hpp"
41 #include "vktProtectedMemImageValidator.hpp"
42 
43 namespace vkt
44 {
45 namespace ProtectedMem
46 {
47 
48 namespace
49 {
50 
51 enum {
52 	RENDER_WIDTH	= 128,
53 	RENDER_HEIGHT	= 128,
54 };
55 
56 class CopyImageTestInstance : public ProtectedTestInstance
57 {
58 public:
59 									CopyImageTestInstance	(Context&						ctx,
60 															 const vk::VkClearColorValue&	clearColorValue,
61 															 const ValidationData&			refData,
62 															 const ImageValidator&			validator,
63 															 const CmdBufferType			cmdBufferType);
64 virtual tcu::TestStatus				iterate					 (void);
65 
66 private:
67 	const vk::VkFormat				m_imageFormat;
68 	const vk::VkClearColorValue&	m_clearColorValue;
69 	const ValidationData&			m_refData;
70 	const ImageValidator&			m_validator;
71 	const CmdBufferType				m_cmdBufferType;
72 };
73 
74 class CopyImageTestCase : public TestCase
75 {
76 public:
CopyImageTestCase(tcu::TestContext & testCtx,const std::string & name,vk::VkClearColorValue clearColorValue,ValidationData data,CmdBufferType cmdBufferType)77 								CopyImageTestCase		(tcu::TestContext&			testCtx,
78 														 const std::string&			name,
79 														 vk::VkClearColorValue		clearColorValue,
80 														 ValidationData				data,
81 														 CmdBufferType				cmdBufferType)
82 									: TestCase			(testCtx, name, "Clear and copy image.")
83 									, m_clearColorValue	(clearColorValue)
84 									, m_refData			(data)
85 									, m_cmdBufferType	(cmdBufferType)
86 								{
87 								}
88 
~CopyImageTestCase(void)89 	virtual						~CopyImageTestCase		(void) {}
createInstance(Context & ctx) const90 	virtual TestInstance*		createInstance			(Context& ctx) const
91 								{
92 									return new CopyImageTestInstance(ctx, m_clearColorValue, m_refData, m_validator, m_cmdBufferType);
93 								}
initPrograms(vk::SourceCollections & programCollection) const94 	virtual void				initPrograms			(vk::SourceCollections& programCollection) const
95 								{
96 									m_validator.initPrograms(programCollection);
97 								}
checkSupport(Context & context) const98 	virtual void				checkSupport			(Context& context) const
99 								{
100 									checkProtectedQueueSupport(context);
101 #ifdef CTS_USES_VULKANSC
102 									if (m_cmdBufferType == CMD_BUFFER_SECONDARY && context.getDeviceVulkanSC10Properties().secondaryCommandBufferNullOrImagelessFramebuffer == VK_FALSE)
103 										TCU_THROW(NotSupportedError, "secondaryCommandBufferNullFramebuffer is not supported");
104 #endif // CTS_USES_VULKANSC
105 								}
106 private:
107 	vk::VkClearColorValue		m_clearColorValue;
108 	ValidationData				m_refData;
109 	ImageValidator				m_validator;
110 	CmdBufferType				m_cmdBufferType;
111 };
112 
CopyImageTestInstance(Context & ctx,const vk::VkClearColorValue & clearColorValue,const ValidationData & refData,const ImageValidator & validator,const CmdBufferType cmdBufferType)113 CopyImageTestInstance::CopyImageTestInstance	(Context&						ctx,
114 												 const vk::VkClearColorValue&	clearColorValue,
115 												 const ValidationData&			refData,
116 												 const ImageValidator&			validator,
117 												 const CmdBufferType			cmdBufferType)
118 	: ProtectedTestInstance		(ctx)
119 	, m_imageFormat				(vk::VK_FORMAT_R8G8B8A8_UNORM)
120 	, m_clearColorValue			(clearColorValue)
121 	, m_refData					(refData)
122 	, m_validator				(validator)
123 	, m_cmdBufferType			(cmdBufferType)
124 {
125 }
126 
iterate()127 tcu::TestStatus CopyImageTestInstance::iterate()
128 {
129 	ProtectedContext&					ctx					(m_protectedContext);
130 	const vk::DeviceInterface&			vk					= ctx.getDeviceInterface();
131 	const vk::VkDevice					device				= ctx.getDevice();
132 	const vk::VkQueue					queue				= ctx.getQueue();
133 	const deUint32						queueFamilyIndex	= ctx.getQueueFamilyIndex();
134 
135 	// Create images
136 	de::MovePtr<vk::ImageWithMemory>	colorImage			= createImage2D(ctx, PROTECTION_ENABLED, queueFamilyIndex,
137 																			RENDER_WIDTH, RENDER_HEIGHT,
138 																			m_imageFormat,
139 																			vk::VK_IMAGE_USAGE_SAMPLED_BIT
140 																			| vk::VK_IMAGE_USAGE_TRANSFER_DST_BIT);
141 	de::MovePtr<vk::ImageWithMemory>	colorImageSrc		= createImage2D(ctx, PROTECTION_ENABLED, queueFamilyIndex,
142 																			RENDER_WIDTH, RENDER_HEIGHT,
143 																			m_imageFormat,
144 																			vk::VK_IMAGE_USAGE_SAMPLED_BIT
145 																			| vk::VK_IMAGE_USAGE_TRANSFER_DST_BIT
146 																			| vk::VK_IMAGE_USAGE_TRANSFER_SRC_BIT);
147 
148 	vk::Unique<vk::VkPipelineLayout>	pipelineLayout		(createPipelineLayout(ctx, 0u, DE_NULL));
149 
150 	vk::Unique<vk::VkCommandPool>		cmdPool				(makeCommandPool(vk, device, PROTECTION_ENABLED, queueFamilyIndex));
151 	vk::Unique<vk::VkCommandBuffer>		cmdBuffer			(vk::allocateCommandBuffer(vk, device, *cmdPool, vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY));
152 	vk::Unique<vk::VkCommandBuffer>		secondaryCmdBuffer	(vk::allocateCommandBuffer(vk, device, *cmdPool, vk::VK_COMMAND_BUFFER_LEVEL_SECONDARY));
153 	vk::VkCommandBuffer					targetCmdBuffer		= (m_cmdBufferType == CMD_BUFFER_SECONDARY) ? *secondaryCmdBuffer : *cmdBuffer;
154 
155 	// Begin cmd buffer
156 	beginCommandBuffer(vk, *cmdBuffer);
157 
158 	if (m_cmdBufferType == CMD_BUFFER_SECONDARY)
159 	{
160 		// Begin secondary command buffer
161 		const vk::VkCommandBufferInheritanceInfo	secCmdBufInheritInfo	=
162 		{
163 			vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO,
164 			DE_NULL,
165 			(vk::VkRenderPass)0u,										// renderPass
166 			0u,															// subpass
167 			(vk::VkFramebuffer)0u,										// framebuffer
168 			VK_FALSE,													// occlusionQueryEnable
169 			(vk::VkQueryControlFlags)0u,								// queryFlags
170 			(vk::VkQueryPipelineStatisticFlags)0u,						// pipelineStatistics
171 		};
172 		beginSecondaryCommandBuffer(vk, *secondaryCmdBuffer, secCmdBufInheritInfo);
173 	}
174 
175 	// Start image barrier for source image.
176 	{
177 		const vk::VkImageMemoryBarrier	startImgBarrier		=
178 		{
179 			vk::VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,			// sType
180 			DE_NULL,											// pNext
181 			0,													// srcAccessMask
182 			vk::VK_ACCESS_TRANSFER_WRITE_BIT,					// dstAccessMask
183 			vk::VK_IMAGE_LAYOUT_UNDEFINED,						// oldLayout
184 			vk::VK_IMAGE_LAYOUT_GENERAL,						// newLayout
185 			queueFamilyIndex,									// srcQueueFamilyIndex
186 			queueFamilyIndex,									// dstQueueFamilyIndex
187 			**colorImageSrc,									// image
188 			{
189 				vk::VK_IMAGE_ASPECT_COLOR_BIT,					// aspectMask
190 				0u,												// baseMipLevel
191 				1u,												// mipLevels
192 				0u,												// baseArraySlice
193 				1u,												// subresourceRange
194 			}
195 		};
196 
197 		vk.cmdPipelineBarrier(targetCmdBuffer,								// commandBuffer
198 							  vk::VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,		// srcStageMask
199 							  vk::VK_PIPELINE_STAGE_TRANSFER_BIT,		    // dstStageMask
200 							  (vk::VkDependencyFlags)0,						// dependencyFlags
201 							  0, (const vk::VkMemoryBarrier*)DE_NULL,		// memoryBarrierCount, pMemoryBarriers
202 							  0, (const vk::VkBufferMemoryBarrier*)DE_NULL,	// bufferMemoryBarrierCount, pBufferMemoryBarriers
203 							  1, &startImgBarrier);							// imageMemoryBarrierCount, pImageMemoryBarriers
204 	}
205 
206 	// Image clear
207 	const vk::VkImageSubresourceRange subresourceRange =
208 	{
209 		vk::VK_IMAGE_ASPECT_COLOR_BIT,	// VkImageAspectFlags	aspectMask
210 		0u,								// uint32_t				baseMipLevel
211 		1u,								// uint32_t				levelCount
212 		0u,								// uint32_t				baseArrayLayer
213 		1u,								// uint32_t				layerCount
214 	};
215 	vk.cmdClearColorImage(targetCmdBuffer, **colorImageSrc, vk::VK_IMAGE_LAYOUT_GENERAL, &m_clearColorValue, 1, &subresourceRange);
216 
217 	// Image barrier to change accessMask to transfer read bit for source image.
218 	{
219 		const vk::VkImageMemoryBarrier initializeBarrier =
220 		{
221 			vk::VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,			// sType
222 			DE_NULL,											// pNext
223 			vk::VK_ACCESS_TRANSFER_WRITE_BIT,					// srcAccessMask
224 			vk::VK_ACCESS_TRANSFER_READ_BIT,					// dstAccessMask
225 			vk::VK_IMAGE_LAYOUT_GENERAL,						// oldLayout
226 			vk::VK_IMAGE_LAYOUT_GENERAL,						// newLayout
227 			queueFamilyIndex,									// srcQueueFamilyIndex
228 			queueFamilyIndex,									// dstQueueFamilyIndex
229 			**colorImageSrc,									// image
230 			{
231 				vk::VK_IMAGE_ASPECT_COLOR_BIT,					// aspectMask
232 				0u,												// baseMipLevel
233 				1u,												// mipLevels
234 				0u,												// baseArraySlice
235 				1u,												// subresourceRange
236 			}
237 		};
238 
239 		vk.cmdPipelineBarrier(targetCmdBuffer,
240 							  vk::VK_PIPELINE_STAGE_TRANSFER_BIT,	// srcStageMask
241 							  vk::VK_PIPELINE_STAGE_TRANSFER_BIT,	// dstStageMask
242 							  (vk::VkDependencyFlags)0,
243 							  0, (const vk::VkMemoryBarrier*)DE_NULL,
244 							  0, (const vk::VkBufferMemoryBarrier*)DE_NULL,
245 							  1, &initializeBarrier);
246 	}
247 
248 	// Image barrier for destination image.
249 	{
250 		const vk::VkImageMemoryBarrier	initializeBarrier	=
251 		{
252 			vk::VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,			// sType
253 			DE_NULL,											// pNext
254 			0,													// srcAccessMask
255 			vk::VK_ACCESS_TRANSFER_WRITE_BIT,					// dstAccessMask
256 			vk::VK_IMAGE_LAYOUT_UNDEFINED,						// oldLayout
257 			vk::VK_IMAGE_LAYOUT_GENERAL,						// newLayout
258 			queueFamilyIndex,									// srcQueueFamilyIndex
259 			queueFamilyIndex,									// dstQueueFamilyIndex
260 			**colorImage,										// image
261 			{
262 				vk::VK_IMAGE_ASPECT_COLOR_BIT,					// aspectMask
263 				0u,												// baseMipLevel
264 				1u,												// mipLevels
265 				0u,												// baseArraySlice
266 				1u,												// subresourceRange
267 			}
268 		};
269 
270 		vk.cmdPipelineBarrier(targetCmdBuffer,
271 							  vk::VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,	// srcStageMask
272 							  vk::VK_PIPELINE_STAGE_TRANSFER_BIT,		// dstStageMask
273 							  (vk::VkDependencyFlags)0,
274 							  0, (const vk::VkMemoryBarrier*)DE_NULL,
275 							  0, (const vk::VkBufferMemoryBarrier*)DE_NULL,
276 							  1, &initializeBarrier);
277 	}
278 
279 	// Copy image
280 	const vk::VkImageSubresourceLayers imgSubResCopy =
281 	{
282 		vk::VK_IMAGE_ASPECT_COLOR_BIT,			// VkImageAspectFlags		aspectMask;
283 		0u,										// deUint32					mipLevel;
284 		0u,										// deUint32					baseArrayLayer;
285 		1u,										// deUint32					layerCount;
286 	};
287 	const vk::VkOffset3D	nullOffset		= {0u, 0u, 0u};
288 	const vk::VkExtent3D	imageExtent		= {(deUint32)RENDER_WIDTH, (deUint32)RENDER_HEIGHT, 1u};
289 	const vk::VkImageCopy	copyImageRegion	=
290 	{
291 		imgSubResCopy,							// VkImageSubresourceCopy	srcSubresource;
292 		nullOffset,								// VkOffset3D				srcOffset;
293 		imgSubResCopy,							// VkImageSubresourceCopy	destSubresource;
294 		nullOffset,								// VkOffset3D				destOffset;
295 		imageExtent,							// VkExtent3D				extent;
296 
297 	};
298 	vk.cmdCopyImage(targetCmdBuffer,
299 					**colorImageSrc, vk::VK_IMAGE_LAYOUT_GENERAL,	// srcImageLayout
300 					**colorImage, vk::VK_IMAGE_LAYOUT_GENERAL,		// dstImageLayout
301 					1u, &copyImageRegion);
302 
303 	// Image barrier to change accessMask for destination image.
304 	{
305 		const vk::VkImageMemoryBarrier	endImgBarrier	=
306 		{
307 			vk::VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,			// sType
308 			DE_NULL,											// pNext
309 			vk::VK_ACCESS_TRANSFER_WRITE_BIT,					// srcAccessMask
310 			vk::VK_ACCESS_SHADER_READ_BIT,						// dstAccessMask
311 			vk::VK_IMAGE_LAYOUT_GENERAL,						// oldLayout
312 			vk::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,		// newLayout
313 			queueFamilyIndex,									// srcQueueFamilyIndex
314 			queueFamilyIndex,									// dstQueueFamilyIndex
315 			**colorImage,										// image
316 			{
317 				vk::VK_IMAGE_ASPECT_COLOR_BIT,					// aspectMask
318 				0u,												// baseMipLevel
319 				1u,												// mipLevels
320 				0u,												// baseArraySlice
321 				1u,												// subresourceRange
322 			}
323 		};
324 		vk.cmdPipelineBarrier(targetCmdBuffer,
325 							  vk::VK_PIPELINE_STAGE_TRANSFER_BIT,		// srcStageMask
326 							  vk::VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,	// dstStageMask
327 							  (vk::VkDependencyFlags)0,
328 							  0, (const vk::VkMemoryBarrier*)DE_NULL,
329 							  0, (const vk::VkBufferMemoryBarrier*)DE_NULL,
330 							  1, &endImgBarrier);
331 	}
332 
333 	if (m_cmdBufferType == CMD_BUFFER_SECONDARY)
334 	{
335 		endCommandBuffer(vk, *secondaryCmdBuffer);
336 		vk.cmdExecuteCommands(*cmdBuffer, 1u, &secondaryCmdBuffer.get());
337 	}
338 
339 	endCommandBuffer(vk, *cmdBuffer);
340 
341 	// Submit command buffer
342 	const vk::Unique<vk::VkFence>	fence		(vk::createFence(vk, device));
343 	VK_CHECK(queueSubmit(ctx, PROTECTION_ENABLED, queue, *cmdBuffer, *fence, ~0ull));
344 
345 	// Log out test data
346 	ctx.getTestContext().getLog()
347 			<< tcu::TestLog::Message << "Color clear value: " << tcu::Vec4(m_clearColorValue.float32) << tcu::TestLog::EndMessage;
348 
349 	// Validate resulting image
350 	if (m_validator.validateImage(ctx, m_refData, **colorImage, m_imageFormat, vk::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL))
351 		return tcu::TestStatus::pass("Everything went OK");
352 	else
353 		return tcu::TestStatus::fail("Something went really wrong");
354 }
355 
createCopyImageTests(tcu::TestContext & testCtx,CmdBufferType cmdBufferType)356 tcu::TestCaseGroup*	createCopyImageTests (tcu::TestContext& testCtx, CmdBufferType cmdBufferType)
357 {
358 	struct {
359 		const vk::VkClearColorValue		clearColorValue;
360 		const ValidationData			data;
361 	} testData[] = {
362 		{	{ { 1.0f, 0.0f, 0.0f, 1.0f } },
363 			{
364 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
365 				  tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f), tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
366 				{ tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f),
367 				  tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), }
368 			}
369 		},
370 		{	{ { 0.0f, 1.0f, 0.0f, 1.0f } },
371 			{
372 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
373 				  tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f), tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
374 				{ tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f), tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f),
375 				  tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f), tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f), }
376 			}
377 		},
378 		{	{ { 0.0f, 0.0f, 1.0f, 1.0f } },
379 			{
380 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
381 				  tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f), tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
382 				{ tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f),
383 				  tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), }
384 			}
385 		},
386 		{	{ { 0.0f, 0.0f, 0.0f, 1.0f } },
387 			{
388 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
389 				  tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f), tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
390 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f),
391 				  tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), }
392 			}
393 		},
394 		{	{ { 1.0f, 0.0f, 0.0f, 1.0f } },
395 			{
396 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
397 				  tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f), tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
398 				{ tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f),
399 				  tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), }
400 			}
401 		},
402 		{	{ { 1.0f, 0.0f, 0.0f, 0.0f } },
403 			{
404 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
405 				  tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f), tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
406 				{ tcu::Vec4(1.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 0.0f, 0.0f, 0.0f),
407 				  tcu::Vec4(1.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 0.0f, 0.0f, 0.0f), }
408 			}
409 		},
410 		{	{ { 0.1f, 0.2f, 0.3f, 0.0f } },
411 			{
412 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
413 				  tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f), tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
414 				{ tcu::Vec4(0.1f, 0.2f, 0.3f, 0.0f), tcu::Vec4(0.1f, 0.2f, 0.3f, 0.0f),
415 				  tcu::Vec4(0.1f, 0.2f, 0.3f, 0.0f), tcu::Vec4(0.1f, 0.2f, 0.3f, 0.0f), }
416 			}
417 		},
418 	};
419 
420 	de::MovePtr<tcu::TestCaseGroup> copyStaticTests	(new tcu::TestCaseGroup(testCtx, "static", "Copy Image Tests with static input"));
421 
422 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(testData); ++ndx)
423 	{
424 		const std::string name = "copy_" + de::toString(ndx + 1);
425 		copyStaticTests->addChild(new CopyImageTestCase(testCtx, name.c_str(), testData[ndx].clearColorValue, testData[ndx].data, cmdBufferType));
426 	}
427 
428 	/* Add a few randomized tests */
429 	de::MovePtr<tcu::TestCaseGroup>	copyRandomTests		(new tcu::TestCaseGroup(testCtx, "random", "Copy Image Tests with random input"));
430 	const int						testCount			= 10;
431 	de::Random						rnd					(testCtx.getCommandLine().getBaseSeed());
432 	for (int ndx = 0; ndx < testCount; ++ndx)
433 	{
434 		const std::string	name		= "copy_" + de::toString(ndx + 1);
435 		vk::VkClearValue	clearValue	= vk::makeClearValueColorVec4(tcu::randomVec4(rnd));
436 		const tcu::Vec4		refValue	(clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]);
437 		const tcu::Vec4		vec0		= tcu::randomVec4(rnd);
438 		const tcu::Vec4		vec1		= tcu::randomVec4(rnd);
439 		const tcu::Vec4		vec2		= tcu::randomVec4(rnd);
440 		const tcu::Vec4		vec3		= tcu::randomVec4(rnd);
441 
442 		ValidationData		data		=
443 		{
444 			{ vec0, vec1, vec2, vec3 },
445 			{ refValue, refValue, refValue, refValue }
446 		};
447 		copyRandomTests->addChild(new CopyImageTestCase(testCtx, name.c_str(), clearValue.color, data, cmdBufferType));
448 	}
449 
450 	std::string groupName = getCmdBufferTypeStr(cmdBufferType);
451 	std::string groupDesc = "Copy Image Tests with " + groupName + " command buffer";
452 	de::MovePtr<tcu::TestCaseGroup> copyTests (new tcu::TestCaseGroup(testCtx, groupName.c_str(), groupDesc.c_str()));
453 	copyTests->addChild(copyStaticTests.release());
454 	copyTests->addChild(copyRandomTests.release());
455 	return copyTests.release();
456 }
457 
458 } // anonymous
459 
createCopyImageTests(tcu::TestContext & testCtx)460 tcu::TestCaseGroup*	createCopyImageTests (tcu::TestContext& testCtx)
461 {
462 	de::MovePtr<tcu::TestCaseGroup> copyTests (new tcu::TestCaseGroup(testCtx, "copy", "Copy Image Tests"));
463 
464 	copyTests->addChild(createCopyImageTests(testCtx, CMD_BUFFER_PRIMARY));
465 	copyTests->addChild(createCopyImageTests(testCtx, CMD_BUFFER_SECONDARY));
466 
467 	return copyTests.release();
468 }
469 
470 } // ProtectedMem
471 } // vkt
472