summaryrefslogtreecommitdiff
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorMichel Dänzer <daenzer@vmware.com>2009-04-04 19:01:51 +0200
committerMichel Dänzer <daenzer@vmware.com>2009-04-04 19:01:51 +0200
commiteb168e26aa63f11a47d70c4555cae30691a2cd57 (patch)
tree8dcde608f562fc781027b4e0e21263f9f295e70e /src/gallium/drivers
parentba14b043bc1ab87e8e5e46e6e909a8def9535028 (diff)
gallium: Clean up driver clear() interface.
Only allows clearing currently bound buffers, but colour and depth/stencil in a single call.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/i915simple/i915_clear.c13
-rw-r--r--src/gallium/drivers/i915simple/i915_context.h4
-rw-r--r--src/gallium/drivers/nv10/nv10_clear.c8
-rw-r--r--src/gallium/drivers/nv10/nv10_context.h5
-rw-r--r--src/gallium/drivers/nv20/nv20_clear.c8
-rw-r--r--src/gallium/drivers/nv20/nv20_context.h4
-rw-r--r--src/gallium/drivers/nv30/nv30_clear.c8
-rw-r--r--src/gallium/drivers/nv30/nv30_context.h4
-rw-r--r--src/gallium/drivers/nv40/nv40_clear.c8
-rw-r--r--src/gallium/drivers/nv40/nv40_context.h4
-rw-r--r--src/gallium/drivers/nv50/nv50_context.h4
-rw-r--r--src/gallium/drivers/softpipe/sp_clear.c65
-rw-r--r--src/gallium/drivers/softpipe/sp_clear.h4
-rw-r--r--src/gallium/drivers/trace/tr_context.c21
14 files changed, 79 insertions, 81 deletions
diff --git a/src/gallium/drivers/i915simple/i915_clear.c b/src/gallium/drivers/i915simple/i915_clear.c
index cde69daacc..90530f2826 100644
--- a/src/gallium/drivers/i915simple/i915_clear.c
+++ b/src/gallium/drivers/i915simple/i915_clear.c
@@ -25,23 +25,24 @@
*
**************************************************************************/
-/* Author:
+/* Authors:
* Brian Paul
*/
-#include "pipe/p_defines.h"
+#include "util/u_clear.h"
#include "i915_context.h"
#include "i915_state.h"
/**
- * Clear the given surface to the specified value.
+ * Clear the given buffers to the specified values.
* No masking, no scissor (clear entire buffer).
*/
void
-i915_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue)
+i915_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+ double depth, unsigned stencil)
{
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
+ util_clear(pipe, &i915_context(pipe)->framebuffer, buffers, rgba, depth,
+ stencil);
}
diff --git a/src/gallium/drivers/i915simple/i915_context.h b/src/gallium/drivers/i915simple/i915_context.h
index 3cdabe45f9..b6983ba86e 100644
--- a/src/gallium/drivers/i915simple/i915_context.h
+++ b/src/gallium/drivers/i915simple/i915_context.h
@@ -314,8 +314,8 @@ void i915_emit_hardware_state(struct i915_context *i915 );
/***********************************************************************
* i915_clear.c:
*/
-void i915_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue);
+void i915_clear( struct pipe_context *pipe, unsigned buffers, const float *rgba,
+ double depth, unsigned stencil);
/***********************************************************************
diff --git a/src/gallium/drivers/nv10/nv10_clear.c b/src/gallium/drivers/nv10/nv10_clear.c
index be7e09cf4b..a39a2b5f52 100644
--- a/src/gallium/drivers/nv10/nv10_clear.c
+++ b/src/gallium/drivers/nv10/nv10_clear.c
@@ -1,12 +1,14 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
+#include "util/u_clear.h"
#include "nv10_context.h"
void
-nv10_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue)
+nv10_clear(struct pipe_context *pipe, unsigned buffers,
+ const float *rgba, double depth, unsigned stencil)
{
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
+ util_clear(pipe, nv10_context(pipe)->framebuffer, buffers, rgba, depth,
+ stencil);
}
diff --git a/src/gallium/drivers/nv10/nv10_context.h b/src/gallium/drivers/nv10/nv10_context.h
index f3b56de25a..f1e003c953 100644
--- a/src/gallium/drivers/nv10/nv10_context.h
+++ b/src/gallium/drivers/nv10/nv10_context.h
@@ -118,8 +118,9 @@ extern void nv10_init_surface_functions(struct nv10_context *nv10);
extern void nv10_screen_init_miptree_functions(struct pipe_screen *pscreen);
/* nv10_clear.c */
-extern void nv10_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue);
+extern void nv10_clear(struct pipe_context *pipe, unsigned buffers,
+ const float *rgba, double depth, unsigned stencil);
+
/* nv10_draw.c */
extern struct draw_stage *nv10_draw_render_stage(struct nv10_context *nv10);
diff --git a/src/gallium/drivers/nv20/nv20_clear.c b/src/gallium/drivers/nv20/nv20_clear.c
index 81b6f3e78a..2b4490fa5e 100644
--- a/src/gallium/drivers/nv20/nv20_clear.c
+++ b/src/gallium/drivers/nv20/nv20_clear.c
@@ -1,12 +1,14 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
+#include "util/u_clear.h"
#include "nv20_context.h"
void
-nv20_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue)
+nv20_clear(struct pipe_context *pipe, unsigned buffers,
+ const float *rgba, double depth, unsigned stencil)
{
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
+ util_clear(pipe, nv20_context(pipe)->framebuffer, buffers, rgba, depth,
+ stencil);
}
diff --git a/src/gallium/drivers/nv20/nv20_context.h b/src/gallium/drivers/nv20/nv20_context.h
index 8ad926db20..fc932f1f90 100644
--- a/src/gallium/drivers/nv20/nv20_context.h
+++ b/src/gallium/drivers/nv20/nv20_context.h
@@ -118,8 +118,8 @@ extern void nv20_init_surface_functions(struct nv20_context *nv20);
extern void nv20_screen_init_miptree_functions(struct pipe_screen *pscreen);
/* nv20_clear.c */
-extern void nv20_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue);
+extern void nv20_clear(struct pipe_context *pipe, unsigned buffers,
+ const float *rgba, double depth, unsigned stencil);
/* nv20_draw.c */
extern struct draw_stage *nv20_draw_render_stage(struct nv20_context *nv20);
diff --git a/src/gallium/drivers/nv30/nv30_clear.c b/src/gallium/drivers/nv30/nv30_clear.c
index 71f413588e..c4ba926664 100644
--- a/src/gallium/drivers/nv30/nv30_clear.c
+++ b/src/gallium/drivers/nv30/nv30_clear.c
@@ -1,12 +1,14 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
+#include "util/u_clear.h"
#include "nv30_context.h"
void
-nv30_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue)
+nv30_clear(struct pipe_context *pipe, unsigned buffers,
+ const float *rgba, double depth, unsigned stencil)
{
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
+ util_clear(pipe, &nv30_context(pipe)->framebuffer, buffers, rgba, depth,
+ stencil);
}
diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
index b933769700..4229c0a0e1 100644
--- a/src/gallium/drivers/nv30/nv30_context.h
+++ b/src/gallium/drivers/nv30/nv30_context.h
@@ -206,7 +206,7 @@ extern boolean nv30_draw_elements(struct pipe_context *pipe,
unsigned count);
/* nv30_clear.c */
-extern void nv30_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue);
+extern void nv30_clear(struct pipe_context *pipe, unsigned buffers,
+ const float *rgba, double depth, unsigned stencil);
#endif
diff --git a/src/gallium/drivers/nv40/nv40_clear.c b/src/gallium/drivers/nv40/nv40_clear.c
index 2c4e8f01fd..ddf13addf3 100644
--- a/src/gallium/drivers/nv40/nv40_clear.c
+++ b/src/gallium/drivers/nv40/nv40_clear.c
@@ -1,12 +1,14 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
+#include "util/u_clear.h"
#include "nv40_context.h"
void
-nv40_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue)
+nv40_clear(struct pipe_context *pipe, unsigned buffers,
+ const float *rgba, double depth, unsigned stencil)
{
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
+ util_clear(pipe, &nv40_context(pipe)->framebuffer, buffers, rgba, depth,
+ stencil);
}
diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
index adcfbdd85a..97bc83292d 100644
--- a/src/gallium/drivers/nv40/nv40_context.h
+++ b/src/gallium/drivers/nv40/nv40_context.h
@@ -227,7 +227,7 @@ extern boolean nv40_draw_elements(struct pipe_context *pipe,
unsigned count);
/* nv40_clear.c */
-extern void nv40_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue);
+extern void nv40_clear(struct pipe_context *pipe, unsigned buffers,
+ const float *rgba, double depth, unsigned stencil);
#endif
diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h
index 313e435e7a..7b67a75439 100644
--- a/src/gallium/drivers/nv50/nv50_context.h
+++ b/src/gallium/drivers/nv50/nv50_context.h
@@ -184,8 +184,8 @@ extern boolean nv50_draw_elements(struct pipe_context *pipe,
extern void nv50_vbo_validate(struct nv50_context *nv50);
/* nv50_clear.c */
-extern void nv50_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue);
+extern void nv50_clear(struct pipe_context *pipe, unsigned buffers,
+ const float *rgba, double depth, unsigned stencil);
/* nv50_program.c */
extern void nv50_vertprog_validate(struct nv50_context *nv50);
diff --git a/src/gallium/drivers/softpipe/sp_clear.c b/src/gallium/drivers/softpipe/sp_clear.c
index a60c6c4c16..f72c6c63e7 100644
--- a/src/gallium/drivers/softpipe/sp_clear.c
+++ b/src/gallium/drivers/softpipe/sp_clear.c
@@ -2,6 +2,7 @@
*
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
+ * Copyright 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
@@ -27,6 +28,7 @@
/* Author:
* Brian Paul
+ * Michel Dänzer
*/
@@ -40,34 +42,15 @@
/**
- * Convert packed pixel from one format to another.
- */
-static unsigned
-convert_color(enum pipe_format srcFormat, unsigned srcColor,
- enum pipe_format dstFormat)
-{
- ubyte r, g, b, a;
- unsigned dstColor;
-
- util_unpack_color_ub(srcFormat, &srcColor, &r, &g, &b, &a);
- util_pack_color_ub(r, g, b, a, dstFormat, &dstColor);
-
- return dstColor;
-}
-
-
-
-/**
- * Clear the given surface to the specified value.
+ * Clear the given buffers to the specified values.
* No masking, no scissor (clear entire buffer).
- * Note: when clearing a color buffer, the clearValue is always
- * encoded as PIPE_FORMAT_A8R8G8B8_UNORM.
*/
void
-softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue)
+softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+ double depth, unsigned stencil)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
+ unsigned cv;
uint i;
if (softpipe->no_rast)
@@ -77,29 +60,29 @@ softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
softpipe_update_derived(softpipe); /* not needed?? */
#endif
- if (ps == sp_tile_cache_get_surface(softpipe->zsbuf_cache)) {
- sp_tile_cache_clear(softpipe->zsbuf_cache, clearValue);
-#if TILE_CLEAR_OPTIMIZATION
- return;
-#endif
- }
+ if (buffers & PIPE_CLEAR_COLOR) {
+ for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) {
+ struct pipe_surface *ps = softpipe->framebuffer.cbufs[i];
- for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) {
- if (ps == sp_tile_cache_get_surface(softpipe->cbuf_cache[i])) {
- unsigned cv;
- if (ps->format != PIPE_FORMAT_A8R8G8B8_UNORM) {
- cv = convert_color(PIPE_FORMAT_A8R8G8B8_UNORM, clearValue,
- ps->format);
- }
- else {
- cv = clearValue;
- }
+ util_pack_color(rgba, ps->format, &cv);
sp_tile_cache_clear(softpipe->cbuf_cache[i], cv);
+
+#if !TILE_CLEAR_OPTIMIZATION
+ /* non-cached surface */
+ pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, cv);
+#endif
}
}
+ if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
+ struct pipe_surface *ps = softpipe->framebuffer.zsbuf;
+
+ cv = util_pack_z_stencil(ps->format, depth, stencil);
+ sp_tile_cache_clear(softpipe->zsbuf_cache, cv);
+
#if !TILE_CLEAR_OPTIMIZATION
- /* non-cached surface */
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
+ /* non-cached surface */
+ pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, cv);
#endif
+ }
}
diff --git a/src/gallium/drivers/softpipe/sp_clear.h b/src/gallium/drivers/softpipe/sp_clear.h
index a8ed1c4ecc..2e450672f5 100644
--- a/src/gallium/drivers/softpipe/sp_clear.h
+++ b/src/gallium/drivers/softpipe/sp_clear.h
@@ -36,8 +36,8 @@
struct pipe_context;
extern void
-softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue);
+softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+ double depth, unsigned stencil);
#endif /* SP_CLEAR_H */
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index b69ed2cb52..6e86a5dfdd 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -973,21 +973,26 @@ trace_context_surface_fill(struct pipe_context *_pipe,
static INLINE void
trace_context_clear(struct pipe_context *_pipe,
- struct pipe_surface *surface,
- unsigned clearValue)
+ unsigned surfaces,
+ const float *rgba,
+ double depth,
+ unsigned stencil)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
- surface = trace_surface_unwrap(tr_ctx, surface);
-
trace_dump_call_begin("pipe_context", "clear");
trace_dump_arg(ptr, pipe);
- trace_dump_arg(ptr, surface);
- trace_dump_arg(uint, clearValue);
-
- pipe->clear(pipe, surface, clearValue);;
+ trace_dump_arg(uint, surfaces);
+ trace_dump_arg(float, rgba[0]);
+ trace_dump_arg(float, rgba[1]);
+ trace_dump_arg(float, rgba[2]);
+ trace_dump_arg(float, rgba[3]);
+ trace_dump_arg(float, depth);
+ trace_dump_arg(uint, stencil);
+
+ pipe->clear(pipe, surfaces, rgba, depth, stencil);
trace_dump_call_end();
}