Vulkan-Hpp
InstanceLayerExtensionProperties.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 : InstanceLayerExtensionProperties
16 // Get list of global layers and their associated extensions, if any.
17 
18 #include <iostream>
19 #include <sstream>
20 #include <vector>
21 #include <vulkan/vulkan.hpp>
22 
24 {
25  PropertyData( vk::LayerProperties const & layerProperties_, std::vector<vk::ExtensionProperties> const & extensionProperties_ )
26  : layerProperties( layerProperties_ ), extensionProperties( extensionProperties_ )
27  {
28  }
29 
31  std::vector<vk::ExtensionProperties> extensionProperties;
32 };
33 
34 int main( int /*argc*/, char ** /*argv*/ )
35 {
36  try
37  {
38  std::vector<vk::LayerProperties> layerProperties = vk::enumerateInstanceLayerProperties();
39 
40  /* VULKAN_KEY_START */
41 
42  std::vector<PropertyData> propertyData;
43  propertyData.reserve( layerProperties.size() );
44 
45  for ( auto const & layerProperty : layerProperties )
46  {
47  std::vector<vk::ExtensionProperties> extensionProperties =
49  propertyData.emplace_back( layerProperty, extensionProperties );
50  }
51 
52  /* VULKAN_KEY_END */
53 
54  std::cout << "Instance Layers:" << std::endl;
55  if ( propertyData.empty() )
56  {
57  std::cout << "Set the environment variable VK_LAYER_PATH to point to the location of your layers" << std::endl;
58  }
59  else
60  {
61  for ( auto const & pd : propertyData )
62  {
63  std::cout << pd.layerProperties.layerName << std::endl;
64  std::cout << "Layer Extensions: ";
65  if ( pd.extensionProperties.empty() )
66  {
67  std::cout << "None";
68  }
69  else
70  {
71  for ( auto it = pd.extensionProperties.begin(); it != pd.extensionProperties.end(); ++it )
72  {
73  if ( it != pd.extensionProperties.begin() )
74  {
75  std::cout << ", ";
76  }
77  std::cout << it->extensionName << " Version " << it->specVersion;
78  }
79  }
80  std::cout << std::endl << std::endl;
81  }
82  }
83  std::cout << std::endl;
84  }
85  catch ( vk::SystemError & err )
86  {
87  std::cout << "vk::SystemError: " << err.what() << std::endl;
88  exit( -1 );
89  }
90  catch ( std::exception & err )
91  {
92  std::cout << "std::exception: " << err.what() << std::endl;
93  exit( -1 );
94  }
95  catch ( ... )
96  {
97  std::cout << "unknown error\n";
98  exit( -1 );
99  }
100  return 0;
101 }
int main(int, char **)
void cout(vk::SurfaceCapabilitiesKHR const &surfaceCapabilities)
virtual const char * what() const VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6206
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE Result enumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pPropertyCount, vk::ExtensionProperties *pProperties, Dispatch const &d) VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE Result enumerateInstanceLayerProperties(uint32_t *pPropertyCount, vk::LayerProperties *pProperties, Dispatch const &d) VULKAN_HPP_NOEXCEPT
PropertyData(vk::LayerProperties const &layerProperties_, std::vector< vk::ExtensionProperties > const &extensionProperties_)
vk::LayerProperties layerProperties
std::vector< vk::ExtensionProperties > extensionProperties