iris: try to fix copyimage vs copybuffers
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 8 Dec 2018 09:32:10 +0000 (01:32 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:12 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_blit.c

index 0f96ec032cd41f4717790d45e1aac070c03ab919..aafbfcf85e28c0185e9a1d89eaefb155cf7f00a0 100644 (file)
@@ -495,15 +495,6 @@ iris_resource_copy_region(struct pipe_context *ctx,
    get_copy_region_aux_settings(devinfo, dst_res, &dst_aux_usage,
                                 &dst_clear_supported);
 
-   iris_resource_prepare_access(ice, batch, src_res, src_level, 1,
-                                src_box->z, src_box->depth,
-                                src_aux_usage, src_clear_supported);
-   iris_resource_prepare_access(ice, batch, dst_res, dst_level, 1,
-                                dstz, src_box->depth,
-                                dst_aux_usage, dst_clear_supported);
-
-   blorp_batch_init(&ice->blorp, &blorp_batch, batch, 0);
-
    if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
       struct blorp_address src_addr = {
          .buffer = iris_resource_bo(src), .offset = src_box->x,
@@ -514,7 +505,12 @@ iris_resource_copy_region(struct pipe_context *ctx,
 
       iris_batch_maybe_flush(batch, 1500);
 
+      blorp_batch_init(&ice->blorp, &blorp_batch, batch, 0);
       blorp_buffer_copy(&blorp_batch, src_addr, dst_addr, src_box->width);
+      blorp_batch_finish(&blorp_batch);
+
+      iris_flush_and_dirty_for_history(ice, batch,
+                                       (struct iris_resource *) dst);
    } else {
       // XXX: what about one surface being a buffer and not the other?
 
@@ -522,6 +518,15 @@ iris_resource_copy_region(struct pipe_context *ctx,
       iris_blorp_surf_for_resource(&src_surf, src, src_aux_usage, false);
       iris_blorp_surf_for_resource(&dst_surf, dst, dst_aux_usage, true);
 
+      iris_resource_prepare_access(ice, batch, src_res, src_level, 1,
+                                   src_box->z, src_box->depth,
+                                   src_aux_usage, src_clear_supported);
+      iris_resource_prepare_access(ice, batch, dst_res, dst_level, 1,
+                                   dstz, src_box->depth,
+                                   dst_aux_usage, dst_clear_supported);
+
+      blorp_batch_init(&ice->blorp, &blorp_batch, batch, 0);
+
       for (int slice = 0; slice < src_box->depth; slice++) {
          iris_batch_maybe_flush(batch, 1500);
 
@@ -530,14 +535,12 @@ iris_resource_copy_region(struct pipe_context *ctx,
                     src_box->x, src_box->y, dstx, dsty,
                     src_box->width, src_box->height);
       }
-   }
+      blorp_batch_finish(&blorp_batch);
 
-   blorp_batch_finish(&blorp_batch);
+      iris_resource_finish_write(ice, dst_res, dst_level, dstz,
+                                 src_box->depth, dst_aux_usage);
 
-   iris_resource_finish_write(ice, dst_res, dst_level, dstz, src_box->depth,
-                              dst_aux_usage);
-
-   iris_flush_and_dirty_for_history(ice, batch, (struct iris_resource *) dst);
+   }
 }
 
 void