Initial work for glClear(), clear color state.

This commit is contained in:
Brian
2007-06-20 08:47:09 -06:00
parent 6cb2d0cb71
commit 73f96c5105
13 changed files with 189 additions and 6 deletions

View 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 * );

View 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;

View File

@@ -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) {
}
}

View File

@@ -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 */

View 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 );

View 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;

View 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 * );

View 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 */
}

View 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 \

View 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,

View 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;

View File

@@ -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
};

View 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;