implement softpipe clearing (untested)
authorBrian <brian.paul@tungstengraphics.com>
Wed, 20 Jun 2007 15:41:41 +0000 (09:41 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Wed, 20 Jun 2007 15:41:41 +0000 (09:41 -0600)
src/mesa/pipe/softpipe/sp_clear.c
src/mesa/pipe/softpipe/sp_surface.h
src/mesa/pipe/softpipe/sp_tile_output.c

index c7fbca422904a20faced2771f48ba4bbcaee7130..536f0d39243ef68f9c65d7af0ed689281fbb0aaf 100644 (file)
 
 
 #include "sp_clear.h"
+#include "sp_context.h"
+#include "sp_surface.h"
+#include "colormac.h"
 
 
 void
 softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth,
                GLboolean stencil, GLboolean accum)
 {
-   /* validate state (scissor)? */
+   struct softpipe_context *softpipe = softpipe_context(pipe);
 
    if (color) {
+      GLuint i;
+      const GLint x = softpipe->scissor.minx;
+      const GLint y = softpipe->scissor.miny;
+      const GLint w = softpipe->scissor.maxx - x;
+      const GLint h = softpipe->scissor.maxy - y;
+      GLubyte clr[4];
+
+      UNCLAMPED_FLOAT_TO_UBYTE(clr[0], softpipe->clear_color.color[0]);
+      UNCLAMPED_FLOAT_TO_UBYTE(clr[1], softpipe->clear_color.color[1]);
+      UNCLAMPED_FLOAT_TO_UBYTE(clr[2], softpipe->clear_color.color[2]);
+      UNCLAMPED_FLOAT_TO_UBYTE(clr[3], softpipe->clear_color.color[3]);
+
+      for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) {
+         struct pipe_surface *ps = softpipe->framebuffer.cbufs[i];
+         struct softpipe_surface *sps = softpipe_surface(ps);
+         GLint j;
+         for (j = 0; j < h; j++) {
+            sps->write_mono_row_ub(sps, w, x, y + j, clr);
+         }
+      }
    }
+
    if (depth) {
    }
 
index dde6b90448e390a6e95b249d83133d87b2a0d685..fc9557dee3ae244c05b02ffe6a7879dc9eb64744 100644 (file)
@@ -73,6 +73,19 @@ struct softpipe_surface {
    void (*write_quad_ub)( struct softpipe_surface *,
                          GLint x, GLint y,
                          GLubyte (*rgba)[NUM_CHANNELS] );
+
+   void (*write_mono_row_ub)( struct softpipe_surface *,
+                              GLuint count, GLint x, GLint y,
+                              GLubyte rgba[NUM_CHANNELS] );
 };
 
+
+/** Cast wrapper */
+static INLINE struct softpipe_surface *
+softpipe_surface(struct pipe_surface *ps)
+{
+   return (struct softpipe_surface *) ps;
+}
+
+
 #endif
index d4add4b162b20e8cadadae939acdff72b0803ecf..23086b702086c3f269c1b25a1fb96e9df11053a7 100644 (file)
@@ -67,7 +67,7 @@ void quad_output( struct softpipe_context *softpipe,
 
    for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) {
       struct softpipe_surface *sps
-         = (struct softpipe_surface *) softpipe->framebuffer.cbufs[i];
+         = softpipe_surface(softpipe->framebuffer.cbufs[i]);
 
       if (quad->mask != MASK_ALL) {
          GLfloat tmp[4][QUAD_SIZE];