Loading vulkan/libvulkan/swapchain.cpp +9 −3 Original line number Original line Diff line number Diff line Loading @@ -176,9 +176,12 @@ enum { MAX_TIMING_INFOS = 10 }; enum { MIN_NUM_FRAMES_AGO = 5 }; enum { MIN_NUM_FRAMES_AGO = 5 }; struct Swapchain { struct Swapchain { Swapchain(Surface& surface_, uint32_t num_images_) Swapchain(Surface& surface_, uint32_t num_images_, VkPresentModeKHR present_mode) : surface(surface_), : surface(surface_), num_images(num_images_), num_images(num_images_), mailbox_mode(present_mode == VK_PRESENT_MODE_MAILBOX_KHR), frame_timestamps_enabled(false) { frame_timestamps_enabled(false) { ANativeWindow* window = surface.window.get(); ANativeWindow* window = surface.window.get(); int64_t rdur; int64_t rdur; Loading @@ -190,6 +193,7 @@ struct Swapchain { Surface& surface; Surface& surface; uint32_t num_images; uint32_t num_images; bool mailbox_mode; bool frame_timestamps_enabled; bool frame_timestamps_enabled; uint64_t refresh_duration; uint64_t refresh_duration; Loading Loading @@ -858,7 +862,8 @@ VkResult CreateSwapchainKHR(VkDevice device, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (!mem) if (!mem) return VK_ERROR_OUT_OF_HOST_MEMORY; return VK_ERROR_OUT_OF_HOST_MEMORY; Swapchain* swapchain = new (mem) Swapchain(surface, num_images); Swapchain* swapchain = new (mem) Swapchain(surface, num_images, create_info->presentMode); // -- Dequeue all buffers and create a VkImage for each -- // -- Dequeue all buffers and create a VkImage for each -- // Any failures during or after this must cancel the dequeued buffers. // Any failures during or after this must cancel the dequeued buffers. Loading Loading @@ -1160,7 +1165,8 @@ VkResult QueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* present_info) { *SwapchainFromHandle(present_info->pSwapchains[sc]); *SwapchainFromHandle(present_info->pSwapchains[sc]); uint32_t image_idx = present_info->pImageIndices[sc]; uint32_t image_idx = present_info->pImageIndices[sc]; Swapchain::Image& img = swapchain.images[image_idx]; Swapchain::Image& img = swapchain.images[image_idx]; const VkPresentRegionKHR* region = (regions) ? ®ions[sc] : nullptr; const VkPresentRegionKHR* region = (regions && !swapchain.mailbox_mode) ? ®ions[sc] : nullptr; const VkPresentTimeGOOGLE* time = (times) ? ×[sc] : nullptr; const VkPresentTimeGOOGLE* time = (times) ? ×[sc] : nullptr; VkResult swapchain_result = VK_SUCCESS; VkResult swapchain_result = VK_SUCCESS; VkResult result; VkResult result; Loading Loading
vulkan/libvulkan/swapchain.cpp +9 −3 Original line number Original line Diff line number Diff line Loading @@ -176,9 +176,12 @@ enum { MAX_TIMING_INFOS = 10 }; enum { MIN_NUM_FRAMES_AGO = 5 }; enum { MIN_NUM_FRAMES_AGO = 5 }; struct Swapchain { struct Swapchain { Swapchain(Surface& surface_, uint32_t num_images_) Swapchain(Surface& surface_, uint32_t num_images_, VkPresentModeKHR present_mode) : surface(surface_), : surface(surface_), num_images(num_images_), num_images(num_images_), mailbox_mode(present_mode == VK_PRESENT_MODE_MAILBOX_KHR), frame_timestamps_enabled(false) { frame_timestamps_enabled(false) { ANativeWindow* window = surface.window.get(); ANativeWindow* window = surface.window.get(); int64_t rdur; int64_t rdur; Loading @@ -190,6 +193,7 @@ struct Swapchain { Surface& surface; Surface& surface; uint32_t num_images; uint32_t num_images; bool mailbox_mode; bool frame_timestamps_enabled; bool frame_timestamps_enabled; uint64_t refresh_duration; uint64_t refresh_duration; Loading Loading @@ -858,7 +862,8 @@ VkResult CreateSwapchainKHR(VkDevice device, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (!mem) if (!mem) return VK_ERROR_OUT_OF_HOST_MEMORY; return VK_ERROR_OUT_OF_HOST_MEMORY; Swapchain* swapchain = new (mem) Swapchain(surface, num_images); Swapchain* swapchain = new (mem) Swapchain(surface, num_images, create_info->presentMode); // -- Dequeue all buffers and create a VkImage for each -- // -- Dequeue all buffers and create a VkImage for each -- // Any failures during or after this must cancel the dequeued buffers. // Any failures during or after this must cancel the dequeued buffers. Loading Loading @@ -1160,7 +1165,8 @@ VkResult QueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* present_info) { *SwapchainFromHandle(present_info->pSwapchains[sc]); *SwapchainFromHandle(present_info->pSwapchains[sc]); uint32_t image_idx = present_info->pImageIndices[sc]; uint32_t image_idx = present_info->pImageIndices[sc]; Swapchain::Image& img = swapchain.images[image_idx]; Swapchain::Image& img = swapchain.images[image_idx]; const VkPresentRegionKHR* region = (regions) ? ®ions[sc] : nullptr; const VkPresentRegionKHR* region = (regions && !swapchain.mailbox_mode) ? ®ions[sc] : nullptr; const VkPresentTimeGOOGLE* time = (times) ? ×[sc] : nullptr; const VkPresentTimeGOOGLE* time = (times) ? ×[sc] : nullptr; VkResult swapchain_result = VK_SUCCESS; VkResult swapchain_result = VK_SUCCESS; VkResult result; VkResult result; Loading