Commit 9041bb7c by Alexis Hetu Committed by Alexis Hétu

Basic CommandBuffer::waitEvents implementation

Implemented waitEvents as a sync operation, like pipeline barriers, since, as the Vulkan spec states: "vkCmdWaitEvents is used with vkCmdSetEvent to define a memory dependency between two sets of action commands, roughly in the same way as pipeline barriers, but split into two commands such that work between the two may execute unhindered." Only the pEvents parameter is supported and currently doesn't support pMemoryBarrier, pBufferMemoryBarriers or pImageMemoryBarriers. Bug b/118620868 Change-Id: I30ccc65c65dfc7d9a99e25ebb535061c618375cb Tests: dEQP-VK.api.command_buffers.record_simul_use_primary Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/27348Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Presubmit-Ready: Alexis Hétu <sugoi@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 29090850
...@@ -540,7 +540,11 @@ struct SignalEvent : public CommandBuffer::Command ...@@ -540,7 +540,11 @@ struct SignalEvent : public CommandBuffer::Command
void play(CommandBuffer::ExecutionState& executionState) override void play(CommandBuffer::ExecutionState& executionState) override
{ {
Cast(ev)->signal(); if(Cast(ev)->signal())
{
// Was waiting for signal on this event, sync now
executionState.renderer->synchronize();
}
} }
private: private:
...@@ -564,6 +568,25 @@ private: ...@@ -564,6 +568,25 @@ private:
VkPipelineStageFlags stageMask; // FIXME(b/117835459) : We currently ignore the flags and reset the event at the last stage VkPipelineStageFlags stageMask; // FIXME(b/117835459) : We currently ignore the flags and reset the event at the last stage
}; };
struct WaitEvent : public CommandBuffer::Command
{
WaitEvent(VkEvent ev) : ev(ev)
{
}
void play(CommandBuffer::ExecutionState& executionState) override
{
if(!Cast(ev)->wait())
{
// Already signaled, sync now
executionState.renderer->synchronize();
}
}
private:
VkEvent ev;
};
struct BindDescriptorSet : public CommandBuffer::Command struct BindDescriptorSet : public CommandBuffer::Command
{ {
BindDescriptorSet(VkPipelineBindPoint pipelineBindPoint, uint32_t set, const VkDescriptorSet& descriptorSet) BindDescriptorSet(VkPipelineBindPoint pipelineBindPoint, uint32_t set, const VkDescriptorSet& descriptorSet)
...@@ -1030,7 +1053,15 @@ void CommandBuffer::waitEvents(uint32_t eventCount, const VkEvent* pEvents, VkPi ...@@ -1030,7 +1053,15 @@ void CommandBuffer::waitEvents(uint32_t eventCount, const VkEvent* pEvents, VkPi
uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers,
uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers) uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers)
{ {
UNIMPLEMENTED("waitEvents"); ASSERT(state == RECORDING);
// TODO(b/117835459): Since we always do a full barrier, all memory barrier related arguments are ignored
// Note: srcStageMask and dstStageMask are currently ignored
for(uint32_t i = 0; i < eventCount; i++)
{
addCommand<WaitEvent>(pEvents[i]);
}
} }
void CommandBuffer::draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) void CommandBuffer::draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
......
...@@ -34,9 +34,12 @@ public: ...@@ -34,9 +34,12 @@ public:
return 0; return 0;
} }
void signal() bool signal()
{ {
status = VK_EVENT_SET; status = VK_EVENT_SET;
bool wasWaiting = waiting;
waiting = false;
return wasWaiting;
} }
void reset() void reset()
...@@ -49,8 +52,19 @@ public: ...@@ -49,8 +52,19 @@ public:
return status; return status;
} }
bool wait()
{
if(status != VK_EVENT_SET)
{
waiting = true;
}
return waiting;
}
private: private:
VkResult status = VK_EVENT_RESET; VkResult status = VK_EVENT_RESET;
bool waiting = false;
}; };
static inline Event* Cast(VkEvent object) static inline Event* Cast(VkEvent object)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment