Commit a5fb5153 authored by Connor Abbott's avatar Connor Abbott Committed by Jonathan Marek
Browse files

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: <mesa/mesa!3713>
parent a94be3da
......@@ -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);
}
......@@ -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 */
......@@ -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
......
......@@ -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,
......
......@@ -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]},
......
......@@ -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,
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment