radeonsi/gfx10: consolidate & improve input_prim determination for NGG
authorMarek Olšák <marek.olsak@amd.com>
Tue, 25 Jun 2019 00:53:41 +0000 (20:53 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 3 Jul 2019 19:51:13 +0000 (15:51 -0400)
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/gallium/drivers/radeonsi/gfx10_shader_ngg.c
src/gallium/drivers/radeonsi/si_state.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index 3713975224599a7f94ad328ad033c374f2019863..ae73133f51a658285bfbddb2b84714304340cb04 100644 (file)
@@ -1265,10 +1265,8 @@ void gfx10_ngg_calculate_subgroup_info(struct si_shader *shader)
                shader->previous_stage_sel ? shader->previous_stage_sel : gs_sel;
        const enum pipe_shader_type gs_type = gs_sel->type;
        const unsigned gs_num_invocations = MAX2(gs_sel->gs_num_invocations, 1);
-       /* TODO: Specialize for known primitive type without GS. */
-       const unsigned input_prim = gs_type == PIPE_SHADER_GEOMETRY ?
-                                   gs_sel->info.properties[TGSI_PROPERTY_GS_INPUT_PRIM] :
-                                   PIPE_PRIM_TRIANGLES;
+
+       const unsigned input_prim = si_get_input_prim(gs_sel);
        const bool use_adjacency = input_prim >= PIPE_PRIM_LINES_ADJACENCY &&
                                   input_prim <= PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY;
        const unsigned max_verts_per_prim = u_vertices_per_prim(input_prim);
index 91b4f1ea13eac110401f5fce2315039762200bee..acdbefbf64f9b51bb8f9e1ec32178b6a879fb8c6 100644 (file)
@@ -599,6 +599,7 @@ void si_shader_selector_key_vs(struct si_context *sctx,
                               struct si_shader_selector *vs,
                               struct si_shader_key *key,
                               struct si_vs_prolog_bits *prolog_key);
+unsigned si_get_input_prim(const struct si_shader_selector *gs);
 
 /* si_state_draw.c */
 void si_emit_surface_sync(struct si_context *sctx, struct radeon_cmdbuf *cs,
index cdcd87f12d1b474b9df0fcff8d228a3e433b698f..b673c6d73fc7026d8eea64fe1c0614c3245d4157 100644 (file)
@@ -1054,6 +1054,23 @@ static void gfx10_emit_shader_ngg_tess_gs(struct si_context *sctx)
        gfx10_emit_shader_ngg_tail(sctx, shader, initial_cdw);
 }
 
+unsigned si_get_input_prim(const struct si_shader_selector *gs)
+{
+       if (gs->type == PIPE_SHADER_GEOMETRY)
+               return gs->info.properties[TGSI_PROPERTY_GS_INPUT_PRIM];
+
+       if (gs->type == PIPE_SHADER_TESS_EVAL) {
+               if (gs->info.properties[TGSI_PROPERTY_TES_POINT_MODE])
+                       return PIPE_PRIM_POINTS;
+               if (gs->info.properties[TGSI_PROPERTY_TES_PRIM_MODE] == PIPE_PRIM_LINES)
+                       return PIPE_PRIM_LINES;
+               return PIPE_PRIM_TRIANGLES;
+       }
+
+       /* TODO: Set this correctly if the primitive type is set in the shader key. */
+       return PIPE_PRIM_TRIANGLES;
+}
+
 /**
  * Prepare the PM4 image for \p shader, which will run as a merged ESGS shader
  * in NGG mode.
@@ -1074,10 +1091,7 @@ static void gfx10_shader_ngg(struct si_screen *sscreen, struct si_shader *shader
                gs_info->properties[TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION];
        bool es_enable_prim_id = shader->key.mono.u.vs_export_prim_id || es_info->uses_primid;
        unsigned gs_num_invocations = MAX2(gs_sel->gs_num_invocations, 1);
-       unsigned input_prim =
-               gs_type == PIPE_SHADER_GEOMETRY ?
-               gs_info->properties[TGSI_PROPERTY_GS_INPUT_PRIM] :
-               PIPE_PRIM_TRIANGLES; /* TODO: Optimize when primtype is known */
+       unsigned input_prim = si_get_input_prim(gs_sel);
        bool break_wave_at_eoi = false;
        struct si_pm4_state *pm4 = si_get_shader_pm4_state(shader);
        if (!pm4)