diff --git a/tools/hello.cpp b/tools/hello.cpp index 808505b..7815678 100644 --- a/tools/hello.cpp +++ b/tools/hello.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -121,14 +122,16 @@ main (void) auto pdevices = cruft::vk::physical_device::find (instance); auto &pdevice = pdevices[0]; - VkSurfaceKHR surface_handle = cruft::vk::error::try_query ( + auto surface = cruft::vk::make_owned ( + cruft::vk::error::try_query ( glfwCreateWindowSurface, instance.native (), window, nullptr + ), + instance ); - cruft::vk::surface surface { surface_handle }; - auto surface_capabilities = pdevice.surface_capabilities (surface); - auto surface_formats = pdevice.surface_formats (surface); - auto present_modes = pdevice.present_modes (surface); + auto surface_capabilities = pdevice.surface_capabilities (surface.get ()); + auto surface_formats = pdevice.surface_formats (surface.get ()); + auto present_modes = pdevice.present_modes (surface.get ()); auto queues = pdevice.queue_families (); int graphics_queue_id = -1, present_queue_id = -1; @@ -141,7 +144,7 @@ main (void) for (int i = 0, last = queues.size (); i != last; ++i) { if (cruft::vk::error::try_query (vkGetPhysicalDeviceSurfaceSupportKHR, - pdevice.native (), i, surface.native ())) { + pdevice.native (), i, surface->native ())) { present_queue_id = i; break; } @@ -218,7 +221,7 @@ main (void) .sType = cruft::vk::structure_type_v, .pNext = nullptr, .flags = {}, - .surface = surface.native (), + .surface = surface->native (), .minImageCount = image_count, .imageFormat = surface_format.format, .imageColorSpace = surface_format.colorSpace, @@ -486,14 +489,10 @@ main (void) pipeline_info.basePipelineHandle = VK_NULL_HANDLE; pipeline_info.basePipelineIndex = -1; - VkPipeline graphics_pipeline; - cruft::vk::error::try_code ( - vkCreateGraphicsPipelines ( - ldevice.native (), VK_NULL_HANDLE, 1, &pipeline_info, nullptr, &graphics_pipeline - ) + auto graphics_pipeline = cruft::vk::make_owned> ( + ldevice, VK_NULL_HANDLE, 1, &pipeline_info, nullptr ); - using framebuffer_ptr = cruft::vk::owned_ptr; std::vector swapchain_framebuffers; swapchain_framebuffers.reserve (swap_image_views.size ()); @@ -556,7 +555,9 @@ main (void) vkCmdBeginRenderPass (command_buffers[i], &render_begin, VK_SUBPASS_CONTENTS_INLINE); - vkCmdBindPipeline (command_buffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, graphics_pipeline); + vkCmdBindPipeline ( + command_buffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, graphics_pipeline->native () + ); VkBuffer buffers[] = {vertex_buffer->native ()}; VkDeviceSize offsets[] = {0};