radeonsi: micro-optimize prim checking and fix guardband with lines+adjacency
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
This commit is contained in:
@@ -1505,6 +1505,23 @@ static inline unsigned si_get_total_colormask(struct si_context *sctx)
|
|||||||
return colormask;
|
return colormask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define UTIL_ALL_PRIM_LINE_MODES ((1 << PIPE_PRIM_LINES) | \
|
||||||
|
(1 << PIPE_PRIM_LINE_LOOP) | \
|
||||||
|
(1 << PIPE_PRIM_LINE_STRIP) | \
|
||||||
|
(1 << PIPE_PRIM_LINES_ADJACENCY) | \
|
||||||
|
(1 << PIPE_PRIM_LINE_STRIP_ADJACENCY))
|
||||||
|
|
||||||
|
static inline bool util_prim_is_lines(unsigned prim)
|
||||||
|
{
|
||||||
|
return ((1 << prim) & UTIL_ALL_PRIM_LINE_MODES) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool util_prim_is_points_or_lines(unsigned prim)
|
||||||
|
{
|
||||||
|
return ((1 << prim) & (UTIL_ALL_PRIM_LINE_MODES |
|
||||||
|
(1 << PIPE_PRIM_POINTS))) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if there is enough memory in VRAM and GTT for the buffers
|
* Return true if there is enough memory in VRAM and GTT for the buffers
|
||||||
* added so far.
|
* added so far.
|
||||||
|
@@ -521,11 +521,7 @@ static bool si_emit_rasterizer_prim_state(struct si_context *sctx)
|
|||||||
struct si_state_rasterizer *rs = sctx->queued.named.rasterizer;
|
struct si_state_rasterizer *rs = sctx->queued.named.rasterizer;
|
||||||
|
|
||||||
/* Skip this if not rendering lines. */
|
/* Skip this if not rendering lines. */
|
||||||
if (rast_prim != PIPE_PRIM_LINES &&
|
if (!util_prim_is_lines(rast_prim))
|
||||||
rast_prim != PIPE_PRIM_LINE_LOOP &&
|
|
||||||
rast_prim != PIPE_PRIM_LINE_STRIP &&
|
|
||||||
rast_prim != PIPE_PRIM_LINES_ADJACENCY &&
|
|
||||||
rast_prim != PIPE_PRIM_LINE_STRIP_ADJACENCY)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (rast_prim == sctx->last_rast_prim &&
|
if (rast_prim == sctx->last_rast_prim &&
|
||||||
@@ -1275,9 +1271,8 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
|
|||||||
rast_prim = info->mode;
|
rast_prim = info->mode;
|
||||||
|
|
||||||
if (rast_prim != sctx->current_rast_prim) {
|
if (rast_prim != sctx->current_rast_prim) {
|
||||||
bool old_is_poly = sctx->current_rast_prim >= PIPE_PRIM_TRIANGLES;
|
if (util_prim_is_points_or_lines(sctx->current_rast_prim) !=
|
||||||
bool new_is_poly = rast_prim >= PIPE_PRIM_TRIANGLES;
|
util_prim_is_points_or_lines(rast_prim))
|
||||||
if (old_is_poly != new_is_poly)
|
|
||||||
si_mark_atom_dirty(sctx, &sctx->atoms.s.guardband);
|
si_mark_atom_dirty(sctx, &sctx->atoms.s.guardband);
|
||||||
|
|
||||||
sctx->current_rast_prim = rast_prim;
|
sctx->current_rast_prim = rast_prim;
|
||||||
|
@@ -1419,10 +1419,8 @@ static inline void si_shader_selector_key(struct pipe_context *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rs) {
|
if (rs) {
|
||||||
bool is_poly = (sctx->current_rast_prim >= PIPE_PRIM_TRIANGLES &&
|
bool is_poly = !util_prim_is_points_or_lines(sctx->current_rast_prim);
|
||||||
sctx->current_rast_prim <= PIPE_PRIM_POLYGON) ||
|
bool is_line = util_prim_is_lines(sctx->current_rast_prim);
|
||||||
sctx->current_rast_prim >= PIPE_PRIM_TRIANGLES_ADJACENCY;
|
|
||||||
bool is_line = !is_poly && sctx->current_rast_prim != PIPE_PRIM_POINTS;
|
|
||||||
|
|
||||||
key->part.ps.prolog.color_two_side = rs->two_side && sel->info.colors_read;
|
key->part.ps.prolog.color_two_side = rs->two_side && sel->info.colors_read;
|
||||||
key->part.ps.prolog.flatshade_colors = rs->flatshade && sel->info.colors_read;
|
key->part.ps.prolog.flatshade_colors = rs->flatshade && sel->info.colors_read;
|
||||||
|
@@ -193,7 +193,7 @@ static void si_emit_guardband(struct si_context *ctx)
|
|||||||
discard_x = 1.0;
|
discard_x = 1.0;
|
||||||
discard_y = 1.0;
|
discard_y = 1.0;
|
||||||
|
|
||||||
if (unlikely(ctx->current_rast_prim < PIPE_PRIM_TRIANGLES) &&
|
if (unlikely(util_prim_is_points_or_lines(ctx->current_rast_prim)) &&
|
||||||
ctx->queued.named.rasterizer) {
|
ctx->queued.named.rasterizer) {
|
||||||
/* When rendering wide points or lines, we need to be more
|
/* When rendering wide points or lines, we need to be more
|
||||||
* conservative about when to discard them entirely. */
|
* conservative about when to discard them entirely. */
|
||||||
|
Reference in New Issue
Block a user