tu/blit: Support blits in secondary cmdstreams
authorConnor Abbott <cwabbott0@gmail.com>
Tue, 4 Feb 2020 12:26:59 +0000 (13:26 +0100)
committerJonathan Marek <jonathan@marek.ca>
Thu, 13 Feb 2020 02:31:44 +0000 (21:31 -0500)
For sysmem rendering we'll have to emit a delayed clear IB to implement
LOAD_OP_*, similar to the existing tile_load_ib.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3713>

src/freedreno/vulkan/tu_blit.c
src/freedreno/vulkan/tu_blit.h
src/freedreno/vulkan/tu_meta_blit.c
src/freedreno/vulkan/tu_meta_buffer.c
src/freedreno/vulkan/tu_meta_clear.c
src/freedreno/vulkan/tu_meta_copy.c
src/freedreno/vulkan/tu_meta_resolve.c

index da5fe3b3654dc66130e001cd239f839ed73f5c05..302a8d4f3f205ea8454e2736936f2423c27b6b12 100644 (file)
@@ -79,10 +79,10 @@ blit_image_info(const struct tu_blit_surf *img, bool src, bool stencil_read)
 }
 
 static void
-emit_blit_step(struct tu_cmd_buffer *cmdbuf, const struct tu_blit *blt)
+emit_blit_step(struct tu_cmd_buffer *cmdbuf, struct tu_cs *cs,
+               const struct tu_blit *blt)
 {
    struct tu_physical_device *phys_dev = cmdbuf->device->physical_device;
-   struct tu_cs *cs = &cmdbuf->cs;
 
    tu_cs_reserve_space(cmdbuf->device, cs, 66);
 
@@ -104,11 +104,11 @@ emit_blit_step(struct tu_cmd_buffer *cmdbuf, const struct tu_blit *blt)
                         A6XX_RB_2D_BLIT_CNTL_MASK(0xf) |
                         A6XX_RB_2D_BLIT_CNTL_IFMT(ifmt);
 
-   tu_cs_emit_pkt4(&cmdbuf->cs, REG_A6XX_RB_2D_BLIT_CNTL, 1);
-   tu_cs_emit(&cmdbuf->cs, blit_cntl);
+   tu_cs_emit_pkt4(cs, REG_A6XX_RB_2D_BLIT_CNTL, 1);
+   tu_cs_emit(cs, blit_cntl);
 
-   tu_cs_emit_pkt4(&cmdbuf->cs, REG_A6XX_GRAS_2D_BLIT_CNTL, 1);
-   tu_cs_emit(&cmdbuf->cs, blit_cntl);
+   tu_cs_emit_pkt4(cs, REG_A6XX_GRAS_2D_BLIT_CNTL, 1);
+   tu_cs_emit(cs, blit_cntl);
 
    /*
     * Emit source:
@@ -213,7 +213,8 @@ emit_blit_step(struct tu_cmd_buffer *cmdbuf, const struct tu_blit *blt)
    tu_cs_emit(cs, 0);
 }
 
-void tu_blit(struct tu_cmd_buffer *cmdbuf, struct tu_blit *blt)
+void tu_blit(struct tu_cmd_buffer *cmdbuf, struct tu_cs *cs,
+             struct tu_blit *blt)
 {
    switch (blt->type) {
    case TU_BLIT_COPY:
@@ -274,17 +275,17 @@ void tu_blit(struct tu_cmd_buffer *cmdbuf, struct tu_blit *blt)
       assert(blt->dst.samples == 1);
    }
 
-   tu_cs_reserve_space(cmdbuf->device, &cmdbuf->cs, 18);
+   tu_cs_reserve_space(cmdbuf->device, cs, 18);
 
-   tu6_emit_event_write(cmdbuf, &cmdbuf->cs, LRZ_FLUSH, false);
-   tu6_emit_event_write(cmdbuf, &cmdbuf->cs, 0x1d, true);
-   tu6_emit_event_write(cmdbuf, &cmdbuf->cs, FACENESS_FLUSH, true);
-   tu6_emit_event_write(cmdbuf, &cmdbuf->cs, PC_CCU_INVALIDATE_COLOR, false);
-   tu6_emit_event_write(cmdbuf, &cmdbuf->cs, PC_CCU_INVALIDATE_DEPTH, false);
+   tu6_emit_event_write(cmdbuf, cs, LRZ_FLUSH, false);
+   tu6_emit_event_write(cmdbuf, cs, 0x1d, true);
+   tu6_emit_event_write(cmdbuf, cs, FACENESS_FLUSH, true);
+   tu6_emit_event_write(cmdbuf, cs, PC_CCU_INVALIDATE_COLOR, false);
+   tu6_emit_event_write(cmdbuf, cs, PC_CCU_INVALIDATE_DEPTH, false);
 
    /* buffer copy setup */
-   tu_cs_emit_pkt7(&cmdbuf->cs, CP_SET_MARKER, 1);
-   tu_cs_emit(&cmdbuf->cs, A6XX_CP_SET_MARKER_0_MODE(RM6_BLIT2DSCALE));
+   tu_cs_emit_pkt7(cs, CP_SET_MARKER, 1);
+   tu_cs_emit(cs, A6XX_CP_SET_MARKER_0_MODE(RM6_BLIT2DSCALE));
 
    for (unsigned layer = 0; layer < blt->layers; layer++) {
       if (blt->buffer) {
@@ -304,7 +305,7 @@ void tu_blit(struct tu_cmd_buffer *cmdbuf, struct tu_blit *blt)
 
             line_blt.src.width = line_blt.dst.width = tmp;
 
-            emit_blit_step(cmdbuf, &line_blt);
+            emit_blit_step(cmdbuf, cs, &line_blt);
 
             src_va += tmp * blocksize;
             dst_va += tmp * blocksize;
@@ -325,7 +326,7 @@ void tu_blit(struct tu_cmd_buffer *cmdbuf, struct tu_blit *blt)
             line_blt.src.x = blt->src.x + (src_va & 63) / vk_format_get_blocksize(blt->src.fmt);
             line_blt.src.va = src_va & ~63;
 
-            emit_blit_step(cmdbuf, &line_blt);
+            emit_blit_step(cmdbuf, cs, &line_blt);
 
             line_blt.dst.y++;
             src_va += blt->src.pitch;
@@ -345,13 +346,13 @@ void tu_blit(struct tu_cmd_buffer *cmdbuf, struct tu_blit *blt)
             line_blt.dst.x = blt->dst.x + (dst_va & 63) / vk_format_get_blocksize(blt->dst.fmt);
             line_blt.dst.va = dst_va & ~63;
 
-            emit_blit_step(cmdbuf, &line_blt);
+            emit_blit_step(cmdbuf, cs, &line_blt);
 
             line_blt.src.y++;
             dst_va += blt->dst.pitch;
          }
       } else {
-         emit_blit_step(cmdbuf, blt);
+         emit_blit_step(cmdbuf, cs, blt);
       }
       blt->dst.va += blt->dst.layer_size;
       blt->src.va += blt->src.layer_size;
@@ -359,10 +360,10 @@ void tu_blit(struct tu_cmd_buffer *cmdbuf, struct tu_blit *blt)
       blt->src.ubwc_va += blt->src.ubwc_size;
    }
 
