intel: rework command buffer waiting
When a bo is submitted, we need the submission sequence number which we can
wait for. However, the kernel does not return the seqno. We have to keep the
bo around and wait for the bo. This fixes
xglQueueSubmit(..., cmd, ...);
xglDeviceWaitIdle(...);
xglDestroyObject(..., cmd);
xglDeviceWaitIdle(...);
where the second wait waited for a destroyed cmd buffer.
diff --git a/icd/intel/queue.c b/icd/intel/queue.c
index 21f7a77..b185419 100644
--- a/icd/intel/queue.c
+++ b/icd/intel/queue.c
@@ -289,6 +289,9 @@
void intel_queue_destroy(struct intel_queue *queue)
{
+ if (queue->seqno_bo)
+ intel_bo_unreference(queue->seqno_bo);
+
if (queue->atomic_bo)
intel_bo_unreference(queue->atomic_bo);
if (queue->select_graphics_bo)
@@ -300,10 +303,10 @@
XGL_RESULT intel_queue_wait(struct intel_queue *queue, int64_t timeout)
{
- struct intel_bo *bo = (queue->last_submitted_cmd) ?
- intel_cmd_get_batch(queue->last_submitted_cmd, NULL) : NULL;
+ if (!queue->seqno_bo)
+ return XGL_SUCCESS;
- return (!bo || intel_bo_wait(bo, timeout) == 0) ?
+ return (intel_bo_wait(queue->seqno_bo, timeout) == 0) ?
XGL_SUCCESS : XGL_ERROR_UNKNOWN;
}
@@ -364,11 +367,14 @@
last_cmd = intel_cmd(pCmdBuffers[i - 1]);
if (ret == XGL_SUCCESS) {
- queue->last_submitted_cmd = last_cmd;
+ if (queue->seqno_bo)
+ intel_bo_unreference(queue->seqno_bo);
+ queue->seqno_bo = intel_cmd_get_batch(last_cmd, NULL);
+ intel_bo_reference(queue->seqno_bo);
if (fence_ != XGL_NULL_HANDLE) {
struct intel_fence *fence = intel_fence(fence_);
- intel_fence_set_cmd(fence, last_cmd);
+ intel_fence_set_seqno(fence, queue->seqno_bo);
}
} else {
struct intel_bo *last_bo;