Refactor RAII-samples to use std::unique_ptr only if needed.
This commit is contained in:
@@ -38,24 +38,23 @@ 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
|
||||
std::unique_ptr<vk::raii::PhysicalDevice> physicalDevice = vk::raii::su::makeUniquePhysicalDevice( *instance );
|
||||
vk::raii::PhysicalDevice physicalDevice = std::move( vk::raii::PhysicalDevices( instance ).front() );
|
||||
|
||||
vk::raii::su::SurfaceData surfaceData( *instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 500, 500 ) );
|
||||
|
||||
std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
|
||||
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( *physicalDevice, *surfaceData.surface );
|
||||
std::unique_ptr<vk::raii::Device> device = vk::raii::su::makeUniqueDevice(
|
||||
*physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, *surfaceData.pSurface );
|
||||
vk::raii::Device device = vk::raii::su::makeDevice(
|
||||
physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
|
||||
|
||||
vk::Format colorFormat =
|
||||
vk::su::pickSurfaceFormat( physicalDevice->getSurfaceFormatsKHR( **surfaceData.surface ) ).format;
|
||||
vk::su::pickSurfaceFormat( physicalDevice.getSurfaceFormatsKHR( **surfaceData.pSurface ) ).format;
|
||||
vk::Format depthFormat = vk::Format::eD16Unorm;
|
||||
|
||||
/* VULKAN_HPP_KEY_START */
|
||||
@@ -84,9 +83,8 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::AttachmentReference depthReference( 1, vk::ImageLayout::eDepthStencilAttachmentOptimal );
|
||||
vk::SubpassDescription subpass( {}, vk::PipelineBindPoint::eGraphics, {}, colorReference, {}, &depthReference );
|
||||
|
||||
vk::RenderPassCreateInfo renderPassCreateInfo( {}, attachmentDescriptions, subpass );
|
||||
std::unique_ptr<vk::raii::RenderPass> renderPass =
|
||||
vk::raii::su::make_unique<vk::raii::RenderPass>( *device, renderPassCreateInfo );
|
||||
vk::RenderPassCreateInfo renderPassCreateInfo( {}, attachmentDescriptions, subpass );
|
||||
vk::raii::RenderPass renderPass( device, renderPassCreateInfo );
|
||||
|
||||
/* VULKAN_HPP_KEY_END */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user