Refactor RAII-samples to use std::unique_ptr only if needed.
This commit is contained in:
@@ -30,29 +30,28 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
{
|
||||
try
|
||||
{
|
||||
std::unique_ptr<vk::raii::Context> context = vk::raii::su::make_unique<vk::raii::Context>();
|
||||
std::unique_ptr<vk::raii::Instance> instance =
|
||||
vk::raii::su::makeUniqueInstance( *context, AppName, EngineName, {}, vk::su::getInstanceExtensions() );
|
||||
vk::raii::Context context;
|
||||
vk::raii::Instance instance =
|
||||
vk::raii::su::makeInstance( context, AppName, EngineName, {}, vk::su::getInstanceExtensions() );
|
||||
#if !defined( NDEBUG )
|
||||
std::unique_ptr<vk::raii::DebugUtilsMessengerEXT> debugUtilsMessenger =
|
||||
vk::raii::su::makeUniqueDebugUtilsMessengerEXT( *instance );
|
||||
vk::raii::DebugUtilsMessengerEXT debugUtilsMessenger( instance, vk::su::makeDebugUtilsMessengerCreateInfoEXT() );
|
||||
#endif
|
||||
vk::raii::PhysicalDevices physicalDevices( *instance );
|
||||
|
||||
vk::raii::PhysicalDevices physicalDevices( instance );
|
||||
assert( !physicalDevices.empty() );
|
||||
|
||||
uint32_t graphicsQueueFamilyIndex =
|
||||
vk::su::findGraphicsQueueFamilyIndex( physicalDevices[0].getQueueFamilyProperties() );
|
||||
std::unique_ptr<vk::raii::Device> device =
|
||||
vk::raii::su::makeUniqueDevice( physicalDevices[0], graphicsQueueFamilyIndex );
|
||||
vk::raii::Device device = vk::raii::su::makeDevice( physicalDevices[0], graphicsQueueFamilyIndex );
|
||||
|
||||
// create an image
|
||||
std::unique_ptr<vk::raii::Image> image = vk::raii::su::makeUniqueImage( *device );
|
||||
vk::raii::Image image = vk::raii::su::makeImage( device );
|
||||
|
||||
/* 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 */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user