diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c index 859da577427..9183460031b 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.c +++ b/src/gallium/drivers/freedreno/freedreno_batch.c @@ -403,12 +403,18 @@ recursive_dependents_mask(struct fd_batch *batch) return dependents_mask; } +bool +fd_batch_has_dep(struct fd_batch *batch, struct fd_batch *dep) +{ + return !!(batch->dependents_mask & (1 << dep->idx)); +} + void fd_batch_add_dep(struct fd_batch *batch, struct fd_batch *dep) { fd_screen_assert_locked(batch->ctx->screen); - if (batch->dependents_mask & (1 << dep->idx)) + if (fd_batch_has_dep(batch, dep)) return; /* a loop should not be possible */ diff --git a/src/gallium/drivers/freedreno/freedreno_batch.h b/src/gallium/drivers/freedreno/freedreno_batch.h index 7c8b9e719a1..22319ab9a78 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.h +++ b/src/gallium/drivers/freedreno/freedreno_batch.h @@ -261,6 +261,7 @@ struct fd_batch *fd_batch_create(struct fd_context *ctx, bool nondraw); void fd_batch_reset(struct fd_batch *batch) assert_dt; void fd_batch_flush(struct fd_batch *batch) assert_dt; +bool fd_batch_has_dep(struct fd_batch *batch, struct fd_batch *dep) assert_dt; void fd_batch_add_dep(struct fd_batch *batch, struct fd_batch *dep) assert_dt; void fd_batch_resource_write(struct fd_batch *batch, struct fd_resource *rsc) assert_dt; diff --git a/src/gallium/drivers/freedreno/freedreno_batch_cache.c b/src/gallium/drivers/freedreno/freedreno_batch_cache.c index 5bd45006230..8de5022d0e4 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch_cache.c +++ b/src/gallium/drivers/freedreno/freedreno_batch_cache.c @@ -380,7 +380,7 @@ alloc_batch_locked(struct fd_batch_cache *cache, struct fd_context *ctx, struct fd_batch *other = cache->batches[i]; if (!other) continue; - if (other->dependents_mask & (1 << flush_batch->idx)) { + if (fd_batch_has_dep(other, flush_batch)) { other->dependents_mask &= ~(1 << flush_batch->idx); struct fd_batch *ref = flush_batch; fd_batch_reference_locked(&ref, NULL);