From: Marek Olšák Date: Tue, 25 Jun 2019 00:54:52 +0000 (-0400) Subject: radeonsi: determine the rasterization primitive type accurately (v2) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f66ee5af2fdde6e0fa511b061a66408a227b8bb4;p=mesa.git radeonsi: determine the rasterization primitive type accurately (v2) v2: reworked version to fix bugs and make it more efficient Acked-by: Bas Nieuwenhuizen --- diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 298e63738c4..01a0ede4126 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -1787,6 +1787,18 @@ static inline bool util_prim_is_points_or_lines(unsigned prim) (1 << PIPE_PRIM_POINTS))) != 0; } +static inline bool util_rast_prim_is_triangles(unsigned prim) +{ + return ((1 << prim) & ((1 << PIPE_PRIM_TRIANGLES) | + (1 << PIPE_PRIM_TRIANGLE_STRIP) | + (1 << PIPE_PRIM_TRIANGLE_FAN) | + (1 << PIPE_PRIM_QUADS) | + (1 << PIPE_PRIM_QUAD_STRIP) | + (1 << PIPE_PRIM_POLYGON) | + (1 << PIPE_PRIM_TRIANGLES_ADJACENCY) | + (1 << PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY))); +} + /** * Return true if there is enough memory in VRAM and GTT for the buffers * added so far. diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index 2649a7cd5b7..86d91f29b3c 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -354,6 +354,7 @@ struct si_shader_selector { unsigned pa_cl_vs_out_cntl; ubyte clipdist_mask; ubyte culldist_mask; + unsigned rast_prim; /* ES parameters. */ unsigned esgs_itemsize; /* vertex stride */ diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index fdde6b08310..04bf391524b 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -1787,15 +1787,18 @@ static void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *i * This must be done after si_decompress_textures, which can call * draw_vbo recursively, and before si_update_shaders, which uses * current_rast_prim for this draw_vbo call. */ - if (sctx->gs_shader.cso) - rast_prim = sctx->gs_shader.cso->gs_output_prim; - else if (sctx->tes_shader.cso) { - if (sctx->tes_shader.cso->info.properties[TGSI_PROPERTY_TES_POINT_MODE]) - rast_prim = PIPE_PRIM_POINTS; - else - rast_prim = sctx->tes_shader.cso->info.properties[TGSI_PROPERTY_TES_PRIM_MODE]; - } else + if (sctx->gs_shader.cso) { + /* Only possibilities: POINTS, LINE_STRIP, TRIANGLES */ + rast_prim = sctx->gs_shader.cso->rast_prim; + } else if (sctx->tes_shader.cso) { + /* Only possibilities: POINTS, LINE_STRIP, TRIANGLES */ + rast_prim = sctx->tes_shader.cso->rast_prim; + } else if (util_rast_prim_is_triangles(prim)) { + rast_prim = PIPE_PRIM_TRIANGLES; + } else { + /* Only possibilities, POINTS, LINE*, RECTANGLES */ rast_prim = prim; + } if (rast_prim != sctx->current_rast_prim) { if (util_prim_is_points_or_lines(sctx->current_rast_prim) != diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index b673c6d73fc..44abc186d16 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -2670,6 +2670,12 @@ static void *si_create_shader_selector(struct pipe_context *ctx, case PIPE_SHADER_GEOMETRY: sel->gs_output_prim = sel->info.properties[TGSI_PROPERTY_GS_OUTPUT_PRIM]; + + /* Only possibilities: POINTS, LINE_STRIP, TRIANGLES */ + sel->rast_prim = sel->gs_output_prim; + if (util_rast_prim_is_triangles(sel->rast_prim)) + sel->rast_prim = PIPE_PRIM_TRIANGLES; + sel->gs_max_out_vertices = sel->info.properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES]; sel->gs_num_invocations = @@ -2738,6 +2744,14 @@ static void *si_create_shader_selector(struct pipe_context *ctx, sel->esgs_itemsize += 4; assert(((sel->esgs_itemsize / 4) & C_028AAC_ITEMSIZE) == 0); + + /* Only for TES: */ + if (sel->info.properties[TGSI_PROPERTY_TES_POINT_MODE]) + sel->rast_prim = PIPE_PRIM_POINTS; + else if (sel->info.properties[TGSI_PROPERTY_TES_PRIM_MODE] == PIPE_PRIM_LINES) + sel->rast_prim = PIPE_PRIM_LINE_STRIP; + else + sel->rast_prim = PIPE_PRIM_TRIANGLES; break; case PIPE_SHADER_FRAGMENT: