1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------
2e5c31af7Sopenharmony_ci * Vulkan Conformance Tests
3e5c31af7Sopenharmony_ci * ------------------------
4e5c31af7Sopenharmony_ci *
5e5c31af7Sopenharmony_ci * Copyright (c) 2023 LunarG, Inc.
6e5c31af7Sopenharmony_ci * Copyright (c) 2023 Nintendo
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 Shader Object API Tests
23e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/
24e5c31af7Sopenharmony_ci
25e5c31af7Sopenharmony_ci#include "tcuDefs.hpp"
26e5c31af7Sopenharmony_ci#include "tcuTestCase.hpp"
27e5c31af7Sopenharmony_ci#include "deUniquePtr.hpp"
28e5c31af7Sopenharmony_ci#include "tcuTestCase.hpp"
29e5c31af7Sopenharmony_ci#include "vktTestCase.hpp"
30e5c31af7Sopenharmony_ci#include "vkQueryUtil.hpp"
31e5c31af7Sopenharmony_ci#include "vktCustomInstancesDevices.hpp"
32e5c31af7Sopenharmony_ci#include "tcuCommandLine.hpp"
33e5c31af7Sopenharmony_ci
34e5c31af7Sopenharmony_cinamespace vkt
35e5c31af7Sopenharmony_ci{
36e5c31af7Sopenharmony_cinamespace ShaderObject
37e5c31af7Sopenharmony_ci{
38e5c31af7Sopenharmony_ci
39e5c31af7Sopenharmony_cinamespace
40e5c31af7Sopenharmony_ci{
41e5c31af7Sopenharmony_ci
42e5c31af7Sopenharmony_cienum ShaderObjectApiTest {
43e5c31af7Sopenharmony_ci	EXT_DISCARD_RECTANGLES = 0,
44e5c31af7Sopenharmony_ci	NV_SCISSOR_EXCLUSIVE,
45e5c31af7Sopenharmony_ci	KHR_DYNAMIC_RENDERING,
46e5c31af7Sopenharmony_ci	SHADER_BINARY_UUID,
47e5c31af7Sopenharmony_ci};
48e5c31af7Sopenharmony_ci
49e5c31af7Sopenharmony_ciclass ShaderObjectApiInstance : public vkt::TestInstance
50e5c31af7Sopenharmony_ci{
51e5c31af7Sopenharmony_cipublic:
52e5c31af7Sopenharmony_ci						ShaderObjectApiInstance		(Context& context)
53e5c31af7Sopenharmony_ci							: vkt::TestInstance (context)
54e5c31af7Sopenharmony_ci							{}
55e5c31af7Sopenharmony_ci	virtual				~ShaderObjectApiInstance	(void) {}
56e5c31af7Sopenharmony_ci
57e5c31af7Sopenharmony_ci	tcu::TestStatus		iterate						(void) override;
58e5c31af7Sopenharmony_ci};
59e5c31af7Sopenharmony_ci
60e5c31af7Sopenharmony_citcu::TestStatus ShaderObjectApiInstance::iterate (void)
61e5c31af7Sopenharmony_ci{
62e5c31af7Sopenharmony_ci	const vk::InstanceInterface&			vki				= m_context.getInstanceInterface();
63e5c31af7Sopenharmony_ci	const vk::PlatformInterface&			vkp				= m_context.getPlatformInterface();
64e5c31af7Sopenharmony_ci	const auto								instance		= m_context.getInstance();
65e5c31af7Sopenharmony_ci	const auto								physicalDevice	= m_context.getPhysicalDevice();
66e5c31af7Sopenharmony_ci	vk::VkPhysicalDeviceFeatures2			deviceFeatures	= vk::initVulkanStructure();
67e5c31af7Sopenharmony_ci
68e5c31af7Sopenharmony_ci	vki.getPhysicalDeviceFeatures2(physicalDevice, &deviceFeatures);
69e5c31af7Sopenharmony_ci
70e5c31af7Sopenharmony_ci	const auto								queuePriority	= 1.0f;
71e5c31af7Sopenharmony_ci	const vk::VkDeviceQueueCreateInfo		queueInfo
72e5c31af7Sopenharmony_ci	{
73e5c31af7Sopenharmony_ci		vk::VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,		//	VkStructureType					sType;
74e5c31af7Sopenharmony_ci		nullptr,											//	const void*						pNext;
75e5c31af7Sopenharmony_ci		0u,													//	VkDeviceQueueCreateFlags		flags;
76e5c31af7Sopenharmony_ci		m_context.getUniversalQueueFamilyIndex(),			//	deUint32						queueFamilyIndex;
77e5c31af7Sopenharmony_ci		1u,													//	deUint32						queueCount;
78e5c31af7Sopenharmony_ci		&queuePriority,										//	const float*					pQueuePriorities;
79e5c31af7Sopenharmony_ci	};
80e5c31af7Sopenharmony_ci
81e5c31af7Sopenharmony_ci	std::vector<const char*>				extensions		= { "VK_EXT_shader_object" };
82e5c31af7Sopenharmony_ci
83e5c31af7Sopenharmony_ci	vk::VkPhysicalDeviceShaderObjectFeaturesEXT shaderObjectFeaturesEXT	= vk::initVulkanStructure();
84e5c31af7Sopenharmony_ci	vk::VkPhysicalDeviceFeatures2				features2				= vk::initVulkanStructure(&shaderObjectFeaturesEXT);
85e5c31af7Sopenharmony_ci	vki.getPhysicalDeviceFeatures2(physicalDevice, &features2);
86e5c31af7Sopenharmony_ci
87e5c31af7Sopenharmony_ci	const vk::VkDeviceCreateInfo			deviceInfo
88e5c31af7Sopenharmony_ci	{
89e5c31af7Sopenharmony_ci		vk::VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,			//	VkStructureType					sType;
90e5c31af7Sopenharmony_ci		&features2,											//	const void*						pNext;
91e5c31af7Sopenharmony_ci		0u,													//	VkDeviceCreateFlags				flags;
92e5c31af7Sopenharmony_ci		1u,													//	deUint32						queueCreateInfoCount;
93e5c31af7Sopenharmony_ci		&queueInfo,											//	const VkDeviceQueueCreateInfo*	pQueueCreateInfos;
94e5c31af7Sopenharmony_ci		0u,													//	deUint32						enabledLayerCount;
95e5c31af7Sopenharmony_ci		nullptr,											//	const char* const*				ppEnabledLayerNames;
96e5c31af7Sopenharmony_ci		(deUint32)extensions.size(),						//	deUint32						enabledExtensionCount;
97e5c31af7Sopenharmony_ci		extensions.data(),									//	const char* const*				ppEnabledExtensionNames;
98e5c31af7Sopenharmony_ci		DE_NULL,											//	const VkPhysicalDeviceFeatures*	pEnabledFeatures;
99e5c31af7Sopenharmony_ci	};
100e5c31af7Sopenharmony_ci
101e5c31af7Sopenharmony_ci	const auto								device			= createCustomDevice(m_context.getTestContext().getCommandLine().isValidationEnabled(), vkp, instance, vki, physicalDevice, &deviceInfo);
102e5c31af7Sopenharmony_ci
103e5c31af7Sopenharmony_ci	de::MovePtr<vk::DeviceDriver>			vkd				(new vk::DeviceDriver(vkp, instance, device.get(), m_context.getUsedApiVersion()));
104e5c31af7Sopenharmony_ci	const auto&								vk				= *vkd.get();
105e5c31af7Sopenharmony_ci
106e5c31af7Sopenharmony_ci	const std::vector<std::string> functions = {
107e5c31af7Sopenharmony_ci		// VK_EXT_extended_dynamic_state
108e5c31af7Sopenharmony_ci		"vkCmdBindVertexBuffers2EXT",
109e5c31af7Sopenharmony_ci		"vkCmdSetCullModeEXT",
110e5c31af7Sopenharmony_ci		"vkCmdSetDepthBoundsTestEnableEXT",
111e5c31af7Sopenharmony_ci		"vkCmdSetDepthCompareOpEXT",
112e5c31af7Sopenharmony_ci		"vkCmdSetDepthTestEnableEXT",
113e5c31af7Sopenharmony_ci		"vkCmdSetDepthWriteEnableEXT",
114e5c31af7Sopenharmony_ci		"vkCmdSetFrontFaceEXT",
115e5c31af7Sopenharmony_ci		"vkCmdSetPrimitiveTopologyEXT",
116e5c31af7Sopenharmony_ci		"vkCmdSetScissorWithCountEXT",
117e5c31af7Sopenharmony_ci		"vkCmdSetStencilOpEXT",
118e5c31af7Sopenharmony_ci		"vkCmdSetStencilTestEnableEXT",
119e5c31af7Sopenharmony_ci		"vkCmdSetViewportWithCountEXT",
120e5c31af7Sopenharmony_ci		// VK_EXT_extended_dynamic_state2
121e5c31af7Sopenharmony_ci		"vkCmdSetDepthBiasEnableEXT",
122e5c31af7Sopenharmony_ci		"vkCmdSetLogicOpEXT",
123e5c31af7Sopenharmony_ci		"vkCmdSetPatchControlPointsEXT",
124e5c31af7Sopenharmony_ci		"vkCmdSetPrimitiveRestartEnableEXT",
125e5c31af7Sopenharmony_ci		"vkCmdSetRasterizerDiscardEnableEXT",
126e5c31af7Sopenharmony_ci		// VK_EXT_extended_dynamic_state3
127e5c31af7Sopenharmony_ci		"vkCmdSetAlphaToCoverageEnableEXT",
128e5c31af7Sopenharmony_ci		"vkCmdSetAlphaToOneEnableEXT",
129e5c31af7Sopenharmony_ci		"vkCmdSetColorBlendAdvancedEXT",
130e5c31af7Sopenharmony_ci		"vkCmdSetColorBlendEnableEXT",
131e5c31af7Sopenharmony_ci		"vkCmdSetColorBlendEquationEXT",
132e5c31af7Sopenharmony_ci		"vkCmdSetColorWriteMaskEXT",
133e5c31af7Sopenharmony_ci		"vkCmdSetConservativeRasterizationModeEXT",
134e5c31af7Sopenharmony_ci		"vkCmdSetCoverageModulationModeNV",
135e5c31af7Sopenharmony_ci		"vkCmdSetCoverageModulationTableEnableNV",
136e5c31af7Sopenharmony_ci		"vkCmdSetCoverageModulationTableNV",
137e5c31af7Sopenharmony_ci		"vkCmdSetCoverageReductionModeNV",
138e5c31af7Sopenharmony_ci		"vkCmdSetCoverageToColorEnableNV",
139e5c31af7Sopenharmony_ci		"vkCmdSetCoverageToColorLocationNV",
140e5c31af7Sopenharmony_ci		"vkCmdSetDepthClampEnableEXT",
141e5c31af7Sopenharmony_ci		"vkCmdSetDepthClipEnableEXT",
142e5c31af7Sopenharmony_ci		"vkCmdSetDepthClipNegativeOneToOneEXT",
143e5c31af7Sopenharmony_ci		"vkCmdSetExtraPrimitiveOverestimationSizeEXT",
144e5c31af7Sopenharmony_ci		"vkCmdSetLineRasterizationModeEXT",
145e5c31af7Sopenharmony_ci		"vkCmdSetLineStippleEnableEXT",
146e5c31af7Sopenharmony_ci		"vkCmdSetLogicOpEnableEXT",
147e5c31af7Sopenharmony_ci		"vkCmdSetPolygonModeEXT",
148e5c31af7Sopenharmony_ci		"vkCmdSetProvokingVertexModeEXT",
149e5c31af7Sopenharmony_ci		"vkCmdSetRasterizationSamplesEXT",
150e5c31af7Sopenharmony_ci		"vkCmdSetRasterizationStreamEXT",
151e5c31af7Sopenharmony_ci		"vkCmdSetRepresentativeFragmentTestEnableNV",
152e5c31af7Sopenharmony_ci		"vkCmdSetSampleLocationsEnableEXT",
153e5c31af7Sopenharmony_ci		"vkCmdSetSampleMaskEXT",
154e5c31af7Sopenharmony_ci		"vkCmdSetShadingRateImageEnableNV",
155e5c31af7Sopenharmony_ci		"vkCmdSetTessellationDomainOriginEXT",
156e5c31af7Sopenharmony_ci		"vkCmdSetViewportSwizzleNV",
157e5c31af7Sopenharmony_ci		"vkCmdSetViewportWScalingEnableNV",
158e5c31af7Sopenharmony_ci		// VK_EXT_vertex_input_dynamic_state
159e5c31af7Sopenharmony_ci		"vkCmdSetVertexInputEXT",
160e5c31af7Sopenharmony_ci	};
161e5c31af7Sopenharmony_ci
162e5c31af7Sopenharmony_ci	for (const auto& func : functions)
163e5c31af7Sopenharmony_ci	{
164e5c31af7Sopenharmony_ci		const auto& f = vk.getDeviceProcAddr(*device, func.c_str());
165e5c31af7Sopenharmony_ci		if (f == DE_NULL)
166e5c31af7Sopenharmony_ci			return tcu::TestStatus::fail("Failed: " + func);
167e5c31af7Sopenharmony_ci	}
168e5c31af7Sopenharmony_ci
169e5c31af7Sopenharmony_ci	return tcu::TestStatus::pass("Pass");
170e5c31af7Sopenharmony_ci}
171e5c31af7Sopenharmony_ci
172e5c31af7Sopenharmony_ciclass ShaderObjectApiCase : public vkt::TestCase
173e5c31af7Sopenharmony_ci{
174e5c31af7Sopenharmony_cipublic:
175e5c31af7Sopenharmony_ci					ShaderObjectApiCase		(tcu::TestContext& testCtx, const std::string& name)
176e5c31af7Sopenharmony_ci						: vkt::TestCase		(testCtx, name)
177e5c31af7Sopenharmony_ci						{}
178e5c31af7Sopenharmony_ci	virtual			~ShaderObjectApiCase	(void) {}
179e5c31af7Sopenharmony_ci
180e5c31af7Sopenharmony_ci	void			checkSupport			(vkt::Context& context) const override;
181e5c31af7Sopenharmony_ci	TestInstance*	createInstance			(Context& context) const override { return new ShaderObjectApiInstance(context); }
182e5c31af7Sopenharmony_ci};
183e5c31af7Sopenharmony_ci
184e5c31af7Sopenharmony_civoid ShaderObjectApiCase::checkSupport (Context& context) const
185e5c31af7Sopenharmony_ci{
186e5c31af7Sopenharmony_ci	context.requireDeviceFunctionality("VK_EXT_shader_object");
187e5c31af7Sopenharmony_ci}
188e5c31af7Sopenharmony_ci
189e5c31af7Sopenharmony_ciclass ShaderObjectExtensionVersionInstance : public vkt::TestInstance
190e5c31af7Sopenharmony_ci{
191e5c31af7Sopenharmony_cipublic:
192e5c31af7Sopenharmony_ci						ShaderObjectExtensionVersionInstance	(Context& context, const ShaderObjectApiTest test)
193e5c31af7Sopenharmony_ci							: vkt::TestInstance	(context)
194e5c31af7Sopenharmony_ci							, m_test			(test)
195e5c31af7Sopenharmony_ci							{}
196e5c31af7Sopenharmony_ci	virtual				~ShaderObjectExtensionVersionInstance	(void) {}
197e5c31af7Sopenharmony_ci
198e5c31af7Sopenharmony_ci	tcu::TestStatus		iterate									(void) override;
199e5c31af7Sopenharmony_ciprivate:
200e5c31af7Sopenharmony_ci	ShaderObjectApiTest m_test;
201e5c31af7Sopenharmony_ci};
202e5c31af7Sopenharmony_ci
203e5c31af7Sopenharmony_citcu::TestStatus ShaderObjectExtensionVersionInstance::iterate (void)
204e5c31af7Sopenharmony_ci{
205e5c31af7Sopenharmony_ci	vk::VkInstance									instance		= m_context.getInstance();
206e5c31af7Sopenharmony_ci	vk::InstanceDriver								instanceDriver	(m_context.getPlatformInterface(), instance);
207e5c31af7Sopenharmony_ci	vk::VkPhysicalDevice							physicalDevice  = m_context.getPhysicalDevice();
208e5c31af7Sopenharmony_ci	const vk::InstanceInterface&					vki				= m_context.getInstanceInterface();
209e5c31af7Sopenharmony_ci	const vk::ApiVersion							deviceVersion	= vk::unpackVersion(m_context.getDeviceVersion());
210e5c31af7Sopenharmony_ci	tcu::TestLog&									log				= m_context.getTestContext().getLog();
211e5c31af7Sopenharmony_ci
212e5c31af7Sopenharmony_ci	vk::VkPhysicalDeviceShaderObjectPropertiesEXT	shaderObjectProperties = vk::initVulkanStructure();
213e5c31af7Sopenharmony_ci
214e5c31af7Sopenharmony_ci	vk::VkPhysicalDeviceProperties					properties;
215e5c31af7Sopenharmony_ci	deMemset(&properties, 0, sizeof(vk::VkPhysicalDeviceProperties));
216e5c31af7Sopenharmony_ci	vk::VkPhysicalDeviceProperties2					properties2 =
217e5c31af7Sopenharmony_ci	{
218e5c31af7Sopenharmony_ci		vk::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,			// VkStructureType					sType
219e5c31af7Sopenharmony_ci		&shaderObjectProperties,									// const void*						pNext
220e5c31af7Sopenharmony_ci		properties													// VkPhysicalDeviceProperties		properties
221e5c31af7Sopenharmony_ci	};
222e5c31af7Sopenharmony_ci
223e5c31af7Sopenharmony_ci	instanceDriver.getPhysicalDeviceProperties2(physicalDevice, &properties2);
224e5c31af7Sopenharmony_ci
225e5c31af7Sopenharmony_ci	const std::vector<vk::VkExtensionProperties>&				deviceExtensionProperties = enumerateCachedDeviceExtensionProperties(vki, physicalDevice);
226e5c31af7Sopenharmony_ci
227e5c31af7Sopenharmony_ci	if (m_test == SHADER_BINARY_UUID)
228e5c31af7Sopenharmony_ci	{
229e5c31af7Sopenharmony_ci		bool nonZero = false;
230e5c31af7Sopenharmony_ci		for (deUint32 i = 0; i < VK_UUID_SIZE; ++i)
231e5c31af7Sopenharmony_ci		{
232e5c31af7Sopenharmony_ci			if (shaderObjectProperties.shaderBinaryUUID[i] != 0)
233e5c31af7Sopenharmony_ci			{
234e5c31af7Sopenharmony_ci				nonZero = true;
235e5c31af7Sopenharmony_ci				break;
236e5c31af7Sopenharmony_ci			}
237e5c31af7Sopenharmony_ci		}
238e5c31af7Sopenharmony_ci		if (!nonZero)
239e5c31af7Sopenharmony_ci		{
240e5c31af7Sopenharmony_ci			log << tcu::TestLog::Message << "All shaderBinaryUUID bytes are 0" << tcu::TestLog::EndMessage;
241e5c31af7Sopenharmony_ci			return tcu::TestStatus::fail("Fail");
242e5c31af7Sopenharmony_ci		}
243e5c31af7Sopenharmony_ci	}
244e5c31af7Sopenharmony_ci	else if (m_test == KHR_DYNAMIC_RENDERING)
245e5c31af7Sopenharmony_ci	{
246e5c31af7Sopenharmony_ci		if (deviceVersion.majorNum == 1 && deviceVersion.minorNum < 3)
247e5c31af7Sopenharmony_ci		{
248e5c31af7Sopenharmony_ci			bool found = false;
249e5c31af7Sopenharmony_ci			for (const auto& ext : deviceExtensionProperties)
250e5c31af7Sopenharmony_ci			{
251e5c31af7Sopenharmony_ci				if (strcmp(ext.extensionName, "VK_KHR_dynamic_rendering") == 0)
252e5c31af7Sopenharmony_ci				{
253e5c31af7Sopenharmony_ci					found = true;
254e5c31af7Sopenharmony_ci					break;
255e5c31af7Sopenharmony_ci				}
256e5c31af7Sopenharmony_ci			}
257e5c31af7Sopenharmony_ci			if (!found)
258e5c31af7Sopenharmony_ci			{
259e5c31af7Sopenharmony_ci				log << tcu::TestLog::Message << "VK_EXT_shader_object is supported, but vulkan version is < 1.3 and VK_KHR_dynamic_rendering is not supported" << tcu::TestLog::EndMessage;
260e5c31af7Sopenharmony_ci				return tcu::TestStatus::fail("Fail");
261e5c31af7Sopenharmony_ci			}
262e5c31af7Sopenharmony_ci		}
263e5c31af7Sopenharmony_ci	}
264e5c31af7Sopenharmony_ci	else
265e5c31af7Sopenharmony_ci	{
266e5c31af7Sopenharmony_ci		for (const auto& ext : deviceExtensionProperties)
267e5c31af7Sopenharmony_ci		{
268e5c31af7Sopenharmony_ci			if (m_test == EXT_DISCARD_RECTANGLES)
269e5c31af7Sopenharmony_ci			{
270e5c31af7Sopenharmony_ci				if (strcmp(ext.extensionName, "VK_EXT_discard_rectangles") == 0)
271e5c31af7Sopenharmony_ci				{
272e5c31af7Sopenharmony_ci					if (ext.specVersion < 2)
273e5c31af7Sopenharmony_ci					{
274e5c31af7Sopenharmony_ci						log << tcu::TestLog::Message << "VK_EXT_shader_object and VK_EXT_discard_rectangles are supported, but VK_EXT_discard_rectangles reports version " << ext.specVersion << tcu::TestLog::EndMessage;
275e5c31af7Sopenharmony_ci						return tcu::TestStatus::fail("Fail");
276e5c31af7Sopenharmony_ci					}
277e5c31af7Sopenharmony_ci					break;
278e5c31af7Sopenharmony_ci				}
279e5c31af7Sopenharmony_ci			}
280e5c31af7Sopenharmony_ci			else if (m_test == NV_SCISSOR_EXCLUSIVE)
281e5c31af7Sopenharmony_ci			{
282e5c31af7Sopenharmony_ci				if (strcmp(ext.extensionName, "VK_NV_scissor_exclusive") == 0)
283e5c31af7Sopenharmony_ci				{
284e5c31af7Sopenharmony_ci					if (ext.specVersion < 2)
285e5c31af7Sopenharmony_ci					{
286e5c31af7Sopenharmony_ci						log << tcu::TestLog::Message << "VK_EXT_shader_object and VK_NV_scissor_exclusive are supported, but VK_NV_scissor_exclusive reports version " << ext.specVersion << tcu::TestLog::EndMessage;
287e5c31af7Sopenharmony_ci						return tcu::TestStatus::fail("Fail");
288e5c31af7Sopenharmony_ci					}
289e5c31af7Sopenharmony_ci					break;
290e5c31af7Sopenharmony_ci				}
291e5c31af7Sopenharmony_ci			}
292e5c31af7Sopenharmony_ci		}
293e5c31af7Sopenharmony_ci	}
294e5c31af7Sopenharmony_ci	return tcu::TestStatus::pass("Pass");
295e5c31af7Sopenharmony_ci}
296e5c31af7Sopenharmony_ci
297e5c31af7Sopenharmony_ciclass ShaderObjectExtensionVersionCase : public vkt::TestCase
298e5c31af7Sopenharmony_ci{
299e5c31af7Sopenharmony_cipublic:
300e5c31af7Sopenharmony_ci					ShaderObjectExtensionVersionCase	(tcu::TestContext& testCtx, const std::string& name, const ShaderObjectApiTest test)
301e5c31af7Sopenharmony_ci						: vkt::TestCase					(testCtx, name)
302e5c31af7Sopenharmony_ci						, m_test						(test)
303e5c31af7Sopenharmony_ci						{}
304e5c31af7Sopenharmony_ci	virtual			~ShaderObjectExtensionVersionCase	(void) {}
305e5c31af7Sopenharmony_ci
306e5c31af7Sopenharmony_ci	void			checkSupport						(vkt::Context& context) const override;
307e5c31af7Sopenharmony_ci	TestInstance*	createInstance						(Context& context) const override { return new ShaderObjectExtensionVersionInstance(context, m_test); }
308e5c31af7Sopenharmony_ciprivate:
309e5c31af7Sopenharmony_ci	ShaderObjectApiTest m_test;
310e5c31af7Sopenharmony_ci};
311e5c31af7Sopenharmony_ci
312e5c31af7Sopenharmony_civoid ShaderObjectExtensionVersionCase::checkSupport(Context& context) const
313e5c31af7Sopenharmony_ci{
314e5c31af7Sopenharmony_ci	context.requireDeviceFunctionality("VK_EXT_shader_object");
315e5c31af7Sopenharmony_ci	if (m_test == EXT_DISCARD_RECTANGLES)
316e5c31af7Sopenharmony_ci	{
317e5c31af7Sopenharmony_ci		context.requireDeviceFunctionality("VK_EXT_discard_rectangles");
318e5c31af7Sopenharmony_ci	}
319e5c31af7Sopenharmony_ci	else if (m_test == NV_SCISSOR_EXCLUSIVE)
320e5c31af7Sopenharmony_ci	{
321e5c31af7Sopenharmony_ci		context.requireDeviceFunctionality("VK_NV_scissor_exclusive");
322e5c31af7Sopenharmony_ci	}
323e5c31af7Sopenharmony_ci}
324e5c31af7Sopenharmony_ci}
325e5c31af7Sopenharmony_ci
326e5c31af7Sopenharmony_citcu::TestCaseGroup* createShaderObjectApiTests (tcu::TestContext& testCtx)
327e5c31af7Sopenharmony_ci{
328e5c31af7Sopenharmony_ci	de::MovePtr<tcu::TestCaseGroup> apiGroup(new tcu::TestCaseGroup(testCtx, "api"));
329e5c31af7Sopenharmony_ci	apiGroup->addChild(new ShaderObjectApiCase(testCtx, "get_device_proc_addr"));
330e5c31af7Sopenharmony_ci
331e5c31af7Sopenharmony_ci	const struct
332e5c31af7Sopenharmony_ci	{
333e5c31af7Sopenharmony_ci		ShaderObjectApiTest		test;
334e5c31af7Sopenharmony_ci		const char*				name;
335e5c31af7Sopenharmony_ci	} apiTests[] =
336e5c31af7Sopenharmony_ci	{
337e5c31af7Sopenharmony_ci		{ EXT_DISCARD_RECTANGLES,	"discard_rectangles"	},
338e5c31af7Sopenharmony_ci		{ NV_SCISSOR_EXCLUSIVE,		"scissor_exclusive"		},
339e5c31af7Sopenharmony_ci		{ KHR_DYNAMIC_RENDERING,	"dynamic_rendering"		},
340e5c31af7Sopenharmony_ci		{ SHADER_BINARY_UUID,		"shader_binary_uuid"	},
341e5c31af7Sopenharmony_ci	};
342e5c31af7Sopenharmony_ci
343e5c31af7Sopenharmony_ci	for (const auto& test : apiTests)
344e5c31af7Sopenharmony_ci	{
345e5c31af7Sopenharmony_ci		apiGroup->addChild(new ShaderObjectExtensionVersionCase(testCtx, test.name, test.test));
346e5c31af7Sopenharmony_ci	}
347e5c31af7Sopenharmony_ci	return apiGroup.release();
348e5c31af7Sopenharmony_ci}
349e5c31af7Sopenharmony_ci
350e5c31af7Sopenharmony_ci} // ShaderObject
351e5c31af7Sopenharmony_ci} // vkt
352