• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2021 The Khronos Group Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *	  http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief  Vulkan SC API Tests
22 *//*--------------------------------------------------------------------*/
23 
24 #include "vktSafetyCriticalApiTests.hpp"
25 
26 #include <set>
27 #include <vector>
28 #include <string>
29 
30 #include "vkDefs.hpp"
31 #include "vktTestCaseUtil.hpp"
32 #include "vkQueryUtil.hpp"
33 
34 namespace vkt
35 {
36 namespace sc
37 {
38 namespace
39 {
40 
forbiddenCoreCommands(Context & context)41 tcu::TestStatus forbiddenCoreCommands (Context& context)
42 {
43 	std::vector<std::string> commands
44 	{
45 		"vkTrimCommandPool",
46 		"vkTrimCommandPoolKHR",
47 		"vkDestroyCommandPool",
48 		"vkCreateShaderModule",
49 		"vkDestroyShaderModule",
50 		"vkMergePipelineCaches",
51 		"vkGetPipelineCacheData",
52 		"vkFreeMemory",
53 		"vkDestroyDescriptorPool",
54 		"vkCreateDescriptorUpdateTemplateKHR",
55 		"vkDestroyDescriptorUpdateTemplateKHR",
56 		"vkUpdateDescriptorSetWithTemplateKHR",
57 		"vkCmdPushDescriptorSetWithTemplateKHR",
58 		"vkDestroyQueryPool",
59 		"vkGetPhysicalDeviceSparseImageFormatProperties",
60 		"vkGetPhysicalDeviceSparseImageFormatProperties2",
61 		"vkGetPhysicalDeviceSparseImageFormatProperties2KHR",
62 		"vkGetImageSparseMemoryRequirements",
63 		"vkGetImageSparseMemoryRequirements2",
64 		"vkGetImageSparseMemoryRequirements2KHR",
65 		"vkQueueBindSparse",
66 		"vkDestroySwapchainKHR"
67 	};
68 
69 	vk::VkDevice device				= context.getDevice();
70 	const vk::DeviceInterface& vkd	= context.getDeviceInterface();
71 
72 	for (const auto& commandName : commands)
73 	{
74 		void* commandPointer = (void *)vkd.getDeviceProcAddr(device, commandName.c_str());
75 		if( commandPointer != DE_NULL )
76 			TCU_THROW(TestError, commandName + std::string(" should not be accessible"));
77 	}
78 
79 	return tcu::TestStatus::pass("All forbidden commands are not accessible");
80 }
81 
forbiddenCoreExtensions(Context & context)82 tcu::TestStatus forbiddenCoreExtensions (Context& context)
83 {
84 	// vector of Vulkan 1.1 and Vulkan 1.2 extensions that should not be advertised in Vulkan SC 1.0
85 	std::set<std::string> coreExtensions
86 	{
87 		"VK_KHR_16bit_storage",
88 		"VK_KHR_bind_memory2",
89 		"VK_KHR_dedicated_allocation",
90 		"VK_KHR_descriptor_update_template",
91 		"VK_KHR_device_group",
92 		"VK_KHR_device_group_creation",
93 		"VK_KHR_external_fence",
94 		"VK_KHR_external_fence_capabilities",
95 		"VK_KHR_external_memory",
96 		"VK_KHR_external_memory_capabilities",
97 		"VK_KHR_external_semaphore",
98 		"VK_KHR_external_semaphore_capabilities",
99 		"VK_KHR_get_memory_requirements2",
100 		"VK_KHR_get_physical_device_properties2",
101 		"VK_KHR_maintenance1",
102 		"VK_KHR_maintenance2",
103 		"VK_KHR_maintenance3",
104 		"VK_KHR_multiview",
105 		"VK_KHR_relaxed_block_layout",
106 		"VK_KHR_sampler_ycbcr_conversion",
107 		"VK_KHR_shader_draw_parameters",
108 		"VK_KHR_storage_buffer_storage_class",
109 		"VK_KHR_variable_pointers",
110 		"VK_KHR_8bit_storage",
111 		"VK_KHR_buffer_device_address",
112 		"VK_KHR_create_renderpass2",
113 		"VK_KHR_depth_stencil_resolve",
114 		"VK_KHR_draw_indirect_count",
115 		"VK_KHR_driver_properties",
116 		"VK_KHR_image_format_list",
117 		"VK_KHR_imageless_framebuffer",
118 		"VK_KHR_sampler_mirror_clamp_to_edge",
119 		"VK_KHR_separate_depth_stencil_layouts",
120 		"VK_KHR_shader_atomic_int64",
121 		"VK_KHR_shader_float16_int8",
122 		"VK_KHR_shader_float_controls",
123 		"VK_KHR_shader_subgroup_extended_types",
124 		"VK_KHR_spirv_1_4",
125 		"VK_KHR_timeline_semaphore",
126 		"VK_KHR_uniform_buffer_standard_layout",
127 		"VK_KHR_vulkan_memory_model",
128 		"VK_EXT_descriptor_indexing",
129 		"VK_EXT_host_query_reset",
130 		"VK_EXT_sampler_filter_minmax",
131 		"VK_EXT_scalar_block_layout",
132 		"VK_EXT_separate_stencil_usage",
133 		"VK_EXT_shader_viewport_index_layer",
134 	};
135 
136 	vk::VkPhysicalDevice							physicalDevice		= context.getPhysicalDevice();
137 	const vk::InstanceInterface&					vki					= context.getInstanceInterface();
138 	const std::vector<vk::VkExtensionProperties>	deviceExtensions	= vk::enumerateDeviceExtensionProperties(vki, physicalDevice, DE_NULL);
139 
140 	for (const auto& extension : deviceExtensions)
141 	{
142 		const std::string extensionName(extension.extensionName);
143 		if(coreExtensions.find(extensionName)!= coreExtensions.end())
144 			TCU_THROW(TestError, extensionName + std::string(" extension is explicitly forbidden"));
145 	}
146 
147 	return tcu::TestStatus::pass("No extensions from forbidden set");
148 }
149 
forbiddenPromotedCommands(Context & context)150 tcu::TestStatus forbiddenPromotedCommands (Context& context)
151 {
152 	std::vector<std::string> commands
153 	{
154 		"vkBindBufferMemory2KHR",
155 		"vkBindImageMemory2KHR",
156 		"vkCreateDescriptorUpdateTemplateKHR",
157 		"vkDestroyDescriptorUpdateTemplateKHR",
158 		"vkUpdateDescriptorSetWithTemplateKHR",
159 		"vkCmdPushDescriptorSetWithTemplateKHR",
160 		"vkCmdDispatchBaseKHR",
161 		"vkCmdSetDeviceMaskKHR",
162 		"vkGetDeviceGroupPeerMemoryFeaturesKHR",
163 		"vkEnumeratePhysicalDeviceGroupsKHR",
164 		"vkGetPhysicalDeviceExternalFencePropertiesKHR",
165 		"vkGetPhysicalDeviceExternalBufferPropertiesKHR",
166 		"vkGetPhysicalDeviceExternalSemaphorePropertiesKHR",
167 		"vkGetBufferMemoryRequirements2KHR",
168 		"vkGetImageMemoryRequirements2KHR",
169 		"vkGetImageSparseMemoryRequirements2KHR",
170 		"vkGetPhysicalDeviceFeatures2KHR",
171 		"vkGetPhysicalDeviceFormatProperties2KHR",
172 		"vkGetPhysicalDeviceImageFormatProperties2KHR",
173 		"vkGetPhysicalDeviceMemoryProperties2KHR",
174 		"vkGetPhysicalDeviceProperties2KHR",
175 		"vkGetPhysicalDeviceQueueFamilyProperties2KHR",
176 		"vkGetPhysicalDeviceSparseImageFormatProperties2KHR",
177 		"vkTrimCommandPoolKHR",
178 		"vkGetDescriptorSetLayoutSupportKHR",
179 		"vkCreateSamplerYcbcrConversionKHR",
180 		"vkDestroySamplerYcbcrConversionKHR",
181 		"vkGetBufferDeviceAddressKHR",
182 		"vkGetBufferOpaqueCaptureAddressKHR",
183 		"vkGetDeviceMemoryOpaqueCaptureAddressKHR",
184 		"vkCmdBeginRenderPass2KHR",
185 		"vkCmdEndRenderPass2KHR",
186 		"vkCmdNextSubpass2KHR",
187 		"vkCreateRenderPass2KHR",
188 		"vkCmdDrawIndexedIndirectCountKHR",
189 		"vkCmdDrawIndirectCountKHR",
190 		"vkGetSemaphoreCounterValueKHR",
191 		"vkSignalSemaphoreKHR",
192 		"vkWaitSemaphoresKHR",
193 		"vkResetQueryPoolEXT",
194 	};
195 
196 	vk::VkDevice device				= context.getDevice();
197 	const vk::DeviceInterface& vkd	= context.getDeviceInterface();
198 
199 	for (const auto& commandName : commands)
200 	{
201 		void* commandPointer = (void *)vkd.getDeviceProcAddr(device, commandName.c_str());
202 		if( commandPointer != DE_NULL )
203 			TCU_THROW(TestError, commandName + std::string(" should not be accessible"));
204 	}
205 
206 	return tcu::TestStatus::pass("All forbidden commands are not accessible");
207 }
208 
forbiddenDeviceFeatures(Context & context)209 tcu::TestStatus forbiddenDeviceFeatures (Context& context)
210 {
211 	if (context.getDeviceFeatures().shaderResourceResidency != VK_FALSE)
212 		TCU_THROW(TestError, "VkPhysicalDeviceFeatures::shaderResourceResidency must be VK_FALSE");
213 	if (context.getDeviceFeatures().sparseBinding != VK_FALSE)
214 		TCU_THROW(TestError, "VkPhysicalDeviceFeatures::sparseBinding must be VK_FALSE");
215 
216 	if (context.getDeviceFeatures().sparseResidencyBuffer != VK_FALSE)
217 		TCU_THROW(TestError, "VkPhysicalDeviceFeatures::sparseResidencyBuffer must be VK_FALSE");
218 	if (context.getDeviceFeatures().sparseResidencyImage2D != VK_FALSE)
219 		TCU_THROW(TestError, "VkPhysicalDeviceFeatures::sparseResidencyImage2D must be VK_FALSE");
220 	if (context.getDeviceFeatures().sparseResidencyImage3D != VK_FALSE)
221 		TCU_THROW(TestError, "VkPhysicalDeviceFeatures::sparseResidencyImage3D must be VK_FALSE");
222 	if (context.getDeviceFeatures().sparseResidency2Samples != VK_FALSE)
223 		TCU_THROW(TestError, "VkPhysicalDeviceFeatures::sparseResidency2Samples must be VK_FALSE");
224 	if (context.getDeviceFeatures().sparseResidency4Samples != VK_FALSE)
225 		TCU_THROW(TestError, "VkPhysicalDeviceFeatures::sparseResidency4Samples must be VK_FALSE");
226 	if (context.getDeviceFeatures().sparseResidency8Samples != VK_FALSE)
227 		TCU_THROW(TestError, "VkPhysicalDeviceFeatures::sparseResidency8Samples must be VK_FALSE");
228 	if (context.getDeviceFeatures().sparseResidency16Samples != VK_FALSE)
229 		TCU_THROW(TestError, "VkPhysicalDeviceFeatures::sparseResidency16Samples must be VK_FALSE");
230 	if (context.getDeviceFeatures().sparseResidencyAliased != VK_FALSE)
231 		TCU_THROW(TestError, "VkPhysicalDeviceFeatures::sparseResidencyAliased must be VK_FALSE");
232 
233 	return tcu::TestStatus::pass("Pass");
234 }
235 
forbiddenDeviceProperties(Context & context)236 tcu::TestStatus forbiddenDeviceProperties (Context& context)
237 {
238 	if (context.getDeviceProperties().sparseProperties.residencyStandard2DBlockShape != VK_FALSE)
239 		TCU_THROW(TestError, "VkPhysicalDeviceSparseProperties::residencyStandard2DBlockShape must be VK_FALSE");
240 	if (context.getDeviceProperties().sparseProperties.residencyStandard2DMultisampleBlockShape != VK_FALSE)
241 		TCU_THROW(TestError, "VkPhysicalDeviceSparseProperties::residencyStandard2DMultisampleBlockShape must be VK_FALSE");
242 	if (context.getDeviceProperties().sparseProperties.residencyStandard3DBlockShape != VK_FALSE)
243 		TCU_THROW(TestError, "VkPhysicalDeviceSparseProperties::residencyStandard3DBlockShape must be VK_FALSE");
244 	if (context.getDeviceProperties().sparseProperties.residencyAlignedMipSize != VK_FALSE)
245 		TCU_THROW(TestError, "VkPhysicalDeviceSparseProperties::residencyAlignedMipSize must be VK_FALSE");
246 	if (context.getDeviceProperties().sparseProperties.residencyNonResidentStrict != VK_FALSE)
247 		TCU_THROW(TestError, "VkPhysicalDeviceSparseProperties::residencyNonResidentStrict must be VK_FALSE");
248 
249 	return tcu::TestStatus::pass("Pass");
250 }
251 
allowedExtensions(Context & context)252 tcu::TestStatus allowedExtensions (Context& context)
253 {
254 	// vector of extensions that are explicitly allowed in Vulkan SC 1.0
255 	std::set<std::string> extensions
256 	{
257 		"VK_KHR_copy_commands2",
258 		"VK_KHR_display",
259 		"VK_KHR_display_swapchain",
260 		"VK_KHR_external_fence_fd",
261 		"VK_KHR_external_memory_fd",
262 		"VK_KHR_external_semaphore_fd",
263 		"VK_KHR_fragment_shading_rate",
264 		"VK_KHR_get_display_properties2",
265 		"VK_KHR_get_surface_capabilities2",
266 		"VK_KHR_incremental_present",
267 		"VK_KHR_object_refresh",
268 		"VK_KHR_shader_clock",
269 		"VK_KHR_shader_terminate_invocation",
270 		"VK_KHR_shared_presentable_image",
271 		"VK_KHR_surface",
272 		"VK_KHR_swapchain",
273 		"VK_KHR_swapchain_mutable_format",
274 		"VK_KHR_synchronization2",
275 		"VK_EXT_4444_formats",
276 		"VK_EXT_astc_decode_mode",
277 		"VK_EXT_blend_operation_advanced",
278 		"VK_EXT_calibrated_timestamps",
279 		"VK_EXT_color_write_enable",
280 		"VK_EXT_conservative_rasterization",
281 		"VK_EXT_custom_border_color",
282 		"VK_EXT_debug_utils",
283 		"VK_EXT_depth_clip_enable",
284 		"VK_EXT_depth_range_unrestricted",
285 		"VK_EXT_direct_mode_display",
286 		"VK_EXT_discard_rectangles",
287 		"VK_EXT_display_control",
288 		"VK_EXT_display_surface_counter",
289 		"VK_EXT_extended_dynamic_state",
290 		"VK_EXT_extended_dynamic_state2",
291 		"VK_EXT_external_memory_dma_buf",
292 		"VK_EXT_external_memory_host",
293 		"VK_EXT_filter_cubic",
294 		"VK_EXT_fragment_shader_interlock",
295 		"VK_EXT_global_priority",
296 		"VK_EXT_hdr_metadata",
297 		"VK_EXT_headless_surface",
298 		"VK_EXT_image_drm_format_modifier",
299 		"VK_EXT_image_robustness",
300 		"VK_EXT_index_type_uint8",
301 		"VK_EXT_line_rasterization",
302 		"VK_EXT_memory_budget",
303 		"VK_EXT_pci_bus_info",
304 		"VK_EXT_post_depth_coverage",
305 		"VK_EXT_queue_family_foreign",
306 		"VK_EXT_robustness2",
307 		"VK_EXT_sample_locations",
308 		"VK_EXT_shader_atomic_float",
309 		"VK_EXT_shader_demote_to_helper_invocation",
310 		"VK_EXT_shader_image_atomic_int64",
311 		"VK_EXT_shader_stencil_export",
312 		"VK_EXT_subgroup_size_control",
313 		"VK_EXT_swapchain_colorspace",
314 		"VK_EXT_texel_buffer_alignment",
315 		"VK_EXT_texture_compression_astc_hdr",
316 		"VK_EXT_validation_features",
317 		"VK_EXT_vertex_attribute_divisor",
318 		"VK_EXT_vertex_input_dynamic_state",
319 		"VK_EXT_ycbcr_2plane_444_formats",
320 		"VK_EXT_ycbcr_image_arrays",
321 	};
322 
323 	vk::VkPhysicalDevice							physicalDevice		= context.getPhysicalDevice();
324 	const vk::InstanceInterface&					vki					= context.getInstanceInterface();
325 	const std::vector<vk::VkExtensionProperties>	deviceExtensions	= vk::enumerateDeviceExtensionProperties(vki, physicalDevice, DE_NULL);
326 
327 	for (const auto& extension : deviceExtensions)
328 	{
329 		const std::string extensionName(extension.extensionName);
330 
331 		// this test applies only to VK_KHR_* and VK_EXT_* extensions
332 		if (extensionName.find("VK_KHR") != 0 && extensionName.find("VK_EXT") != 0)
333 			continue;
334 
335 		if(extensions.find(extensionName)==extensions.end())
336 			TCU_THROW(TestError, extensionName + std::string(" extension is not allowed"));
337 	}
338 
339 	return tcu::TestStatus::pass("All implemented extensions are defined in specification");
340 }
341 
342 } // anonymous
343 
createSafetyCriticalAPITests(tcu::TestContext & testCtx)344 tcu::TestCaseGroup*	createSafetyCriticalAPITests (tcu::TestContext& testCtx)
345 {
346 	de::MovePtr<tcu::TestCaseGroup> group(new tcu::TestCaseGroup(testCtx, "api", "Tests verifying Vulkan SC specific API"));
347 
348 	addFunctionCase(group.get(), "forbidden_core_commands",		"Verify existence of functions removed from Vulkan",				forbiddenCoreCommands);
349 	addFunctionCase(group.get(), "forbidden_core_extensions",	"Verify existence of extensions removed from Vulkan",				forbiddenCoreExtensions);
350 	addFunctionCase(group.get(), "forbidden_promoted_commands",	"Verify existence of promoted functions removed from Vulkan",		forbiddenPromotedCommands);
351 	addFunctionCase(group.get(), "forbidden_features",			"Verify if specific device features are forbidden for Vulkan SC",	forbiddenDeviceFeatures);
352 	addFunctionCase(group.get(), "forbidden_properties",		"Verify if specific device properties are forbidden for Vulkan SC", forbiddenDeviceProperties);
353 	addFunctionCase(group.get(), "allowed_extensions",			"Verify if extensions are allowed for Vulkan SC",					allowedExtensions);
354 
355 	return group.release();
356 }
357 
358 }	// sc
359 
360 }	// vkt
361