Unbreak some synchronization edge cases
- Renderer fence signaling only really worked for work in the same
submission. If the fence was submitted standalone later, there would
be no renderer work tagged with this fence, and so no ordering.
- Get rid of old uncounted fence operations. This is a landmine.
Bug: b/132897411
Test: dEQP-VK.api.copy_and_blit.*
Test: dEQP-VK.binding_model.*
Test: dEQP-VK.query_pool.*
Test: dEQP-VK.api.object_management.*
Test: dEQP-VK.memory.pipeline*
Change-Id: I9050b96d111a6c348c5675724c8017c483c06182
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31188
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Vulkan/VkFence.hpp b/src/Vulkan/VkFence.hpp
index 32ce06c..7e8761c 100644
--- a/src/Vulkan/VkFence.hpp
+++ b/src/Vulkan/VkFence.hpp
@@ -60,14 +60,6 @@
}
}
- void signal()
- {
- std::unique_lock<std::mutex> lock(mutex);
- status = VK_SUCCESS;
- lock.unlock();
- condition.notify_all();
- }
-
void reset()
{
std::unique_lock<std::mutex> lock(mutex);
diff --git a/src/Vulkan/VkQueue.cpp b/src/Vulkan/VkQueue.cpp
index 23de338..2e47ba0 100644
--- a/src/Vulkan/VkQueue.cpp
+++ b/src/Vulkan/VkQueue.cpp
@@ -17,6 +17,7 @@
#include "VkQueue.hpp"
#include "VkSemaphore.hpp"
#include "WSI/VkSwapchainKHR.hpp"
+#include "Device/Renderer.hpp"
#include <cstring>
@@ -151,6 +152,9 @@
if(task.fence)
{
+ // TODO: fix renderer signaling so that work submitted separately from (but before) a fence
+ // is guaranteed complete by the time the fence signals.
+ renderer->synchronize();
task.fence->done();
}
}
@@ -188,9 +192,6 @@
fence.wait();
- // Wait for all draw operations to complete, if any
- renderer->synchronize();
-
garbageCollect();
return VK_SUCCESS;
diff --git a/src/WSI/VkSwapchainKHR.cpp b/src/WSI/VkSwapchainKHR.cpp
index 5963935..672be09 100644
--- a/src/WSI/VkSwapchainKHR.cpp
+++ b/src/WSI/VkSwapchainKHR.cpp
@@ -193,7 +193,8 @@
if(fence)
{
- vk::Cast(fence)->signal();
+ vk::Cast(fence)->add();
+ vk::Cast(fence)->done();
}
return VK_SUCCESS;