1 #ifndef _VKQUERYUTIL_HPP
2 #define _VKQUERYUTIL_HPP
3 /*-------------------------------------------------------------------------
7 * Copyright (c) 2015 Google Inc.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and/or associated documentation files (the
11 * "Materials"), to deal in the Materials without restriction, including
12 * without limitation the rights to use, copy, modify, merge, publish,
13 * distribute, sublicense, and/or sell copies of the Materials, and to
14 * permit persons to whom the Materials are furnished to do so, subject to
15 * the following conditions:
17 * The above copyright notice(s) and this permission notice shall be
18 * included in all copies or substantial portions of the Materials.
20 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
30 * \brief Vulkan query utilities.
31 *//*--------------------------------------------------------------------*/
34 #include "tcuMaybe.hpp"
44 std::vector<VkPhysicalDevice> enumeratePhysicalDevices (const InstanceInterface& vk, VkInstance instance);
45 std::vector<VkQueueFamilyProperties> getPhysicalDeviceQueueFamilyProperties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice);
46 VkPhysicalDeviceFeatures getPhysicalDeviceFeatures (const InstanceInterface& vk, VkPhysicalDevice physicalDevice);
47 VkPhysicalDeviceProperties getPhysicalDeviceProperties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice);
48 VkPhysicalDeviceMemoryProperties getPhysicalDeviceMemoryProperties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice);
49 VkFormatProperties getPhysicalDeviceFormatProperties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice, VkFormat format);
50 VkImageFormatProperties getPhysicalDeviceImageFormatProperties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags);
52 VkMemoryRequirements getBufferMemoryRequirements (const DeviceInterface& vk, VkDevice device, VkBuffer buffer);
53 VkMemoryRequirements getImageMemoryRequirements (const DeviceInterface& vk, VkDevice device, VkImage image);
55 std::vector<VkLayerProperties> enumerateInstanceLayerProperties (const PlatformInterface& vkp);
56 std::vector<VkExtensionProperties> enumerateInstanceExtensionProperties (const PlatformInterface& vkp, const char* layerName);
57 std::vector<VkLayerProperties> enumerateDeviceLayerProperties (const InstanceInterface& vki, VkPhysicalDevice physicalDevice);
58 std::vector<VkExtensionProperties> enumerateDeviceExtensionProperties (const InstanceInterface& vki, VkPhysicalDevice physicalDevice, const char* layerName);
60 // Feature / extension support
62 bool isShaderStageSupported (const VkPhysicalDeviceFeatures& deviceFeatures, VkShaderStageFlagBits stage);
64 struct RequiredExtension
67 tcu::Maybe<deUint32> minVersion;
68 tcu::Maybe<deUint32> maxVersion;
70 explicit RequiredExtension (const std::string& name_,
71 tcu::Maybe<deUint32> minVersion_ = tcu::nothing<deUint32>(),
72 tcu::Maybe<deUint32> maxVersion_ = tcu::nothing<deUint32>())
74 , minVersion (minVersion_)
75 , maxVersion (maxVersion_)
79 bool isCompatible (const VkExtensionProperties& extensionProperties, const RequiredExtension& required);
81 template<typename ExtensionIterator>
82 bool isExtensionSupported (ExtensionIterator begin, ExtensionIterator end, const RequiredExtension& required);
83 bool isExtensionSupported (const std::vector<VkExtensionProperties>& extensions, const RequiredExtension& required);
85 // Return variable initialization validation
91 } QueryMemberTableEntry;
92 template <typename Context, typename Interface, typename Type>
93 bool validateInitComplete(Context context, void (Interface::*Function)(Context, Type*)const, const Interface& interface, const QueryMemberTableEntry* queryMemberTableEntry)
95 const QueryMemberTableEntry *iterator;
97 deMemset(&vec[0], 0x00, sizeof(Type));
98 deMemset(&vec[1], 0xFF, sizeof(Type));
100 (interface.*Function)(context, &vec[0]);
101 (interface.*Function)(context, &vec[1]);
103 for (iterator = queryMemberTableEntry; iterator->size != 0; iterator++)
105 if (deMemCmp(((deUint8*)(&vec[0]))+iterator->offset, ((deUint8*)(&vec[1]))+iterator->offset, iterator->size) != 0)
112 // Template implementations
114 template<typename ExtensionIterator>
115 bool isExtensionSupported (ExtensionIterator begin, ExtensionIterator end, const RequiredExtension& required)
117 for (ExtensionIterator cur = begin; cur != end; ++cur)
119 if (isCompatible(*cur, required))
127 #endif // _VKQUERYUTIL_HPP