From: Hyunjun Ko Date: Thu, 5 Mar 2020 06:59:55 +0000 (+0000) Subject: turnip: Add tu6_control struct. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1896b44aee637929e1e6deaca7518a7475c4d867;p=mesa.git turnip: Add tu6_control struct. Follow the way that freedreno is doing so that we could see the whole layout of the scratch buffer. Signed-off-by: Hyunjun Ko Reviewed-by: Jonathan Marek Tested-by: Marge Bot Part-of: --- diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index d3e04889feb..f403893ad03 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -1228,7 +1228,7 @@ emit_vsc_overflow_test(struct tu_cmd_buffer *cmd, struct tu_cs *cs) /* Clear vsc_scratch: */ tu_cs_emit_pkt7(cs, CP_MEM_WRITE, 3); - tu_cs_emit_qw(cs, cmd->scratch_bo.iova + VSC_SCRATCH); + tu_cs_emit_qw(cs, cmd->scratch_bo.iova + ctrl_offset(vsc_scratch)); tu_cs_emit(cs, 0x0); /* Check for overflow, write vsc_scratch if detected: */ @@ -1240,7 +1240,7 @@ emit_vsc_overflow_test(struct tu_cmd_buffer *cmd, struct tu_cs *cs) tu_cs_emit(cs, CP_COND_WRITE5_2_POLL_ADDR_HI(0)); tu_cs_emit(cs, CP_COND_WRITE5_3_REF(cmd->vsc_data_pitch)); tu_cs_emit(cs, CP_COND_WRITE5_4_MASK(~0)); - tu_cs_emit_qw(cs, cmd->scratch_bo.iova + VSC_SCRATCH); + tu_cs_emit_qw(cs, cmd->scratch_bo.iova + ctrl_offset(vsc_scratch)); tu_cs_emit(cs, CP_COND_WRITE5_7_WRITE_DATA(1 + cmd->vsc_data_pitch)); tu_cs_emit_pkt7(cs, CP_COND_WRITE5, 8); @@ -1250,7 +1250,7 @@ emit_vsc_overflow_test(struct tu_cmd_buffer *cmd, struct tu_cs *cs) tu_cs_emit(cs, CP_COND_WRITE5_2_POLL_ADDR_HI(0)); tu_cs_emit(cs, CP_COND_WRITE5_3_REF(cmd->vsc_data2_pitch)); tu_cs_emit(cs, CP_COND_WRITE5_4_MASK(~0)); - tu_cs_emit_qw(cs, cmd->scratch_bo.iova + VSC_SCRATCH); + tu_cs_emit_qw(cs, cmd->scratch_bo.iova + ctrl_offset(vsc_scratch)); tu_cs_emit(cs, CP_COND_WRITE5_7_WRITE_DATA(3 + cmd->vsc_data2_pitch)); } @@ -1261,7 +1261,7 @@ emit_vsc_overflow_test(struct tu_cmd_buffer *cmd, struct tu_cs *cs) tu_cs_emit_pkt7(cs, CP_MEM_TO_REG, 3); tu_cs_emit(cs, CP_MEM_TO_REG_0_REG(OVERFLOW_FLAG_REG) | CP_MEM_TO_REG_0_CNT(1 - 1)); - tu_cs_emit_qw(cs, cmd->scratch_bo.iova + VSC_SCRATCH); + tu_cs_emit_qw(cs, cmd->scratch_bo.iova + ctrl_offset(vsc_scratch)); /* * This is a bit awkward, we really want a way to invert the @@ -1293,7 +1293,7 @@ emit_vsc_overflow_test(struct tu_cmd_buffer *cmd, struct tu_cs *cs) tu_cs_emit_pkt7(cs, CP_REG_TO_MEM, 3); tu_cs_emit(cs, CP_REG_TO_MEM_0_REG(OVERFLOW_FLAG_REG) | CP_REG_TO_MEM_0_CNT(0)); - tu_cs_emit_qw(cs, cmd->scratch_bo.iova + VSC_OVERFLOW); + tu_cs_emit_qw(cs, cmd->scratch_bo.iova + ctrl_offset(vsc_overflow)); tu_cs_emit_pkt4(cs, OVERFLOW_FLAG_REG, 1); tu_cs_emit(cs, 0x0); @@ -3440,11 +3440,13 @@ tu6_emit_streamout(struct tu_cmd_buffer *cmd, struct tu_cs *cs) tu_cs_emit(cs, CP_MEM_TO_REG_0_REG(REG_A6XX_VPC_SO_BUFFER_OFFSET(i)) | CP_MEM_TO_REG_0_SHIFT_BY_2 | CP_MEM_TO_REG_0_UNK31 | CP_MEM_TO_REG_0_CNT(0)); - tu_cs_emit_qw(cs, cmd->scratch_bo.iova + VSC_FLUSH * (i + 1)); + tu_cs_emit_qw(cs, cmd->scratch_bo.iova + + ctrl_offset(flush_base[i].offset)); } tu_cs_emit_regs(cs, A6XX_VPC_SO_FLUSH_BASE(i, .bo = &cmd->scratch_bo, - .bo_offset = VSC_FLUSH * (i + 1))); + .bo_offset = + ctrl_offset(flush_base[i]))); } if (cmd->state.streamout_enabled) { diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 661529fa537..c7b64a20cc8 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -947,6 +947,28 @@ tu_bo_list_add(struct tu_bo_list *list, VkResult tu_bo_list_merge(struct tu_bo_list *list, const struct tu_bo_list *other); +/* This struct defines the layout of the scratch_bo */ +struct tu6_control +{ + uint32_t seqno; /* seqno for async CP_EVENT_WRITE, etc */ + uint32_t _pad0; + volatile uint32_t vsc_overflow; + uint32_t _pad1; + /* flag set from cmdstream when VSC overflow detected: */ + uint32_t vsc_scratch; + uint32_t _pad2; + uint32_t _pad3; + uint32_t _pad4; + + /* scratch space for VPC_SO[i].FLUSH_BASE_LO/HI, start on 32 byte boundary. */ + struct { + uint32_t offset; + uint32_t pad[7]; + } flush_base[4]; +}; + +#define ctrl_offset(member) offsetof(struct tu6_control, member) + struct tu_cmd_buffer { VK_LOADER_DATA _loader_data; @@ -982,9 +1004,6 @@ struct tu_cmd_buffer struct tu_bo scratch_bo; uint32_t scratch_seqno; -#define VSC_OVERFLOW 0x8 -#define VSC_SCRATCH 0x10 -#define VSC_FLUSH 0x20 struct tu_bo vsc_data; struct tu_bo vsc_data2;