summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2010-10-23 03:01:06 +0200
committerFrancisco Jerez <currojerez@riseup.net>2010-10-30 19:25:31 +0200
commit920481d38751957ec24de323ae8f15a6aec334a5 (patch)
tree9892bf48875676771f28a8e58221ec9b27c61ec1 /src
parentcfc81d93f7b07a89437cbbce173fc468070e06da (diff)
dri/nv20: Clear with the 3D engine.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/nouveau/nv20_context.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nv20_context.c b/src/mesa/drivers/dri/nouveau/nv20_context.c
index c6111a2a9a..4ca7cd6c98 100644
--- a/src/mesa/drivers/dri/nouveau/nv20_context.c
+++ b/src/mesa/drivers/dri/nouveau/nv20_context.c
@@ -26,6 +26,8 @@
#include "nouveau_driver.h"
#include "nouveau_context.h"
+#include "nouveau_fbo.h"
+#include "nouveau_util.h"
#include "nouveau_class.h"
#include "nv04_driver.h"
#include "nv10_driver.h"
@@ -40,6 +42,57 @@ static const struct dri_extension nv20_extensions[] = {
};
static void
+nv20_clear(struct gl_context *ctx, GLbitfield buffers)
+{
+ struct nouveau_channel *chan = context_chan(ctx);
+ struct nouveau_grobj *kelvin = context_eng3d(ctx);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ uint32_t clear = 0;
+
+ nouveau_validate_framebuffer(ctx);
+
+ if (buffers & BUFFER_BITS_COLOR) {
+ struct nouveau_surface *s = &to_nouveau_renderbuffer(
+ fb->_ColorDrawBuffers[0])->surface;
+
+ if (ctx->Color.ColorMask[0][RCOMP])
+ clear |= NV20TCL_CLEAR_BUFFERS_COLOR_R;
+ if (ctx->Color.ColorMask[0][GCOMP])
+ clear |= NV20TCL_CLEAR_BUFFERS_COLOR_G;
+ if (ctx->Color.ColorMask[0][BCOMP])
+ clear |= NV20TCL_CLEAR_BUFFERS_COLOR_B;
+ if (ctx->Color.ColorMask[0][ACOMP])
+ clear |= NV20TCL_CLEAR_BUFFERS_COLOR_A;
+
+ BEGIN_RING(chan, kelvin, NV20TCL_CLEAR_VALUE, 1);
+ OUT_RING(chan, pack_rgba_f(s->format, ctx->Color.ClearColor));
+
+ buffers &= ~BUFFER_BITS_COLOR;
+ }
+
+ if (buffers & (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)) {
+ struct nouveau_surface *s = &to_nouveau_renderbuffer(
+ fb->_DepthBuffer->Wrapped)->surface;
+
+ if (buffers & BUFFER_BIT_DEPTH && ctx->Depth.Mask)
+ clear |= NV20TCL_CLEAR_BUFFERS_DEPTH;
+ if (buffers & BUFFER_BIT_STENCIL && ctx->Stencil.WriteMask[0])
+ clear |= NV20TCL_CLEAR_BUFFERS_STENCIL;
+
+ BEGIN_RING(chan, kelvin, NV20TCL_CLEAR_DEPTH_VALUE, 1);
+ OUT_RING(chan, pack_zs_f(s->format, ctx->Depth.Clear,
+ ctx->Stencil.Clear));
+
+ buffers &= ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
+ }
+
+ BEGIN_RING(chan, kelvin, NV20TCL_CLEAR_BUFFERS, 1);
+ OUT_RING(chan, clear);
+
+ nouveau_clear(ctx, buffers);
+}
+
+static void
nv20_hwctx_init(struct gl_context *ctx)
{
struct nouveau_channel *chan = context_chan(ctx);
@@ -410,6 +463,7 @@ nv20_context_create(struct nouveau_screen *screen, const struct gl_config *visua
ctx->Const.MaxTextureUnits = NV20_TEXTURE_UNITS;
ctx->Const.MaxTextureMaxAnisotropy = 8;
ctx->Const.MaxTextureLodBias = 15;
+ ctx->Driver.Clear = nv20_clear;
/* 2D engine. */
ret = nv04_surface_init(ctx);