Threaded Queue submit with events and fences
This cl does 3 main things:
- It pushes the queue submit operation to its own thread
- It implements events
- It implements fences
Some details:
- Because we can have N async draw operations and we need to signal
the fence only after all operations are completed, fences have a
add/done mechanism to allow signaling the fence only when all
draw operations are completed.
- Device::waitForFences() detects large timeouts to avoid integer
overflow if now+timeout is bigger than the remaining nanoseconds
available in a long long.
Bug b/117835459
Change-Id: I2f02c3b4bb9d9ac9037909b02b0601e1bae15d21
Tests: dEQP-VK.synchronization.*
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/29769
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Vulkan/VkCommandBuffer.cpp b/src/Vulkan/VkCommandBuffer.cpp
index 9a25dad..56c37f1 100644
--- a/src/Vulkan/VkCommandBuffer.cpp
+++ b/src/Vulkan/VkCommandBuffer.cpp
@@ -15,6 +15,7 @@
#include "VkCommandBuffer.hpp"
#include "VkBuffer.hpp"
#include "VkEvent.hpp"
+#include "VkFence.hpp"
#include "VkFramebuffer.hpp"
#include "VkImage.hpp"
#include "VkImageView.hpp"
@@ -523,7 +524,8 @@
for(uint32_t instance = firstInstance; instance != firstInstance + instanceCount; instance++)
{
executionState.renderer->setInstanceID(instance);
- executionState.renderer->draw(context.topology, executionState.indexType, primitiveCount, vertexOffset);
+ executionState.renderer->draw(context.topology, executionState.indexType, primitiveCount, vertexOffset,
+ executionState.fence);
executionState.renderer->advanceInstanceAttributes();
}
}
@@ -843,11 +845,8 @@
void play(CommandBuffer::ExecutionState& executionState) override
{
- if(Cast(ev)->signal())
- {
- // Was waiting for signal on this event, sync now
- executionState.renderer->synchronize();
- }
+ executionState.renderer->synchronize();
+ Cast(ev)->signal();
}
private:
@@ -879,11 +878,8 @@
void play(CommandBuffer::ExecutionState& executionState) override
{
- if(!Cast(ev)->wait())
- {
- // Already signaled, sync now
- executionState.renderer->synchronize();
- }
+ executionState.renderer->synchronize();
+ Cast(ev)->wait();
}
private: