Vulkan-Hpp
PhysicalDeviceExtensions.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 : DeviceExtensionProperties
16 // Get extension properties per physical device.
17 
18 #include "../utils/utils.hpp"
19 
20 #include <vector>
21 
22 static char const * AppName = "DeviceExtensionProperties";
23 static char const * EngineName = "Vulkan.hpp";
24 
25 int main( int /*argc*/, char ** /*argv*/ )
26 {
27  try
28  {
29  vk::Instance instance = vk::su::createInstance( AppName, EngineName );
30 #if !defined( NDEBUG )
32 #endif
33 
34  // enumerate the physicalDevices
35  std::vector<vk::PhysicalDevice> physicalDevices = instance.enumeratePhysicalDevices();
36 
37  /* VULKAN_KEY_START */
38 
39  for ( size_t i = 0; i < physicalDevices.size(); i++ )
40  {
41  std::vector<vk::ExtensionProperties> extensionProperties = physicalDevices[i].enumerateDeviceExtensionProperties();
42  std::cout << "PhysicalDevice " << i << " : " << extensionProperties.size() << " extensions:\n";
43 
44  // sort the extensions alphabetically
45  std::sort( extensionProperties.begin(),
46  extensionProperties.end(),
47  []( vk::ExtensionProperties const & a, vk::ExtensionProperties const & b ) { return strcmp( a.extensionName, b.extensionName ) < 0; } );
48  for ( auto const & ep : extensionProperties )
49  {
50  std::cout << "\t" << ep.extensionName << ":" << std::endl;
51  std::cout << "\t\tVersion: " << ep.specVersion << std::endl;
52  std::cout << std::endl;
53  }
54  }
55 
56  /* VULKAN_KEY_END */
57 
58 #if !defined( NDEBUG )
59  instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
60 #endif
61  instance.destroy();
62  }
63  catch ( vk::SystemError & err )
64  {
65  std::cout << "vk::SystemError: " << err.what() << std::endl;
66  exit( -1 );
67  }
68  catch ( std::exception & err )
69  {
70  std::cout << "std::exception: " << err.what() << std::endl;
71  exit( -1 );
72  }
73  catch ( ... )
74  {
75  std::cout << "unknown error\n";
76  exit( -1 );
77  }
78  return 0;
79 }
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