Introduce raii-compliant handle wrapper classes.
This commit is contained in:
@@ -31,17 +31,18 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
{
|
||||
try
|
||||
{
|
||||
vk::UniqueInstance instance = vk::su::createInstance( AppName, EngineName );
|
||||
vk::Instance instance = vk::su::createInstance( AppName, EngineName );
|
||||
#if !defined( NDEBUG )
|
||||
vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger( instance );
|
||||
vk::DebugUtilsMessengerEXT debugUtilsMessenger =
|
||||
instance.createDebugUtilsMessengerEXT( vk::su::makeDebugUtilsMessengerCreateInfoEXT() );
|
||||
#endif
|
||||
|
||||
std::vector<vk::PhysicalDevice> physicalDevices = instance->enumeratePhysicalDevices();
|
||||
std::vector<vk::PhysicalDevice> physicalDevices = instance.enumeratePhysicalDevices();
|
||||
assert( !physicalDevices.empty() );
|
||||
|
||||
uint32_t graphicsQueueFamilyIndex =
|
||||
vk::su::findGraphicsQueueFamilyIndex( physicalDevices[0].getQueueFamilyProperties() );
|
||||
vk::UniqueDevice device = vk::su::createDevice( physicalDevices[0], graphicsQueueFamilyIndex );
|
||||
vk::Device device = vk::su::createDevice( physicalDevices[0], graphicsQueueFamilyIndex );
|
||||
|
||||
// create an image
|
||||
vk::ImageCreateInfo imageCreateInfo( {},
|
||||
@@ -53,15 +54,20 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::SampleCountFlagBits::e1,
|
||||
vk::ImageTiling::eLinear,
|
||||
vk::ImageUsageFlagBits::eTransferSrc );
|
||||
vk::UniqueImage image = device->createImageUnique( imageCreateInfo );
|
||||
vk::Image image = device.createImage( imageCreateInfo );
|
||||
|
||||
/* VULKAN_KEY_START */
|
||||
|
||||
vk::DebugUtilsObjectNameInfoEXT debugUtilsObjectNameInfo(
|
||||
vk::ObjectType::eImage, NON_DISPATCHABLE_HANDLE_TO_UINT64_CAST( VkImage, *image ), "Image name" );
|
||||
device->setDebugUtilsObjectNameEXT( debugUtilsObjectNameInfo );
|
||||
vk::ObjectType::eImage, NON_DISPATCHABLE_HANDLE_TO_UINT64_CAST( VkImage, image ), "Image name" );
|
||||
device.setDebugUtilsObjectNameEXT( debugUtilsObjectNameInfo );
|
||||
|
||||
/* VULKAN_KEY_END */
|
||||
|
||||
device.destroyImage( image );
|
||||
device.destroy();
|
||||
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
|
||||
instance.destroy();
|
||||
}
|
||||
catch ( vk::SystemError & err )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user