summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/softpipe
diff options
context:
space:
mode:
authorBrian <brian@i915.localnet.net>2007-08-02 16:08:18 -0600
committerBrian <brian@i915.localnet.net>2007-08-02 16:08:18 -0600
commit47fdaf0ed9ef2f89cdaa97d0d48b1f1194d710c6 (patch)
tree3e4be03579b8bc860dc29e4c7b2ae93fded4e759 /src/mesa/pipe/softpipe
parent184b6a1f04e060e73858438561a0261d32eeb506 (diff)
pipe->clear() now takes a surface, rather than color/depth/stencil flags.
pipe->clear() only used to clear whole buffers (no scissor) w/out masking. Draw a colored quadrilateral in all other cases.
Diffstat (limited to 'src/mesa/pipe/softpipe')
-rw-r--r--src/mesa/pipe/softpipe/sp_clear.c109
-rw-r--r--src/mesa/pipe/softpipe/sp_clear.h4
2 files changed, 9 insertions, 104 deletions
diff --git a/src/mesa/pipe/softpipe/sp_clear.c b/src/mesa/pipe/softpipe/sp_clear.c
index e9b142e780..d7684d2044 100644
--- a/src/mesa/pipe/softpipe/sp_clear.c
+++ b/src/mesa/pipe/softpipe/sp_clear.c
@@ -38,32 +38,13 @@
#include "colormac.h"
-static GLuint
-color_value(GLuint format, const GLfloat color[4])
-{
- GLubyte r, g, b, a;
-
- UNCLAMPED_FLOAT_TO_UBYTE(r, color[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(g, color[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(b, color[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(a, color[3]);
-
- switch (format) {
- case PIPE_FORMAT_U_R8_G8_B8_A8:
- return (r << 24) | (g << 16) | (b << 8) | a;
- case PIPE_FORMAT_U_A8_R8_G8_B8:
- return (a << 24) | (r << 16) | (g << 8) | b;
- case PIPE_FORMAT_U_R5_G6_B5:
- return ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
- default:
- return 0;
- }
-}
-
-
+/**
+ * Clear the given surface to the specified value.
+ * No masking, no scissor (clear entire buffer).
+ */
void
-softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth,
- GLboolean stencil)
+softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
+ GLuint clearValue)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
GLint x, y, w, h;
@@ -75,81 +56,5 @@ softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth,
w = softpipe->framebuffer.cbufs[0]->width;
h = softpipe->framebuffer.cbufs[0]->height;
- if (color) {
- GLuint i;
- for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) {
- struct pipe_surface *ps = softpipe->framebuffer.cbufs[i];
- GLuint clearVal = color_value(ps->format,
- softpipe->clear_color.color);
- pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, ~0);
- }
- }
-
- if (depth && stencil &&
- softpipe->framebuffer.zbuf == softpipe->framebuffer.sbuf) {
- /* clear Z and stencil together */
- struct pipe_surface *ps = softpipe->framebuffer.zbuf;
- if (ps->format == PIPE_FORMAT_S8_Z24) {
- GLuint mask = (softpipe->stencil.write_mask[0] << 8) | 0xffffff;
- GLuint clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffff);
-
- assert (mask == ~0);
-
- clearVal |= (softpipe->stencil.clear_value << 24);
- pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, ~0);
- }
- else {
- /* XXX Z24_S8 format? */
- assert(0);
- }
- }
- else {
- /* separate Z and stencil */
- if (depth) {
- struct pipe_surface *ps = softpipe->framebuffer.zbuf;
- GLuint clearVal;
-
- switch (ps->format) {
- case PIPE_FORMAT_U_Z16:
- clearVal = (GLuint) (softpipe->depth_test.clear * 65535.0);
- break;
- case PIPE_FORMAT_U_Z32:
- clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffffff);
- break;
- case PIPE_FORMAT_S8_Z24:
- clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffff);
- break;
- default:
- assert(0);
- }
-
- pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, ~0);
- }
-
- if (stencil) {
- struct pipe_surface *ps = softpipe->framebuffer.sbuf;
- GLuint clearVal = softpipe->stencil.clear_value;
-
- /* If this is not ~0, we shouldn't get here - clear should be
- * done with geometry instead.
- */
- GLuint mask = softpipe->stencil.write_mask[0];
-
- assert((mask & 0xff) == 0xff);
-
- switch (ps->format) {
- case PIPE_FORMAT_S8_Z24:
- clearVal = clearVal << 24;
- mask = mask << 24;
- break;
- case PIPE_FORMAT_U_S8:
- /* nothing */
- break;
- default:
- assert(0);
- }
-
- pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearVal, mask);
- }
- }
+ pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearValue, ~0);
}
diff --git a/src/mesa/pipe/softpipe/sp_clear.h b/src/mesa/pipe/softpipe/sp_clear.h
index d41cc1d070..e706e731c2 100644
--- a/src/mesa/pipe/softpipe/sp_clear.h
+++ b/src/mesa/pipe/softpipe/sp_clear.h
@@ -36,8 +36,8 @@
struct pipe_context;
extern void
-softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth,
- GLboolean stencil);
+softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
+ GLuint clearValue);
#endif /* SP_CLEAR_H */