diff --git a/bldsys/cmake/global_options.cmake b/bldsys/cmake/global_options.cmake index 142d074f2..eb3d53942 100644 --- a/bldsys/cmake/global_options.cmake +++ b/bldsys/cmake/global_options.cmake @@ -37,8 +37,9 @@ if(APPLE) # the following assumes MoltenVK is used for these cases: a) standalone deployment on macOS (i.e. set USE_MoltenVK=ON), and b) for iOS deployment # if this assumption changes (e.g. KosmicKrisp adds standalone or iOS support), then this section will require modification to handle optionality + # note: Vulkan SDK 1.4.357+ now provides xcframeworks for the Vulkan loader and Validation Layers for iphonesimulator on arm64 and x86_64 hosts find_package(Vulkan QUIET OPTIONAL_COMPONENTS MoltenVK) - if(USE_MoltenVK OR (IOS AND (NOT Vulkan_MoltenVK_FOUND OR ${CMAKE_OSX_SYSROOT} STREQUAL "iphonesimulator"))) + if(USE_MoltenVK OR (IOS AND (NOT Vulkan_MoltenVK_FOUND OR (${CMAKE_OSX_SYSROOT} STREQUAL "iphonesimulator" AND Vulkan_VERSION VERSION_LESS "1.4.357")))) # if using MoltenVK standalone, or MoltenVK for iOS not found or using iOS Simulator, look for MoltenVK in Vulkan SDK and MoltenVK project paths if(NOT Vulkan_MoltenVK_LIBRARY) # since both are available in the Vulkan SDK and MoltenVK github project, make sure we look for MoltenVK framework on iOS and dylib on macOS diff --git a/framework/gui.h b/framework/gui.h index 5f084960d..cddf3e1d1 100644 --- a/framework/gui.h +++ b/framework/gui.h @@ -645,7 +645,10 @@ inline void #if defined(PLATFORM__MACOS) && TARGET_OS_IOS && TARGET_OS_SIMULATOR // iOS Simulator does not support vkCmdDrawIndexed() with vertex_offset > 0, so rebind vertex buffer instead vertex_offsets[0] += cmd_list->VtxBuffer.Size * sizeof(ImDrawVert); - command_buffer.bindVertexBuffers(0, vertex_buffer_handle, vertex_offsets); + if (vertex_offsets[0] < vertex_buffer->get_size()) + { + command_buffer.bindVertexBuffers(0, vertex_buffer_handle, vertex_offsets); + } #else vertex_offset += cmd_list->VtxBuffer.Size; #endif @@ -753,6 +756,7 @@ inline void Gui::draw_impl(vkb::core::CommandBufferCpp &command_buf std::vector> vertex_buffers; std::vector vertex_offsets; + vk::DeviceSize vertex_size; // If a render context is used, then use the frames buffer pools to allocate GUI vertex/index data from if (!explicit_update) @@ -763,12 +767,14 @@ inline void Gui::draw_impl(vkb::core::CommandBufferCpp &command_buf { vertex_buffers.push_back(vertex_allocation.get_buffer()); vertex_offsets.push_back(vertex_allocation.get_offset()); + vertex_size = vertex_allocation.get_size(); } } else { vertex_buffers.push_back(*vertex_buffer); vertex_offsets.push_back(0); + vertex_size = vertex_buffer->get_size(); command_buffer.bind_vertex_buffers(0, vertex_buffers, vertex_offsets); command_buffer.bind_index_buffer(*index_buffer, 0, vk::IndexType::eUint16); } @@ -821,7 +827,10 @@ inline void Gui::draw_impl(vkb::core::CommandBufferCpp &command_buf if (!vertex_offsets.empty()) { vertex_offsets.back() += cmd_list->VtxBuffer.Size * sizeof(ImDrawVert); - command_buffer.bind_vertex_buffers(0, vertex_buffers, vertex_offsets); + if (vertex_offsets.back() < vertex_size) + { + command_buffer.bind_vertex_buffers(0, vertex_buffers, vertex_offsets); + } } #else vertex_offset += cmd_list->VtxBuffer.Size;