Browse Source

nvc0: don't forget to also clear additional layers

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
tags/mesa-10.1-rc1
Ilia Mirkin 11 years ago
parent
commit
250e7c835e
1 changed files with 27 additions and 5 deletions
  1. 27
    5
      src/gallium/drivers/nouveau/nvc0/nvc0_surface.c

+ 27
- 5
src/gallium/drivers/nouveau/nvc0/nvc0_surface.c View File

@@ -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));
}
}
}

Loading…
Cancel
Save