• 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 memory blit image tests
23  *//*--------------------------------------------------------------------*/
24 
25 #include "vktProtectedMemBlitImageTests.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 BlitImageTestInstance : public ProtectedTestInstance
57 {
58 public:
59 									BlitImageTestInstance	(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 BlitImageTestCase : public TestCase
75 {
76 public:
BlitImageTestCase(tcu::TestContext & testCtx,const std::string & name,vk::VkClearColorValue clearColorValue,ValidationData data,CmdBufferType cmdBufferType)77 								BlitImageTestCase			(tcu::TestContext&			testCtx,
78 															 const std::string&			name,
79 															 vk::VkClearColorValue		clearColorValue,
80 															 ValidationData				data,
81 															 CmdBufferType				cmdBufferType)
82 									: TestCase				(testCtx, name, "Clear and blit image.")
83 									, m_clearColorValue		(clearColorValue)
84 									, m_refData				(data)
85 									, m_cmdBufferType		(cmdBufferType)
86 								{
87 								}
88 
~BlitImageTestCase(void)89 	virtual						~BlitImageTestCase			(void) {}
createInstance(Context & ctx) const90 	virtual TestInstance*		createInstance				(Context& ctx) const
91 								{
92 									return new BlitImageTestInstance(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
105 								}
106 private:
107 	vk::VkClearColorValue		m_clearColorValue;
108 	ValidationData				m_refData;
109 	ImageValidator				m_validator;
110 	CmdBufferType				m_cmdBufferType;
111 };
112 
BlitImageTestInstance(Context & ctx,const vk::VkClearColorValue & clearColorValue,const ValidationData & refData,const ImageValidator & validator,const CmdBufferType cmdBufferType)113 BlitImageTestInstance::BlitImageTestInstance	(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 BlitImageTestInstance::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 	// Blit 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::VkOffset3D				imageOffset		=	{RENDER_WIDTH, RENDER_HEIGHT, 1};
289 	const vk::VkImageBlit				imageBlit		=
290 	 {
291 		imgSubResCopy,											// VkImageSubresourceLayers		srcSubresource;
292 		{
293 			nullOffset,
294 			imageOffset,
295 		},														// VkOffset3D					srcOffsets[2];
296 		imgSubResCopy,											// VkImageSubresourceLayers		dstSubresource;
297 		{
298 			nullOffset,
299 			imageOffset,
300 		},														// VkOffset3D					dstOffsets[2];
301 	 };
302 	vk.cmdBlitImage(targetCmdBuffer, **colorImageSrc, vk::VK_IMAGE_LAYOUT_GENERAL,
303 					**colorImage, vk::VK_IMAGE_LAYOUT_GENERAL, 1u, &imageBlit, vk::VK_FILTER_NEAREST);
304 
305 	// Image barrier to change accessMask to shader read bit for destination image.
306 	{
307 		const vk::VkImageMemoryBarrier	endImgBarrier	=
308 		{
309 			vk::VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,			// sType
310 			DE_NULL,											// pNext
311 			vk::VK_ACCESS_TRANSFER_WRITE_BIT,					// srcAccessMask
312 			vk::VK_ACCESS_SHADER_READ_BIT,						// dstAccessMask
313 			vk::VK_IMAGE_LAYOUT_GENERAL,						// oldLayout
314 			vk::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,		// newLayout
315 			queueFamilyIndex,									// srcQueueFamilyIndex
316 			queueFamilyIndex,									// dstQueueFamilyIndex
317 			**colorImage,										// image
318 			{
319 				vk::VK_IMAGE_ASPECT_COLOR_BIT,					// aspectMask
320 				0u,												// baseMipLevel
321 				1u,												// mipLevels
322 				0u,												// baseArraySlice
323 				1u,												// subresourceRange
324 			}
325 		};
326 		vk.cmdPipelineBarrier(targetCmdBuffer,
327 							  vk::VK_PIPELINE_STAGE_TRANSFER_BIT,		// srcStageMask
328 							  vk::VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,	// dstStageMask
329 							  (vk::VkDependencyFlags)0,
330 							  0, (const vk::VkMemoryBarrier*)DE_NULL,
331 							  0, (const vk::VkBufferMemoryBarrier*)DE_NULL,
332 							  1, &endImgBarrier);
333 	}
334 
335 	if (m_cmdBufferType == CMD_BUFFER_SECONDARY)
336 	{
337 		endCommandBuffer(vk, *secondaryCmdBuffer);
338 		vk.cmdExecuteCommands(*cmdBuffer, 1u, &secondaryCmdBuffer.get());
339 	}
340 
341 	endCommandBuffer(vk, *cmdBuffer);
342 
343 	// Submit command buffer
344 	const vk::Unique<vk::VkFence>	fence		(vk::createFence(vk, device));
345 	VK_CHECK(queueSubmit(ctx, PROTECTION_ENABLED, queue, *cmdBuffer, *fence, ~0ull));
346 
347 	// Log out test data
348 	ctx.getTestContext().getLog()
349 		<< tcu::TestLog::Message << "Color clear value: " << tcu::Vec4(m_clearColorValue.float32) << tcu::TestLog::EndMessage;
350 
351 	// Validate resulting image
352 	if (m_validator.validateImage(ctx, m_refData, **colorImage, m_imageFormat, vk::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL))
353 		return tcu::TestStatus::pass("Everything went OK");
354 	else
355 		return tcu::TestStatus::fail("Something went really wrong");
356 }
357 
createBlitImageTests(tcu::TestContext & testCtx,CmdBufferType cmdBufferType)358 tcu::TestCaseGroup*	createBlitImageTests (tcu::TestContext& testCtx, CmdBufferType cmdBufferType)
359 {
360 	struct {
361 		const vk::VkClearColorValue		clearColorValue;
362 		const ValidationData			data;
363 	} testData[] = {
364 		{	{ { 1.0f, 0.0f, 0.0f, 1.0f } },
365 			{
366 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
367 				  tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f), tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
368 				{ tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f),
369 				  tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), }
370 			}
371 		},
372 		{	{ { 0.0f, 1.0f, 0.0f, 1.0f } },
373 			{
374 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
375 				  tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f), tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
376 				{ tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f), tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f),
377 				  tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f), tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f), }
378 			}
379 		},
380 		{	{ { 0.0f, 0.0f, 1.0f, 1.0f } },
381 			{
382 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
383 				  tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f), tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
384 				{ tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f),
385 				  tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), }
386 			}
387 		},
388 		{	{ { 0.0f, 0.0f, 0.0f, 1.0f } },
389 			{
390 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
391 				  tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f), tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
392 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f),
393 				  tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), }
394 			}
395 		},
396 		{	{ { 1.0f, 0.0f, 0.0f, 1.0f } },
397 			{
398 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
399 				  tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f), tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
400 				{ tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f),
401 				  tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), }
402 			}
403 		},
404 		{	{ { 1.0f, 0.0f, 0.0f, 0.0f } },
405 			{
406 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
407 				  tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f), tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
408 				{ tcu::Vec4(1.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 0.0f, 0.0f, 0.0f),
409 				  tcu::Vec4(1.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 0.0f, 0.0f, 0.0f), }
410 			}
411 		},
412 		{	{ { 0.1f, 0.2f, 0.3f, 0.0f } },
413 			{
414 				{ tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
415 				  tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f), tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
416 				{ tcu::Vec4(0.1f, 0.2f, 0.3f, 0.0f), tcu::Vec4(0.1f, 0.2f, 0.3f, 0.0f),
417 				  tcu::Vec4(0.1f, 0.2f, 0.3f, 0.0f), tcu::Vec4(0.1f, 0.2f, 0.3f, 0.0f), }
418 			}
419 		},
420 	};
421 
422 	de::MovePtr<tcu::TestCaseGroup> blitStaticTests (new tcu::TestCaseGroup(testCtx, "static", "Blit Image Tests with static input"));
423 
424 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(testData); ++ndx)
425 	{
426 		const std::string name = "blit_" + de::toString(ndx + 1);
427 		blitStaticTests->addChild(new BlitImageTestCase(testCtx, name.c_str(), testData[ndx].clearColorValue, testData[ndx].data, cmdBufferType));
428 	}
429 
430 	/* Add a few randomized tests */
431 	de::MovePtr<tcu::TestCaseGroup>	blitRandomTests	(new tcu::TestCaseGroup(testCtx, "random", "Blit Image Tests with random input"));
432 	const int						testCount			= 10;
433 	de::Random						rnd					(testCtx.getCommandLine().getBaseSeed());
434 	for (int ndx = 0; ndx < testCount; ++ndx)
435 	{
436 		const std::string	name		= "blit_" + de::toString(ndx + 1);
437 		vk::VkClearValue	clearValue	= vk::makeClearValueColorVec4(tcu::randomVec4(rnd));
438 		const tcu::Vec4		refValue	(clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]);
439 		const tcu::Vec4		vec0		= tcu::randomVec4(rnd);
440 		const tcu::Vec4		vec1		= tcu::randomVec4(rnd);
441 		const tcu::Vec4		vec2		= tcu::randomVec4(rnd);
442 		const tcu::Vec4		vec3		= tcu::randomVec4(rnd);
443 
444 		ValidationData		data		=
445 		{
446 			{ vec0, vec1, vec2, vec3 },
447 			{ refValue, refValue, refValue, refValue }
448 		};
449 		blitRandomTests->addChild(new BlitImageTestCase(testCtx, name.c_str(), clearValue.color, data, cmdBufferType));
450 	}
451 
452 	std::string groupName = getCmdBufferTypeStr(cmdBufferType);
453 	std::string groupDesc = "Blit Image Tests with " + groupName + " command buffer";
454 	de::MovePtr<tcu::TestCaseGroup> blitTests (new tcu::TestCaseGroup(testCtx, groupName.c_str(), groupDesc.c_str()));
455 	blitTests->addChild(blitStaticTests.release());
456 	blitTests->addChild(blitRandomTests.release());
457 	return blitTests.release();
458 }
459 
460 } // anonymous
461 
createBlitImageTests(tcu::TestContext & testCtx)462 tcu::TestCaseGroup*	createBlitImageTests (tcu::TestContext& testCtx)
463 {
464 	de::MovePtr<tcu::TestCaseGroup> blitTests (new tcu::TestCaseGroup(testCtx, "blit", "Blit Image Tests"));
465 
466 	blitTests->addChild(createBlitImageTests(testCtx, CMD_BUFFER_PRIMARY));
467 	blitTests->addChild(createBlitImageTests(testCtx, CMD_BUFFER_SECONDARY));
468 
469 	return blitTests.release();
470 }
471 
472 } // ProtectedMem
473 } // vkt
474