aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Marek <[email protected]>2019-12-16 10:56:54 -0500
committerMarge Bot <[email protected]>2020-01-29 23:13:43 +0000
commit1c5d84fcae71b40f77891386ac53c8addee4f554 (patch)
treec9820e571ad119cb147421bf9f088bcd764f747e
parent5b5b7624753b57c8df0c3eab71124da012fbf3e4 (diff)
turnip: hook up cmdbuffer event set/wait
Gets some basic tests under "dEQP-VK.synchronization.*event*" passing Signed-off-by: Jonathan Marek <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3123> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3123>
-rw-r--r--src/freedreno/vulkan/tu_cmd_buffer.c58
1 files changed, 42 insertions, 16 deletions
diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c
index b9b9e2e0193..766279183a7 100644
--- a/src/freedreno/vulkan/tu_cmd_buffer.c
+++ b/src/freedreno/vulkan/tu_cmd_buffer.c
@@ -3869,11 +3869,23 @@ tu_CmdPipelineBarrier(VkCommandBuffer commandBuffer,
}
static void
-write_event(struct tu_cmd_buffer *cmd_buffer,
- struct tu_event *event,
- VkPipelineStageFlags stageMask,
- unsigned value)
+write_event(struct tu_cmd_buffer *cmd, struct tu_event *event, unsigned value)
{
+ struct tu_cs *cs = &cmd->cs;
+
+ VkResult result = tu_cs_reserve_space(cmd->device, cs, 4);
+ if (result != VK_SUCCESS) {
+ cmd->record_result = result;
+ return;
+ }
+
+ tu_bo_list_add(&cmd->bo_list, &event->bo, MSM_SUBMIT_BO_WRITE);
+
+ /* TODO: any flush required before/after ? */
+
+ tu_cs_emit_pkt7(cs, CP_MEM_WRITE, 3);
+ tu_cs_emit_qw(cs, event->bo.iova); /* ADDR_LO/HI */
+ tu_cs_emit(cs, value);
}
void
@@ -3881,10 +3893,10 @@ tu_CmdSetEvent(VkCommandBuffer commandBuffer,
VkEvent _event,
VkPipelineStageFlags stageMask)
{
- TU_FROM_HANDLE(tu_cmd_buffer, cmd_buffer, commandBuffer);
+ TU_FROM_HANDLE(tu_cmd_buffer, cmd, commandBuffer);
TU_FROM_HANDLE(tu_event, event, _event);
- write_event(cmd_buffer, event, stageMask, 1);
+ write_event(cmd, event, 1);
}
void
@@ -3892,10 +3904,10 @@ tu_CmdResetEvent(VkCommandBuffer commandBuffer,
VkEvent _event,
VkPipelineStageFlags stageMask)
{
- TU_FROM_HANDLE(tu_cmd_buffer, cmd_buffer, commandBuffer);
+ TU_FROM_HANDLE(tu_cmd_buffer, cmd, commandBuffer);
TU_FROM_HANDLE(tu_event, event, _event);
- write_event(cmd_buffer, event, stageMask, 0);
+ write_event(cmd, event, 0);
}
void
@@ -3911,16 +3923,30 @@ tu_CmdWaitEvents(VkCommandBuffer commandBuffer,
uint32_t imageMemoryBarrierCount,
const VkImageMemoryBarrier *pImageMemoryBarriers)
{
- TU_FROM_HANDLE(tu_cmd_buffer, cmd_buffer, commandBuffer);
- struct tu_barrier_info info;
+ TU_FROM_HANDLE(tu_cmd_buffer, cmd, commandBuffer);
+ struct tu_cs *cs = &cmd->cs;
+
+ VkResult result = tu_cs_reserve_space(cmd->device, cs, eventCount * 7);
+ if (result != VK_SUCCESS) {
+ cmd->record_result = result;
+ return;
+ }
- info.eventCount = eventCount;
- info.pEvents = pEvents;
- info.srcStageMask = 0;
+ /* TODO: any flush required before/after? (CP_WAIT_FOR_ME?) */
- tu_barrier(cmd_buffer, memoryBarrierCount, pMemoryBarriers,
- bufferMemoryBarrierCount, pBufferMemoryBarriers,
- imageMemoryBarrierCount, pImageMemoryBarriers, &info);
+ for (uint32_t i = 0; i < eventCount; i++) {
+ const struct tu_event *event = (const struct tu_event*) pEvents[i];
+
+ tu_bo_list_add(&cmd->bo_list, &event->bo, MSM_SUBMIT_BO_READ);
+
+ tu_cs_emit_pkt7(cs, CP_WAIT_REG_MEM, 6);
+ tu_cs_emit(cs, CP_WAIT_REG_MEM_0_FUNCTION(WRITE_EQ) |
+ CP_WAIT_REG_MEM_0_POLL_MEMORY);
+ tu_cs_emit_qw(cs, event->bo.iova); /* POLL_ADDR_LO/HI */
+ tu_cs_emit(cs, CP_WAIT_REG_MEM_3_REF(1));
+ tu_cs_emit(cs, CP_WAIT_REG_MEM_4_MASK(~0u));
+ tu_cs_emit(cs, CP_WAIT_REG_MEM_5_DELAY_LOOP_CYCLES(20));
+ }
}
void