nv30: Fix non-scissored clears after a scissor has been set

Additionally add support for PIPE_CAP_CLEAR_SCISSORED since we are already
touching the scissor state.

Fixes various gnome-shell rendering artifacts.

v2: Remove NEW_SCISSOR as clear now updates scissor registers explicitly
v3: Reset scissor_off state since its not off now after clear

Cc: mesa-stable

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18137>
This commit is contained in:
Glenn Kennard 2021-07-30 18:44:54 +02:00 committed by Marge Bot
parent 49e6a55e5e
commit 7908cb895e
2 changed files with 24 additions and 1 deletions

View file

@ -58,9 +58,25 @@ nv30_clear(struct pipe_context *pipe, unsigned buffers, const struct pipe_scisso
struct pipe_framebuffer_state *fb = &nv30->framebuffer;
uint32_t colr = 0, zeta = 0, mode = 0;
if (!nv30_state_validate(nv30, NV30_NEW_FRAMEBUFFER | NV30_NEW_SCISSOR, true))
if (!nv30_state_validate(nv30, NV30_NEW_FRAMEBUFFER, true))
return;
if (scissor_state) {
uint32_t minx = scissor_state->minx;
uint32_t maxx = MIN2(fb->width, scissor_state->maxx);
uint32_t miny = scissor_state->miny;
uint32_t maxy = MIN2(fb->height, scissor_state->maxy);
BEGIN_NV04(push, NV30_3D(SCISSOR_HORIZ), 2);
PUSH_DATA (push, minx | (maxx - minx) << 16);
PUSH_DATA (push, miny | (maxy - miny) << 16);
}
else {
BEGIN_NV04(push, NV30_3D(SCISSOR_HORIZ), 2);
PUSH_DATA (push, 0x10000000);
PUSH_DATA (push, 0x10000000);
}
if (buffers & PIPE_CLEAR_COLOR && fb->nr_cbufs) {
colr = pack_rgba(fb->cbufs[0]->format, color->f);
mode |= NV30_3D_CLEAR_BUFFERS_COLOR_R |
@ -96,6 +112,10 @@ nv30_clear(struct pipe_context *pipe, unsigned buffers, const struct pipe_scisso
PUSH_DATA (push, mode);
nv30_state_release(nv30);
/* Make sure regular draw commands will get their scissor state set */
nv30->dirty |= NV30_NEW_SCISSOR;
nv30->state.scissor_off = 0;
}
static void
@ -156,6 +176,7 @@ nv30_clear_render_target(struct pipe_context *pipe, struct pipe_surface *ps,
NV30_3D_CLEAR_BUFFERS_COLOR_A);
nv30->dirty |= NV30_NEW_FRAMEBUFFER | NV30_NEW_SCISSOR;
nv30->state.scissor_off = 0;
}
static void
@ -222,6 +243,7 @@ nv30_clear_depth_stencil(struct pipe_context *pipe, struct pipe_surface *ps,
PUSH_DATA (push, mode);
nv30->dirty |= NV30_NEW_FRAMEBUFFER | NV30_NEW_SCISSOR;
nv30->state.scissor_off = 0;
}
void

View file

@ -96,6 +96,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_FS_COORD_PIXEL_CENTER_INTEGER:
case PIPE_CAP_TGSI_TEXCOORD:
case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
case PIPE_CAP_CLEAR_SCISSORED:
case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY: