1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------
2e5c31af7Sopenharmony_ci * Vulkan Conformance Tests
3e5c31af7Sopenharmony_ci * ------------------------
4e5c31af7Sopenharmony_ci *
5e5c31af7Sopenharmony_ci * Copyright (c) 2016 The Khronos Group Inc.
6e5c31af7Sopenharmony_ci * Copyright (c) 2016 Imagination Technologies Ltd.
7e5c31af7Sopenharmony_ci *
8e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
9e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License.
10e5c31af7Sopenharmony_ci * You may obtain a copy of the License at
11e5c31af7Sopenharmony_ci *
12e5c31af7Sopenharmony_ci *	  http://www.apache.org/licenses/LICENSE-2.0
13e5c31af7Sopenharmony_ci *
14e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
15e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
16e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and
18e5c31af7Sopenharmony_ci * limitations under the License.
19e5c31af7Sopenharmony_ci *
20e5c31af7Sopenharmony_ci *//*!
21e5c31af7Sopenharmony_ci * \file
22e5c31af7Sopenharmony_ci * \brief Robustness Utilities
23e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/
24e5c31af7Sopenharmony_ci
25e5c31af7Sopenharmony_ci#include "vktRobustnessUtil.hpp"
26e5c31af7Sopenharmony_ci#include "vktCustomInstancesDevices.hpp"
27e5c31af7Sopenharmony_ci#include "vkDefs.hpp"
28e5c31af7Sopenharmony_ci#include "vkImageUtil.hpp"
29e5c31af7Sopenharmony_ci#include "vkPrograms.hpp"
30e5c31af7Sopenharmony_ci#include "vkQueryUtil.hpp"
31e5c31af7Sopenharmony_ci#include "vkRefUtil.hpp"
32e5c31af7Sopenharmony_ci#include "vkTypeUtil.hpp"
33e5c31af7Sopenharmony_ci#include "vkCmdUtil.hpp"
34e5c31af7Sopenharmony_ci#include "vkObjUtil.hpp"
35e5c31af7Sopenharmony_ci#include "vkSafetyCriticalUtil.hpp"
36e5c31af7Sopenharmony_ci#include "tcuCommandLine.hpp"
37e5c31af7Sopenharmony_ci#include "vkDeviceUtil.hpp"
38e5c31af7Sopenharmony_ci#include "deMath.h"
39e5c31af7Sopenharmony_ci#include <iomanip>
40e5c31af7Sopenharmony_ci#include <limits>
41e5c31af7Sopenharmony_ci#include <sstream>
42e5c31af7Sopenharmony_ci
43e5c31af7Sopenharmony_cinamespace vkt
44e5c31af7Sopenharmony_ci{
45e5c31af7Sopenharmony_cinamespace robustness
46e5c31af7Sopenharmony_ci{
47e5c31af7Sopenharmony_ci
48e5c31af7Sopenharmony_ciusing namespace vk;
49e5c31af7Sopenharmony_ciusing std::vector;
50e5c31af7Sopenharmony_ciusing std::string;
51e5c31af7Sopenharmony_ci
52e5c31af7Sopenharmony_ciMove<VkDevice> createRobustBufferAccessDevice (Context& context, const VkPhysicalDeviceFeatures2* enabledFeatures2)
53e5c31af7Sopenharmony_ci{
54e5c31af7Sopenharmony_ci	const float queuePriority = 1.0f;
55e5c31af7Sopenharmony_ci
56e5c31af7Sopenharmony_ci	// Create a universal queue that supports graphics and compute
57e5c31af7Sopenharmony_ci	const VkDeviceQueueCreateInfo	queueParams =
58e5c31af7Sopenharmony_ci	{
59e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,	// VkStructureType				sType;
60e5c31af7Sopenharmony_ci		DE_NULL,									// const void*					pNext;
61e5c31af7Sopenharmony_ci		0u,											// VkDeviceQueueCreateFlags		flags;
62e5c31af7Sopenharmony_ci		context.getUniversalQueueFamilyIndex(),		// deUint32						queueFamilyIndex;
63e5c31af7Sopenharmony_ci		1u,											// deUint32						queueCount;
64e5c31af7Sopenharmony_ci		&queuePriority								// const float*					pQueuePriorities;
65e5c31af7Sopenharmony_ci	};
66e5c31af7Sopenharmony_ci
67e5c31af7Sopenharmony_ci	VkPhysicalDeviceFeatures enabledFeatures = context.getDeviceFeatures();
68e5c31af7Sopenharmony_ci	enabledFeatures.robustBufferAccess = true;
69e5c31af7Sopenharmony_ci
70e5c31af7Sopenharmony_ci	// \note Extensions in core are not explicitly enabled even though
71e5c31af7Sopenharmony_ci	//		 they are in the extension list advertised to tests.
72e5c31af7Sopenharmony_ci	const auto& extensionPtrs = context.getDeviceCreationExtensions();
73e5c31af7Sopenharmony_ci
74e5c31af7Sopenharmony_ci	void* pNext												= (void*)enabledFeatures2;
75e5c31af7Sopenharmony_ci#ifdef CTS_USES_VULKANSC
76e5c31af7Sopenharmony_ci	VkDeviceObjectReservationCreateInfo memReservationInfo	= context.getTestContext().getCommandLine().isSubProcess() ? context.getResourceInterface()->getStatMax() : resetDeviceObjectReservationCreateInfo();
77e5c31af7Sopenharmony_ci	memReservationInfo.pNext								= pNext;
78e5c31af7Sopenharmony_ci	pNext													= &memReservationInfo;
79e5c31af7Sopenharmony_ci
80e5c31af7Sopenharmony_ci	VkPhysicalDeviceVulkanSC10Features sc10Features			= createDefaultSC10Features();
81e5c31af7Sopenharmony_ci	sc10Features.pNext										= pNext;
82e5c31af7Sopenharmony_ci	pNext													= &sc10Features;
83e5c31af7Sopenharmony_ci
84e5c31af7Sopenharmony_ci	VkPipelineCacheCreateInfo			pcCI;
85e5c31af7Sopenharmony_ci	std::vector<VkPipelinePoolSize>		poolSizes;
86e5c31af7Sopenharmony_ci	if (context.getTestContext().getCommandLine().isSubProcess())
87e5c31af7Sopenharmony_ci	{
88e5c31af7Sopenharmony_ci		if (context.getResourceInterface()->getCacheDataSize() > 0)
89e5c31af7Sopenharmony_ci		{
90e5c31af7Sopenharmony_ci			pcCI =
91e5c31af7Sopenharmony_ci			{
92e5c31af7Sopenharmony_ci				VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO,		// VkStructureType				sType;
93e5c31af7Sopenharmony_ci				DE_NULL,											// const void*					pNext;
94e5c31af7Sopenharmony_ci				VK_PIPELINE_CACHE_CREATE_READ_ONLY_BIT |
95e5c31af7Sopenharmony_ci					VK_PIPELINE_CACHE_CREATE_USE_APPLICATION_STORAGE_BIT,	// VkPipelineCacheCreateFlags	flags;
96e5c31af7Sopenharmony_ci				context.getResourceInterface()->getCacheDataSize(),	// deUintptr					initialDataSize;
97e5c31af7Sopenharmony_ci				context.getResourceInterface()->getCacheData()		// const void*					pInitialData;
98e5c31af7Sopenharmony_ci			};
99e5c31af7Sopenharmony_ci			memReservationInfo.pipelineCacheCreateInfoCount		= 1;
100e5c31af7Sopenharmony_ci			memReservationInfo.pPipelineCacheCreateInfos		= &pcCI;
101e5c31af7Sopenharmony_ci		}
102e5c31af7Sopenharmony_ci
103e5c31af7Sopenharmony_ci		poolSizes							= context.getResourceInterface()->getPipelinePoolSizes();
104e5c31af7Sopenharmony_ci		if (!poolSizes.empty())
105e5c31af7Sopenharmony_ci		{
106e5c31af7Sopenharmony_ci			memReservationInfo.pipelinePoolSizeCount			= deUint32(poolSizes.size());
107e5c31af7Sopenharmony_ci			memReservationInfo.pPipelinePoolSizes				= poolSizes.data();
108e5c31af7Sopenharmony_ci		}
109e5c31af7Sopenharmony_ci	}
110e5c31af7Sopenharmony_ci#endif
111e5c31af7Sopenharmony_ci
112e5c31af7Sopenharmony_ci	const VkDeviceCreateInfo		deviceParams =
113e5c31af7Sopenharmony_ci	{
114e5c31af7Sopenharmony_ci		VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,	// VkStructureType					sType;
115e5c31af7Sopenharmony_ci		pNext,									// const void*						pNext;
116e5c31af7Sopenharmony_ci		0u,										// VkDeviceCreateFlags				flags;
117e5c31af7Sopenharmony_ci		1u,										// deUint32							queueCreateInfoCount;
118e5c31af7Sopenharmony_ci		&queueParams,							// const VkDeviceQueueCreateInfo*	pQueueCreateInfos;
119e5c31af7Sopenharmony_ci		0u,										// deUint32							enabledLayerCount;
120e5c31af7Sopenharmony_ci		nullptr,								// const char* const*				ppEnabledLayerNames;
121e5c31af7Sopenharmony_ci		de::sizeU32(extensionPtrs),				// deUint32							enabledExtensionCount;
122e5c31af7Sopenharmony_ci		de::dataOrNull(extensionPtrs),			// const char* const*				ppEnabledExtensionNames;
123e5c31af7Sopenharmony_ci		enabledFeatures2 ? nullptr : &enabledFeatures	// const VkPhysicalDeviceFeatures*	pEnabledFeatures;
124e5c31af7Sopenharmony_ci	};
125e5c31af7Sopenharmony_ci
126e5c31af7Sopenharmony_ci	// We are creating a custom device with a potentially large amount of extensions and features enabled, using the default device
127e5c31af7Sopenharmony_ci	// as a reference. Some implementations may only enable certain device extensions if some instance extensions are enabled, so in
128e5c31af7Sopenharmony_ci	// this case it's important to reuse the context instance when creating the device.
129e5c31af7Sopenharmony_ci	const auto&	vki				= context.getInstanceInterface();
130e5c31af7Sopenharmony_ci	const auto	instance		= context.getInstance();
131e5c31af7Sopenharmony_ci	const auto	physicalDevice	= chooseDevice(vki, instance, context.getTestContext().getCommandLine());
132e5c31af7Sopenharmony_ci
133e5c31af7Sopenharmony_ci	return createCustomDevice(context.getTestContext().getCommandLine().isValidationEnabled(), context.getPlatformInterface(),
134e5c31af7Sopenharmony_ci							  instance, vki, physicalDevice, &deviceParams);
135e5c31af7Sopenharmony_ci}
136e5c31af7Sopenharmony_ci
137e5c31af7Sopenharmony_cibool areEqual (float a, float b)
138e5c31af7Sopenharmony_ci{
139e5c31af7Sopenharmony_ci	return deFloatAbs(a - b) <= 0.001f;
140e5c31af7Sopenharmony_ci}
141e5c31af7Sopenharmony_ci
142e5c31af7Sopenharmony_cibool isValueZero (const void* valuePtr, size_t valueSizeInBytes)
143e5c31af7Sopenharmony_ci{
144e5c31af7Sopenharmony_ci	const deUint8* bytePtr = reinterpret_cast<const deUint8*>(valuePtr);
145e5c31af7Sopenharmony_ci
146e5c31af7Sopenharmony_ci	for (size_t i = 0; i < valueSizeInBytes; i++)
147e5c31af7Sopenharmony_ci	{
148e5c31af7Sopenharmony_ci		if (bytePtr[i] != 0)
149e5c31af7Sopenharmony_ci			return false;
150e5c31af7Sopenharmony_ci	}
151e5c31af7Sopenharmony_ci
152e5c31af7Sopenharmony_ci	return true;
153e5c31af7Sopenharmony_ci}
154e5c31af7Sopenharmony_ci
155e5c31af7Sopenharmony_cibool isValueWithinBuffer (const void* buffer, VkDeviceSize bufferSize, const void* valuePtr, size_t valueSizeInBytes)
156e5c31af7Sopenharmony_ci{
157e5c31af7Sopenharmony_ci	const deUint8* byteBuffer = reinterpret_cast<const deUint8*>(buffer);
158e5c31af7Sopenharmony_ci
159e5c31af7Sopenharmony_ci	if (bufferSize < ((VkDeviceSize)valueSizeInBytes))
160e5c31af7Sopenharmony_ci		return false;
161e5c31af7Sopenharmony_ci
162e5c31af7Sopenharmony_ci	for (VkDeviceSize i = 0; i <= (bufferSize - valueSizeInBytes); i++)
163e5c31af7Sopenharmony_ci	{
164e5c31af7Sopenharmony_ci		if (!deMemCmp(&byteBuffer[i], valuePtr, valueSizeInBytes))
165e5c31af7Sopenharmony_ci			return true;
166e5c31af7Sopenharmony_ci	}
167e5c31af7Sopenharmony_ci
168e5c31af7Sopenharmony_ci	return false;
169e5c31af7Sopenharmony_ci}
170e5c31af7Sopenharmony_ci
171e5c31af7Sopenharmony_cibool isValueWithinBufferOrZero (const void* buffer, VkDeviceSize bufferSize, const void* valuePtr, size_t valueSizeInBytes)
172e5c31af7Sopenharmony_ci{
173e5c31af7Sopenharmony_ci	return isValueWithinBuffer(buffer, bufferSize, valuePtr, valueSizeInBytes) || isValueZero(valuePtr, valueSizeInBytes);
174e5c31af7Sopenharmony_ci}
175e5c31af7Sopenharmony_ci
176e5c31af7Sopenharmony_citemplate<typename T>
177e5c31af7Sopenharmony_cibool verifyVec4IntegerValues (const void* vecPtr)
178e5c31af7Sopenharmony_ci{
179e5c31af7Sopenharmony_ci	const T Tzero	= T{0};
180e5c31af7Sopenharmony_ci	const T Tone	= T{1};
181e5c31af7Sopenharmony_ci	const T	Tmax	= std::numeric_limits<T>::max();
182e5c31af7Sopenharmony_ci
183e5c31af7Sopenharmony_ci	T values[4];
184e5c31af7Sopenharmony_ci	deMemcpy(values, vecPtr, 4*sizeof(T));
185e5c31af7Sopenharmony_ci	return (values[0] == Tzero && values[1] == Tzero && values[2] == Tzero &&
186e5c31af7Sopenharmony_ci		    (values[3] == Tzero || values[3] == Tone || values[3] == Tmax));
187e5c31af7Sopenharmony_ci}
188e5c31af7Sopenharmony_ci
189e5c31af7Sopenharmony_cibool verifyOutOfBoundsVec4 (const void* vecPtr, VkFormat bufferFormat)
190e5c31af7Sopenharmony_ci{
191e5c31af7Sopenharmony_ci	if (isUintFormat(bufferFormat))
192e5c31af7Sopenharmony_ci	{
193e5c31af7Sopenharmony_ci		if (bufferFormat == VK_FORMAT_R64_UINT)
194e5c31af7Sopenharmony_ci			return verifyVec4IntegerValues<deUint64>(vecPtr);
195e5c31af7Sopenharmony_ci		return verifyVec4IntegerValues<deUint32>(vecPtr);
196e5c31af7Sopenharmony_ci	}
197e5c31af7Sopenharmony_ci	else if (isIntFormat(bufferFormat))
198e5c31af7Sopenharmony_ci	{
199e5c31af7Sopenharmony_ci		if (bufferFormat == VK_FORMAT_R64_SINT)
200e5c31af7Sopenharmony_ci			return verifyVec4IntegerValues<deInt64>(vecPtr);
201e5c31af7Sopenharmony_ci		return verifyVec4IntegerValues<deInt32>(vecPtr);
202e5c31af7Sopenharmony_ci	}
203e5c31af7Sopenharmony_ci	else if (isFloatFormat(bufferFormat))
204e5c31af7Sopenharmony_ci	{
205e5c31af7Sopenharmony_ci		const float* data = (float*)vecPtr;
206e5c31af7Sopenharmony_ci
207e5c31af7Sopenharmony_ci		return areEqual(data[0], 0.0f)
208e5c31af7Sopenharmony_ci			&& areEqual(data[1], 0.0f)
209e5c31af7Sopenharmony_ci			&& areEqual(data[2], 0.0f)
210e5c31af7Sopenharmony_ci			&& (areEqual(data[3], 0.0f) || areEqual(data[3], 1.0f));
211e5c31af7Sopenharmony_ci	}
212e5c31af7Sopenharmony_ci	else if (bufferFormat == VK_FORMAT_A2B10G10R10_UNORM_PACK32)
213e5c31af7Sopenharmony_ci	{
214e5c31af7Sopenharmony_ci		return *((deUint32*)vecPtr) == 0xc0000000u;
215e5c31af7Sopenharmony_ci	}
216e5c31af7Sopenharmony_ci
217e5c31af7Sopenharmony_ci	DE_ASSERT(false);
218e5c31af7Sopenharmony_ci	return false;
219e5c31af7Sopenharmony_ci}
220e5c31af7Sopenharmony_ci
221e5c31af7Sopenharmony_civoid populateBufferWithTestValues (void* buffer, VkDeviceSize size, VkFormat format)
222e5c31af7Sopenharmony_ci{
223e5c31af7Sopenharmony_ci	// Assign a sequence of 32-bit values
224e5c31af7Sopenharmony_ci	for (VkDeviceSize scalarNdx = 0; scalarNdx < size / 4; scalarNdx++)
225e5c31af7Sopenharmony_ci	{
226e5c31af7Sopenharmony_ci		const deUint32 valueIndex = (deUint32)(2 + scalarNdx); // Do not use 0 or 1
227e5c31af7Sopenharmony_ci
228e5c31af7Sopenharmony_ci		if (isUintFormat(format))
229e5c31af7Sopenharmony_ci		{
230e5c31af7Sopenharmony_ci			reinterpret_cast<deUint32*>(buffer)[scalarNdx] = valueIndex;
231e5c31af7Sopenharmony_ci		}
232e5c31af7Sopenharmony_ci		else if (isIntFormat(format))
233e5c31af7Sopenharmony_ci		{
234e5c31af7Sopenharmony_ci			reinterpret_cast<deInt32*>(buffer)[scalarNdx] = -deInt32(valueIndex);
235e5c31af7Sopenharmony_ci		}
236e5c31af7Sopenharmony_ci		else if (isFloatFormat(format))
237e5c31af7Sopenharmony_ci		{
238e5c31af7Sopenharmony_ci			reinterpret_cast<float*>(buffer)[scalarNdx] = float(valueIndex);
239e5c31af7Sopenharmony_ci		}
240e5c31af7Sopenharmony_ci		else if (format == VK_FORMAT_A2B10G10R10_UNORM_PACK32)
241e5c31af7Sopenharmony_ci		{
242e5c31af7Sopenharmony_ci			const deUint32	r	= ((valueIndex + 0) & ((2u << 10) - 1u));
243e5c31af7Sopenharmony_ci			const deUint32	g	= ((valueIndex + 1) & ((2u << 10) - 1u));
244e5c31af7Sopenharmony_ci			const deUint32	b	= ((valueIndex + 2) & ((2u << 10) - 1u));
245e5c31af7Sopenharmony_ci			const deUint32	a	= ((valueIndex + 0) & ((2u << 2) - 1u));
246e5c31af7Sopenharmony_ci
247e5c31af7Sopenharmony_ci			reinterpret_cast<deUint32*>(buffer)[scalarNdx] = (a << 30) | (b << 20) | (g << 10) | r;
248e5c31af7Sopenharmony_ci		}
249e5c31af7Sopenharmony_ci		else
250e5c31af7Sopenharmony_ci		{
251e5c31af7Sopenharmony_ci			DE_ASSERT(false);
252e5c31af7Sopenharmony_ci		}
253e5c31af7Sopenharmony_ci	}
254e5c31af7Sopenharmony_ci}
255e5c31af7Sopenharmony_ci
256e5c31af7Sopenharmony_civoid logValue (std::ostringstream& logMsg, const void* valuePtr, VkFormat valueFormat, size_t valueSize)
257e5c31af7Sopenharmony_ci{
258e5c31af7Sopenharmony_ci	if (isUintFormat(valueFormat))
259e5c31af7Sopenharmony_ci	{
260e5c31af7Sopenharmony_ci		logMsg << *reinterpret_cast<const deUint32*>(valuePtr);
261e5c31af7Sopenharmony_ci	}
262e5c31af7Sopenharmony_ci	else if (isIntFormat(valueFormat))
263e5c31af7Sopenharmony_ci	{
264e5c31af7Sopenharmony_ci		logMsg << *reinterpret_cast<const deInt32*>(valuePtr);
265e5c31af7Sopenharmony_ci	}
266e5c31af7Sopenharmony_ci	else if (isFloatFormat(valueFormat))
267e5c31af7Sopenharmony_ci	{
268e5c31af7Sopenharmony_ci		logMsg << *reinterpret_cast<const float*>(valuePtr);
269e5c31af7Sopenharmony_ci	}
270e5c31af7Sopenharmony_ci	else
271e5c31af7Sopenharmony_ci	{
272e5c31af7Sopenharmony_ci		const deUint8*				bytePtr		= reinterpret_cast<const deUint8*>(valuePtr);
273e5c31af7Sopenharmony_ci		const std::ios::fmtflags	streamFlags	= logMsg.flags();
274e5c31af7Sopenharmony_ci
275e5c31af7Sopenharmony_ci		logMsg << std::hex;
276e5c31af7Sopenharmony_ci		for (size_t i = 0; i < valueSize; i++)
277e5c31af7Sopenharmony_ci		{
278e5c31af7Sopenharmony_ci			logMsg << " " << (deUint32)bytePtr[i];
279e5c31af7Sopenharmony_ci		}
280e5c31af7Sopenharmony_ci		logMsg.flags(streamFlags);
281e5c31af7Sopenharmony_ci	}
282e5c31af7Sopenharmony_ci}
283e5c31af7Sopenharmony_ci
284e5c31af7Sopenharmony_ci// TestEnvironment
285e5c31af7Sopenharmony_ci
286e5c31af7Sopenharmony_ciTestEnvironment::TestEnvironment (Context&					context,
287e5c31af7Sopenharmony_ci								  const DeviceInterface&	vk,
288e5c31af7Sopenharmony_ci								  VkDevice					device,
289e5c31af7Sopenharmony_ci								  VkDescriptorSetLayout		descriptorSetLayout,
290e5c31af7Sopenharmony_ci								  VkDescriptorSet			descriptorSet)
291e5c31af7Sopenharmony_ci	: m_context				(context)
292e5c31af7Sopenharmony_ci	, m_device				(device)
293e5c31af7Sopenharmony_ci	, m_descriptorSetLayout	(descriptorSetLayout)
294e5c31af7Sopenharmony_ci	, m_descriptorSet		(descriptorSet)
295e5c31af7Sopenharmony_ci{
296e5c31af7Sopenharmony_ci	// Create command pool
297e5c31af7Sopenharmony_ci	{
298e5c31af7Sopenharmony_ci		const VkCommandPoolCreateInfo commandPoolParams =
299e5c31af7Sopenharmony_ci		{
300e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,		// VkStructureType			sType;
301e5c31af7Sopenharmony_ci			DE_NULL,										// const void*				pNext;
302e5c31af7Sopenharmony_ci			VK_COMMAND_POOL_CREATE_TRANSIENT_BIT,			// VkCommandPoolCreateFlags	flags;
303e5c31af7Sopenharmony_ci			context.getUniversalQueueFamilyIndex()			// deUint32					queueFamilyIndex;
304e5c31af7Sopenharmony_ci		};
305e5c31af7Sopenharmony_ci
306e5c31af7Sopenharmony_ci		m_commandPool = createCommandPool(vk, m_device, &commandPoolParams);
307e5c31af7Sopenharmony_ci	}
308e5c31af7Sopenharmony_ci
309e5c31af7Sopenharmony_ci	// Create command buffer
310e5c31af7Sopenharmony_ci	{
311e5c31af7Sopenharmony_ci		const VkCommandBufferAllocateInfo commandBufferAllocateInfo =
312e5c31af7Sopenharmony_ci		{
313e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,	// VkStructureType			sType;
314e5c31af7Sopenharmony_ci			DE_NULL,										// const void*				pNext;
315e5c31af7Sopenharmony_ci			*m_commandPool,										// VkCommandPool			commandPool;
316e5c31af7Sopenharmony_ci			VK_COMMAND_BUFFER_LEVEL_PRIMARY,				// VkCommandBufferLevel		level;
317e5c31af7Sopenharmony_ci			1u,												// deUint32					bufferCount;
318e5c31af7Sopenharmony_ci		};
319e5c31af7Sopenharmony_ci
320e5c31af7Sopenharmony_ci		m_commandBuffer = allocateCommandBuffer(vk, m_device, &commandBufferAllocateInfo);
321e5c31af7Sopenharmony_ci	}
322e5c31af7Sopenharmony_ci}
323e5c31af7Sopenharmony_ci
324e5c31af7Sopenharmony_ciVkCommandBuffer TestEnvironment::getCommandBuffer (void)
325e5c31af7Sopenharmony_ci{
326e5c31af7Sopenharmony_ci	return *m_commandBuffer;
327e5c31af7Sopenharmony_ci}
328e5c31af7Sopenharmony_ci
329e5c31af7Sopenharmony_ci// GraphicsEnvironment
330e5c31af7Sopenharmony_ci
331e5c31af7Sopenharmony_ciGraphicsEnvironment::GraphicsEnvironment (Context&					context,
332e5c31af7Sopenharmony_ci										  const DeviceInterface&	vk,
333e5c31af7Sopenharmony_ci										  VkDevice					device,
334e5c31af7Sopenharmony_ci										  VkDescriptorSetLayout		descriptorSetLayout,
335e5c31af7Sopenharmony_ci										  VkDescriptorSet			descriptorSet,
336e5c31af7Sopenharmony_ci										  const VertexBindings&		vertexBindings,
337e5c31af7Sopenharmony_ci										  const VertexAttributes&	vertexAttributes,
338e5c31af7Sopenharmony_ci										  const DrawConfig&			drawConfig,
339e5c31af7Sopenharmony_ci										  bool						testPipelineRobustness)
340e5c31af7Sopenharmony_ci
341e5c31af7Sopenharmony_ci	: TestEnvironment		(context, vk, device, descriptorSetLayout, descriptorSet)
342e5c31af7Sopenharmony_ci	, m_renderSize			(16, 16)
343e5c31af7Sopenharmony_ci	, m_colorFormat			(VK_FORMAT_R8G8B8A8_UNORM)
344e5c31af7Sopenharmony_ci{
345e5c31af7Sopenharmony_ci	const auto&					vki						= context.getInstanceInterface();
346e5c31af7Sopenharmony_ci	const auto					instance				= context.getInstance();
347e5c31af7Sopenharmony_ci	const deUint32				queueFamilyIndex		= context.getUniversalQueueFamilyIndex();
348e5c31af7Sopenharmony_ci	const VkComponentMapping	componentMappingRGBA	= { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
349e5c31af7Sopenharmony_ci	const VkPhysicalDevice		physicalDevice			= chooseDevice(vki, instance, context.getTestContext().getCommandLine());
350e5c31af7Sopenharmony_ci	SimpleAllocator				memAlloc				(vk, m_device, getPhysicalDeviceMemoryProperties(vki, physicalDevice));
351e5c31af7Sopenharmony_ci
352e5c31af7Sopenharmony_ci	// Create color image and view
353e5c31af7Sopenharmony_ci	{
354e5c31af7Sopenharmony_ci		const VkImageCreateInfo colorImageParams =
355e5c31af7Sopenharmony_ci		{
356e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,										// VkStructureType			sType;
357e5c31af7Sopenharmony_ci			DE_NULL,																	// const void*				pNext;
358e5c31af7Sopenharmony_ci			0u,																			// VkImageCreateFlags		flags;
359e5c31af7Sopenharmony_ci			VK_IMAGE_TYPE_2D,															// VkImageType				imageType;
360e5c31af7Sopenharmony_ci			m_colorFormat,																// VkFormat					format;
361e5c31af7Sopenharmony_ci			{ (deUint32)m_renderSize.x(), (deUint32)m_renderSize.y(), 1u },				// VkExtent3D				extent;
362e5c31af7Sopenharmony_ci			1u,																			// deUint32					mipLevels;
363e5c31af7Sopenharmony_ci			1u,																			// deUint32					arrayLayers;
364e5c31af7Sopenharmony_ci			VK_SAMPLE_COUNT_1_BIT,														// VkSampleCountFlagBits	samples;
365e5c31af7Sopenharmony_ci			VK_IMAGE_TILING_OPTIMAL,													// VkImageTiling			tiling;
366e5c31af7Sopenharmony_ci			VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT,		// VkImageUsageFlags		usage;
367e5c31af7Sopenharmony_ci			VK_SHARING_MODE_EXCLUSIVE,													// VkSharingMode			sharingMode;
368e5c31af7Sopenharmony_ci			1u,																			// deUint32					queueFamilyIndexCount;
369e5c31af7Sopenharmony_ci			&queueFamilyIndex,															// const deUint32*			pQueueFamilyIndices;
370e5c31af7Sopenharmony_ci			VK_IMAGE_LAYOUT_UNDEFINED													// VkImageLayout			initialLayout;
371e5c31af7Sopenharmony_ci		};
372e5c31af7Sopenharmony_ci
373e5c31af7Sopenharmony_ci		m_colorImage			= createImage(vk, m_device, &colorImageParams);
374e5c31af7Sopenharmony_ci		m_colorImageAlloc		= memAlloc.allocate(getImageMemoryRequirements(vk, m_device, *m_colorImage), MemoryRequirement::Any);
375e5c31af7Sopenharmony_ci		VK_CHECK(vk.bindImageMemory(m_device, *m_colorImage, m_colorImageAlloc->getMemory(), m_colorImageAlloc->getOffset()));
376e5c31af7Sopenharmony_ci
377e5c31af7Sopenharmony_ci		const VkImageViewCreateInfo colorAttachmentViewParams =
378e5c31af7Sopenharmony_ci		{
379e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,			// VkStructureType			sType;
380e5c31af7Sopenharmony_ci			DE_NULL,											// const void*				pNext;
381e5c31af7Sopenharmony_ci			0u,													// VkImageViewCreateFlags	flags;
382e5c31af7Sopenharmony_ci			*m_colorImage,										// VkImage					image;
383e5c31af7Sopenharmony_ci			VK_IMAGE_VIEW_TYPE_2D,								// VkImageViewType			viewType;
384e5c31af7Sopenharmony_ci			m_colorFormat,										// VkFormat					format;
385e5c31af7Sopenharmony_ci			componentMappingRGBA,								// VkComponentMapping		components;
386e5c31af7Sopenharmony_ci			{ VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u }		// VkImageSubresourceRange	subresourceRange;
387e5c31af7Sopenharmony_ci		};
388e5c31af7Sopenharmony_ci
389e5c31af7Sopenharmony_ci		m_colorAttachmentView = createImageView(vk, m_device, &colorAttachmentViewParams);
390e5c31af7Sopenharmony_ci	}
391e5c31af7Sopenharmony_ci
392e5c31af7Sopenharmony_ci	// Create render pass
393e5c31af7Sopenharmony_ci	m_renderPass = makeRenderPass(vk, m_device, m_colorFormat);
394e5c31af7Sopenharmony_ci
395e5c31af7Sopenharmony_ci	// Create framebuffer
396e5c31af7Sopenharmony_ci	{
397e5c31af7Sopenharmony_ci		const VkFramebufferCreateInfo framebufferParams =
398e5c31af7Sopenharmony_ci		{
399e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,			// VkStructureType			sType;
400e5c31af7Sopenharmony_ci			DE_NULL,											// const void*				pNext;
401e5c31af7Sopenharmony_ci			0u,													// VkFramebufferCreateFlags	flags;
402e5c31af7Sopenharmony_ci			*m_renderPass,										// VkRenderPass				renderPass;
403e5c31af7Sopenharmony_ci			1u,													// deUint32					attachmentCount;
404e5c31af7Sopenharmony_ci			&m_colorAttachmentView.get(),						// const VkImageView*		pAttachments;
405e5c31af7Sopenharmony_ci			(deUint32)m_renderSize.x(),							// deUint32					width;
406e5c31af7Sopenharmony_ci			(deUint32)m_renderSize.y(),							// deUint32					height;
407e5c31af7Sopenharmony_ci			1u													// deUint32					layers;
408e5c31af7Sopenharmony_ci		};
409e5c31af7Sopenharmony_ci
410e5c31af7Sopenharmony_ci		m_framebuffer = createFramebuffer(vk, m_device, &framebufferParams);
411e5c31af7Sopenharmony_ci	}
412e5c31af7Sopenharmony_ci
413e5c31af7Sopenharmony_ci	// Create pipeline layout
414e5c31af7Sopenharmony_ci	{
415e5c31af7Sopenharmony_ci		const VkPipelineLayoutCreateInfo pipelineLayoutParams =
416e5c31af7Sopenharmony_ci		{
417e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,		// VkStructureType				sType;
418e5c31af7Sopenharmony_ci			DE_NULL,											// const void*					pNext;
419e5c31af7Sopenharmony_ci			0u,													// VkPipelineLayoutCreateFlags	flags;
420e5c31af7Sopenharmony_ci			1u,													// deUint32						setLayoutCount;
421e5c31af7Sopenharmony_ci			&m_descriptorSetLayout,								// const VkDescriptorSetLayout*	pSetLayouts;
422e5c31af7Sopenharmony_ci			0u,													// deUint32						pushConstantRangeCount;
423e5c31af7Sopenharmony_ci			DE_NULL												// const VkPushConstantRange*	pPushConstantRanges;
424e5c31af7Sopenharmony_ci		};
425e5c31af7Sopenharmony_ci
426e5c31af7Sopenharmony_ci		m_pipelineLayout = createPipelineLayout(vk, m_device, &pipelineLayoutParams);
427e5c31af7Sopenharmony_ci	}
428e5c31af7Sopenharmony_ci
429e5c31af7Sopenharmony_ci	m_vertexShaderModule	= createShaderModule(vk, m_device, m_context.getBinaryCollection().get("vertex"), 0);
430e5c31af7Sopenharmony_ci	m_fragmentShaderModule	= createShaderModule(vk, m_device, m_context.getBinaryCollection().get("fragment"), 0);
431e5c31af7Sopenharmony_ci
432e5c31af7Sopenharmony_ci	// Create pipeline
433e5c31af7Sopenharmony_ci	{
434e5c31af7Sopenharmony_ci		const VkPipelineVertexInputStateCreateInfo vertexInputStateParams =
435e5c31af7Sopenharmony_ci		{
436e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,		// VkStructureType							sType;
437e5c31af7Sopenharmony_ci			DE_NULL,														// const void*								pNext;
438e5c31af7Sopenharmony_ci			0u,																// VkPipelineVertexInputStateCreateFlags	flags;
439e5c31af7Sopenharmony_ci			(deUint32)vertexBindings.size(),								// deUint32									vertexBindingDescriptionCount;
440e5c31af7Sopenharmony_ci			vertexBindings.data(),											// const VkVertexInputBindingDescription*	pVertexBindingDescriptions;
441e5c31af7Sopenharmony_ci			(deUint32)vertexAttributes.size(),								// deUint32									vertexAttributeDescriptionCount;
442e5c31af7Sopenharmony_ci			vertexAttributes.data()											// const VkVertexInputAttributeDescription*	pVertexAttributeDescriptions;
443e5c31af7Sopenharmony_ci		};
444e5c31af7Sopenharmony_ci
445e5c31af7Sopenharmony_ci		const std::vector<VkViewport>	viewports	(1, makeViewport(m_renderSize));
446e5c31af7Sopenharmony_ci		const std::vector<VkRect2D>		scissors	(1, makeRect2D(m_renderSize));
447e5c31af7Sopenharmony_ci
448e5c31af7Sopenharmony_ci		const void* pNext = DE_NULL;
449e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
450e5c31af7Sopenharmony_ci		VkPipelineRobustnessCreateInfoEXT pipelineRobustnessInfo = initVulkanStructure();
451e5c31af7Sopenharmony_ci
452e5c31af7Sopenharmony_ci		if (testPipelineRobustness)
453e5c31af7Sopenharmony_ci		{
454e5c31af7Sopenharmony_ci			pipelineRobustnessInfo.storageBuffers	= VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_EXT;
455e5c31af7Sopenharmony_ci			pipelineRobustnessInfo.uniformBuffers	= VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_EXT;
456e5c31af7Sopenharmony_ci			pipelineRobustnessInfo.vertexInputs		= VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_EXT;
457e5c31af7Sopenharmony_ci			pipelineRobustnessInfo.images			= VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_DISABLED_EXT;
458e5c31af7Sopenharmony_ci			pNext									= &pipelineRobustnessInfo;
459e5c31af7Sopenharmony_ci		}
460e5c31af7Sopenharmony_ci#else
461e5c31af7Sopenharmony_ci		DE_UNREF(testPipelineRobustness);
462e5c31af7Sopenharmony_ci#endif
463e5c31af7Sopenharmony_ci
464e5c31af7Sopenharmony_ci		m_graphicsPipeline = makeGraphicsPipeline(vk,															// const DeviceInterface&                        vk
465e5c31af7Sopenharmony_ci												  m_device,														// const VkDevice                                device
466e5c31af7Sopenharmony_ci												  *m_pipelineLayout,											// const VkPipelineLayout                        pipelineLayout
467e5c31af7Sopenharmony_ci												  *m_vertexShaderModule,										// const VkShaderModule                          vertexShaderModule
468e5c31af7Sopenharmony_ci												  DE_NULL,														// const VkShaderModule                          tessellationControlShaderModule
469e5c31af7Sopenharmony_ci												  DE_NULL,														// const VkShaderModule                          tessellationEvalShaderModule
470e5c31af7Sopenharmony_ci												  DE_NULL,														// const VkShaderModule                          geometryShaderModule
471e5c31af7Sopenharmony_ci												  *m_fragmentShaderModule,										// const VkShaderModule                          fragmentShaderModule
472e5c31af7Sopenharmony_ci												  *m_renderPass,												// const VkRenderPass                            renderPass
473e5c31af7Sopenharmony_ci												  viewports,													// const std::vector<VkViewport>&                viewports
474e5c31af7Sopenharmony_ci												  scissors,														// const std::vector<VkRect2D>&                  scissors
475e5c31af7Sopenharmony_ci												  VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,							// const VkPrimitiveTopology                     topology
476e5c31af7Sopenharmony_ci												  0u,															// const deUint32                                subpass
477e5c31af7Sopenharmony_ci												  0u,															// const deUint32                                patchControlPoints
478e5c31af7Sopenharmony_ci												  &vertexInputStateParams,										// const VkPipelineVertexInputStateCreateInfo*   vertexInputStateCreateInfo
479e5c31af7Sopenharmony_ci												  DE_NULL,														// const VkPipelineRasterizationStateCreateInfo*	rasterizationStateCreateInfo
480e5c31af7Sopenharmony_ci												  DE_NULL,														// const VkPipelineMultisampleStateCreateInfo*		multisampleStateCreateInfo
481e5c31af7Sopenharmony_ci												  DE_NULL,														// const VkPipelineDepthStencilStateCreateInfo*		depthStencilStateCreateInfo
482e5c31af7Sopenharmony_ci												  DE_NULL,														// const VkPipelineColorBlendStateCreateInfo*		colorBlendStateCreateInfo
483e5c31af7Sopenharmony_ci												  DE_NULL,														// const VkPipelineDynamicStateCreateInfo*			dynamicStateCreateInfo
484e5c31af7Sopenharmony_ci												  pNext);														// void* pNext
485e5c31af7Sopenharmony_ci	}
486e5c31af7Sopenharmony_ci
487e5c31af7Sopenharmony_ci	// Record commands
488e5c31af7Sopenharmony_ci	{
489e5c31af7Sopenharmony_ci		const VkImageMemoryBarrier imageLayoutBarrier =
490e5c31af7Sopenharmony_ci		{
491e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,					// VkStructureType			sType;
492e5c31af7Sopenharmony_ci			DE_NULL,												// const void*				pNext;
493e5c31af7Sopenharmony_ci			(VkAccessFlags)0,										// VkAccessFlags			srcAccessMask;
494e5c31af7Sopenharmony_ci			VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,					// VkAccessFlags			dstAccessMask;
495e5c31af7Sopenharmony_ci			VK_IMAGE_LAYOUT_UNDEFINED,								// VkImageLayout			oldLayout;
496e5c31af7Sopenharmony_ci			VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,				// VkImageLayout			newLayout;
497e5c31af7Sopenharmony_ci			VK_QUEUE_FAMILY_IGNORED,								// uint32_t					srcQueueFamilyIndex;
498e5c31af7Sopenharmony_ci			VK_QUEUE_FAMILY_IGNORED,								// uint32_t					dstQueueFamilyIndex;
499e5c31af7Sopenharmony_ci			*m_colorImage,											// VkImage					image;
500e5c31af7Sopenharmony_ci			{ VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u }			// VkImageSubresourceRange	subresourceRange;
501e5c31af7Sopenharmony_ci		};
502e5c31af7Sopenharmony_ci
503e5c31af7Sopenharmony_ci		beginCommandBuffer(vk, *m_commandBuffer, 0u);
504e5c31af7Sopenharmony_ci		{
505e5c31af7Sopenharmony_ci			vk.cmdPipelineBarrier(*m_commandBuffer,
506e5c31af7Sopenharmony_ci								  VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
507e5c31af7Sopenharmony_ci								  VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
508e5c31af7Sopenharmony_ci								  (VkDependencyFlags)0,
509e5c31af7Sopenharmony_ci								  0u, DE_NULL,
510e5c31af7Sopenharmony_ci								  0u, DE_NULL,
511e5c31af7Sopenharmony_ci								  1u, &imageLayoutBarrier);
512e5c31af7Sopenharmony_ci
513e5c31af7Sopenharmony_ci			beginRenderPass(vk, *m_commandBuffer, *m_renderPass, *m_framebuffer, makeRect2D(0, 0, m_renderSize.x(), m_renderSize.y()), tcu::Vec4(0.0f));
514e5c31af7Sopenharmony_ci			{
515e5c31af7Sopenharmony_ci				const std::vector<VkDeviceSize> vertexBufferOffsets(drawConfig.vertexBuffers.size(), 0ull);
516e5c31af7Sopenharmony_ci
517e5c31af7Sopenharmony_ci				vk.cmdBindPipeline(*m_commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_graphicsPipeline);
518e5c31af7Sopenharmony_ci				vk.cmdBindDescriptorSets(*m_commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_pipelineLayout, 0, 1, &m_descriptorSet, 0, DE_NULL);
519e5c31af7Sopenharmony_ci				vk.cmdBindVertexBuffers(*m_commandBuffer, 0, (deUint32)drawConfig.vertexBuffers.size(), drawConfig.vertexBuffers.data(), vertexBufferOffsets.data());
520e5c31af7Sopenharmony_ci
521e5c31af7Sopenharmony_ci				if (drawConfig.indexBuffer == DE_NULL || drawConfig.indexCount == 0)
522e5c31af7Sopenharmony_ci				{
523e5c31af7Sopenharmony_ci					vk.cmdDraw(*m_commandBuffer, drawConfig.vertexCount, drawConfig.instanceCount, 0, 0);
524e5c31af7Sopenharmony_ci				}
525e5c31af7Sopenharmony_ci				else
526e5c31af7Sopenharmony_ci				{
527e5c31af7Sopenharmony_ci					vk.cmdBindIndexBuffer(*m_commandBuffer, drawConfig.indexBuffer, 0, VK_INDEX_TYPE_UINT32);
528e5c31af7Sopenharmony_ci					vk.cmdDrawIndexed(*m_commandBuffer, drawConfig.indexCount, drawConfig.instanceCount, 0, 0, 0);
529e5c31af7Sopenharmony_ci				}
530e5c31af7Sopenharmony_ci			}
531e5c31af7Sopenharmony_ci			endRenderPass(vk, *m_commandBuffer);
532e5c31af7Sopenharmony_ci		}
533e5c31af7Sopenharmony_ci		endCommandBuffer(vk, *m_commandBuffer);
534e5c31af7Sopenharmony_ci	}
535e5c31af7Sopenharmony_ci}
536e5c31af7Sopenharmony_ci
537e5c31af7Sopenharmony_ci// ComputeEnvironment
538e5c31af7Sopenharmony_ci
539e5c31af7Sopenharmony_ciComputeEnvironment::ComputeEnvironment (Context&					context,
540e5c31af7Sopenharmony_ci										const DeviceInterface&		vk,
541e5c31af7Sopenharmony_ci										VkDevice					device,
542e5c31af7Sopenharmony_ci										VkDescriptorSetLayout		descriptorSetLayout,
543e5c31af7Sopenharmony_ci										VkDescriptorSet				descriptorSet,
544e5c31af7Sopenharmony_ci										bool						testPipelineRobustness)
545e5c31af7Sopenharmony_ci
546e5c31af7Sopenharmony_ci	: TestEnvironment	(context, vk, device, descriptorSetLayout, descriptorSet)
547e5c31af7Sopenharmony_ci{
548e5c31af7Sopenharmony_ci	// Create pipeline layout
549e5c31af7Sopenharmony_ci	{
550e5c31af7Sopenharmony_ci		const VkPipelineLayoutCreateInfo pipelineLayoutParams =
551e5c31af7Sopenharmony_ci		{
552e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,			// VkStructureType					sType;
553e5c31af7Sopenharmony_ci			DE_NULL,												// const void*						pNext;
554e5c31af7Sopenharmony_ci			0u,														// VkPipelineLayoutCreateFlags		flags;
555e5c31af7Sopenharmony_ci			1u,														// deUint32							setLayoutCount;
556e5c31af7Sopenharmony_ci			&m_descriptorSetLayout,									// const VkDescriptorSetLayout*		pSetLayouts;
557e5c31af7Sopenharmony_ci			0u,														// deUint32							pushConstantRangeCount;
558e5c31af7Sopenharmony_ci			DE_NULL													// const VkPushConstantRange*		pPushConstantRanges;
559e5c31af7Sopenharmony_ci		};
560e5c31af7Sopenharmony_ci
561e5c31af7Sopenharmony_ci		m_pipelineLayout = createPipelineLayout(vk, m_device, &pipelineLayoutParams);
562e5c31af7Sopenharmony_ci	}
563e5c31af7Sopenharmony_ci
564e5c31af7Sopenharmony_ci	// Create compute pipeline
565e5c31af7Sopenharmony_ci	{
566e5c31af7Sopenharmony_ci		m_computeShaderModule = createShaderModule(vk, m_device, m_context.getBinaryCollection().get("compute"), 0);
567e5c31af7Sopenharmony_ci
568e5c31af7Sopenharmony_ci		const VkPipelineShaderStageCreateInfo computeStageParams =
569e5c31af7Sopenharmony_ci		{
570e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,	// VkStructureType						sType;
571e5c31af7Sopenharmony_ci			DE_NULL,												// const void*							pNext;
572e5c31af7Sopenharmony_ci			0u,														// VkPipelineShaderStageCreateFlags		flags;
573e5c31af7Sopenharmony_ci			VK_SHADER_STAGE_COMPUTE_BIT,							// VkShaderStageFlagBits				stage;
574e5c31af7Sopenharmony_ci			*m_computeShaderModule,									// VkShaderModule						module;
575e5c31af7Sopenharmony_ci			"main",													// const char*							pName;
576e5c31af7Sopenharmony_ci			DE_NULL,												// const VkSpecializationInfo*			pSpecializationInfo;
577e5c31af7Sopenharmony_ci		};
578e5c31af7Sopenharmony_ci
579e5c31af7Sopenharmony_ci		const void* pNext = DE_NULL;
580e5c31af7Sopenharmony_ci#ifndef CTS_USES_VULKANSC
581e5c31af7Sopenharmony_ci		VkPipelineRobustnessCreateInfoEXT pipelineRobustnessInfo = initVulkanStructure();
582e5c31af7Sopenharmony_ci
583e5c31af7Sopenharmony_ci		if (testPipelineRobustness)
584e5c31af7Sopenharmony_ci		{
585e5c31af7Sopenharmony_ci			pipelineRobustnessInfo.storageBuffers	= VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_EXT;
586e5c31af7Sopenharmony_ci			pipelineRobustnessInfo.uniformBuffers	= VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_EXT;
587e5c31af7Sopenharmony_ci			pipelineRobustnessInfo.vertexInputs		= VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT;
588e5c31af7Sopenharmony_ci			pipelineRobustnessInfo.images			= VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_DISABLED_EXT;
589e5c31af7Sopenharmony_ci			pNext									= &pipelineRobustnessInfo;
590e5c31af7Sopenharmony_ci		}
591e5c31af7Sopenharmony_ci#else
592e5c31af7Sopenharmony_ci		DE_UNREF(testPipelineRobustness);
593e5c31af7Sopenharmony_ci#endif
594e5c31af7Sopenharmony_ci
595e5c31af7Sopenharmony_ci		const VkComputePipelineCreateInfo computePipelineParams =
596e5c31af7Sopenharmony_ci		{
597e5c31af7Sopenharmony_ci			VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,				// VkStructureType						sType;
598e5c31af7Sopenharmony_ci			pNext,														// const void*							pNext;
599e5c31af7Sopenharmony_ci			0u,															// VkPipelineCreateFlags				flags;
600e5c31af7Sopenharmony_ci			computeStageParams,											// VkPipelineShaderStageCreateInfo		stage;
601e5c31af7Sopenharmony_ci			*m_pipelineLayout,											// VkPipelineLayout						layout;
602e5c31af7Sopenharmony_ci			DE_NULL,													// VkPipeline							basePipelineHandle;
603e5c31af7Sopenharmony_ci			0u															// deInt32								basePipelineIndex;
604e5c31af7Sopenharmony_ci		};
605e5c31af7Sopenharmony_ci
606e5c31af7Sopenharmony_ci		m_computePipeline = createComputePipeline(vk, m_device, DE_NULL, &computePipelineParams);
607e5c31af7Sopenharmony_ci	}
608e5c31af7Sopenharmony_ci
609e5c31af7Sopenharmony_ci	// Record commands
610e5c31af7Sopenharmony_ci	{
611e5c31af7Sopenharmony_ci		beginCommandBuffer(vk, *m_commandBuffer, 0u);
612e5c31af7Sopenharmony_ci		vk.cmdBindPipeline(*m_commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *m_computePipeline);
613e5c31af7Sopenharmony_ci		vk.cmdBindDescriptorSets(*m_commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *m_pipelineLayout, 0, 1, &m_descriptorSet, 0, DE_NULL);
614e5c31af7Sopenharmony_ci		vk.cmdDispatch(*m_commandBuffer, 32, 32, 1);
615e5c31af7Sopenharmony_ci		endCommandBuffer(vk, *m_commandBuffer);
616e5c31af7Sopenharmony_ci	}
617e5c31af7Sopenharmony_ci}
618e5c31af7Sopenharmony_ci
619e5c31af7Sopenharmony_ci} // robustness
620e5c31af7Sopenharmony_ci} // vkt
621