anv/batch_chain: Remove padding from the BO before emitting BUFFER_END
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 15 Jan 2016 23:59:58 +0000 (15:59 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 15 Jan 2016 23:59:58 +0000 (15:59 -0800)
src/vulkan/anv_batch_chain.c

index 9c80f5e3b03ff257188ce153679a2361e6428108..89215fe699283eff7e5551c4248ec196472998ab 100644 (file)
@@ -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. */