Vulkan-Hpp
PhysicalDeviceQueueFamilyProperties.cpp
Go to the documentation of this file.
1 // Copyright(c) 2019, NVIDIA CORPORATION. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // VulkanHpp Samples : PhysicalDeviceQueueFamilyProperties
16 // Get queue family properties per physical device.
17 
18 #include "../utils/utils.hpp"
19 
20 #include <iomanip>
21 #include <sstream>
22 #include <vector>
24 
25 static char const * AppName = "PhysicalDeviceQueueFamilyProperties";
26 static char const * EngineName = "Vulkan.hpp";
27 
28 int main( int /*argc*/, char ** /*argv*/ )
29 {
30  try
31  {
32  vk::Instance instance = vk::su::createInstance( AppName, EngineName, {}, {}, VK_API_VERSION_1_1 );
33 #if !defined( NDEBUG )
35 #endif
36 
37  // enumerate the physicalDevices
38  std::vector<vk::PhysicalDevice> physicalDevices = instance.enumeratePhysicalDevices();
39 
40  /* VULKAN_KEY_START */
41 
42  std::cout << std::boolalpha;
43  for ( size_t i = 0; i < physicalDevices.size(); i++ )
44  {
45  // some features are only valid, if a corresponding extension is available!
46  std::vector<vk::ExtensionProperties> extensionProperties = physicalDevices[i].enumerateDeviceExtensionProperties();
47 
48  std::cout << "PhysicalDevice " << i << "\n";
49 
50  // need to explicitly specify all the template arguments for getQueueFamilyProperties2 to make the compiler happy
52  auto queueFamilyProperties2 = physicalDevices[i].getQueueFamilyProperties2<Chain, std::allocator<Chain>, vk::DispatchLoaderDynamic>();
53  for ( size_t j = 0; j < queueFamilyProperties2.size(); j++ )
54  {
55  std::cout << std::string( "\t" ) << "QueueFamily " << j << "\n";
56  vk::QueueFamilyProperties const & properties = queueFamilyProperties2[j].get<vk::QueueFamilyProperties2>().queueFamilyProperties;
57  std::cout << std::string( "\t\t" ) << "QueueFamilyProperties:\n";
58  std::cout << std::string( "\t\t\t" ) << "queueFlags = " << vk::to_string( properties.queueFlags ) << "\n";
59  std::cout << std::string( "\t\t\t" ) << "queueCount = " << properties.queueCount << "\n";
60  std::cout << std::string( "\t\t\t" ) << "timestampValidBits = " << properties.timestampValidBits << "\n";
61  std::cout << std::string( "\t\t\t" ) << "minImageTransferGranularity = " << properties.minImageTransferGranularity.width << " x "
62  << properties.minImageTransferGranularity.height << " x " << properties.minImageTransferGranularity.depth << "\n";
63  std::cout << "\n";
64 
65  if ( vk::su::contains( extensionProperties, "VK_NV_device_diagnostic_checkpoints" ) )
66  {
67  vk::QueueFamilyCheckpointPropertiesNV const & checkpointProperties = queueFamilyProperties2[j].get<vk::QueueFamilyCheckpointPropertiesNV>();
68  std::cout << std::string( "\t\t" ) << "CheckPointPropertiesNV:\n";
69  std::cout << std::string( "\t\t\t" ) << "checkpointExecutionStageMask = " << vk::to_string( checkpointProperties.checkpointExecutionStageMask )
70  << "\n";
71  std::cout << "\n";
72  }
73  }
74  }
75 
76  /* VULKAN_KEY_END */
77 
78 #if !defined( NDEBUG )
79  instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
80 #endif
81  instance.destroy();
82  }
83  catch ( vk::SystemError & err )
84  {
85  std::cout << "vk::SystemError: " << err.what() << std::endl;
86  exit( -1 );
87  }
88  catch ( std::exception & err )
89  {
90  std::cout << "std::exception: " << err.what() << std::endl;
91  exit( -1 );
92  }
93  catch ( ... )
94  {
95  std::cout << "unknown error\n";
96  exit( -1 );
97  }
98  return 0;
99 }
int main(int, char **)
void cout(vk::SurfaceCapabilitiesKHR const &surfaceCapabilities)
VULKAN_HPP_NODISCARD Result createDebugUtilsMessengerEXT(const vk::DebugUtilsMessengerCreateInfoEXT *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::DebugUtilsMessengerEXT *pMessenger, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroy(const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result enumeratePhysicalDevices(uint32_t *pPhysicalDeviceCount, vk::PhysicalDevice *pPhysicalDevices, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroyDebugUtilsMessengerEXT(vk::DebugUtilsMessengerEXT messenger, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
virtual const char * what() const VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6206
vk::DebugUtilsMessengerCreateInfoEXT makeDebugUtilsMessengerCreateInfoEXT()
Definition: utils.cpp:1025
vk::Instance createInstance(std::string const &appName, std::string const &engineName, std::vector< std::string > const &layers, std::vector< std::string > const &extensions, uint32_t apiVersion)
Definition: utils.cpp:279
bool contains(std::vector< vk::ExtensionProperties > const &extensionProperties, std::string const &extensionName)
Definition: utils.cpp:54
VULKAN_HPP_INLINE std::string to_string(FormatFeatureFlags value)
vk::PipelineStageFlags checkpointExecutionStageMask
vk::Extent3D minImageTransferGranularity
#define VK_API_VERSION_1_1
Definition: vulkan_core.h:4854