Initial work for glClear(), clear color state.
authorBrian <brian.paul@tungstengraphics.com>
Wed, 20 Jun 2007 14:47:09 +0000 (08:47 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Wed, 20 Jun 2007 14:47:09 +0000 (08:47 -0600)
13 files changed:
src/mesa/pipe/p_context.h
src/mesa/pipe/p_state.h
src/mesa/pipe/softpipe/sp_clear.c [new file with mode: 0644]
src/mesa/pipe/softpipe/sp_clear.h [new file with mode: 0644]
src/mesa/pipe/softpipe/sp_context.c
src/mesa/pipe/softpipe/sp_context.h
src/mesa/pipe/softpipe/sp_state.h
src/mesa/pipe/softpipe/sp_state_surface.c
src/mesa/sources
src/mesa/state_tracker/st_atom.c
src/mesa/state_tracker/st_atom.h
src/mesa/state_tracker/st_atom_clear_color.c [new file with mode: 0644]
src/mesa/state_tracker/st_context.h

index 3e0c61e..3244434 100644 (file)
@@ -53,6 +53,10 @@ struct pipe_context {
    void (*draw_vb)( struct pipe_context *pipe,
                    struct vertex_buffer *VB );
 
+   /** Clear framebuffer */
+   void (*clear)(struct pipe_context *pipe, GLboolean color, GLboolean depth,
+                 GLboolean stencil, GLboolean accum);
+
    /*
     * State functions
     */
@@ -62,12 +66,12 @@ struct pipe_context {
    void (*set_blend_state)( struct pipe_context *,
                             const struct pipe_blend_state * );
 
-   void (*set_cbuf_state)( struct pipe_context *,
-                          const struct pipe_surface * );
-
    void (*set_clip_state)( struct pipe_context *,
                           const struct pipe_clip_state * );
 
+   void (*set_clear_color_state)( struct pipe_context *,
+                                  const struct pipe_clear_color_state * );
+
    void (*set_depth_state)( struct pipe_context *,
                               const struct pipe_depth_state * );
 
index c88c0de..c4bf0d2 100644 (file)
@@ -133,6 +133,11 @@ struct pipe_blend_color {
    GLfloat color[4];
 };
 
+struct pipe_clear_color_state
+{
+   GLfloat color[4];
+};
+
 struct pipe_line_state
 {
    GLuint smooth:1;
diff --git a/src/mesa/pipe/softpipe/sp_clear.c b/src/mesa/pipe/softpipe/sp_clear.c
new file mode 100644 (file)
index 0000000..c7fbca4
--- /dev/null
@@ -0,0 +1,47 @@
+/**************************************************************************
+ * 
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+/* Author:
+ *    Brian Paul
+ */
+
+
+#include "sp_clear.h"
+
+
+void
+softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth,
+               GLboolean stencil, GLboolean accum)
+{
+   /* validate state (scissor)? */
+
+   if (color) {
+   }
+   if (depth) {
+   }
+
+}
diff --git a/src/mesa/pipe/softpipe/sp_clear.h b/src/mesa/pipe/softpipe/sp_clear.h
new file mode 100644 (file)
index 0000000..f9db99d
--- /dev/null
@@ -0,0 +1,43 @@
+/**************************************************************************
+ * 
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+/* Author:
+ *    Brian Paul
+ */
+
+#ifndef SP_CLEAR_H
+#define SP_CLEAR_H
+
+#include "pipe/p_state.h"
+struct pipe_context;
+
+extern void
+softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth,
+               GLboolean stencil, GLboolean accum);
+
+
+#endif /* SP_CLEAR_H */
index e0acf41..7ab6516 100644 (file)
@@ -36,6 +36,7 @@
 #include "vf/vf.h"
 
 #include "sp_context.h"
+#include "sp_clear.h"
 #include "sp_prim.h"
 #include "sp_state.h"
 #include "sp_draw.h"
@@ -68,6 +69,7 @@ struct pipe_context *softpipe_create( void )
    softpipe->pipe.destroy = softpipe_destroy;
    softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
    softpipe->pipe.set_clip_state = softpipe_set_clip_state;
+   softpipe->pipe.set_clear_color_state = softpipe_set_clear_color_state;
    softpipe->pipe.set_point_state = softpipe_set_point_state;
    softpipe->pipe.set_viewport = softpipe_set_viewport;
    softpipe->pipe.set_setup_state = softpipe_set_setup_state;
@@ -75,7 +77,7 @@ struct pipe_context *softpipe_create( void )
    softpipe->pipe.set_fs_state = softpipe_set_fs_state;
    softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
    softpipe->pipe.draw_vb = softpipe_draw_vb;
-
+   softpipe->pipe.clear = softpipe_clear;
 
 
    softpipe->prim.setup     = prim_setup( softpipe );
index 43cb6f3..0a183ea 100644 (file)
@@ -76,6 +76,7 @@ struct softpipe_context {
    struct pipe_blend_state  blend;
    struct pipe_alpha_test_state alpha_test;
    struct pipe_clip_state   clip;
+   struct pipe_clear_color_state   clear_color;
    struct pipe_point_state  point;
    struct pipe_scissor_rect scissor;
    struct pipe_poly_stipple poly_stipple;
index 4d18e80..bc5a351 100644 (file)
@@ -38,6 +38,9 @@
 void softpipe_set_framebuffer_state( struct pipe_context *,
                             const struct pipe_framebuffer_state * );
 
+void softpipe_set_clear_color_state( struct pipe_context *,
+                                     const struct pipe_clear_color_state * );
+
 void softpipe_set_clip_state( struct pipe_context *,
                             const struct pipe_clip_state * );
 
index 99332fd..4d27814 100644 (file)
@@ -37,8 +37,9 @@
 /*
  * XXX this might get moved someday
  */
-void softpipe_set_framebuffer_state( struct pipe_context *pipe,
-                                     const struct pipe_framebuffer_state *fb )
+void
+softpipe_set_framebuffer_state(struct pipe_context *pipe,
+                               const struct pipe_framebuffer_state *fb)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
@@ -48,3 +49,13 @@ void softpipe_set_framebuffer_state( struct pipe_context *pipe,
 }
 
 
+
+
+void
+softpipe_set_clear_color_state(struct pipe_context *pipe,
+                               const struct pipe_clear_color_state *clear)
+{
+   struct softpipe_context *softpipe = softpipe_context(pipe);
+
+   softpipe->clear_color = *clear; /* struct copy */
+}
index 0bf7dbc..9780164 100644 (file)
@@ -155,6 +155,7 @@ VF_SOURCES = \
        vf/vf_sse.c
 
 SOFTPIPE_SOURCES = \
+       pipe/softpipe/sp_clear.c \
        pipe/softpipe/sp_context.c \
        pipe/softpipe/sp_draw.c \
        pipe/softpipe/sp_prim_clip.c \
@@ -177,6 +178,7 @@ STATETRACKER_SOURCES = \
        state_tracker/st_atom.c \
        state_tracker/st_atom_alphatest.c \
        state_tracker/st_atom_blend.c \
+       state_tracker/st_atom_clear_color.c \
        state_tracker/st_atom_clip.c \
        state_tracker/st_atom_depth.c \
        state_tracker/st_atom_fs.c \
index 8ac4350..e1d187f 100644 (file)
@@ -43,6 +43,7 @@
 static const struct st_tracked_state *atoms[] =
 {
    &st_update_framebuffer,
+   &st_update_clear_color,
    &st_update_clip,
    &st_update_fs,
    &st_update_point,
index 56c33f3..8c1219f 100644 (file)
@@ -46,6 +46,7 @@ void st_validate_state( struct st_context *st );
 
 const struct st_tracked_state st_update_framebuffer;
 const struct st_tracked_state st_update_clip;
+const struct st_tracked_state st_update_clear_color;
 const struct st_tracked_state st_update_depth;
 const struct st_tracked_state st_update_fs;
 const struct st_tracked_state st_update_point;
diff --git a/src/mesa/state_tracker/st_atom_clear_color.c b/src/mesa/state_tracker/st_atom_clear_color.c
new file mode 100644 (file)
index 0000000..adf730c
--- /dev/null
@@ -0,0 +1,62 @@
+/**************************************************************************
+ * 
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  *   Brian Paul
+  */
+#include "st_context.h"
+#include "st_atom.h"
+#include "pipe/p_context.h"
+
+
+static void
+update_clear_color_state( struct st_context *st )
+{
+   struct pipe_clear_color_state clear;
+
+   clear.color[0] = st->ctx->Color.ClearColor[0];
+   clear.color[1] = st->ctx->Color.ClearColor[1];
+   clear.color[2] = st->ctx->Color.ClearColor[2];
+   clear.color[3] = st->ctx->Color.ClearColor[3];
+
+   if (memcmp(&clear, &st->state.clear_color, sizeof(clear)) != 0) {
+      st->state.clear_color = clear;
+      st->pipe->set_clear_color_state( st->pipe, &clear );
+   }
+}
+
+
+const struct st_tracked_state st_update_clear_color = {
+   .dirty = {
+      .mesa = _NEW_COLOR,
+      .st  = 0,
+   },
+   .update = update_clear_color_state
+};
index 94388f1..0f1fa23 100644 (file)
@@ -71,6 +71,7 @@ struct st_context
       struct pipe_fs_state     fs;
       struct pipe_alpha_test_state  alpha_test;
       struct pipe_blend_state  blend;
+      struct pipe_clear_color_state clear_color;
       struct pipe_clip_state   clip;
       struct pipe_depth_state  depth;
       struct pipe_point_state  point;