freedreno: add fd_context_batch() accessor
[mesa.git] / src / gallium / drivers / freedreno / freedreno_batch_cache.c
index 1bf656cf2087af2fb25005d7203e20f29e2318b6..9d046f205bc7154dcc907f8930c5b8d81588bada 100644 (file)
@@ -144,10 +144,11 @@ bc_flush(struct fd_batch_cache *cache, struct fd_context *ctx, bool deferred)
        }
 
        if (deferred) {
-               struct fd_batch *current_batch = ctx->batch;
+               struct fd_batch *current_batch = fd_context_batch(ctx);
 
                for (unsigned i = 0; i < n; i++) {
-                       if (batches[i] != current_batch) {
+                       if (batches[i] && (batches[i]->ctx == ctx) &&
+                                       (batches[i] != current_batch)) {
                                fd_batch_add_dep(current_batch, batches[i]);
                        }
                }