-   tu_cs_reserve_space(cmdbuf->device, &cmdbuf->cs, 17);
+   tu_cs_reserve_space(cmdbuf->device, cs, 17);
 
-   tu6_emit_event_write(cmdbuf, &cmdbuf->cs, 0x1d, true);
-   tu6_emit_event_write(cmdbuf, &cmdbuf->cs, FACENESS_FLUSH, true);
-   tu6_emit_event_write(cmdbuf, &cmdbuf->cs, CACHE_FLUSH_TS, true);
-   tu6_emit_event_write(cmdbuf, &cmdbuf->cs, CACHE_INVALIDATE, false);
+   tu6_emit_event_write(cmdbuf, cs, 0x1d, true);
+   tu6_emit_event_write(cmdbuf, cs, FACENESS_FLUSH, true);
+   tu6_emit_event_write(cmdbuf, cs, CACHE_FLUSH_TS, true);
+   tu6_emit_event_write(cmdbuf, cs, CACHE_INVALIDATE, false);
 }
index 341598179c87f65b49ccbcf52407af36b902fd75..cadcfc0cf294afe90ece8c5a1ebd088fbb2efd9c 100644 (file)
@@ -120,6 +120,7 @@ struct tu_blit {
    enum tu_blit_type type;
 };
 
-void tu_blit(struct tu_cmd_buffer *cmdbuf, struct tu_blit *blt);
+void tu_blit(struct tu_cmd_buffer *cmdbuf, struct tu_cs *cs,
+             struct tu_blit *blt);
 
 #endif /* TU_BLIT_H */
index ec45e011a12528fbbfe0926dd99338c7a22da3ba..b45309336eddc4b644a058dfbd34ba1e5921c257 100644 (file)
@@ -64,7 +64,7 @@ tu_blit_image(struct tu_cmd_buffer *cmdbuf,
       .rotation = rotate[mirror_y][mirror_x],
    };
 
-   tu_blit(cmdbuf, &blt);
+   tu_blit(cmdbuf, &cmdbuf->cs, &blt);
 }
 
 void
