Merge branch 'mesa_7_6_branch' of git+ssh://agd5f@git.freedesktop.org/git/mesa/mesa
[mesa.git] / src / gallium / drivers / nv50 / nv50_clear.c
index eca65a88c15dc9a4bbbafc37b21d58177dbd7356..e0b2d2880b00b1e42bfe7d02a3ba121ea06c208b 100644 (file)
@@ -31,7 +31,7 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers,
           const float *rgba, double depth, unsigned stencil)
 {
        struct nv50_context *nv50 = nv50_context(pipe);
-       struct nouveau_channel *chan = nv50->screen->nvws->channel;
+       struct nouveau_channel *chan = nv50->screen->base.channel;
        struct nouveau_grobj *tesla = nv50->screen->tesla;
        struct pipe_framebuffer_state *fb = &nv50->framebuffer;
        unsigned mode = 0, i;
@@ -39,14 +39,12 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers,
        if (!nv50_state_validate(nv50))
                return;
 
-       if (buffers & PIPE_CLEAR_COLOR) {
-               BEGIN_RING(chan, tesla, NV50TCL_CLEAR_COLOR(0), 4*fb->nr_cbufs);
-               for (i = 0; i < fb->nr_cbufs; i++) {
-                       OUT_RING  (chan, fui(rgba[0]));
-                       OUT_RING  (chan, fui(rgba[1]));
-                       OUT_RING  (chan, fui(rgba[2]));
-                       OUT_RING  (chan, fui(rgba[3]));
-               }
+       if (buffers & PIPE_CLEAR_COLOR && fb->nr_cbufs) {
+               BEGIN_RING(chan, tesla, NV50TCL_CLEAR_COLOR(0), 4);
+               OUT_RING  (chan, fui(rgba[0]));
+               OUT_RING  (chan, fui(rgba[1]));
+               OUT_RING  (chan, fui(rgba[2]));
+               OUT_RING  (chan, fui(rgba[3]));
                mode |= 0x3c;
        }
 
@@ -61,5 +59,10 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers,
 
        BEGIN_RING(chan, tesla, NV50TCL_CLEAR_BUFFERS, 1);
        OUT_RING  (chan, mode);
+
+       for (i = 1; i < fb->nr_cbufs; i++) {
+               BEGIN_RING(chan, tesla, NV50TCL_CLEAR_BUFFERS, 1);
+               OUT_RING  (chan, (i << 6) | 0x3c);
+       }
 }