Vulkan-Hpp
DebugUtilsObjectName.cpp
Go to the documentation of this file.
1 // Copyright(c) 2020, 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 : DebugUtilsObjectName
16 // Demonstrate usage of DebugUtilsObjectName
17 
18 #include "../utils/utils.hpp"
19 
20 static char const * AppName = "DebugUtilsObjectName";
21 static char const * EngineName = "Vulkan.hpp";
22 
23 #if defined( _MSC_VER ) && !defined( _WIN64 )
24 # define NON_DISPATCHABLE_HANDLE_TO_UINT64_CAST( type, x ) static_cast<type>( x )
25 #else
26 # define NON_DISPATCHABLE_HANDLE_TO_UINT64_CAST( type, x ) reinterpret_cast<uint64_t>( static_cast<type>( x ) )
27 #endif
28 
29 int main( int /*argc*/, char ** /*argv*/ )
30 {
31  try
32  {
33  vk::Instance instance = vk::su::createInstance( AppName, EngineName );
34 #if !defined( NDEBUG )
36 #endif
37 
38  std::vector<vk::PhysicalDevice> physicalDevices = instance.enumeratePhysicalDevices();
39  assert( !physicalDevices.empty() );
40 
41  uint32_t graphicsQueueFamilyIndex = vk::su::findGraphicsQueueFamilyIndex( physicalDevices[0].getQueueFamilyProperties() );
42  vk::Device device = vk::su::createDevice( physicalDevices[0], graphicsQueueFamilyIndex );
43 
44  // create an image
45  vk::ImageCreateInfo imageCreateInfo( {},
48  vk::Extent3D( 640, 640, 1 ),
49  1,
50  1,
54  vk::Image image = device.createImage( imageCreateInfo );
55 
56  /* VULKAN_KEY_START */
57 
59  device.setDebugUtilsObjectNameEXT( debugUtilsObjectNameInfo );
60 
61  /* VULKAN_KEY_END */
62 
63  device.destroyImage( image );
64  device.destroy();
65 #if !defined( NDEBUG )
66  instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
67 #endif
68  instance.destroy();
69  }
70  catch ( vk::SystemError & err )
71  {
72  std::cout << "vk::SystemError: " << err.what() << std::endl;
73  exit( -1 );
74  }
75  catch ( std::exception & err )
76  {
77  std::cout << "std::exception: " << err.what() << std::endl;
78  exit( -1 );
79  }
80  catch ( ... )
81  {
82  std::cout << "unknown error\n";
83  exit( -1 );
84  }
85  return 0;
86 }
int main(int, char **)
#define NON_DISPATCHABLE_HANDLE_TO_UINT64_CAST(type, x)
void cout(vk::SurfaceCapabilitiesKHR const &surfaceCapabilities)
void destroy(const vk::AllocationCallbacks *pAllocator, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result setDebugUtilsObjectNameEXT(const vk::DebugUtilsObjectNameInfoEXT *pNameInfo, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
VULKAN_HPP_NODISCARD Result createImage(const vk::ImageCreateInfo *pCreateInfo, const vk::AllocationCallbacks *pAllocator, vk::Image *pImage, Dispatch const &d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT) const VULKAN_HPP_NOEXCEPT
void destroyImage(vk::Image image, const vk::AllocationCallbacks *pAllocator, 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
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
uint64_t VkImage
Definition: vulkan_core.h:100