index ea764c5790e419a02ab6ba78aebc9eabda50f4d9..c7fcbd5e6723050786715db49e4a57d6f81c4278 100644 (file)
@@ -17,7 +17,7 @@ tu_CmdFillBuffer(VkCommandBuffer commandBuffer,
 
    tu_bo_list_add(&cmd->bo_list, buffer->bo, MSM_SUBMIT_BO_WRITE);
 
-   tu_blit(cmd, &(struct tu_blit) {
+   tu_blit(cmd, &cmd->cs, &(struct tu_blit) {
       .dst = {
          .fmt = VK_FORMAT_R32_UINT,
          .va = tu_buffer_iova(buffer) + dstOffset,
@@ -53,7 +53,7 @@ tu_CmdUpdateBuffer(VkCommandBuffer commandBuffer,
 
    memcpy(tmp.map, pData, dataSize);
 
-   tu_blit(cmd, &(struct tu_blit) {
+   tu_blit(cmd, &cmd->cs, &(struct tu_blit) {
       .dst = {
          .fmt = VK_FORMAT_R32_UINT,
          .va = tu_buffer_iova(buffer) + dstOffset,
index 4b7e116949b9194f5226707dfd1d7349c3999b9f..478b7ce9aa3b4072c1c00851c2420798242dbb66 100644 (file)
@@ -43,7 +43,7 @@ clear_image(struct tu_cmd_buffer *cmdbuf,
       if (image->type == VK_IMAGE_TYPE_3D)
          layer_count = u_minify(image->extent.depth, range->baseMipLevel + j);
 
-      tu_blit(cmdbuf, &(struct tu_blit) {
+      tu_blit(cmdbuf, &cmdbuf->cs, &(struct tu_blit) {
          .dst = tu_blit_surf_whole(image, range->baseMipLevel + j, range->baseArrayLayer),
          .layers = layer_count,
          .clear_value = {clear_value[0], clear_value[1], clear_value[2], clear_value[3]},
index ecded029a7ae057ff56510aab8e76b4fa309c52d..cf7a38c64ec5b8cef62aa87d75c597c1a041c988 100644 (file)
@@ -41,7 +41,7 @@ tu_copy_buffer(struct tu_cmd_buffer *cmd,
    tu_bo_list_add(&cmd->bo_list, src->bo, MSM_SUBMIT_BO_READ);
    tu_bo_list_add(&cmd->bo_list, dst->bo, MSM_SUBMIT_BO_WRITE);
 
-   tu_blit(cmd, &(struct tu_blit) {
+   tu_blit(cmd, &cmd->cs, &(struct tu_blit) {
       .dst = {
          .fmt = VK_FORMAT_R8_UNORM,
          .va = tu_buffer_iova(dst) + region->dstOffset,
@@ -97,7 +97,7 @@ tu_copy_buffer_to_image(struct tu_cmd_buffer *cmdbuf,
       return;
    }
 
-   tu_blit(cmdbuf, &(struct tu_blit) {
+   tu_blit(cmdbuf, &cmdbuf->cs, &(struct tu_blit) {
       .dst = tu_blit_surf_ext(dst_image, info->imageSubresource, info->imageOffset, info->imageExtent),
       .src = tu_blit_buffer(src_buffer, dst_image->vk_format, info),
       .layers = MAX2(info->imageExtent.depth, info->imageSubresource.layerCount),
@@ -111,7 +111,7 @@ tu_copy_image_to_buffer(struct tu_cmd_buffer *cmdbuf,
                         struct tu_buffer *dst_buffer,
                         const VkBufferImageCopy *info)
 {
-   tu_blit(cmdbuf, &(struct tu_blit) {
+   tu_blit(cmdbuf, &cmdbuf->cs, &(struct tu_blit) {
       .dst = tu_blit_buffer(dst_buffer, src_image->vk_format, info),
       .src = tu_blit_surf_ext(src_image, info->imageSubresource, info->imageOffset, info->imageExtent),
       .layers = MAX2(info->imageExtent.depth, info->imageSubresource.layerCount),
@@ -133,7 +133,7 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmdbuf,
       return;
    }
 
-   tu_blit(cmdbuf, &(struct tu_blit) {
+   tu_blit(cmdbuf, &cmdbuf->cs, &(struct tu_blit) {
       .dst = tu_blit_surf_ext(dst_image, info->dstSubresource, info->dstOffset, info->extent),
       .src = tu_blit_surf_ext(src_image, info->srcSubresource, info->srcOffset, info->extent),
       .layers = info->extent.depth,
index b879f84bdd5ef9319dcf8e9943fcdc21a67379be..aac4dbf00c2d42f6c747e78fa4bd16740ebdaead 100644 (file)
@@ -39,7 +39,7 @@ tu_resolve_image(struct tu_cmd_buffer *cmdbuf,
 {
    assert(info->dstSubresource.layerCount == info->srcSubresource.layerCount);
 
-   tu_blit(cmdbuf, &(struct tu_blit) {
+   tu_blit(cmdbuf, &cmdbuf->cs, &(struct tu_blit) {
       .dst = tu_blit_surf_ext(dst_image, info->dstSubresource, info->dstOffset, info->extent),
       .src = tu_blit_surf_ext(src_image, info->srcSubresource, info->srcOffset, info->extent),
       .layers = MAX2(info->extent.depth, info->dstSubresource.layerCount)