freedreno: fence_server_sync() fixes
[mesa.git] / src / gallium / drivers / freedreno / freedreno_batch_cache.c
index 448e701bbc6276c81d2edd155c466ad0b2f60c6a..c407cc5e33dddc10727fb4ee98d4eced1a1eae42 100644 (file)
@@ -317,6 +317,13 @@ fd_bc_alloc_batch(struct fd_batch_cache *cache, struct fd_context *ctx, bool non
        struct fd_batch *batch;
        uint32_t idx;
 
+       /* For normal draw batches, pctx->set_framebuffer_state() handles
+        * this, but for nondraw batches, this is a nice central location
+        * to handle them all.
+        */
+       if (nondraw)
+               fd_context_switch_from(ctx);
+
        fd_screen_lock(ctx->screen);
 
        while ((idx = ffs(~cache->batch_mask)) == 0) {
@@ -382,6 +389,9 @@ fd_bc_alloc_batch(struct fd_batch_cache *cache, struct fd_context *ctx, bool non
        debug_assert(cache->batches[idx] == NULL);
        cache->batches[idx] = batch;
 
+       if (nondraw)
+               fd_context_switch_to(ctx, batch);
+
 out:
        fd_screen_unlock(ctx->screen);