From bbac6f52cf75f80dd7aef64e5af73269bd5cb4d1 Mon Sep 17 00:00:00 2001 From: Ginu Jacob Date: Tue, 29 Oct 2024 08:49:31 +0000 Subject: [PATCH] Changes to move the functional code outside of assert() call --- wsi/external_memory.cpp | 4 ++-- wsi/swapchain_base.cpp | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/wsi/external_memory.cpp b/wsi/external_memory.cpp index 630681f..7c1783c 100644 --- a/wsi/external_memory.cpp +++ b/wsi/external_memory.cpp @@ -55,7 +55,7 @@ external_memory::~external_memory() else if (m_buffer_fds[plane] >= 0) { auto it = std::find(std::begin(m_buffer_fds), std::end(m_buffer_fds), m_buffer_fds[plane]); - if (std::distance(std::begin(m_buffer_fds), it) == plane) + if (std::distance(std::begin(m_buffer_fds), it) == static_cast(plane)) { close(m_buffer_fds[plane]); } @@ -108,7 +108,7 @@ VkResult external_memory::import_plane_memories() for (uint32_t plane = 0; plane < get_num_planes(); plane++) { auto it = std::find(std::begin(m_buffer_fds), std::end(m_buffer_fds), m_buffer_fds[plane]); - if (std::distance(std::begin(m_buffer_fds), it) == plane) + if (std::distance(std::begin(m_buffer_fds), it) == static_cast(plane)) { TRY_LOG_CALL(import_plane_memory(m_buffer_fds[plane], &m_memories[memory_plane])); memory_plane++; diff --git a/wsi/swapchain_base.cpp b/wsi/swapchain_base.cpp index 3c390cd..c99624a 100644 --- a/wsi/swapchain_base.cpp +++ b/wsi/swapchain_base.cpp @@ -276,8 +276,13 @@ VkResult swapchain_base::handle_swapchain_present_modes_create_info( assert(props != nullptr); for (uint32_t i = 0; i < swapchain_present_modes_create_info->presentModeCount; i++) { - assert( - props->is_compatible_present_modes(m_present_mode, swapchain_present_modes_create_info->pPresentModes[i])); + auto res = + props->is_compatible_present_modes(m_present_mode, swapchain_present_modes_create_info->pPresentModes[i]); + if (!res) + { + WSI_LOG_ERROR("present modes incompatible"); + return VK_ERROR_INITIALIZATION_FAILED; + } m_present_modes[i] = swapchain_present_modes_create_info->pPresentModes[i]; } } @@ -851,7 +856,11 @@ VkResult swapchain_base::handle_switching_presentation_mode(VkPresentModeKHR swa assert(m_present_modes.size() > 0); auto it = std::find_if(m_present_modes.begin(), m_present_modes.end(), [swapchain_present_mode](VkPresentModeKHR p) { return p == swapchain_present_mode; }); - assert(it != m_present_modes.end()); + if (it == m_present_modes.end()) + { + WSI_LOG_ERROR("unable to switch presentation mode"); + return VK_ERROR_SURFACE_LOST_KHR; + } m_present_mode = swapchain_present_mode; return VK_SUCCESS; }