diff --git a/include/mbgl/vulkan/context.hpp b/include/mbgl/vulkan/context.hpp index b9fb8c608..6a4880c9d 100644 --- a/include/mbgl/vulkan/context.hpp +++ b/include/mbgl/vulkan/context.hpp @@ -157,19 +157,14 @@ private: struct FrameResources { vk::UniqueCommandBuffer commandBuffer; - vk::UniqueSemaphore surfaceSemaphore; - vk::UniqueSemaphore frameSemaphore; + vk::UniqueSemaphore acquireSurfaceSemaphore; vk::UniqueFence flightFrameFence; std::vector> deletionQueue; - FrameResources(vk::UniqueCommandBuffer& cb, - vk::UniqueSemaphore&& surf, - vk::UniqueSemaphore&& frame, - vk::UniqueFence&& flight) + FrameResources(vk::UniqueCommandBuffer& cb, vk::UniqueSemaphore&& surf, vk::UniqueFence&& flight) : commandBuffer(std::move(cb)), - surfaceSemaphore(std::move(surf)), - frameSemaphore(std::move(frame)), + acquireSurfaceSemaphore(std::move(surf)), flightFrameFence(std::move(flight)) {} void runDeletionQueue(Context&); diff --git a/include/mbgl/vulkan/renderable_resource.hpp b/include/mbgl/vulkan/renderable_resource.hpp index 369e53d1e..35a2337c0 100644 --- a/include/mbgl/vulkan/renderable_resource.hpp +++ b/include/mbgl/vulkan/renderable_resource.hpp @@ -58,6 +58,7 @@ public: uint32_t getAcquiredImageIndex() const { return acquiredImageIndex; }; void setAcquiredImageIndex(uint32_t index) { acquiredImageIndex = index; }; const vk::Image getAcquiredImage() const; + const vk::Semaphore& getAcquiredSemaphore() const; bool hasSurfaceTransformSupport() const; bool didSurfaceTransformUpdate() const; @@ -86,6 +87,7 @@ protected: std::vector swapchainImages; std::vector swapchainImageViews; std::vector swapchainFramebuffers; + std::vector swapchainSemaphores; vk::Format colorFormat{vk::Format::eUndefined}; UniqueImageAllocation depthAllocation; diff --git a/platform/android/buildSrc/src/main/kotlin/maplibre.download-vulkan-validation.gradle.kts b/platform/android/buildSrc/src/main/kotlin/maplibre.download-vulkan-validation.gradle.kts index b9fe7e642..a74f8759b 100644 --- a/platform/android/buildSrc/src/main/kotlin/maplibre.download-vulkan-validation.gradle.kts +++ b/platform/android/buildSrc/src/main/kotlin/maplibre.download-vulkan-validation.gradle.kts @@ -18,7 +18,7 @@ import java.net.URL */ // Define the validation layer version, with a default value. -var vvlVersion = "1.3.290.0" +var vvlVersion = "1.4.313.0" if (extra.has("vvl_version")) { vvlVersion = extra["vvl_version"] as String } diff --git a/src/mbgl/vulkan/context.cpp b/src/mbgl/vulkan/context.cpp index ed795052d..22ca8ca71 100644 --- a/src/mbgl/vulkan/context.cpp +++ b/src/mbgl/vulkan/context.cpp @@ -99,15 +99,13 @@ void Context::initFrameResources() { for (uint32_t index = 0; index < frameCount; ++index) { frameResources.emplace_back(commandBuffers[index], - device->createSemaphoreUnique({}), device->createSemaphoreUnique({}), device->createFenceUnique(vk::FenceCreateInfo(vk::FenceCreateFlagBits::eSignaled))); const auto& frame = frameResources.back(); backend.setDebugName(frame.commandBuffer.get(), "FrameCommandBuffer_" + std::to_string(index)); - backend.setDebugName(frame.frameSemaphore.get(), "FrameSemaphore_" + std::to_string(index)); - backend.setDebugName(frame.surfaceSemaphore.get(), "SurfaceSemaphore_" + std::to_string(index)); + backend.setDebugName(frame.acquireSurfaceSemaphore.get(), "AcquireSurfaceSemaphore_" + std::to_string(index)); backend.setDebugName(frame.flightFrameFence.get(), "FrameFence_" + std::to_string(index)); } @@ -259,7 +257,7 @@ void Context::beginFrame() { MLN_TRACE_ZONE(acquireNextImageKHR); try { const vk::ResultValue acquireImageResult = device->acquireNextImageKHR( - renderableResource.getSwapchain().get(), timeout, frame.surfaceSemaphore.get(), nullptr); + renderableResource.getSwapchain().get(), timeout, frame.acquireSurfaceSemaphore.get(), nullptr); if (acquireImageResult.result == vk::Result::eSuccess) { renderableResource.setAcquiredImageIndex(acquireImageResult.value); @@ -303,8 +301,8 @@ void Context::submitFrame() { auto submitInfo = vk::SubmitInfo().setCommandBuffers(frame.commandBuffer.get()); if (platformSurface) { - submitInfo.setSignalSemaphores(frame.frameSemaphore.get()) - .setWaitSemaphores(frame.surfaceSemaphore.get()) + submitInfo.setSignalSemaphores(renderableResource.getAcquiredSemaphore()) + .setWaitSemaphores(frame.acquireSurfaceSemaphore.get()) .setWaitDstStageMask(waitStageMask); } @@ -320,7 +318,7 @@ void Context::submitFrame() { const auto acquiredImage = renderableResource.getAcquiredImageIndex(); const auto presentInfo = vk::PresentInfoKHR() .setSwapchains(renderableResource.getSwapchain().get()) - .setWaitSemaphores(frame.frameSemaphore.get()) + .setWaitSemaphores(renderableResource.getAcquiredSemaphore()) .setImageIndices(acquiredImage); try { diff --git a/src/mbgl/vulkan/renderable_resource.cpp b/src/mbgl/vulkan/renderable_resource.cpp index f129a6176..eb46f5deb 100644 --- a/src/mbgl/vulkan/renderable_resource.cpp +++ b/src/mbgl/vulkan/renderable_resource.cpp @@ -159,6 +159,12 @@ void SurfaceRenderableResource::initSwapchain(uint32_t w, uint32_t h) { colorFormat = swapchainCreateInfo.imageFormat; extent = swapchainCreateInfo.imageExtent; + + swapchainSemaphores.reserve(swapchainImageCount); + for (uint32_t index = 0; index < swapchainImageCount; ++index) { + swapchainSemaphores.emplace_back(device->createSemaphoreUnique({})); + backend.setDebugName(swapchainSemaphores.back().get(), "SurfaceSemaphore_" + std::to_string(index)); + } } void SurfaceRenderableResource::initDepthStencil() { @@ -241,6 +247,10 @@ const vk::Image SurfaceRenderableResource::getAcquiredImage() const { return colorAllocations[acquiredImageIndex]->image; } +const vk::Semaphore& SurfaceRenderableResource::getAcquiredSemaphore() const { + return swapchainSemaphores[acquiredImageIndex].get(); +} + bool SurfaceRenderableResource::hasSurfaceTransformSupport() const { #ifdef __ANDROID__ return surface && capabilities.supportedTransforms != vk::SurfaceTransformFlagBitsKHR::eIdentity; @@ -391,6 +401,7 @@ void SurfaceRenderableResource::recreateSwapchain() { renderPass.reset(); swapchainImageViews.clear(); swapchainImages.clear(); + swapchainSemaphores.clear(); init(extent.width, extent.height); }