From a5fb515301251b476800a1560f9f8edc8ff325d6 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Tue, 4 Feb 2020 13:26:59 +0100 Subject: [PATCH] tu/blit: Support blits in secondary cmdstreams 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: --- src/freedreno/vulkan/tu_blit.c | 49 +++++++++++++------------- src/freedreno/vulkan/tu_blit.h | 3 +- src/freedreno/vulkan/tu_meta_blit.c | 2 +- src/freedreno/vulkan/tu_meta_buffer.c | 4 +-- src/freedreno/vulkan/tu_meta_clear.c | 2 +- src/freedreno/vulkan/tu_meta_copy.c | 8 ++--- src/freedreno/vulkan/tu_meta_resolve.c | 2 +- 7 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/freedreno/vulkan/tu_blit.c b/src/freedreno/vulkan/tu_blit.c index da5fe3b3654..302a8d4f3f2 100644 --- a/src/freedreno/vulkan/tu_blit.c +++ b/src/freedreno/vulkan/tu_blit.c @@ -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); } diff --git a/src/freedreno/vulkan/tu_blit.h b/src/freedreno/vulkan/tu_blit.h index 341598179c8..cadcfc0cf29 100644 --- a/src/freedreno/vulkan/tu_blit.h +++ b/src/freedreno/vulkan/tu_blit.h @@ -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 */ diff --git a/src/freedreno/vulkan/tu_meta_blit.c b/src/freedreno/vulkan/tu_meta_blit.c index ec45e011a12..b45309336ed 100644 --- a/src/freedreno/vulkan/tu_meta_blit.c +++ b/src/freedreno/vulkan/tu_meta_blit.c @@ -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 diff --git a/src/freedreno/vulkan/tu_meta_buffer.c b/src/freedreno/vulkan/tu_meta_buffer.c index ea764c5790e..c7fcbd5e672 100644 --- a/src/freedreno/vulkan/tu_meta_buffer.c +++ b/src/freedreno/vulkan/tu_meta_buffer.c @@ -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, diff --git a/src/freedreno/vulkan/tu_meta_clear.c b/src/freedreno/vulkan/tu_meta_clear.c index 4b7e116949b..478b7ce9aa3 100644 --- a/src/freedreno/vulkan/tu_meta_clear.c +++ b/src/freedreno/vulkan/tu_meta_clear.c @@ -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]}, diff --git a/src/freedreno/vulkan/tu_meta_copy.c b/src/freedreno/vulkan/tu_meta_copy.c index ecded029a7a..cf7a38c64ec 100644 --- a/src/freedreno/vulkan/tu_meta_copy.c +++ b/src/freedreno/vulkan/tu_meta_copy.c @@ -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, diff --git a/src/freedreno/vulkan/tu_meta_resolve.c b/src/freedreno/vulkan/tu_meta_resolve.c index b879f84bdd5..aac4dbf00c2 100644 --- a/src/freedreno/vulkan/tu_meta_resolve.c +++ b/src/freedreno/vulkan/tu_meta_resolve.c @@ -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) -- 2.30.2