From 6b64dddd7118e75dbb9d6aa4917b296f384aba89 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 15 Jan 2016 15:59:58 -0800 Subject: [PATCH] anv/batch_chain: Remove padding from the BO before emitting BUFFER_END --- src/vulkan/anv_batch_chain.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/vulkan/anv_batch_chain.c b/src/vulkan/anv_batch_chain.c index 9c80f5e3b03..89215fe6992 100644 --- a/src/vulkan/anv_batch_chain.c +++ b/src/vulkan/anv_batch_chain.c @@ -649,6 +649,15 @@ anv_cmd_buffer_end_batch_buffer(struct anv_cmd_buffer *cmd_buffer) struct anv_batch_bo *batch_bo = anv_cmd_buffer_current_batch_bo(cmd_buffer); if (cmd_buffer->level == VK_COMMAND_BUFFER_LEVEL_PRIMARY) { + /* When we start a batch buffer, we subtract a certain amount of + * padding from the end to ensure that we always have room to emit a + * BATCH_BUFFER_START to chain to the next BO. We need to remove + * that padding before we end the batch; otherwise, we may end up + * with our BATCH_BUFFER_END in another BO. + */ + cmd_buffer->batch.end += GEN8_MI_BATCH_BUFFER_START_length * 4; + assert(cmd_buffer->batch.end == batch_bo->bo.map + batch_bo->bo.size); + anv_batch_emit(&cmd_buffer->batch, GEN7_MI_BATCH_BUFFER_END); /* Round batch up to an even number of dwords. */ -- 2.30.2