radv: compute prim_vertex_count at draw time
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 7 Jul 2020 16:31:58 +0000 (18:31 +0200)
committerMarge Bot <eric+marge@anholt.net>
Thu, 9 Jul 2020 06:31:39 +0000 (06:31 +0000)
In preparation for the dynamic topology state.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5801>

src/amd/vulkan/radv_pipeline.c
src/amd/vulkan/radv_private.h
src/amd/vulkan/si_cmd_buffer.c

index 03a73794ecb70d96123da5dc0bd61a333750a6d3..8006b39b1ce43e9831bbe7c1a4fb51304d1eb842 100644 (file)
@@ -2032,24 +2032,6 @@ calculate_tess_state(struct radv_pipeline *pipeline,
        return tess;
 }
 
-static const struct radv_prim_vertex_count prim_size_table[] = {
-       [V_008958_DI_PT_NONE] = {0, 0},
-       [V_008958_DI_PT_POINTLIST] = {1, 1},
-       [V_008958_DI_PT_LINELIST] = {2, 2},
-       [V_008958_DI_PT_LINESTRIP] = {2, 1},
-       [V_008958_DI_PT_TRILIST] = {3, 3},
-       [V_008958_DI_PT_TRIFAN] = {3, 1},
-       [V_008958_DI_PT_TRISTRIP] = {3, 1},
-       [V_008958_DI_PT_LINELIST_ADJ] = {4, 4},
-       [V_008958_DI_PT_LINESTRIP_ADJ] = {4, 1},
-       [V_008958_DI_PT_TRILIST_ADJ] = {6, 6},
-       [V_008958_DI_PT_TRISTRIP_ADJ] = {6, 2},
-       [V_008958_DI_PT_RECTLIST] = {3, 3},
-       [V_008958_DI_PT_LINELOOP] = {2, 1},
-       [V_008958_DI_PT_POLYGON] = {3, 1},
-       [V_008958_DI_PT_2D_TRI_STRIP] = {0, 0},
-};
-
 static const struct radv_vs_output_info *get_vs_output_info(const struct radv_pipeline *pipeline)
 {
        if (radv_pipeline_has_gs(pipeline))
@@ -5057,8 +5039,6 @@ radv_pipeline_init(struct radv_pipeline *pipeline,
                        gs_out = V_028A6C_VGT_OUT_RECT_V0;
        }
        pipeline->graphics.prim_restart_enable = !!pCreateInfo->pInputAssemblyState->primitiveRestartEnable;
-       /* prim vertex count will need TESS changes */
-       pipeline->graphics.prim_vertex_count = prim_size_table[prim];
 
        radv_pipeline_init_dynamic_state(pipeline, pCreateInfo);
 
@@ -5115,10 +5095,8 @@ radv_pipeline_init(struct radv_pipeline *pipeline,
 
        struct radv_tessellation_state tess = {0};
        if (radv_pipeline_has_tess(pipeline)) {
-               if (prim == V_008958_DI_PT_PATCH) {
-                       pipeline->graphics.prim_vertex_count.min = pCreateInfo->pTessellationState->patchControlPoints;
-                       pipeline->graphics.prim_vertex_count.incr = 1;
-               }
+               pipeline->graphics.tess_patch_control_points =
+                       pCreateInfo->pTessellationState->patchControlPoints;
                tess = calculate_tess_state(pipeline, pCreateInfo);
        }
 
index 0fe611b068de09aaad0a1e7541ecb0fec14d7025..e710b0d58fbcc2e7d1cdc5317d583a81000e1b93 100644 (file)
@@ -1679,11 +1679,11 @@ struct radv_pipeline {
                        uint32_t vtx_base_sgpr;
                        struct radv_ia_multi_vgt_param_helpers ia_multi_vgt_param;
                        uint8_t vtx_emit_num;
-                       struct radv_prim_vertex_count prim_vertex_count;
                        bool can_use_guardband;
                        uint32_t needed_dynamic_state;
                        bool disable_out_of_order_rast_for_occlusion;
                        uint8_t topology;
+                       unsigned tess_patch_control_points;
 
                        /* Used for rbplus */
                        uint32_t col_format;
index 87256eda926fd965e58a663707eb22367fe8931c..68cd3d6865b3f4d62ecfd6820342a97c9f1a1bbb 100644 (file)
@@ -689,6 +689,24 @@ radv_prims_for_vertices(struct radv_prim_vertex_count *info, unsigned num)
        return 1 + ((num - info->min) / info->incr);
 }
 
+static const struct radv_prim_vertex_count prim_size_table[] = {
+       [V_008958_DI_PT_NONE] = {0, 0},
+       [V_008958_DI_PT_POINTLIST] = {1, 1},
+       [V_008958_DI_PT_LINELIST] = {2, 2},
+       [V_008958_DI_PT_LINESTRIP] = {2, 1},
+       [V_008958_DI_PT_TRILIST] = {3, 3},
+       [V_008958_DI_PT_TRIFAN] = {3, 1},
+       [V_008958_DI_PT_TRISTRIP] = {3, 1},
+       [V_008958_DI_PT_LINELIST_ADJ] = {4, 4},
+       [V_008958_DI_PT_LINESTRIP_ADJ] = {4, 1},
+       [V_008958_DI_PT_TRILIST_ADJ] = {6, 6},
+       [V_008958_DI_PT_TRISTRIP_ADJ] = {6, 2},
+       [V_008958_DI_PT_RECTLIST] = {3, 3},
+       [V_008958_DI_PT_LINELOOP] = {2, 1},
+       [V_008958_DI_PT_POLYGON] = {3, 1},
+       [V_008958_DI_PT_2D_TRI_STRIP] = {0, 0},
+};
+
 uint32_t
 si_get_ia_multi_vgt_param(struct radv_cmd_buffer *cmd_buffer,
                          bool instanced_draw, bool indirect_draw,
@@ -707,10 +725,18 @@ si_get_ia_multi_vgt_param(struct radv_cmd_buffer *cmd_buffer,
        bool partial_es_wave = cmd_buffer->state.pipeline->graphics.ia_multi_vgt_param.partial_es_wave;
        unsigned topology = cmd_buffer->state.pipeline->graphics.topology;
        bool multi_instances_smaller_than_primgroup;
+       struct radv_prim_vertex_count prim_vertex_count = prim_size_table[topology];
+
+       if (radv_pipeline_has_tess(cmd_buffer->state.pipeline)) {
+               if (topology == V_008958_DI_PT_PATCH) {
+                       prim_vertex_count.min = cmd_buffer->state.pipeline->graphics.tess_patch_control_points;
+                       prim_vertex_count.incr = 1;
+               }
+       }
 
        multi_instances_smaller_than_primgroup = indirect_draw;
        if (!multi_instances_smaller_than_primgroup && instanced_draw) {
-               uint32_t num_prims = radv_prims_for_vertices(&cmd_buffer->state.pipeline->graphics.prim_vertex_count, draw_vertex_count);
+               uint32_t num_prims = radv_prims_for_vertices(&prim_vertex_count, draw_vertex_count);
                if (num_prims < cmd_buffer->state.pipeline->graphics.ia_multi_vgt_param.primgroup_size)
                        multi_instances_smaller_than_primgroup = true;
        }
@@ -788,7 +814,7 @@ si_get_ia_multi_vgt_param(struct radv_cmd_buffer *cmd_buffer,
                if (family == CHIP_HAWAII && ia_switch_on_eoi) {
                        bool set_vgt_flush = indirect_draw;
                        if (!set_vgt_flush && instanced_draw) {
-                               uint32_t num_prims = radv_prims_for_vertices(&cmd_buffer->state.pipeline->graphics.prim_vertex_count, draw_vertex_count);
+                               uint32_t num_prims = radv_prims_for_vertices(&prim_vertex_count, draw_vertex_count);
                                if (num_prims <= 1)
                                        set_vgt_flush = true;
                        }