• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * Vulkan CTS Framework
3  * --------------------
4  *
5  * Copyright (c) 2015 Google 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 query utilities.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "vkQueryUtil.hpp"
25 #include "vkApiVersion.hpp"
26 
27 #include "deMemory.h"
28 #include "deString.h"
29 #include "deSTLUtil.hpp"
30 
31 #include <vector>
32 #include <sstream>
33 
34 namespace vk
35 {
36 
37 using std::vector;
38 
39 namespace
40 {
41 
42 #include "vkSupportedExtensions.inl"
43 
44 }
45 
getCoreInstanceExtensions(deUint32 apiVersion,vector<const char * > & dst)46 void getCoreInstanceExtensions(deUint32 apiVersion, vector<const char*>& dst)
47 {
48 	getCoreInstanceExtensionsImpl(apiVersion, dst);
49 }
50 
getCoreDeviceExtensions(deUint32 apiVersion,vector<const char * > & dst)51 void getCoreDeviceExtensions(deUint32 apiVersion, vector<const char*>& dst)
52 {
53 	getCoreDeviceExtensionsImpl(apiVersion, dst);
54 }
55 
isCoreInstanceExtension(const deUint32 apiVersion,const std::string & extension)56 bool isCoreInstanceExtension(const deUint32 apiVersion, const std::string& extension)
57 {
58 	vector<const char*> coreExtensions;
59 	getCoreInstanceExtensions(apiVersion, coreExtensions);
60 	if (de::contains(coreExtensions.begin(), coreExtensions.end(), extension))
61 		return true;
62 
63 	return false;
64 }
65 
isCoreDeviceExtension(const deUint32 apiVersion,const std::string & extension)66 bool isCoreDeviceExtension(const deUint32 apiVersion, const std::string& extension)
67 {
68 	vector<const char*> coreExtensions;
69 	getCoreDeviceExtensions(apiVersion, coreExtensions);
70 	if (de::contains(coreExtensions.begin(), coreExtensions.end(), extension))
71 		return true;
72 
73 	return false;
74 }
75 
enumeratePhysicalDevices(const InstanceInterface & vk,VkInstance instance)76 vector<VkPhysicalDevice> enumeratePhysicalDevices (const InstanceInterface& vk, VkInstance instance)
77 {
78 	deUint32					numDevices	= 0;
79 	vector<VkPhysicalDevice>	devices;
80 
81 	VK_CHECK(vk.enumeratePhysicalDevices(instance, &numDevices, DE_NULL));
82 
83 	if (numDevices > 0)
84 	{
85 		devices.resize(numDevices);
86 		VK_CHECK(vk.enumeratePhysicalDevices(instance, &numDevices, &devices[0]));
87 
88 		if ((size_t)numDevices != devices.size())
89 			TCU_FAIL("Returned device count changed between queries");
90 	}
91 
92 	return devices;
93 }
94 
enumeratePhysicalDeviceGroups(const InstanceInterface & vk,VkInstance instance)95 vector<VkPhysicalDeviceGroupProperties> enumeratePhysicalDeviceGroups(const InstanceInterface& vk, VkInstance instance)
96 {
97 	deUint32								numDeviceGroups = 0;
98 	vector<VkPhysicalDeviceGroupProperties>	properties;
99 
100 	VK_CHECK(vk.enumeratePhysicalDeviceGroups(instance, &numDeviceGroups, DE_NULL));
101 
102 	if (numDeviceGroups > 0)
103 	{
104 		properties.resize(numDeviceGroups, initVulkanStructure());
105 		VK_CHECK(vk.enumeratePhysicalDeviceGroups(instance, &numDeviceGroups, &properties[0]));
106 
107 		if ((size_t)numDeviceGroups != properties.size())
108 			TCU_FAIL("Returned device group count changed between queries");
109 	}
110 	return properties;
111 }
112 
getPhysicalDeviceQueueFamilyProperties(const InstanceInterface & vk,VkPhysicalDevice physicalDevice)113 vector<VkQueueFamilyProperties> getPhysicalDeviceQueueFamilyProperties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
114 {
115 	deUint32						numQueues	= 0;
116 	vector<VkQueueFamilyProperties>	properties;
117 
118 	vk.getPhysicalDeviceQueueFamilyProperties(physicalDevice, &numQueues, DE_NULL);
119 
120 	if (numQueues > 0)
121 	{
122 		properties.resize(numQueues);
123 		vk.getPhysicalDeviceQueueFamilyProperties(physicalDevice, &numQueues, &properties[0]);
124 
125 		if ((size_t)numQueues != properties.size())
126 			TCU_FAIL("Returned queue family count changes between queries");
127 	}
128 
129 	return properties;
130 }
131 
getPhysicalDeviceFeatures(const InstanceInterface & vk,VkPhysicalDevice physicalDevice)132 VkPhysicalDeviceFeatures getPhysicalDeviceFeatures (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
133 {
134 	VkPhysicalDeviceFeatures	features;
135 
136 	deMemset(&features, 0, sizeof(features));
137 
138 	vk.getPhysicalDeviceFeatures(physicalDevice, &features);
139 	return features;
140 }
141 
getPhysicalDeviceFeatures2(const InstanceInterface & vk,VkPhysicalDevice physicalDevice)142 VkPhysicalDeviceFeatures2 getPhysicalDeviceFeatures2 (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
143 {
144 	VkPhysicalDeviceFeatures2	features;
145 
146 	deMemset(&features, 0, sizeof(features));
147 	features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
148 
149 	vk.getPhysicalDeviceFeatures2(physicalDevice, &features);
150 	return features;
151 }
152 
getPhysicalDeviceVulkan11Features(const InstanceInterface & vk,VkPhysicalDevice physicalDevice)153 VkPhysicalDeviceVulkan11Features getPhysicalDeviceVulkan11Features (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
154 {
155 	VkPhysicalDeviceFeatures2			features;
156 	VkPhysicalDeviceVulkan11Features	vulkan_11_features;
157 
158 	deMemset(&features, 0, sizeof(features));
159 	features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
160 
161 	deMemset(&vulkan_11_features, 0, sizeof(vulkan_11_features));
162 	vulkan_11_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES;
163 
164 	features.pNext = &vulkan_11_features;
165 
166 	vk.getPhysicalDeviceFeatures2(physicalDevice, &features);
167 	return vulkan_11_features;
168 }
169 
getPhysicalDeviceVulkan12Features(const InstanceInterface & vk,VkPhysicalDevice physicalDevice)170 VkPhysicalDeviceVulkan12Features getPhysicalDeviceVulkan12Features (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
171 {
172 	VkPhysicalDeviceFeatures2			features;
173 	VkPhysicalDeviceVulkan12Features	vulkan_12_features;
174 
175 	deMemset(&features, 0, sizeof(features));
176 	features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
177 
178 	deMemset(&vulkan_12_features, 0, sizeof(vulkan_12_features));
179 	vulkan_12_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
180 
181 	features.pNext = &vulkan_12_features;
182 
183 	vk.getPhysicalDeviceFeatures2(physicalDevice, &features);
184 	return vulkan_12_features;
185 }
186 
getPhysicalDeviceVulkan11Properties(const InstanceInterface & vk,VkPhysicalDevice physicalDevice)187 VkPhysicalDeviceVulkan11Properties getPhysicalDeviceVulkan11Properties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
188 {
189 	VkPhysicalDeviceVulkan11Properties	vulkan11properties	= initVulkanStructure();
190 	VkPhysicalDeviceProperties2			properties			= initVulkanStructure(&vulkan11properties);
191 
192 	vk.getPhysicalDeviceProperties2(physicalDevice, &properties);
193 
194 	return vulkan11properties;
195 }
196 
getPhysicalDeviceVulkan12Properties(const InstanceInterface & vk,VkPhysicalDevice physicalDevice)197 VkPhysicalDeviceVulkan12Properties getPhysicalDeviceVulkan12Properties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
198 {
199 	VkPhysicalDeviceVulkan12Properties	vulkan12properties	= initVulkanStructure();
200 	VkPhysicalDeviceProperties2			properties			= initVulkanStructure(&vulkan12properties);
201 
202 	vk.getPhysicalDeviceProperties2(physicalDevice, &properties);
203 
204 	return vulkan12properties;
205 }
206 
207 #ifdef CTS_USES_VULKANSC
getPhysicalDeviceVulkanSC10Features(const InstanceInterface & vk,VkPhysicalDevice physicalDevice)208 VkPhysicalDeviceVulkanSC10Features getPhysicalDeviceVulkanSC10Features (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
209 {
210 	VkPhysicalDeviceFeatures2			features;
211 	VkPhysicalDeviceVulkanSC10Features	vulkanSC10Features;
212 
213 	deMemset(&features, 0, sizeof(features));
214 	features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
215 
216 	deMemset(&vulkanSC10Features, 0, sizeof(vulkanSC10Features));
217 	vulkanSC10Features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_SC_1_0_FEATURES;
218 
219 	features.pNext = &vulkanSC10Features;
220 
221 	vk.getPhysicalDeviceFeatures2(physicalDevice, &features);
222 	return vulkanSC10Features;
223 }
224 
getPhysicalDeviceVulkanSC10Properties(const InstanceInterface & vk,VkPhysicalDevice physicalDevice)225 VkPhysicalDeviceVulkanSC10Properties getPhysicalDeviceVulkanSC10Properties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
226 {
227 	VkPhysicalDeviceVulkanSC10Properties	vulkanSC10properties	= initVulkanStructure();
228 	VkPhysicalDeviceProperties2				properties				= initVulkanStructure(&vulkanSC10properties);
229 
230 	vk.getPhysicalDeviceProperties2(physicalDevice, &properties);
231 
232 	return vulkanSC10properties;
233 }
234 #endif // CTS_USES_VULKANSC
235 
getPhysicalDeviceProperties(const InstanceInterface & vk,VkPhysicalDevice physicalDevice)236 VkPhysicalDeviceProperties getPhysicalDeviceProperties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
237 {
238 	VkPhysicalDeviceProperties	properties;
239 
240 	deMemset(&properties, 0, sizeof(properties));
241 
242 	vk.getPhysicalDeviceProperties(physicalDevice, &properties);
243 	return properties;
244 }
245 
getPhysicalDeviceMemoryProperties(const InstanceInterface & vk,VkPhysicalDevice physicalDevice)246 VkPhysicalDeviceMemoryProperties getPhysicalDeviceMemoryProperties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
247 {
248 	VkPhysicalDeviceMemoryProperties	properties;
249 
250 	deMemset(&properties, 0, sizeof(properties));
251 
252 	vk.getPhysicalDeviceMemoryProperties(physicalDevice, &properties);
253 
254 	if (properties.memoryTypeCount > VK_MAX_MEMORY_TYPES)
255 	{
256 		std::ostringstream msg;
257 		msg << "Invalid memoryTypeCount in VkPhysicalDeviceMemoryProperties (got " << properties.memoryTypeCount
258 			<< ", max " << VK_MAX_MEMORY_TYPES << ")";
259 		TCU_FAIL(msg.str());
260 	}
261 
262 	if (properties.memoryHeapCount > VK_MAX_MEMORY_HEAPS)
263 	{
264 		std::ostringstream msg;
265 		msg << "Invalid memoryHeapCount in VkPhysicalDeviceMemoryProperties (got " << properties.memoryHeapCount
266 			<< ", max " << VK_MAX_MEMORY_HEAPS << ")";
267 		TCU_FAIL(msg.str());
268 	}
269 
270 	return properties;
271 }
272 
getPhysicalDeviceFormatProperties(const InstanceInterface & vk,VkPhysicalDevice physicalDevice,VkFormat format)273 VkFormatProperties getPhysicalDeviceFormatProperties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice, VkFormat format)
274 {
275 	VkFormatProperties	properties;
276 
277 	deMemset(&properties, 0, sizeof(properties));
278 
279 	vk.getPhysicalDeviceFormatProperties(physicalDevice, format, &properties);
280 	return properties;
281 }
282 
getPhysicalDeviceImageFormatProperties(const InstanceInterface & vk,VkPhysicalDevice physicalDevice,VkFormat format,VkImageType type,VkImageTiling tiling,VkImageUsageFlags usage,VkImageCreateFlags flags)283 VkImageFormatProperties getPhysicalDeviceImageFormatProperties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags)
284 {
285 	VkImageFormatProperties	properties;
286 
287 	deMemset(&properties, 0, sizeof(properties));
288 
289 	VK_CHECK(vk.getPhysicalDeviceImageFormatProperties(physicalDevice, format, type, tiling, usage, flags, &properties));
290 	return properties;
291 }
292 
293 #ifndef CTS_USES_VULKANSC
getPhysicalDeviceSparseImageFormatProperties(const InstanceInterface & vk,VkPhysicalDevice physicalDevice,VkFormat format,VkImageType type,VkSampleCountFlagBits samples,VkImageUsageFlags usage,VkImageTiling tiling)294 std::vector<VkSparseImageFormatProperties> getPhysicalDeviceSparseImageFormatProperties(const InstanceInterface& vk, VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling)
295 {
296 	deUint32								numProp = 0;
297 	vector<VkSparseImageFormatProperties>	properties;
298 
299 	vk.getPhysicalDeviceSparseImageFormatProperties(physicalDevice, format, type, samples, usage, tiling, &numProp, DE_NULL);
300 
301 	if (numProp > 0)
302 	{
303 		properties.resize(numProp);
304 		vk.getPhysicalDeviceSparseImageFormatProperties(physicalDevice, format, type, samples, usage, tiling, &numProp, &properties[0]);
305 
306 		if ((size_t)numProp != properties.size())
307 			TCU_FAIL("Returned sparse image properties count changes between queries");
308 	}
309 
310 	return properties;
311 }
312 
getImageSparseMemoryRequirements(const DeviceInterface & vk,VkDevice device,VkImage image)313 std::vector<VkSparseImageMemoryRequirements> getImageSparseMemoryRequirements(const DeviceInterface& vk, VkDevice device, VkImage image)
314 {
315 	deUint32								requirementsCount = 0;
316 	vector<VkSparseImageMemoryRequirements> requirements;
317 
318 	vk.getImageSparseMemoryRequirements(device, image, &requirementsCount, DE_NULL);
319 
320 	if (requirementsCount > 0)
321 	{
322 		requirements.resize(requirementsCount);
323 		vk.getImageSparseMemoryRequirements(device, image, &requirementsCount, &requirements[0]);
324 
325 		if ((size_t)requirementsCount != requirements.size())
326 			TCU_FAIL("Returned sparse image memory requirements count changes between queries");
327 	}
328 
329 	return requirements;
330 }
331 #endif // CTS_USES_VULKANSC
332 
getBufferMemoryRequirements(const DeviceInterface & vk,VkDevice device,VkBuffer buffer)333 VkMemoryRequirements getBufferMemoryRequirements (const DeviceInterface& vk, VkDevice device, VkBuffer buffer)
334 {
335 	VkMemoryRequirements req;
336 	vk.getBufferMemoryRequirements(device, buffer, &req);
337 	return req;
338 }
339 
getImageMemoryRequirements(const DeviceInterface & vk,VkDevice device,VkImage image)340 VkMemoryRequirements getImageMemoryRequirements (const DeviceInterface& vk, VkDevice device, VkImage image)
341 {
342 	VkMemoryRequirements req;
343 	vk.getImageMemoryRequirements(device, image, &req);
344 	return req;
345 }
346 
getImagePlaneMemoryRequirements(const DeviceInterface & vkd,VkDevice device,VkImage image,VkImageAspectFlagBits planeAspect)347 VkMemoryRequirements getImagePlaneMemoryRequirements (const DeviceInterface&	vkd,
348 													  VkDevice					device,
349 													  VkImage					image,
350 													  VkImageAspectFlagBits		planeAspect)
351 {
352 	VkImageMemoryRequirementsInfo2		coreInfo;
353 	VkImagePlaneMemoryRequirementsInfo	planeInfo;
354 	VkMemoryRequirements2				reqs;
355 
356 	deMemset(&coreInfo,		0, sizeof(coreInfo));
357 	deMemset(&planeInfo,	0, sizeof(planeInfo));
358 	deMemset(&reqs,			0, sizeof(reqs));
359 
360 	coreInfo.sType			= VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2;
361 	coreInfo.pNext			= &planeInfo;
362 	coreInfo.image			= image;
363 
364 	planeInfo.sType			= VK_STRUCTURE_TYPE_IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO;
365 	planeInfo.planeAspect	= planeAspect;
366 
367 	reqs.sType				= VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
368 
369 	vkd.getImageMemoryRequirements2(device, &coreInfo, &reqs);
370 
371 	return reqs.memoryRequirements;
372 }
373 
enumerateInstanceLayerProperties(const PlatformInterface & vkp)374 vector<VkLayerProperties> enumerateInstanceLayerProperties (const PlatformInterface& vkp)
375 {
376 	vector<VkLayerProperties>	properties;
377 	deUint32					numLayers	= 0;
378 
379 	VK_CHECK(vkp.enumerateInstanceLayerProperties(&numLayers, DE_NULL));
380 
381 	if (numLayers > 0)
382 	{
383 		properties.resize(numLayers);
384 		VK_CHECK(vkp.enumerateInstanceLayerProperties(&numLayers, &properties[0]));
385 		TCU_CHECK((size_t)numLayers == properties.size());
386 	}
387 
388 	return properties;
389 }
390 
enumerateInstanceExtensionProperties(const PlatformInterface & vkp,const char * layerName)391 vector<VkExtensionProperties> enumerateInstanceExtensionProperties (const PlatformInterface& vkp, const char* layerName)
392 {
393 	vector<VkExtensionProperties>	properties;
394 	deUint32						numExtensions	= 0;
395 
396 	VK_CHECK(vkp.enumerateInstanceExtensionProperties(layerName, &numExtensions, DE_NULL));
397 
398 	if (numExtensions > 0)
399 	{
400 		properties.resize(numExtensions);
401 		VK_CHECK(vkp.enumerateInstanceExtensionProperties(layerName, &numExtensions, &properties[0]));
402 		TCU_CHECK((size_t)numExtensions == properties.size());
403 	}
404 
405 	return properties;
406 }
407 
enumerateDeviceLayerProperties(const InstanceInterface & vki,VkPhysicalDevice physicalDevice)408 vector<VkLayerProperties> enumerateDeviceLayerProperties (const InstanceInterface& vki, VkPhysicalDevice physicalDevice)
409 {
410 	vector<VkLayerProperties>	properties;
411 	deUint32					numLayers	= 0;
412 
413 	VK_CHECK(vki.enumerateDeviceLayerProperties(physicalDevice, &numLayers, DE_NULL));
414 
415 	if (numLayers > 0)
416 	{
417 		properties.resize(numLayers);
418 		VK_CHECK(vki.enumerateDeviceLayerProperties(physicalDevice, &numLayers, &properties[0]));
419 		TCU_CHECK((size_t)numLayers == properties.size());
420 	}
421 
422 	return properties;
423 }
424 
enumerateDeviceExtensionProperties(const InstanceInterface & vki,VkPhysicalDevice physicalDevice,const char * layerName)425 vector<VkExtensionProperties> enumerateDeviceExtensionProperties (const InstanceInterface& vki, VkPhysicalDevice physicalDevice, const char* layerName)
426 {
427 	vector<VkExtensionProperties>	properties;
428 	deUint32						numExtensions	= 0;
429 
430 	VK_CHECK(vki.enumerateDeviceExtensionProperties(physicalDevice, layerName, &numExtensions, DE_NULL));
431 
432 	if (numExtensions > 0)
433 	{
434 		properties.resize(numExtensions);
435 		VK_CHECK(vki.enumerateDeviceExtensionProperties(physicalDevice, layerName, &numExtensions, &properties[0]));
436 		TCU_CHECK((size_t)numExtensions == properties.size());
437 	}
438 
439 	return properties;
440 }
441 
isShaderStageSupported(const VkPhysicalDeviceFeatures & deviceFeatures,VkShaderStageFlagBits stage)442 bool isShaderStageSupported (const VkPhysicalDeviceFeatures& deviceFeatures, VkShaderStageFlagBits stage)
443 {
444 	if (stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT || stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT)
445 		return deviceFeatures.tessellationShader == VK_TRUE;
446 	else if (stage == VK_SHADER_STAGE_GEOMETRY_BIT)
447 		return deviceFeatures.geometryShader == VK_TRUE;
448 	else
449 		return true;
450 }
451 
isCompatible(const VkExtensionProperties & extensionProperties,const RequiredExtension & required)452 bool isCompatible (const VkExtensionProperties& extensionProperties, const RequiredExtension& required)
453 {
454 	if (required.name != extensionProperties.extensionName)
455 		return false;
456 
457 	if (required.minVersion && required.minVersion.get() > extensionProperties.specVersion)
458 		return false;
459 
460 	if (required.maxVersion && required.maxVersion.get() < extensionProperties.specVersion)
461 		return false;
462 
463 	return true;
464 }
465 
isCompatible(const VkLayerProperties & layerProperties,const RequiredLayer & required)466 bool isCompatible (const VkLayerProperties& layerProperties, const RequiredLayer& required)
467 {
468 	if (required.name != layerProperties.layerName)
469 		return false;
470 
471 	if (required.minSpecVersion && required.minSpecVersion.get() > layerProperties.specVersion)
472 		return false;
473 
474 	if (required.maxSpecVersion && required.maxSpecVersion.get() < layerProperties.specVersion)
475 		return false;
476 
477 	if (required.minImplVersion && required.minImplVersion.get() > layerProperties.implementationVersion)
478 		return false;
479 
480 	if (required.maxImplVersion && required.maxImplVersion.get() < layerProperties.implementationVersion)
481 		return false;
482 
483 	return true;
484 }
485 
isExtensionStructSupported(const std::vector<VkExtensionProperties> & extensions,const RequiredExtension & required)486 bool isExtensionStructSupported (const std::vector<VkExtensionProperties>& extensions, const RequiredExtension& required)
487 {
488 	return isExtensionStructSupported(extensions.begin(), extensions.end(), required);
489 }
490 
isExtensionStructSupported(const vector<std::string> & extensionStrings,const std::string & extensionName)491 bool isExtensionStructSupported (const vector<std::string>& extensionStrings, const std::string& extensionName)
492 {
493 	return de::contains(extensionStrings.begin(), extensionStrings.end(), extensionName);
494 }
495 
isInstanceExtensionSupported(const deUint32 instanceVersion,const std::vector<std::string> & extensions,const std::string & required)496 bool isInstanceExtensionSupported(const deUint32 instanceVersion, const std::vector<std::string>& extensions, const std::string& required)
497 {
498 	// NOTE: this function is only needed in few cases during creation of context,
499 	// dont use it, call Context::isInstanceFunctionalitySupported instead
500 	if (isCoreInstanceExtension(instanceVersion, required))
501 		return true;
502 	return de::contains(extensions.begin(), extensions.end(), required);
503 }
504 
isLayerSupported(const std::vector<VkLayerProperties> & layers,const RequiredLayer & required)505 bool isLayerSupported (const std::vector<VkLayerProperties>& layers, const RequiredLayer& required)
506 {
507 	return isLayerSupported(layers.begin(), layers.end(), required);
508 }
509 
getDeviceQueue(const DeviceInterface & vkd,VkDevice device,deUint32 queueFamilyIndex,deUint32 queueIndex)510 VkQueue getDeviceQueue (const DeviceInterface& vkd, VkDevice device, deUint32 queueFamilyIndex, deUint32 queueIndex)
511 {
512 	VkQueue queue;
513 
514 	vkd.getDeviceQueue(device, queueFamilyIndex, queueIndex, &queue);
515 
516 	return queue;
517 }
518 
getDeviceQueue2(const DeviceInterface & vkd,VkDevice device,const VkDeviceQueueInfo2 * queueInfo)519 VkQueue getDeviceQueue2 (const DeviceInterface& vkd, VkDevice device, const VkDeviceQueueInfo2* queueInfo)
520 {
521 	VkQueue queue;
522 
523 	vkd.getDeviceQueue2(device, queueInfo, &queue);
524 
525 	return queue;
526 }
527 
findStructureInChain(const void * first,VkStructureType type)528 const void* findStructureInChain (const void* first, VkStructureType type)
529 {
530 	struct StructureBase
531 	{
532 		VkStructureType		sType;
533 		void*				pNext;
534 	};
535 
536 	const StructureBase*	cur		= reinterpret_cast<const StructureBase*>(first);
537 
538 	while (cur)
539 	{
540 		if (cur->sType == type)
541 			break;
542 		else
543 			cur = reinterpret_cast<const StructureBase*>(cur->pNext);
544 	}
545 
546 	return cur;
547 }
548 
findStructureInChain(void * first,VkStructureType type)549 void* findStructureInChain (void* first, VkStructureType type)
550 {
551 	return const_cast<void*>(findStructureInChain(const_cast<const void*>(first), type));
552 }
553 
appendStructurePtrToVulkanChain(const void ** chainHead,const void * structurePtr)554 void appendStructurePtrToVulkanChain (const void**	chainHead, const void*	structurePtr)
555 {
556 	struct StructureBase
557 	{
558 		VkStructureType		sType;
559 		const void*			pNext;
560 	};
561 
562 	while (*chainHead != DE_NULL)
563 	{
564 		StructureBase* ptr = (StructureBase*)(*chainHead);
565 
566 		chainHead = &(ptr->pNext);
567 	}
568 
569 	(*chainHead) = structurePtr;
570 }
571 
572 // getStructureType<T> implementations
573 #include "vkGetStructureTypeImpl.inl"
574 
575 } // vk
576