Have final present function perform a VkQueueWaitIdle() This is just a small hack to prevent screen tearing. Later, we should properly implement VkSemaphore to prevent this. Bug: b/132458423 Change-Id: I825f100a73c4b5b9b909eba83552cbec51ff1792 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31152 Reviewed-by: Alexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: Hernan Liatis <hliatis@google.com>
diff --git a/src/Vulkan/VkQueue.cpp b/src/Vulkan/VkQueue.cpp index 037f347..23de338 100644 --- a/src/Vulkan/VkQueue.cpp +++ b/src/Vulkan/VkQueue.cpp
@@ -209,6 +209,11 @@ #ifndef __ANDROID__ void Queue::present(const VkPresentInfoKHR* presentInfo) { + // This is a hack to deal with screen tearing for now. + // Need to correctly implement threading using VkSemaphore + // to get rid of it. b/132458423 + waitIdle(); + for(uint32_t i = 0; i < presentInfo->waitSemaphoreCount; i++) { vk::Cast(presentInfo->pWaitSemaphores[i])->wait();
diff --git a/src/Vulkan/libVulkan.cpp b/src/Vulkan/libVulkan.cpp index 21b982d..eb5251c 100644 --- a/src/Vulkan/libVulkan.cpp +++ b/src/Vulkan/libVulkan.cpp
@@ -2677,6 +2677,11 @@ TRACE("(VkQueue queue = %p, uint32_t waitSemaphoreCount = %d, const VkSemaphore* pWaitSemaphores = %p, VkImage image = %p, int* pNativeFenceFd = %p)", queue, waitSemaphoreCount, pWaitSemaphores, image.get(), pNativeFenceFd); + // This is a hack to deal with screen tearing for now. + // Need to correctly implement threading using VkSemaphore + // to get rid of it. b/132458423 + vkQueueWaitIdle(queue); + GrallocModule* grallocMod = GrallocModule::getInstance(); void* nativeBuffer;