summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2007-06-14 18:11:48 +0100
committerKeith Whitwell <[email protected]>2007-06-14 18:11:48 +0100
commit6393cda6766b707ef01e925d378239a66d143ae0 (patch)
tree31b5c8cc27ee16b142e27c42d5cb69f2fe9826d2 /src/mesa/state_tracker
parent7050a4a7bc779b2c30fbd8244d4e77e6bd3dc30f (diff)
Renamed softpipe directories and files to something less confusing.
softpipe/state_tracker --> state_tracker/ softpipe/ --> pipe/ softpipe/generic --> pipe/softpipe/ I don't think pipe is a great name, but I disliked all the others too. Luckily it's fairly easy to rename with git, so this can be revisited later.
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/Makefile2
-rw-r--r--src/mesa/state_tracker/st_atom.c171
-rw-r--r--src/mesa/state_tracker/st_atom.h59
-rw-r--r--src/mesa/state_tracker/st_atom_blend.c202
-rw-r--r--src/mesa/state_tracker/st_atom_cbuf.c72
-rw-r--r--src/mesa/state_tracker/st_atom_clip.c75
-rw-r--r--src/mesa/state_tracker/st_atom_depth.c88
-rw-r--r--src/mesa/state_tracker/st_atom_fs.c56
-rw-r--r--src/mesa/state_tracker/st_atom_scissor.c88
-rw-r--r--src/mesa/state_tracker/st_atom_setup.c175
-rw-r--r--src/mesa/state_tracker/st_atom_stencil.c140
-rw-r--r--src/mesa/state_tracker/st_atom_viewport.c117
-rw-r--r--src/mesa/state_tracker/st_cb_program.c165
-rw-r--r--src/mesa/state_tracker/st_context.c76
-rw-r--r--src/mesa/state_tracker/st_context.h111
-rw-r--r--src/mesa/state_tracker/st_draw.c107
-rw-r--r--src/mesa/state_tracker/st_draw.h40
-rw-r--r--src/mesa/state_tracker/st_program.h68
-rw-r--r--src/mesa/state_tracker/st_public.h43
19 files changed, 1855 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/Makefile b/src/mesa/state_tracker/Makefile
new file mode 100644
index 00000000000..0ab1dc6e6bd
--- /dev/null
+++ b/src/mesa/state_tracker/Makefile
@@ -0,0 +1,2 @@
+default:
+ cd ../.. ; make \ No newline at end of file
diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c
new file mode 100644
index 00000000000..fdbfb9021da
--- /dev/null
+++ b/src/mesa/state_tracker/st_atom.c
@@ -0,0 +1,171 @@
+/**************************************************************************
+ *
+ * Copyright 2003 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.
+ *
+ **************************************************************************/
+
+
+#include "glheader.h"
+#include "context.h"
+
+#include "st_context.h"
+#include "st_atom.h"
+
+
+
+/* This is used to initialize st->atoms[]. We could use this list
+ * directly except for a single atom, st_update_constants, which has a
+ * .dirty value which changes according to the parameters of the
+ * current fragment and vertex programs, and so cannot be a static
+ * value.
+ */
+static const struct st_tracked_state *atoms[] =
+{
+ &st_update_cbuf,
+ &st_update_clip,
+ &st_update_fs,
+ &st_update_setup,
+ &st_update_viewport,
+ &st_update_scissor,
+ &st_update_blend,
+ &st_update_stencil,
+ /* will be patched out at runtime */
+/* &st_update_constants */
+};
+
+
+void st_init_atoms( struct st_context *st )
+{
+ GLuint i;
+
+ st->atoms = _mesa_malloc(sizeof(atoms));
+ st->nr_atoms = sizeof(atoms)/sizeof(*atoms);
+ memcpy(st->atoms, atoms, sizeof(atoms));
+
+ /* Patch in a pointer to the dynamic state atom:
+ */
+ for (i = 0; i < st->nr_atoms; i++)
+ if (st->atoms[i] == &st_update_constants)
+ st->atoms[i] = &st->constants.tracked_state;
+
+ memcpy(&st->constants.tracked_state,
+ &st_update_constants,
+ sizeof(st_update_constants));
+}
+
+
+void st_destroy_atoms( struct st_context *st )
+{
+ if (st->atoms) {
+ _mesa_free(st->atoms);
+ st->atoms = NULL;
+ }
+}
+
+
+/***********************************************************************
+ */
+
+static GLboolean check_state( const struct st_state_flags *a,
+ const struct st_state_flags *b )
+{
+ return ((a->mesa & b->mesa) ||
+ (a->st & b->st));
+}
+
+static void accumulate_state( struct st_state_flags *a,
+ const struct st_state_flags *b )
+{
+ a->mesa |= b->mesa;
+ a->st |= b->st;
+}
+
+
+static void xor_states( struct st_state_flags *result,
+ const struct st_state_flags *a,
+ const struct st_state_flags *b )
+{
+ result->mesa = a->mesa ^ b->mesa;
+ result->st = a->st ^ b->st;
+}
+
+
+/***********************************************************************
+ * Update all derived state:
+ */
+
+void st_validate_state( struct st_context *st )
+{
+ struct st_state_flags *state = &st->dirty;
+ GLuint i;
+
+ if (state->st == 0)
+ return;
+
+ if (1) {
+ /* Debug version which enforces various sanity checks on the
+ * state flags which are generated and checked to help ensure
+ * state atoms are ordered correctly in the list.
+ */
+ struct st_state_flags examined, prev;
+ _mesa_memset(&examined, 0, sizeof(examined));
+ prev = *state;
+
+ for (i = 0; i < st->nr_atoms; i++) {
+ const struct st_tracked_state *atom = st->atoms[i];
+ struct st_state_flags generated;
+
+ assert(atom->dirty.mesa ||
+ atom->dirty.st);
+ assert(atom->update);
+
+ if (check_state(state, &atom->dirty)) {
+ st->atoms[i]->update( st );
+ }
+
+ accumulate_state(&examined, &atom->dirty);
+
+ /* generated = (prev ^ state)
+ * if (examined & generated)
+ * fail;
+ */
+ xor_states(&generated, &prev, state);
+ assert(!check_state(&examined, &generated));
+ prev = *state;
+ }
+ }
+ else {
+ const GLuint nr = st->nr_atoms;
+
+ for (i = 0; i < nr; i++) {
+ if (check_state(state, &st->atoms[i]->dirty))
+ st->atoms[i]->update( st );
+ }
+ }
+
+ memset(state, 0, sizeof(*state));
+}
+
+
+
diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h
new file mode 100644
index 00000000000..1d8da463368
--- /dev/null
+++ b/src/mesa/state_tracker/st_atom.h
@@ -0,0 +1,59 @@
+/**************************************************************************
+ *
+ * Copyright 2003 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 <[email protected]>
+ */
+
+
+#ifndef ST_ATOM_H
+#define ST_ATOM_H
+
+struct st_context;
+struct st_tracked_state;
+
+void st_init_atoms( struct st_context *st );
+void st_destroy_atoms( struct st_context *st );
+
+
+void st_validate_state( struct st_context *st );
+
+
+const struct st_tracked_state st_update_cbuf;
+const struct st_tracked_state st_update_clip;
+const struct st_tracked_state st_update_depth;
+const struct st_tracked_state st_update_fs;
+const struct st_tracked_state st_update_setup;
+const struct st_tracked_state st_update_viewport;
+const struct st_tracked_state st_update_constants;
+const struct st_tracked_state st_update_scissor;
+const struct st_tracked_state st_update_blend;
+const struct st_tracked_state st_update_stencil;
+
+
+#endif
diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c
new file mode 100644
index 00000000000..eabb9172ba5
--- /dev/null
+++ b/src/mesa/state_tracker/st_atom_blend.c
@@ -0,0 +1,202 @@
+/**************************************************************************
+ *
+ * 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 <[email protected]>
+ * Brian Paul
+ */
+
+
+#include "st_context.h"
+#include "st_atom.h"
+#include "softpipe/sp_context.h"
+#include "softpipe/sp_defines.h"
+
+
+/**
+ * Convert GLenum blend tokens to softpipe tokens.
+ * Both blend factors and blend funcs are accepted.
+ */
+static GLuint
+gl_blend_to_sp(GLenum blend)
+{
+ switch (blend) {
+ /* blend functions */
+ case GL_FUNC_ADD:
+ return SP_BLEND_ADD;
+ case GL_FUNC_SUBTRACT:
+ return SP_BLEND_SUBTRACT;
+ case GL_FUNC_REVERSE_SUBTRACT:
+ return SP_BLEND_REVERSE_SUBTRACT;
+ case GL_MIN:
+ return SP_BLEND_MIN;
+ case GL_MAX:
+ return SP_BLEND_MAX;
+
+ /* blend factors */
+ case GL_ONE:
+ return SP_BLENDFACTOR_ONE;
+ case GL_SRC_COLOR:
+ return SP_BLENDFACTOR_SRC_COLOR;
+ case GL_SRC_ALPHA:
+ return SP_BLENDFACTOR_SRC_ALPHA;
+ case GL_DST_ALPHA:
+ return SP_BLENDFACTOR_DST_ALPHA;
+ case GL_DST_COLOR:
+ return SP_BLENDFACTOR_DST_COLOR;
+ case GL_SRC_ALPHA_SATURATE:
+ return SP_BLENDFACTOR_SRC_ALPHA_SATURATE;
+ case GL_CONSTANT_COLOR:
+ return SP_BLENDFACTOR_CONST_COLOR;
+ case GL_CONSTANT_ALPHA:
+ return SP_BLENDFACTOR_CONST_ALPHA;
+ /*
+ return SP_BLENDFACTOR_SRC1_COLOR;
+ return SP_BLENDFACTOR_SRC1_ALPHA;
+ */
+ case GL_ZERO:
+ return SP_BLENDFACTOR_ZERO;
+ case GL_ONE_MINUS_SRC_COLOR:
+ return SP_BLENDFACTOR_INV_SRC_COLOR;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ return SP_BLENDFACTOR_INV_SRC_ALPHA;
+ case GL_ONE_MINUS_DST_COLOR:
+ return SP_BLENDFACTOR_INV_DST_ALPHA;
+ case GL_ONE_MINUS_DST_ALPHA:
+ return SP_BLENDFACTOR_INV_DST_COLOR;
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ return SP_BLENDFACTOR_INV_CONST_COLOR;
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ return SP_BLENDFACTOR_INV_CONST_ALPHA;
+ /*
+ return SP_BLENDFACTOR_INV_SRC1_COLOR;
+ return SP_BLENDFACTOR_INV_SRC1_ALPHA;
+ */
+ default:
+ assert("invalid GL token in gl_blend_to_sp()" == NULL);
+ return 0;
+ }
+}
+
+
+/**
+ * Convert GLenum logicop tokens to softpipe tokens.
+ */
+static GLuint
+gl_logicop_to_sp(GLenum logicop)
+{
+ switch (logicop) {
+ case GL_CLEAR:
+ return SP_LOGICOP_CLEAR;
+ case GL_NOR:
+ return SP_LOGICOP_NOR;
+ case GL_AND_INVERTED:
+ return SP_LOGICOP_AND_INVERTED;
+ case GL_COPY_INVERTED:
+ return SP_LOGICOP_COPY_INVERTED;
+ case GL_AND_REVERSE:
+ return SP_LOGICOP_AND_REVERSE;
+ case GL_INVERT:
+ return SP_LOGICOP_INVERT;
+ case GL_XOR:
+ return SP_LOGICOP_XOR;
+ case GL_NAND:
+ return SP_LOGICOP_NAND;
+ case GL_AND:
+ return SP_LOGICOP_AND;
+ case GL_EQUIV:
+ return SP_LOGICOP_EQUIV;
+ case GL_NOOP:
+ return SP_LOGICOP_NOOP;
+ case GL_OR_INVERTED:
+ return SP_LOGICOP_OR_INVERTED;
+ case GL_COPY:
+ return SP_LOGICOP_COPY;
+ case GL_OR_REVERSE:
+ return SP_LOGICOP_OR_REVERSE;
+ case GL_OR:
+ return SP_LOGICOP_OR;
+ case GL_SET:
+ return SP_LOGICOP_SET;
+ default:
+ assert("invalid GL token in gl_logicop_to_sp()" == NULL);
+ return 0;
+ }
+}
+
+
+static void
+update_blend( struct st_context *st )
+{
+ struct softpipe_blend_state blend;
+
+ memset(&blend, 0, sizeof(blend));
+
+ if (st->ctx->Color.ColorLogicOpEnabled ||
+ (st->ctx->Color.BlendEnabled &&
+ st->ctx->Color.BlendEquationRGB == GL_LOGIC_OP)) {
+ /* logicop enabled */
+ blend.logicop_enable = 1;
+ blend.logicop_func = gl_logicop_to_sp(st->ctx->Color.LogicOp);
+ }
+ else if (st->ctx->Color.BlendEnabled) {
+ /* blending enabled */
+ blend.blend_enable = 1;
+
+ blend.rgb_func = gl_blend_to_sp(st->ctx->Color.BlendEquationRGB);
+ blend.rgb_src_factor = gl_blend_to_sp(st->ctx->Color.BlendSrcRGB);
+ blend.rgb_dst_factor = gl_blend_to_sp(st->ctx->Color.BlendDstRGB);
+
+ blend.alpha_func = gl_blend_to_sp(st->ctx->Color.BlendEquationA);
+ blend.alpha_src_factor = gl_blend_to_sp(st->ctx->Color.BlendSrcA);
+ blend.alpha_dst_factor = gl_blend_to_sp(st->ctx->Color.BlendDstA);
+ }
+ else {
+ /* no blending / logicop */
+ }
+
+ if (memcmp(&blend, &st->state.blend, sizeof(blend)) != 0) {
+ /* state has changed */
+ st->state.blend = blend; /* struct copy */
+ st->softpipe->set_blend_state(st->softpipe, &blend); /* set new state */
+ }
+}
+
+
+const struct st_tracked_state st_update_blend = {
+ .dirty = {
+ .mesa = (_NEW_COLOR), /* XXX _NEW_BLEND someday? */
+ .st = 0,
+ },
+ .update = update_blend
+};
+
+
+
+
+
diff --git a/src/mesa/state_tracker/st_atom_cbuf.c b/src/mesa/state_tracker/st_atom_cbuf.c
new file mode 100644
index 00000000000..cd707ec5ef5
--- /dev/null
+++ b/src/mesa/state_tracker/st_atom_cbuf.c
@@ -0,0 +1,72 @@
+/**************************************************************************
+ *
+ * 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 <[email protected]>
+ */
+
+#include "st_context.h"
+#include "softpipe/sp_context.h"
+#include "st_atom.h"
+
+extern GLboolean xmesa_get_cbuf_details( GLcontext *ctx,
+ void **ptr,
+ GLuint *cpp,
+ GLint *stride,
+ GLuint *format );
+
+
+/* This is a hack to work with the X11 driver as a test harness
+ */
+static void update_cbuf_state( struct st_context *st )
+{
+ struct softpipe_surface cbuf;
+ GLboolean ok;
+
+ ok = xmesa_get_cbuf_details( st->ctx,
+ (void **)&cbuf.ptr,
+ &cbuf.cpp,
+ &cbuf.stride,
+ &cbuf.format );
+
+ assert(ok);
+
+ if (memcmp(&cbuf, &st->state.cbuf, sizeof(cbuf)) != 0) {
+ st->state.cbuf = cbuf;
+ st->softpipe->set_cbuf_state( st->softpipe, &cbuf );
+ }
+}
+
+const struct st_tracked_state st_update_cbuf = {
+ .dirty = {
+ .mesa = _NEW_BUFFERS,
+ .st = 0,
+ },
+ .update = update_cbuf_state
+};
+
diff --git a/src/mesa/state_tracker/st_atom_clip.c b/src/mesa/state_tracker/st_atom_clip.c
new file mode 100644
index 00000000000..710d6ffc84f
--- /dev/null
+++ b/src/mesa/state_tracker/st_atom_clip.c
@@ -0,0 +1,75 @@
+/**************************************************************************
+ *
+ * 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 <[email protected]>
+ */
+
+
+#include "st_context.h"
+#include "softpipe/sp_context.h"
+#include "st_atom.h"
+
+
+/* Second state atom for user clip planes:
+ */
+static void update_clip( struct st_context *st )
+{
+ struct softpipe_clip_state clip;
+ GLuint i;
+
+ memset(&clip, 0, sizeof(clip));
+
+ for (i = 0; i < SP_MAX_CLIP_PLANES; i++) {
+ if (st->ctx->Transform.ClipPlanesEnabled & (1 << i)) {
+ memcpy(clip.ucp[clip.nr],
+ st->ctx->Transform._ClipUserPlane[i],
+ sizeof(clip.ucp[0]));
+ clip.nr++;
+ }
+ }
+
+ if (memcmp(&clip, &st->state.clip, sizeof(clip)) != 0) {
+ st->state.clip = clip;
+ st->softpipe->set_clip_state(st->softpipe, &clip);
+ }
+}
+
+
+const struct st_tracked_state st_update_clip = {
+ .dirty = {
+ .mesa = (_NEW_TRANSFORM),
+ .st = 0,
+ },
+ .update = update_clip
+};
+
+
+
+
+
diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c
new file mode 100644
index 00000000000..5532abc8fd7
--- /dev/null
+++ b/src/mesa/state_tracker/st_atom_depth.c
@@ -0,0 +1,88 @@
+/**************************************************************************
+ *
+ * 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 <[email protected]>
+ * Brian Paul
+ */
+
+
+#include "st_context.h"
+#include "st_atom.h"
+#include "softpipe/sp_context.h"
+#include "softpipe/sp_defines.h"
+
+
+/**
+ * Convert GLenum depth func tokens to softpipe tokens.
+ */
+static GLuint
+gl_depth_func_to_sp(GLenum func)
+{
+ /* Same values, just biased */
+ assert(SP_DEPTH_FUNC_NEVER == GL_NEVER - GL_NEVER);
+ assert(SP_DEPTH_FUNC_LESS == GL_LESS - GL_NEVER);
+ assert(SP_DEPTH_FUNC_EQUAL == GL_EQUAL - GL_NEVER);
+ assert(SP_DEPTH_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER);
+ assert(SP_DEPTH_FUNC_GREATER == GL_GREATER - GL_NEVER);
+ assert(SP_DEPTH_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER);
+ assert(SP_DEPTH_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER);
+ assert(SP_DEPTH_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER);
+ assert(func >= GL_NEVER);
+ assert(func <= GL_ALWAYS);
+ return func - GL_NEVER;
+}
+
+
+static void
+update_depth( struct st_context *st )
+{
+ struct softpipe_depth_state depth;
+
+ memset(&depth, 0, sizeof(depth));
+
+ depth.enabled = st->ctx->Depth.Test;
+ depth.writemask = st->ctx->Depth.Mask;
+ depth.func = gl_depth_func_to_sp(st->ctx->Depth.Func);
+ depth.clear = st->ctx->Depth.Clear;
+
+ if (memcmp(&depth, &st->state.depth, sizeof(depth)) != 0) {
+ /* state has changed */
+ st->state.depth = depth; /* struct copy */
+ st->softpipe->set_depth_state(st->softpipe, &depth); /* set new state */
+ }
+}
+
+
+const struct st_tracked_state st_update_depth = {
+ .dirty = {
+ .mesa = (_NEW_DEPTH),
+ .st = 0,
+ },
+ .update = update_depth
+};
diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c
new file mode 100644
index 00000000000..ca109d2d343
--- /dev/null
+++ b/src/mesa/state_tracker/st_atom_fs.c
@@ -0,0 +1,56 @@
+/**************************************************************************
+ *
+ * Copyright 2003 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 <[email protected]>
+ */
+
+#include "st_context.h"
+#include "softpipe/sp_context.h"
+#include "st_atom.h"
+
+
+static void update_fs( struct st_context *st )
+{
+ struct softpipe_fs_state fs;
+
+ fs.fp = st->ctx->FragmentProgram._Current;
+
+ if (memcmp(&fs, &st->state.fs, sizeof(fs)) != 0) {
+ st->state.fs = fs;
+ st->softpipe->set_fs_state(st->softpipe, &fs);
+ }
+}
+
+
+const struct st_tracked_state st_update_fs = {
+ .dirty = {
+ .mesa = 0,
+ .st = ST_NEW_FRAGMENT_PROGRAM,
+ },
+ .update = update_fs
+};
diff --git a/src/mesa/state_tracker/st_atom_scissor.c b/src/mesa/state_tracker/st_atom_scissor.c
new file mode 100644
index 00000000000..105c2a6dd92
--- /dev/null
+++ b/src/mesa/state_tracker/st_atom_scissor.c
@@ -0,0 +1,88 @@
+/**************************************************************************
+ *
+ * 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 <[email protected]>
+ */
+
+
+#include "st_context.h"
+#include "softpipe/sp_context.h"
+#include "st_atom.h"
+
+
+/**
+ * Scissor depends on the scissor box, and the framebuffer dimensions.
+ */
+static void
+update_scissor( struct st_context *st )
+{
+ struct softpipe_scissor_rect scissor;
+ const struct gl_framebuffer *fb = st->ctx->DrawBuffer;
+
+ scissor.minx = 0;
+ scissor.miny = 0;
+ scissor.maxx = fb->Width;
+ scissor.maxy = fb->Height;
+
+ if (st->ctx->Scissor.Enabled) {
+ if (st->ctx->Scissor.X > scissor.minx)
+ scissor.minx = st->ctx->Scissor.X;
+ if (st->ctx->Scissor.Y > scissor.miny)
+ scissor.miny = st->ctx->Scissor.Y;
+
+ if (st->ctx->Scissor.X + st->ctx->Scissor.Width < scissor.maxx)
+ scissor.maxx = st->ctx->Scissor.X + st->ctx->Scissor.Width;
+ if (st->ctx->Scissor.Y + st->ctx->Scissor.Height < scissor.maxy)
+ scissor.maxy = st->ctx->Scissor.Y + st->ctx->Scissor.Height;
+
+ /* check for null space */
+ if (scissor.minx >= scissor.maxx || scissor.miny >= scissor.maxy)
+ scissor.minx = scissor.miny = scissor.maxx = scissor.maxy = 0;
+ }
+
+ if (memcmp(&scissor, &st->state.scissor, sizeof(scissor)) != 0) {
+ /* state has changed */
+ st->state.scissor = scissor; /* struct copy */
+ st->softpipe->set_scissor_rect(st->softpipe, &scissor); /* activate */
+ }
+}
+
+
+const struct st_tracked_state st_update_scissor = {
+ .dirty = {
+ .mesa = (_NEW_SCISSOR | _NEW_BUFFERS),
+ .st = 0,
+ },
+ .update = update_scissor
+};
+
+
+
+
+
diff --git a/src/mesa/state_tracker/st_atom_setup.c b/src/mesa/state_tracker/st_atom_setup.c
new file mode 100644
index 00000000000..2a582ea36ca
--- /dev/null
+++ b/src/mesa/state_tracker/st_atom_setup.c
@@ -0,0 +1,175 @@
+/**************************************************************************
+ *
+ * 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 <[email protected]>
+ */
+
+
+#include "st_context.h"
+#include "softpipe/sp_context.h"
+#include "st_atom.h"
+
+static GLuint translate_fill( GLenum mode )
+{
+ switch (mode) {
+ case GL_POINT: return FILL_POINT;
+ case GL_LINE: return FILL_LINE;
+ case GL_FILL: return FILL_TRI;
+ default: assert(0); return 0;
+ }
+}
+
+static GLboolean get_offset_flag( GLuint fill_mode,
+ const struct gl_polygon_attrib *Polygon )
+{
+ switch (fill_mode) {
+ case FILL_POINT: return Polygon->OffsetPoint;
+ case FILL_LINE: return Polygon->OffsetLine;
+ case FILL_TRI: return Polygon->OffsetFill;
+ default: assert(0); return 0;
+ }
+}
+
+
+static void update_setup_state( struct st_context *st )
+{
+ GLcontext *ctx = st->ctx;
+ struct softpipe_setup_state setup;
+
+ memset(&setup, 0, sizeof(setup));
+
+ /* _NEW_POLYGON, _NEW_BUFFERS
+ */
+ {
+ setup.front_winding = WINDING_CW;
+
+ if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0)
+ setup.front_winding ^= WINDING_BOTH;
+
+ if (ctx->Polygon.FrontFace != GL_CCW)
+ setup.front_winding ^= WINDING_BOTH;
+ }
+
+ /* _NEW_LIGHT
+ */
+ if (ctx->Light.ShadeModel == GL_FLAT)
+ setup.flatshade = 1;
+
+ /* _NEW_LIGHT
+ *
+ * Not sure about the light->enabled requirement - does this still
+ * apply??
+ */
+ if (ctx->Light.Enabled &&
+ ctx->Light.Model.TwoSide)
+ setup.light_twoside = 1;
+
+
+ /* _NEW_POLYGON
+ */
+ if (ctx->Polygon.CullFlag) {
+ if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) {
+ setup.cull_mode = WINDING_BOTH;
+ }
+ else if (ctx->Polygon.CullFaceMode == GL_FRONT) {
+ setup.cull_mode = setup.front_winding;
+ }
+ else {
+ setup.cull_mode = setup.front_winding ^ WINDING_BOTH;
+ }
+ }
+
+ /* _NEW_POLYGON
+ */
+ {
+ GLuint fill_front = translate_fill( ctx->Polygon.FrontMode );
+ GLuint fill_back = translate_fill( ctx->Polygon.BackMode );
+
+ if (setup.front_winding == WINDING_CW) {
+ setup.fill_cw = fill_front;
+ setup.fill_ccw = fill_back;
+ }
+ else {
+ setup.fill_cw = fill_back;
+ setup.fill_ccw = fill_front;
+ }
+
+ /* Simplify when culling is active:
+ */
+ if (setup.cull_mode & WINDING_CW) {
+ setup.fill_cw = setup.fill_ccw;
+ }
+
+ if (setup.cull_mode & WINDING_CCW) {
+ setup.fill_ccw = setup.fill_cw;
+ }
+ }
+
+ /* Hardware does offset for filled prims, but need to do it in
+ * software for unfilled.
+ *
+ * _NEW_POLYGON
+ */
+ if (setup.fill_cw != FILL_TRI)
+ setup.offset_cw = get_offset_flag( setup.fill_cw,
+ &ctx->Polygon );
+
+ if (setup.fill_ccw != FILL_TRI)
+ setup.offset_ccw = get_offset_flag( setup.fill_ccw,
+ &ctx->Polygon );
+
+
+ /* _NEW_BUFFERS, _NEW_POLYGON
+ */
+ if (setup.fill_cw != FILL_TRI ||
+ setup.fill_ccw != FILL_TRI)
+ {
+ GLfloat mrd = (ctx->DrawBuffer ?
+ ctx->DrawBuffer->_MRD :
+ 1.0);
+
+ setup.offset_units = ctx->Polygon.OffsetFactor * mrd;
+ setup.offset_scale = (ctx->Polygon.OffsetUnits * mrd *
+ st->polygon_offset_scale);
+ }
+
+
+ if (memcmp(&setup, &st->state.setup, sizeof(setup)) != 0) {
+ st->state.setup = setup;
+ st->softpipe->set_setup_state( st->softpipe, &setup );
+ }
+}
+
+const struct st_tracked_state st_update_setup = {
+ .dirty = {
+ .mesa = (_NEW_LIGHT | _NEW_POLYGON | _NEW_BUFFERS),
+ .st = 0,
+ },
+ .update = update_setup_state
+};
diff --git a/src/mesa/state_tracker/st_atom_stencil.c b/src/mesa/state_tracker/st_atom_stencil.c
new file mode 100644
index 00000000000..32610c3d24d
--- /dev/null
+++ b/src/mesa/state_tracker/st_atom_stencil.c
@@ -0,0 +1,140 @@
+/**************************************************************************
+ *
+ * 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 <[email protected]>
+ * Brian Paul
+ */
+
+
+#include "st_context.h"
+#include "st_atom.h"
+#include "softpipe/sp_context.h"
+#include "softpipe/sp_defines.h"
+
+
+/**
+ * Convert GLenum stencil func tokens to softpipe tokens.
+ */
+static GLuint
+gl_stencil_func_to_sp(GLenum func)
+{
+ /* Same values, just biased */
+ assert(SP_STENCIL_FUNC_NEVER == GL_NEVER - GL_NEVER);
+ assert(SP_STENCIL_FUNC_LESS == GL_LESS - GL_NEVER);
+ assert(SP_STENCIL_FUNC_EQUAL == GL_EQUAL - GL_NEVER);
+ assert(SP_STENCIL_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER);
+ assert(SP_STENCIL_FUNC_GREATER == GL_GREATER - GL_NEVER);
+ assert(SP_STENCIL_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER);
+ assert(SP_STENCIL_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER);
+ assert(SP_STENCIL_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER);
+ assert(func >= GL_NEVER);
+ assert(func <= GL_ALWAYS);
+ return func - GL_NEVER;
+}
+
+
+/**
+ * Convert GLenum stencil op tokens to softpipe tokens.
+ */
+static GLuint
+gl_stencil_op_to_sp(GLenum func)
+{
+ switch (func) {
+ case GL_KEEP:
+ return SP_STENCIL_OP_KEEP;
+ case GL_ZERO:
+ return SP_STENCIL_OP_ZERO;
+ case GL_REPLACE:
+ return SP_STENCIL_OP_REPLACE;
+ case GL_INCR:
+ return SP_STENCIL_OP_INCR;
+ case GL_DECR:
+ return SP_STENCIL_OP_DECR;
+ case GL_INCR_WRAP:
+ return SP_STENCIL_OP_INCR_WRAP;
+ case GL_DECR_WRAP:
+ return SP_STENCIL_OP_DECR_WRAP;
+ case GL_INVERT:
+ return SP_STENCIL_OP_INVERT;
+ default:
+ assert("invalid GL token in gl_stencil_op_to_sp()" == NULL);
+ return 0;
+ }
+}
+
+
+static void
+update_stencil( struct st_context *st )
+{
+ struct softpipe_stencil_state stencil;
+
+ memset(&stencil, 0, sizeof(stencil));
+
+ if (st->ctx->Stencil.Enabled) {
+ stencil.front_enabled = 1;
+ stencil.front_func = gl_stencil_func_to_sp(st->ctx->Stencil.Function[0]);
+ stencil.front_fail_op = gl_stencil_op_to_sp(st->ctx->Stencil.FailFunc[0]);
+ stencil.front_zfail_op = gl_stencil_op_to_sp(st->ctx->Stencil.ZFailFunc[0]);
+ stencil.front_zpass_op = gl_stencil_op_to_sp(st->ctx->Stencil.ZPassFunc[0]);
+ stencil.ref_value[0] = st->ctx->Stencil.Ref[0] & 0xff;
+ stencil.value_mask[0] = st->ctx->Stencil.ValueMask[0] & 0xff;
+ stencil.write_mask[0] = st->ctx->Stencil.WriteMask[0] & 0xff;
+ if (st->ctx->Stencil.TestTwoSide) {
+ stencil.back_enabled = 1;
+ stencil.back_func = gl_stencil_func_to_sp(st->ctx->Stencil.Function[1]);
+ stencil.back_fail_op = gl_stencil_op_to_sp(st->ctx->Stencil.FailFunc[1]);
+ stencil.back_zfail_op = gl_stencil_op_to_sp(st->ctx->Stencil.ZFailFunc[1]);
+ stencil.back_zpass_op = gl_stencil_op_to_sp(st->ctx->Stencil.ZPassFunc[1]);
+ stencil.ref_value[1] = st->ctx->Stencil.Ref[1] & 0xff;
+ stencil.value_mask[1] = st->ctx->Stencil.ValueMask[1] & 0xff;
+ stencil.write_mask[1] = st->ctx->Stencil.WriteMask[1] & 0xff;
+ }
+ stencil.clear_value = st->ctx->Stencil.Clear & 0xff;
+ }
+
+ if (memcmp(&stencil, &st->state.stencil, sizeof(stencil)) != 0) {
+ /* state has changed */
+ st->state.stencil = stencil; /* struct copy */
+ st->softpipe->set_stencil_state(st->softpipe, &stencil); /* set new state */
+ }
+}
+
+
+const struct st_tracked_state st_update_stencil = {
+ .dirty = {
+ .mesa = (_NEW_STENCIL),
+ .st = 0,
+ },
+ .update = update_stencil
+};
+
+
+
+
+
diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c
new file mode 100644
index 00000000000..af896e2e31a
--- /dev/null
+++ b/src/mesa/state_tracker/st_atom_viewport.c
@@ -0,0 +1,117 @@
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+
+#include "context.h"
+#include "colormac.h"
+#include "st_context.h"
+#include "softpipe/sp_context.h"
+#include "st_atom.h"
+
+
+
+
+
+/**
+ * Update the viewport transformation matrix. Depends on:
+ * - viewport pos/size
+ * - depthrange
+ * - window pos/size or FBO size
+ */
+static void update_viewport( struct st_context *st )
+{
+ GLcontext *ctx = st->ctx;
+ const GLframebuffer *DrawBuffer = ctx->DrawBuffer;
+ GLfloat yScale = 1.0;
+ GLfloat yBias = 0.0;
+
+ /* _NEW_BUFFERS
+ */
+ if (DrawBuffer) {
+
+#if 0
+ if (DrawBuffer->Name) {
+ /* User created FBO */
+ struct st_renderbuffer *irb
+ = st_renderbuffer(DrawBuffer->_ColorDrawBuffers[0][0]);
+ if (irb && !irb->RenderToTexture) {
+ /* y=0=top */
+ yScale = -1.0;
+ yBias = irb->Base.Height;
+ }
+ else {
+ /* y=0=bottom */
+ yScale = 1.0;
+ yBias = 0.0;
+ }
+ }
+ else
+ {
+ /* window buffer, y=0=top */
+ yScale = -1.0;
+ yBias = DrawBuffer->Height;
+ }
+#endif
+ }
+
+ {
+ /* _NEW_VIEWPORT
+ */
+ GLfloat x = ctx->Viewport.X;
+ GLfloat y = ctx->Viewport.Y;
+ GLfloat z = ctx->Viewport.Near;
+ GLfloat half_width = ctx->Viewport.Width / 2.0;
+ GLfloat half_height = ctx->Viewport.Height / 2.0;
+ GLfloat half_depth = (ctx->Viewport.Far - ctx->Viewport.Near) / 2.0;
+
+ struct softpipe_viewport vp;
+
+ vp.scale[0] = half_width;
+ vp.scale[1] = half_height * yScale;
+ vp.scale[2] = half_depth;
+ vp.scale[3] = 1.0;
+
+ vp.translate[0] = (half_width + x);
+ vp.translate[1] = (half_height + y) * yScale + yBias;
+ vp.translate[2] = (half_depth + z);
+ vp.translate[3] = 0.0;
+
+ if (memcmp(&vp, &st->state.viewport, sizeof(vp)) != 0) {
+ st->state.viewport = vp;
+ st->softpipe->set_viewport(st->softpipe, &vp);
+ }
+ }
+}
+
+
+const struct st_tracked_state st_update_viewport = {
+ .dirty = {
+ .mesa = _NEW_BUFFERS | _NEW_VIEWPORT,
+ .st = 0,
+ },
+ .update = update_viewport
+};
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
new file mode 100644
index 00000000000..67a589ca8d3
--- /dev/null
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -0,0 +1,165 @@
+/**************************************************************************
+ *
+ * Copyright 2003 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 <[email protected]>
+ */
+
+#include "st_context.h"
+#include "st_program.h"
+
+#include "glheader.h"
+#include "macros.h"
+#include "enums.h"
+#include "prog_instruction.h"
+#include "prog_parameter.h"
+#include "program.h"
+#include "programopt.h"
+#include "tnl/tnl.h"
+
+
+static void st_bind_program( GLcontext *ctx,
+ GLenum target,
+ struct gl_program *prog )
+{
+ struct st_context *st = st_context(ctx);
+
+ switch (target) {
+ case GL_VERTEX_PROGRAM_ARB:
+ break;
+ case GL_FRAGMENT_PROGRAM_ARB:
+ st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
+ break;
+ }
+}
+
+static struct gl_program *st_new_program( GLcontext *ctx,
+ GLenum target,
+ GLuint id )
+{
+ struct st_context *st = st_context(ctx);
+
+ switch (target) {
+ case GL_VERTEX_PROGRAM_ARB:
+ return _mesa_init_vertex_program(ctx,
+ CALLOC_STRUCT(gl_vertex_program),
+ target,
+ id);
+
+ case GL_FRAGMENT_PROGRAM_ARB: {
+ struct st_fragment_program *prog = CALLOC_STRUCT(st_fragment_program);
+
+ prog->id = st->program_id++;
+
+ return _mesa_init_fragment_program( ctx,
+ &prog->Base,
+ target,
+ id );
+ }
+
+ default:
+ return _mesa_new_program(ctx, target, id);
+ }
+}
+
+static void st_delete_program( GLcontext *ctx,
+ struct gl_program *prog )
+{
+ _mesa_delete_program( ctx, prog );
+}
+
+
+static GLboolean st_is_program_native( GLcontext *ctx,
+ GLenum target,
+ struct gl_program *prog )
+{
+ return GL_TRUE;
+}
+
+static void st_program_string_notify( GLcontext *ctx,
+ GLenum target,
+ struct gl_program *prog )
+{
+ if (target == GL_FRAGMENT_PROGRAM_ARB) {
+ struct st_context *st = st_context(ctx);
+
+ if (prog == &st->ctx->FragmentProgram._Current->Base)
+ {
+ struct st_fragment_program *p =
+ (struct st_fragment_program *) prog;
+
+ st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
+
+ p->id = st->program_id++;
+#if 0
+ p->param_state = p->Base.Base.Parameters->StateFlags;
+ p->translated = 0;
+#endif
+
+ /* Gack! do this in the compiler:
+ */
+ if (p->Base.FogOption) {
+ /* add extra instructions to do fog, then turn off FogOption field */
+ _mesa_append_fog_code(ctx, &p->Base);
+ p->Base.FogOption = GL_NONE;
+ }
+ }
+ }
+ else if (target == GL_VERTEX_PROGRAM_ARB) {
+
+ /* Also tell tnl about it:
+ */
+ _tnl_program_string(ctx, target, prog);
+ }
+}
+
+
+
+void st_init_cb_program( struct st_context *st )
+{
+ struct dd_function_table *functions = &st->ctx->Driver;
+
+ /* Need these flags:
+ */
+ st->ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
+ st->ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE;
+
+
+ assert(functions->ProgramStringNotify == _tnl_program_string);
+ functions->BindProgram = st_bind_program;
+ functions->NewProgram = st_new_program;
+ functions->DeleteProgram = st_delete_program;
+ functions->IsProgramNative = st_is_program_native;
+ functions->ProgramStringNotify = st_program_string_notify;
+}
+
+
+void st_destroy_cb_program( struct st_context *st )
+{
+}
+
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
new file mode 100644
index 00000000000..8a06dd88df7
--- /dev/null
+++ b/src/mesa/state_tracker/st_context.c
@@ -0,0 +1,76 @@
+/**************************************************************************
+ *
+ * Copyright 2003 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.
+ *
+ **************************************************************************/
+
+#include "imports.h"
+#include "st_public.h"
+#include "st_context.h"
+#include "st_atom.h"
+#include "st_draw.h"
+#include "st_program.h"
+#include "softpipe/sp_context.h"
+
+void st_invalidate_state(GLcontext * ctx, GLuint new_state)
+{
+ struct st_context *st = st_context(ctx);
+
+ st->dirty.mesa |= new_state;
+ st->dirty.st |= ST_NEW_MESA;
+}
+
+
+struct st_context *st_create_context( GLcontext *ctx,
+ struct softpipe_context *softpipe )
+{
+ struct st_context *st = CALLOC_STRUCT( st_context );
+
+ ctx->st = st;
+
+ st->ctx = ctx;
+ st->softpipe = softpipe;
+
+ st->dirty.mesa = ~0;
+ st->dirty.st = ~0;
+
+ st_init_atoms( st );
+ st_init_draw( st );
+ st_init_cb_program( st );
+
+ return st;
+}
+
+
+void st_destroy_context( struct st_context *st )
+{
+ st_destroy_atoms( st );
+ st_destroy_draw( st );
+ st_destroy_cb_program( st );
+ st->softpipe->destroy( st->softpipe );
+ FREE( st );
+}
+
+
+
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
new file mode 100644
index 00000000000..317d3773718
--- /dev/null
+++ b/src/mesa/state_tracker/st_context.h
@@ -0,0 +1,111 @@
+/**************************************************************************
+ *
+ * Copyright 2003 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.
+ *
+ **************************************************************************/
+
+#ifndef ST_CONTEXT_H
+#define ST_CONTEXT_H
+
+#include "mtypes.h"
+#include "softpipe/sp_state.h"
+
+
+struct st_context;
+struct st_region;
+struct st_texture_object;
+struct st_texture_image;
+struct st_fragment_program;
+
+#define ST_NEW_MESA 0x1 /* Mesa state has changed */
+#define ST_NEW_FRAGMENT_PROGRAM 0x2
+
+struct st_state_flags {
+ GLuint mesa;
+ GLuint st;
+};
+
+struct st_tracked_state {
+ struct st_state_flags dirty;
+ void (*update)( struct st_context *st );
+};
+
+
+
+
+struct st_context
+{
+ GLcontext *ctx;
+
+ struct softpipe_context *softpipe;
+
+ /* Eventually will use a cache to feed the softpipe with
+ * create/bind/delete calls to constant state objects. Not yet
+ * though, we just shove random objects across the interface.
+ */
+ struct {
+ struct softpipe_viewport viewport;
+ struct softpipe_setup_state setup;
+ struct softpipe_fs_state fs;
+ struct softpipe_blend_state blend;
+ struct softpipe_surface cbuf;
+ struct softpipe_clip_state clip;
+ struct softpipe_depth_state depth;
+ struct softpipe_scissor_rect scissor;
+ struct softpipe_poly_stipple poly_stipple;
+ struct softpipe_stencil_state stencil;
+ } state;
+
+ struct {
+ struct st_tracked_state tracked_state;
+ } constants;
+
+ struct {
+ struct gl_fragment_program *fragment_program;
+ } cb;
+
+ /* State to be validated:
+ */
+ struct st_tracked_state **atoms;
+ GLuint nr_atoms;
+
+ struct st_state_flags dirty;
+
+ /* Counter to track program string changes:
+ */
+ GLuint program_id;
+
+ GLfloat polygon_offset_scale; /* ?? */
+};
+
+
+/* Need this so that we can implement Mesa callbacks in this module.
+ */
+static INLINE struct st_context *st_context(GLcontext *ctx)
+{
+ return ctx->st;
+}
+
+
+#endif
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
new file mode 100644
index 00000000000..12646402eec
--- /dev/null
+++ b/src/mesa/state_tracker/st_draw.c
@@ -0,0 +1,107 @@
+/**************************************************************************
+ *
+ * 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 <[email protected]>
+ */
+
+#include "imports.h"
+
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+#include "st_context.h"
+#include "st_atom.h"
+#include "st_draw.h"
+#include "softpipe/sp_context.h"
+
+/*
+ * TNL stage which feedsinto the above.
+ *
+ * XXX: this needs to go into each driver using this code, because we
+ * cannot make the leap from ctx->draw_context in this file. The
+ * driver needs to customize tnl anyway, so this isn't a big deal.
+ */
+static GLboolean draw( GLcontext * ctx, struct tnl_pipeline_stage *stage )
+{
+ struct st_context *st = st_context(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ /* Validate driver and softpipe state:
+ */
+ st_validate_state( st );
+
+ /* Call into the new draw code to handle the VB:
+ */
+ st->softpipe->draw_vb( st->softpipe, VB );
+
+ /* Finished
+ */
+ return GL_FALSE;
+}
+
+const struct tnl_pipeline_stage st_draw = {
+ "check state and draw",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ draw
+};
+
+static const struct tnl_pipeline_stage *intel_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_vertex_cull_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ &_tnl_point_attenuation_stage,
+ &_tnl_vertex_program_stage,
+ &st_draw, /* ADD: escape to softpipe */
+ 0,
+};
+
+/* This is all a hack to keep using tnl until we have vertex programs
+ * up and running.
+ */
+void st_init_draw( struct st_context *st )
+{
+ GLcontext *ctx = st->ctx;
+
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, intel_pipeline );
+}
+
+
+void st_destroy_draw( struct st_context *st )
+{
+ /* Nothing to do.
+ */
+}
diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h
new file mode 100644
index 00000000000..f51059706ad
--- /dev/null
+++ b/src/mesa/state_tracker/st_draw.h
@@ -0,0 +1,40 @@
+/**************************************************************************
+ *
+ * Copyright 2003 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 <[email protected]>
+ */
+
+
+#ifndef ST_DRAW_H
+#define ST_DRAW_H
+
+void st_init_draw( struct st_context *st );
+void st_destroy_draw( struct st_context *st );
+
+#endif
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
new file mode 100644
index 00000000000..a47059d7a69
--- /dev/null
+++ b/src/mesa/state_tracker/st_program.h
@@ -0,0 +1,68 @@
+/**************************************************************************
+ *
+ * Copyright 2003 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 <[email protected]>
+ */
+
+
+#ifndef ST_PROGRAM_H
+#define ST_PROGRAM_H
+
+struct st_fragment_program
+{
+ struct gl_fragment_program Base;
+ GLboolean error; /* If program is malformed for any reason. */
+
+ GLuint id; /* String id, for tracking
+ * ProgramStringNotify changes.
+ */
+
+#if 0
+ GLfloat (*cbuffer)[4];
+ GLuint nr_constants;
+
+ /* Translate all the parameters, etc, into a constant buffer which
+ * we update on state changes.
+ */
+ struct
+ {
+ GLuint reg; /* Constant idx */
+ const GLfloat *values; /* Pointer to tracked values */
+ } *param;
+ GLuint nr_params;
+
+ GLuint param_state;
+#endif
+};
+
+
+void st_init_cb_program( struct st_context *st );
+void st_destroy_cb_program( struct st_context *st );
+
+#endif
diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h
new file mode 100644
index 00000000000..8241dbd52d1
--- /dev/null
+++ b/src/mesa/state_tracker/st_public.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.
+ *
+ **************************************************************************/
+
+#ifndef ST_PUBLIC_H
+#define ST_PUBLIC_H
+
+#include "mtypes.h"
+
+struct st_context;
+struct softpipe_context;
+
+struct st_context *st_create_context( GLcontext *ctx,
+ struct softpipe_context *softpipe);
+
+void st_destroy_context( struct st_context *st );
+
+void st_invalidate_state(GLcontext * ctx, GLuint new_state);
+
+#endif