From f08a80dcd493c64922c04a2563025bddabcac230 Mon Sep 17 00:00:00 2001 From: Brian Ho Date: Fri, 15 May 2020 10:52:43 -0700 Subject: turnip: Allocate tess BOs as a function of draw size To store tess outputs, the HS stg's into two buffers, one for per-vertex/per-patch output variables (tess_param) and one for TessLevelInner/Outer (tess_factor). The addresses of these buffers are uploaded as consts to the HS/DS and the tess_factor iova is written to REG_A6XX_PC_TESSFACTOR_ADDR. While the sizes of these buffers are a function of vetex count and patch count, allocation is relatively straightforward on freedreno- just keep track of the max required buffer size for the entire batch and allocate before batch submit. In Vulkan, however, a given pipeline can be bound multiple times across any number of command buffers, each drawing with a different number of vertices. One solution is to track the max buffer size for the entire command buffer (similar to fd_batch) and on vkEndCommandBuffer, allocate appropriately sized tess BOs. Since the tess BOs addresses are emitted as part of the pipeline state setup (e.g. PKT4 to REG_A6XX_PC_TESSFACTOR_ADDR), we need to create a new state group independent of a specific pipeline and parameterize its IB with the command buffer specific tess BO iovas. Without a larger refactor, the simplest way to do this is just to emit per-draw call consts and leverage scratch_bo to re-use buffers. This way we won't have to store and rewrite earlier packets in the command stream on vkEndCommandBuffer. Part-of: --- src/freedreno/vulkan/tu_private.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/freedreno/vulkan/tu_private.h') diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 39f303ee7d7..153184f5999 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -427,6 +427,7 @@ enum tu_draw_state_group_id { TU_DRAW_STATE_PROGRAM, TU_DRAW_STATE_PROGRAM_BINNING, + TU_DRAW_STATE_TESS, TU_DRAW_STATE_VB, TU_DRAW_STATE_VI, TU_DRAW_STATE_VI_BINNING, @@ -1100,6 +1101,15 @@ struct tu_pipeline bool primitive_restart; } ia; + struct + { + uint32_t patch_type; + uint32_t per_vertex_output_size; + uint32_t per_patch_output_size; + uint32_t hs_bo_regid; + uint32_t ds_bo_regid; + } tess; + struct { struct tu_cs_entry state_ib; -- cgit v1.2.3