X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fnv50%2Fnv50_clear.c;h=5447904e9ca11a7babff49b33e438335ba3cfbb8;hb=880e3fb09b538f6f0b6fad2db7e0e10e9df43555;hp=f9bc3b53caa9775e5effd3f53124a9ae8a9fad18;hpb=916de35d677ca5238e9515840fa5aa9f81302c5b;p=mesa.git diff --git a/src/gallium/drivers/nv50/nv50_clear.c b/src/gallium/drivers/nv50/nv50_clear.c index f9bc3b53caa..5447904e9ca 100644 --- a/src/gallium/drivers/nv50/nv50_clear.c +++ b/src/gallium/drivers/nv50/nv50_clear.c @@ -27,66 +27,46 @@ #include "nv50_context.h" void -nv50_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue) +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, s_fb = nv50->framebuffer; - struct pipe_scissor_state sc, s_sc = nv50->scissor; - unsigned dirty = nv50->dirty; + struct pipe_framebuffer_state *fb = &nv50->framebuffer; + unsigned mode = 0, i; + const unsigned dirty = nv50->dirty; - nv50->dirty = 0; + /* don't need NEW_BLEND, NV50TCL_COLOR_MASK doesn't affect CLEAR_BUFFERS */ + nv50->dirty &= NV50_NEW_FRAMEBUFFER | NV50_NEW_SCISSOR; + if (!nv50_state_validate(nv50, 64)) + return; - if (ps->format == PIPE_FORMAT_Z24S8_UNORM || - ps->format == PIPE_FORMAT_Z16_UNORM) { - fb.nr_cbufs = 0; - fb.zsbuf = ps; - } else { - fb.nr_cbufs = 1; - fb.cbufs[0] = ps; - fb.zsbuf = NULL; + 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; } - fb.width = ps->width; - fb.height = ps->height; - pipe->set_framebuffer_state(pipe, &fb); - sc.minx = sc.miny = 0; - sc.maxx = fb.width; - sc.maxy = fb.height; - pipe->set_scissor_state(pipe, &sc); + if (buffers & PIPE_CLEAR_DEPTHSTENCIL) { + BEGIN_RING(chan, tesla, NV50TCL_CLEAR_DEPTH, 1); + OUT_RING (chan, fui(depth)); + BEGIN_RING(chan, tesla, NV50TCL_CLEAR_STENCIL, 1); + OUT_RING (chan, stencil & 0xff); - nv50_state_validate(nv50); - - switch (ps->format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - BEGIN_RING(chan, tesla, 0x0d80, 4); - OUT_RINGf (chan, ubyte_to_float((clearValue >> 16) & 0xff)); - OUT_RINGf (chan, ubyte_to_float((clearValue >> 8) & 0xff)); - OUT_RINGf (chan, ubyte_to_float((clearValue >> 0) & 0xff)); - OUT_RINGf (chan, ubyte_to_float((clearValue >> 24) & 0xff)); - BEGIN_RING(chan, tesla, 0x19d0, 1); - OUT_RING (chan, 0x3c); - break; - case PIPE_FORMAT_Z24S8_UNORM: - BEGIN_RING(chan, tesla, 0x0d90, 1); - OUT_RINGf (chan, (float)(clearValue >> 8) * (1.0 / 16777215.0)); - BEGIN_RING(chan, tesla, 0x0da0, 1); - OUT_RING (chan, clearValue & 0xff); - BEGIN_RING(chan, tesla, 0x19d0, 1); - OUT_RING (chan, 0x03); - break; - default: - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, - clearValue); - break; + mode |= 0x03; } - pipe->set_framebuffer_state(pipe, &s_fb); - pipe->set_scissor_state(pipe, &s_sc); - nv50->dirty |= dirty; + BEGIN_RING(chan, tesla, NV50TCL_CLEAR_BUFFERS, 1); + OUT_RING (chan, mode); - ps->status = PIPE_SURFACE_STATUS_CLEAR; + for (i = 1; i < fb->nr_cbufs; i++) { + BEGIN_RING(chan, tesla, NV50TCL_CLEAR_BUFFERS, 1); + OUT_RING (chan, (i << 6) | 0x3c); + } + nv50->dirty = dirty; }