diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c index 9b2d53678dd..c3414835ab1 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c @@ -238,6 +238,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_TWO_SIDED_COLOR: case PIPE_CAP_CLIP_PLANES: case PIPE_CAP_PACKED_STREAM_OUTPUT: + case PIPE_CAP_CLEAR_SCISSORED: return 1; case PIPE_CAP_SEAMLESS_CUBE_MAP: return 1; /* class_3d >= NVA0_3D_CLASS; */ @@ -368,7 +369,6 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_GLSL_ZERO_INIT: case PIPE_CAP_BLEND_EQUATION_ADVANCED: case PIPE_CAP_NO_CLIP_ON_COPY_TEX: - case PIPE_CAP_CLEAR_SCISSORED: /* TODO */ case PIPE_CAP_DEVICE_PROTECTED_CONTENT: case PIPE_CAP_NIR_IMAGES_AS_DEREF: return 0; diff --git a/src/gallium/drivers/nouveau/nv50/nv50_surface.c b/src/gallium/drivers/nouveau/nv50/nv50_surface.c index b133997641a..97bc4f2c9fe 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_surface.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_surface.c @@ -538,6 +538,19 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers, const struct pipe_scisso if (!nv50_state_validate_3d(nv50, NV50_NEW_3D_FRAMEBUFFER)) 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); + if (maxx <= minx || maxy <= miny) + return; + + BEGIN_NV04(push, NV50_3D(SCREEN_SCISSOR_HORIZ), 2); + PUSH_DATA (push, minx | (maxx - minx) << 16); + PUSH_DATA (push, miny | (maxy - miny) << 16); + } + /* We have to clear ALL of the layers, not up to the min number of layers * of any attachment. */ BEGIN_NV04(push, NV50_3D(RT_ARRAY_MODE), 1); @@ -602,6 +615,13 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers, const struct pipe_scisso /* restore the array mode */ BEGIN_NV04(push, NV50_3D(RT_ARRAY_MODE), 1); PUSH_DATA (push, nv50->rt_array_mode); + + /* restore screen scissor */ + if (scissor_state) { + BEGIN_NV04(push, NV50_3D(SCREEN_SCISSOR_HORIZ), 2); + PUSH_DATA (push, fb->width << 16); + PUSH_DATA (push, fb->height << 16); + } } static void diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c index 95d8a29d31b..3c548161c74 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c @@ -300,6 +300,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_CLIP_PLANES: case PIPE_CAP_TEXTURE_SHADOW_LOD: case PIPE_CAP_PACKED_STREAM_OUTPUT: + case PIPE_CAP_CLEAR_SCISSORED: return 1; case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER: return nouveau_screen(pscreen)->vram_domain & NOUVEAU_BO_VRAM ? 1 : 0; @@ -410,7 +411,6 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_GLSL_ZERO_INIT: case PIPE_CAP_BLEND_EQUATION_ADVANCED: case PIPE_CAP_NO_CLIP_ON_COPY_TEX: - case PIPE_CAP_CLEAR_SCISSORED: /* TODO */ case PIPE_CAP_DEVICE_PROTECTED_CONTENT: return 0; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c index e0b81b679a2..27d1fddaf8d 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c @@ -704,6 +704,19 @@ nvc0_clear(struct pipe_context *pipe, unsigned buffers, if (!nvc0_state_validate_3d(nvc0, NVC0_NEW_3D_FRAMEBUFFER)) 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); + if (maxx <= minx || maxy <= miny) + return; + + BEGIN_NVC0(push, NVC0_3D(SCREEN_SCISSOR_HORIZ), 2); + PUSH_DATA (push, minx | (maxx - minx) << 16); + PUSH_DATA (push, miny | (maxy - miny) << 16); + } + if (buffers & PIPE_CLEAR_COLOR && fb->nr_cbufs) { BEGIN_NVC0(push, NVC0_3D(CLEAR_COLOR(0)), 4); PUSH_DATAf(push, color->f[0]); @@ -761,6 +774,13 @@ nvc0_clear(struct pipe_context *pipe, unsigned buffers, (j << NVC0_3D_CLEAR_BUFFERS_LAYER__SHIFT)); } } + + /* restore screen scissor */ + if (scissor_state) { + BEGIN_NVC0(push, NVC0_3D(SCREEN_SCISSOR_HORIZ), 2); + PUSH_DATA (push, fb->width << 16); + PUSH_DATA (push, fb->height << 16); + } } static void