diff options
Diffstat (limited to 'src/gallium/drivers/nouveau/nvc0/nvc0_surface.c')
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_surface.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c index 321c3664ed0..32d234e3453 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c @@ -414,7 +414,7 @@ nvc0_clear(struct pipe_context *pipe, unsigned buffers, struct nvc0_context *nvc0 = nvc0_context(pipe); struct nouveau_pushbuf *push = nvc0->base.pushbuf; struct pipe_framebuffer_state *fb = &nvc0->framebuffer; - unsigned i; + unsigned i, j, k; uint32_t mode = 0; /* don't need NEW_BLEND, COLOR_MASK doesn't affect CLEAR_BUFFERS */ @@ -446,14 +446,36 @@ nvc0_clear(struct pipe_context *pipe, unsigned buffers, } if (mode) { - BEGIN_NVC0(push, NVC0_3D(CLEAR_BUFFERS), 1); - PUSH_DATA (push, mode); + int zs_layers = 0, color0_layers = 0; + if (fb->cbufs[0] && (mode & 0x3c)) + color0_layers = fb->cbufs[0]->u.tex.last_layer - + fb->cbufs[0]->u.tex.first_layer + 1; + if (fb->zsbuf && (mode & ~0x3c)) + zs_layers = fb->zsbuf->u.tex.last_layer - + fb->zsbuf->u.tex.first_layer + 1; + + for (j = 0; j < MIN2(zs_layers, color0_layers); j++) { + BEGIN_NVC0(push, NVC0_3D(CLEAR_BUFFERS), 1); + PUSH_DATA(push, mode | (j << NVC0_3D_CLEAR_BUFFERS_LAYER__SHIFT)); + } + for (k = j; k < zs_layers; k++) { + BEGIN_NVC0(push, NVC0_3D(CLEAR_BUFFERS), 1); + PUSH_DATA(push, (mode & ~0x3c) | (k << NVC0_3D_CLEAR_BUFFERS_LAYER__SHIFT)); + } + for (k = j; k < color0_layers; k++) { + BEGIN_NVC0(push, NVC0_3D(CLEAR_BUFFERS), 1); + PUSH_DATA(push, (mode & 0x3c) | (k << NVC0_3D_CLEAR_BUFFERS_LAYER__SHIFT)); + } } for (i = 1; i < fb->nr_cbufs; i++) { - if (buffers & (PIPE_CLEAR_COLOR0 << i)) { + struct pipe_surface *sf = fb->cbufs[i]; + if (!sf || !(buffers & (PIPE_CLEAR_COLOR0 << i))) + continue; + for (j = 0; j <= sf->u.tex.last_layer - sf->u.tex.first_layer; j++) { BEGIN_NVC0(push, NVC0_3D(CLEAR_BUFFERS), 1); - PUSH_DATA (push, (i << 6) | 0x3c); + PUSH_DATA (push, (i << 6) | 0x3c | + (j << NVC0_3D_CLEAR_BUFFERS_LAYER__SHIFT)); } } } |