diff options
author | Grigori Goronzy <greg@chown.ath.cx> | 2016-04-04 01:49:52 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@chown.ath.cx> | 2016-04-05 19:49:20 +0200 |
commit | 5bef310be621793515eb800f1fd14ab4eedb2265 (patch) | |
tree | 29a0b11fd9b5d3d83cb83c0448fd920569d612ed | |
parent | bd53232b99a214b59b1d143f1cf80f16cc3fcbc5 (diff) |
radeonsi: use guard band clippingguardband
With the previous changes to handling of viewport clipping, it is
almost trivial to add proper support for guard band clipping. Select a
suitable integer clipping value to keep inside the rasterizer's guard
band range of [-32768, 32767] and program the hardware to use guard
band clipping.
Guard band clipping speeds up rasterization for primitives that are
partially off-screen. This change in particular results in small
framerate improvements in a wide range of games.
v2: width/height are zero in some cases, which may be a bug.
Just handle that case explicitly right now.
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 559e1d0acb..57a2f2e512 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -2724,6 +2724,7 @@ static void si_emit_framebuffer_state(struct si_context *sctx, struct r600_atom unsigned i, nr_cbufs = state->nr_cbufs; struct r600_texture *tex = NULL; struct r600_surface *cb = NULL; + float guardband_x, guardband_y; /* Colorbuffers. */ for (i = 0; i < nr_cbufs; i++) { @@ -2830,6 +2831,13 @@ static void si_emit_framebuffer_state(struct si_context *sctx, struct r600_atom radeon_set_context_reg(cs, R_028208_PA_SC_WINDOW_SCISSOR_BR, S_028208_BR_X(state->width) | S_028208_BR_Y(state->height)); + /* Guard band clipping. */ + /* Select a suitable guard band setting based on framebuffer size. */ + guardband_x = state->width ? (32767 / state->width) : 1.0; + guardband_y = state->height ? (32767 / state->height) : 1.0; + radeon_set_context_reg(cs, R_028BF0_PA_CL_GB_HORZ_CLIP_ADJ, fui(guardband_x)); + radeon_set_context_reg(cs, R_028BE8_PA_CL_GB_VERT_CLIP_ADJ, fui(guardband_y)); + sctx->framebuffer.dirty_cbufs = 0; sctx->framebuffer.dirty_zsbuf = false; } |