zink: process one aspect-mask bit at the time
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 11 Jul 2019 12:09:15 +0000 (14:09 +0200)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 28 Oct 2019 08:51:46 +0000 (08:51 +0000)
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
src/gallium/drivers/zink/zink_resource.c

index 55ad8115651fca3876646ae62952be96f83c7bca..658774fcdf0ccc28c10edc9d41be675a1bc4fc43 100644 (file)
@@ -350,7 +350,6 @@ zink_transfer_copy_bufimage(struct zink_context *ctx,
    copyRegion.bufferOffset = staging_res->offset;
    copyRegion.bufferRowLength = 0;
    copyRegion.bufferImageHeight = 0;
-   copyRegion.imageSubresource.aspectMask = res->aspect;
    copyRegion.imageSubresource.mipLevel = trans->base.level;
    copyRegion.imageSubresource.layerCount = 1;
    if (res->base.array_size > 1) {
@@ -369,10 +368,16 @@ zink_transfer_copy_bufimage(struct zink_context *ctx,
    zink_batch_reference_resoure(batch, res);
    zink_batch_reference_resoure(batch, staging_res);
 
-   if (buf2img)
-      vkCmdCopyBufferToImage(batch->cmdbuf, staging_res->buffer, res->image, res->layout, 1, &copyRegion);
-   else
-      vkCmdCopyImageToBuffer(batch->cmdbuf, res->image, res->layout, staging_res->buffer, 1, &copyRegion);
+   unsigned aspects = res->aspect;
+   while (aspects) {
+      int aspect = 1 << u_bit_scan(&aspects);
+      copyRegion.imageSubresource.aspectMask = aspect;
+
+      if (buf2img)
+         vkCmdCopyBufferToImage(batch->cmdbuf, staging_res->buffer, res->image, res->layout, 1, &copyRegion);
+      else
+         vkCmdCopyImageToBuffer(batch->cmdbuf, res->image, res->layout, staging_res->buffer, 1, &copyRegion);
+   }
 
    return true;
 }