diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-06-20 08:47:09 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-06-20 08:47:09 -0600 |
commit | 73f96c51052bf5233191d852ef463462306bf1d5 (patch) | |
tree | 29a1f9f4b5f052f7894dce351ebfb4a8ae69b85a | |
parent | 6cb2d0cb71d2019bd2c941a8c042e56275b22c1c (diff) |
Initial work for glClear(), clear color state.
-rw-r--r-- | src/mesa/pipe/p_context.h | 10 | ||||
-rw-r--r-- | src/mesa/pipe/p_state.h | 5 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_clear.c | 47 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_clear.h | 43 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_context.c | 4 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_context.h | 1 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_state.h | 3 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_state_surface.c | 15 | ||||
-rw-r--r-- | src/mesa/sources | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom.c | 1 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom.h | 1 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_clear_color.c | 62 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.h | 1 |
13 files changed, 189 insertions, 6 deletions
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 3e0c61eda2..32444343be 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -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 * ); diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index c88c0de6ad..c4bf0d2195 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -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 index 0000000000..c7fbca4229 --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_clear.c @@ -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 index 0000000000..f9db99dd32 --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_clear.h @@ -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 */ diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index e0acf4177b..7ab65162bd 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -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 ); diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index 43cb6f3f0b..0a183ea385 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -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; diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index 4d18e80b38..bc5a3512ae 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -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 * ); diff --git a/src/mesa/pipe/softpipe/sp_state_surface.c b/src/mesa/pipe/softpipe/sp_state_surface.c index 99332fdd52..4d27814e1b 100644 --- a/src/mesa/pipe/softpipe/sp_state_surface.c +++ b/src/mesa/pipe/softpipe/sp_state_surface.c @@ -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 */ +} diff --git a/src/mesa/sources b/src/mesa/sources index 0bf7dbceb3..97801648c4 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -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 \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 8ac435041d..e1d187f2db 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -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, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 56c33f3076..8c1219fefd 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -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 index 0000000000..adf730cd8c --- /dev/null +++ b/src/mesa/state_tracker/st_atom_clear_color.c @@ -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 +}; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 94388f1aee..0f1fa2327b 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -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; |