Vulkan-Hpp
InstanceLayerProperties.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 : InstanceLayerProperties
16 // Get global layer properties to know what layers are available to enable at CreateInstance time.
17 
18 #include <iostream>
19 #include <sstream>
20 #include <vector>
21 #include <vulkan/vulkan.hpp>
22 
23 int main( int /*argc*/, char ** /*argv*/ )
24 {
25  try
26  {
27  /* VULKAN_KEY_START */
28 
29  std::vector<vk::LayerProperties> layerProperties = vk::enumerateInstanceLayerProperties();
30 
31  std::cout << "Instance Layers:" << std::endl;
32  if ( layerProperties.empty() )
33  {
34  std::cout << "Set the environment variable VK_LAYER_PATH to point to the location of your layers" << std::endl;
35  }
36  for ( auto const & lp : layerProperties )
37  {
38  std::cout << lp.layerName << ":" << std::endl;
39  std::cout << "\tVersion: " << lp.implementationVersion << std::endl;
40  std::cout << "\tAPI Version: (" << ( lp.specVersion >> 22 ) << "." << ( ( lp.specVersion >> 12 ) & 0x03FF ) << "." << ( lp.specVersion & 0xFFF ) << ")"
41  << std::endl;
42  std::cout << "\tDescription: " << lp.description << std::endl;
43  std::cout << std::endl;
44  }
45 
46  /* VULKAN_KEY_END */
47  }
48  catch ( vk::SystemError & err )
49  {
50  std::cout << "vk::SystemError: " << err.what() << std::endl;
51  exit( -1 );
52  }
53  catch ( std::exception & err )
54  {
55  std::cout << "std::runtexceptionime_error: " << err.what() << std::endl;
56  exit( -1 );
57  }
58  catch ( ... )
59  {
60  std::cout << "unknown error\n";
61  exit( -1 );
62  }
63  return 0;
64 }
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 enumerateInstanceLayerProperties(uint32_t *pPropertyCount, vk::LayerProperties *pProperties, Dispatch const &d) VULKAN_HPP_NOEXCEPT