diff options
author | Hyunjun Ko <[email protected]> | 2020-02-25 06:35:01 +0000 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-04 01:20:32 +0000 |
commit | 3199b8b9e7f0a63075ea082f51fae28daee2bd3a (patch) | |
tree | ea7a33bb77a95d4d81e87f8cf4cadd6ef618c4e8 /src/freedreno | |
parent | a933934efbf343b6df3ea65ac70545bf200986ef (diff) |
turnip: support indirect draw
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3976>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3976>
Diffstat (limited to 'src/freedreno')
-rw-r--r-- | src/freedreno/vulkan/tu_cmd_buffer.c | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index 8727c3376fe..27295cfdb25 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -3633,6 +3633,51 @@ tu6_bind_draw_states(struct tu_cmd_buffer *cmd, } static void +tu6_emit_draw_indirect(struct tu_cmd_buffer *cmd, + struct tu_cs *cs, + const struct tu_draw_info *draw) +{ + const enum pc_di_primtype primtype = cmd->state.pipeline->ia.primtype; + + tu_cs_emit_regs(cs, + A6XX_VFD_INDEX_OFFSET(draw->vertex_offset), + A6XX_VFD_INSTANCE_START_OFFSET(draw->first_instance)); + + if (draw->indexed) { + const enum a4xx_index_size index_size = + tu6_index_size(cmd->state.index_type); + const uint32_t index_bytes = + (cmd->state.index_type == VK_INDEX_TYPE_UINT32) ? 4 : 2; + const struct tu_buffer *index_buf = cmd->state.index_buffer; + unsigned max_indicies = + (index_buf->size - cmd->state.index_offset) / index_bytes; + + const uint32_t cp_draw_indx = + CP_DRAW_INDX_OFFSET_0_PRIM_TYPE(primtype) | + CP_DRAW_INDX_OFFSET_0_SOURCE_SELECT(DI_SRC_SEL_DMA) | + CP_DRAW_INDX_OFFSET_0_INDEX_SIZE(index_size) | + CP_DRAW_INDX_OFFSET_0_VIS_CULL(USE_VISIBILITY) | 0x2000; + + tu_cs_emit_pkt7(cs, CP_DRAW_INDX_INDIRECT, 6); + tu_cs_emit(cs, cp_draw_indx); + tu_cs_emit_qw(cs, index_buf->bo->iova + cmd->state.index_offset); + tu_cs_emit(cs, A5XX_CP_DRAW_INDX_INDIRECT_3_MAX_INDICES(max_indicies)); + tu_cs_emit_qw(cs, draw->indirect->bo->iova + draw->indirect_offset); + } else { + const uint32_t cp_draw_indx = + CP_DRAW_INDX_OFFSET_0_PRIM_TYPE(primtype) | + CP_DRAW_INDX_OFFSET_0_SOURCE_SELECT(DI_SRC_SEL_AUTO_INDEX) | + CP_DRAW_INDX_OFFSET_0_VIS_CULL(USE_VISIBILITY) | 0x2000; + + tu_cs_emit_pkt7(cs, CP_DRAW_INDIRECT, 3); + tu_cs_emit(cs, cp_draw_indx); + tu_cs_emit_qw(cs, draw->indirect->bo->iova + draw->indirect_offset); + } + + tu_bo_list_add(&cmd->bo_list, draw->indirect->bo, MSM_SUBMIT_BO_READ); +} + +static void tu6_emit_draw_direct(struct tu_cmd_buffer *cmd, struct tu_cs *cs, const struct tu_draw_info *draw) @@ -3693,12 +3738,10 @@ tu_draw(struct tu_cmd_buffer *cmd, const struct tu_draw_info *draw) return; } - if (draw->indirect) { - tu_finishme("indirect draw"); - return; - } - - tu6_emit_draw_direct(cmd, cs, draw); + if (draw->indirect) + tu6_emit_draw_indirect(cmd, cs, draw); + else + tu6_emit_draw_direct(cmd, cs, draw); cmd->wait_for_idle = true; |