Pass around sw::TaskEvents* instead of vk::Fence*. Bug: b/133127573 Change-Id: I0ce0164de401524014eb295547b899f24f437e21 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31683 Tested-by: Ben Clayton <bclayton@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Device/Renderer.cpp b/src/Device/Renderer.cpp index c4d4177..cce1724 100644 --- a/src/Device/Renderer.cpp +++ b/src/Device/Renderer.cpp
@@ -185,7 +185,7 @@ references = -1; - fence = nullptr; + events = nullptr; data = (DrawData*)allocate(sizeof(DrawData)); data->constants = &constants; @@ -299,7 +299,7 @@ return false; } - void Renderer::draw(const sw::Context* context, VkIndexType indexType, unsigned int count, int baseVertex, vk::Fence* fence, bool update) + void Renderer::draw(const sw::Context* context, VkIndexType indexType, unsigned int count, int baseVertex, TaskEvents *events, bool update) { if(count == 0) { return; } @@ -403,12 +403,13 @@ data->descriptorSets = context->descriptorSets; data->descriptorDynamicOffsets = context->descriptorDynamicOffsets; - if(fence) + if(events) { - fence->start(); + events->start(); } - ASSERT(!draw->fence); - draw->fence = fence; + + ASSERT(!draw->events); + draw->events = events; for(int i = 0; i < MAX_VERTEX_INPUTS; i++) { @@ -889,10 +890,10 @@ draw.setupRoutine->unbind(); draw.pixelRoutine->unbind(); - if(draw.fence) + if(draw.events) { - draw.fence->finish(); - draw.fence = nullptr; + draw.events->finish(); + draw.events = nullptr; } sync->unlock();
diff --git a/src/Device/Renderer.hpp b/src/Device/Renderer.hpp index 5b29780..9768b08 100644 --- a/src/Device/Renderer.hpp +++ b/src/Device/Renderer.hpp
@@ -30,7 +30,6 @@ namespace vk { class DescriptorSet; - class Fence; struct Query; } @@ -41,6 +40,7 @@ class VertexShader; class SwiftConfig; struct Task; + class TaskEvents; class Resource; struct Constants; @@ -200,7 +200,7 @@ bool hasQueryOfType(VkQueryType type) const; - void draw(const sw::Context* context, VkIndexType indexType, unsigned int count, int baseVertex, vk::Fence* fence, bool update = true); + void draw(const sw::Context* context, VkIndexType indexType, unsigned int count, int baseVertex, TaskEvents *events, bool update = true); // Viewport & Clipper void setViewport(const VkViewport &viewport); @@ -333,7 +333,7 @@ vk::ImageView *renderTarget[RENDERTARGETS]; vk::ImageView *depthBuffer; vk::ImageView *stencilBuffer; - vk::Fence* fence; + TaskEvents *events; std::list<vk::Query*> *queries;
diff --git a/src/Vulkan/VkCommandBuffer.cpp b/src/Vulkan/VkCommandBuffer.cpp index b60fe3e..92f5a6a 100644 --- a/src/Vulkan/VkCommandBuffer.cpp +++ b/src/Vulkan/VkCommandBuffer.cpp
@@ -601,7 +601,7 @@ { const uint32_t primitiveCount = indexBuffer.first; context.indexBuffer = indexBuffer.second; - executionState.renderer->draw(&context, executionState.indexType, primitiveCount, vertexOffset, executionState.fence); + executionState.renderer->draw(&context, executionState.indexType, primitiveCount, vertexOffset, executionState.events); } executionState.renderer->advanceInstanceAttributes(context.input);
diff --git a/src/Vulkan/VkCommandBuffer.hpp b/src/Vulkan/VkCommandBuffer.hpp index 40ea76f..5e59a79 100644 --- a/src/Vulkan/VkCommandBuffer.hpp +++ b/src/Vulkan/VkCommandBuffer.hpp
@@ -26,12 +26,12 @@ { class Context; class Renderer; + class TaskEvents; } namespace vk { -class Fence; class Framebuffer; class Pipeline; class RenderPass; @@ -133,7 +133,7 @@ }; sw::Renderer* renderer = nullptr; - Fence* fence = nullptr; + sw::TaskEvents* events = nullptr; RenderPass* renderPass = nullptr; Framebuffer* renderPassFramebuffer = nullptr; std::array<PipelineState, VK_PIPELINE_BIND_POINT_RANGE_SIZE> pipelineState;
diff --git a/src/Vulkan/VkQueue.cpp b/src/Vulkan/VkQueue.cpp index de19f0e..73e3602 100644 --- a/src/Vulkan/VkQueue.cpp +++ b/src/Vulkan/VkQueue.cpp
@@ -102,11 +102,11 @@ Task task; task.submitCount = submitCount; task.pSubmits = DeepCopySubmitInfo(submitCount, pSubmits); - task.fence = (fence != VK_NULL_HANDLE) ? vk::Cast(fence) : nullptr; + task.events = (fence != VK_NULL_HANDLE) ? vk::Cast(fence) : nullptr; - if(task.fence) + if(task.events) { - task.fence->start(); + task.events->start(); } pending.put(task); @@ -132,7 +132,7 @@ { CommandBuffer::ExecutionState executionState; executionState.renderer = renderer.get(); - executionState.fence = task.fence; + executionState.events = task.events; for(uint32_t j = 0; j < submitInfo.commandBufferCount; j++) { vk::Cast(submitInfo.pCommandBuffers[j])->submit(executionState); @@ -150,12 +150,12 @@ toDelete.put(task.pSubmits); } - if(task.fence) + if(task.events) { // 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->finish(); + task.events->finish(); } } @@ -187,7 +187,7 @@ fence.start(); Task task; - task.fence = &fence; + task.events = &fence; pending.put(task); fence.wait();
diff --git a/src/Vulkan/VkQueue.hpp b/src/Vulkan/VkQueue.hpp index 2fdb552..f4180c3 100644 --- a/src/Vulkan/VkQueue.hpp +++ b/src/Vulkan/VkQueue.hpp
@@ -56,7 +56,7 @@ { uint32_t submitCount = 0; VkSubmitInfo* pSubmits = nullptr; - Fence* fence = nullptr; + sw::TaskEvents* events = nullptr; enum Type { KILL_THREAD, SUBMIT_QUEUE }; Type type = SUBMIT_QUEUE;