Vulkan-Hpp
08_InitPipelineLayout.cpp
Go to the documentation of this file.
1 // Copyright(c) 2018-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 : 08_InitPipelineLayout
16 // Initialize a descriptor and pipeline layout
17 
18 #include "../utils/utils.hpp"
19 
20 #include <iostream>
21 
22 static char const * AppName = "08_InitPipelineLayout";
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  vk::PhysicalDevice physicalDevice = instance.enumeratePhysicalDevices().front();
35 
36  uint32_t graphicsQueueFamilyIndex = vk::su::findGraphicsQueueFamilyIndex( physicalDevice.getQueueFamilyProperties() );
37  vk::Device device = vk::su::createDevice( physicalDevice, graphicsQueueFamilyIndex );
38 
39  /* VULKAN_HPP_KEY_START */
40 
41  // create a DescriptorSetLayout
43  vk::DescriptorSetLayout descriptorSetLayout =
45 
46  // create a PipelineLayout using that DescriptorSetLayout
48 
49  // destroy the pipelineLayout and the descriptorSetLayout
50  device.destroyPipelineLayout( pipelineLayout );
51  device.destroyDescriptorSetLayout( descriptorSetLayout );
52 
53  /* VULKAN_HPP_KEY_END */
54 
55  device.destroy();
56 #if !defined( NDEBUG )
57  instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
58 #endif
59  instance.destroy();
60  }
61  catch ( vk::SystemError & err )
62  {
63  std::cout << "vk::SystemError: " << err.what() << std::endl;
64  exit( -1 );
65  }
66  catch ( std::exception & err )
67  {
68  std::cout << "std::exception: " << err.what() << std::endl;
69  exit( -1 );
70  }
71  catch ( ... )
72  {
73  std::cout << "unknown error\n";
74  exit( -1 );
75  }
76  return 0;
77 }
int main(int, char **)
void cout(vk::SurfaceCapabilitiesKHR const &surfaceCapabilities)
VULKAN_HPP_NODISCARD Result createPipelineLayout(const vk::PipelineLayoutCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::PipelineLayout *pPipelineLayout, 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
void destroyPipelineLayout(vk::PipelineLayout pipelineLayout, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroyDescriptorSetLayout(vk::DescriptorSetLayout descriptorSetLayout, const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result createDescriptorSetLayout(const vk::DescriptorSetLayoutCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::DescriptorSetLayout *pSetLayout, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
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
void getQueueFamilyProperties(uint32_t *pQueueFamilyPropertyCount, vk::QueueFamilyProperties *pQueueFamilyProperties, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
virtual const char * what() const VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6206
uint32_t findGraphicsQueueFamilyIndex(std::vector< vk::QueueFamilyProperties > const &queueFamilyProperties)
Definition: utils.cpp:409
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
vk::Device createDevice(vk::PhysicalDevice const &physicalDevice, uint32_t queueFamilyIndex, std::vector< std::string > const &extensions, vk::PhysicalDeviceFeatures const *physicalDeviceFeatures, void const *pNext)
Definition: utils.cpp:86