freedreno: Synchronize batch and flush for staging resource
authorKristian H. Kristensen <hoegsberg@chromium.org>
Thu, 17 Jan 2019 19:32:14 +0000 (11:32 -0800)
committerKristian H. Kristensen <hoegsberg@chromium.org>
Fri, 18 Jan 2019 22:27:12 +0000 (14:27 -0800)
Staging blit downloads would wait on the src resource instead of the
staging resource and didn't make sure to submit the blit batch first.

Signed-off-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/freedreno_resource.c

index f19f38add8552bd7a265394f8ad62d8aa8112459..14751074aceeab25837123c487238c559193822f 100644 (file)
@@ -498,7 +498,21 @@ fd_resource_transfer_map(struct pipe_context *pctx,
 
                        if (usage & PIPE_TRANSFER_READ) {
                                fd_blit_to_staging(ctx, trans);
-                               fd_bo_cpu_prep(rsc->bo, ctx->pipe, DRM_FREEDRENO_PREP_READ);
+
+                               struct fd_batch *batch = NULL;
+                               fd_batch_reference(&batch, staging_rsc->write_batch);
+
+                               /* we can't fd_bo_cpu_prep() until the blit to staging
+                                * is submitted to kernel.. in that case write_batch
+                                * wouldn't be NULL yet:
+                                */
+                               if (batch) {
+                                       fd_batch_sync(batch);
+                                       fd_batch_reference(&batch, NULL);
+                               }
+
+                               fd_bo_cpu_prep(staging_rsc->bo, ctx->pipe,
+                                               DRM_FREEDRENO_PREP_READ);
                        }
 
                        buf = fd_bo_map(staging_rsc->bo);