VG_BO_FREE(bo);
for (int i = 0; i < bo->nr_fences; i++)
- fd_pipe_del(bo->fences[i].pipe);
+ fd_fence_del(bo->fences[i]);
if (bo->fences != &bo->_inline_fence)
free(bo->fences);
static void
bo_flush(struct fd_bo *bo)
{
- for (int i = 0; i < bo->nr_fences; i++) {
- struct fd_bo_fence *f = &bo->fences[i];
- fd_pipe_flush(f->pipe, f->fence);
+ simple_mtx_lock(&fence_lock);
+ unsigned nr = bo->nr_fences;
+ struct fd_fence *fences[nr];
+ for (unsigned i = 0; i < nr; i++)
+ fences[i] = fd_fence_ref_locked(bo->fences[i]);
+ simple_mtx_unlock(&fence_lock);
+
+ for (unsigned i = 0; i < nr; i++) {
+ fd_fence_flush(bo->fences[i]);
+ fd_fence_del(fences[i]);
}
}
simple_mtx_assert_locked(&fence_lock);
for (int i = 0; i < bo->nr_fences; i++) {
- struct fd_bo_fence *f = &bo->fences[i];
+ struct fd_fence *f = bo->fences[i];
- if (fd_fence_before(f->pipe->control->fence, f->fence))
+ if (fd_fence_before(f->pipe->control->fence, f->ufence))
continue;
- struct fd_pipe *pipe = f->pipe;
-
bo->nr_fences--;
if (bo->nr_fences > 0) {
i--;
}
- fd_pipe_del_locked(pipe);
+ fd_fence_del_locked(f);
}
}
void
-fd_bo_add_fence(struct fd_bo *bo, struct fd_pipe *pipe, uint32_t fence)
+fd_bo_add_fence(struct fd_bo *bo, struct fd_fence *fence)
{
simple_mtx_assert_locked(&fence_lock);
return;
/* The common case is bo re-used on the same pipe it had previously
- * been used on:
+ * been used on, so just replace the previous fence.
*/
for (int i = 0; i < bo->nr_fences; i++) {
- struct fd_bo_fence *f = &bo->fences[i];
- if (f->pipe == pipe) {
- assert(fd_fence_before(f->fence, fence));
- f->fence = fence;
+ struct fd_fence *f = bo->fences[i];
+ if (f == fence)
+ return;
+ if (f->pipe == fence->pipe) {
+ assert(fd_fence_before(f->ufence, fence->ufence));
+ fd_fence_del_locked(f);
+ bo->fences[i] = fd_fence_ref_locked(fence);
return;
}
}
APPEND(bo, fences, bo->_inline_fence);
}
- APPEND(bo, fences, (struct fd_bo_fence){
- .pipe = fd_pipe_ref_locked(pipe),
- .fence = fence,
- });
+ APPEND(bo, fences, fd_fence_ref_locked(fence));
}
enum fd_bo_state
/* buffer-object functions:
*/
-struct fd_bo_fence {
- /* For non-shared buffers, track the last pipe the buffer was active
- * on, and the per-pipe fence value that indicates when the buffer is
- * idle:
- */
- uint32_t fence;
- struct fd_pipe *pipe;
-};
-
struct fd_bo {
struct fd_device *dev;
uint32_t size;
time_t free_time; /* time when added to bucket-list */
unsigned short nr_fences, max_fences;
- struct fd_bo_fence *fences;
+ struct fd_fence **fences;
/* In the common case, there is no more than one fence attached.
* This provides storage for the fences table until it grows to
* be larger than a single element.
*/
- struct fd_bo_fence _inline_fence;
+ struct fd_fence *_inline_fence;
};
struct fd_bo *_fd_bo_new(struct fd_device *dev, uint32_t size, uint32_t flags);
for (unsigned i = 0; i < primary->u.nr_cmds; i++)
fd_submit_append_bo(fd_submit, primary->u.cmds[i].ring_bo);
+ out_fence->ufence = submit->fence;
+
simple_mtx_lock(&fence_lock);
for (unsigned i = 0; i < fd_submit->nr_bos; i++) {
- fd_bo_add_fence(fd_submit->bos[i], submit->pipe, submit->fence);
+ fd_bo_add_fence(fd_submit->bos[i], out_fence);
has_shared |= fd_submit->bos[i]->alloc_flags & FD_BO_SHARED;
}
simple_mtx_unlock(&fence_lock);