summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-07-24 09:17:59 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-07-24 09:17:59 -0600
commit5b737b7df21b418c71f71af987a20c495b1133f8 (patch)
tree6aa3a54cb5d3c43f789488147f3b61b56e09c5fc /src/mesa/state_tracker
parentf0636d9653d142bdf71475d2d2066f5c7c436978 (diff)
parent98eaf5503d0d7c4f18fab6910a08aba7a3d08639 (diff)
Merge branch 'softpipe_0_1_branch' of git+ssh://brianp@git.freedesktop.org/git/mesa/mesa into softpipe_0_1_branch
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom.c1
-rw-r--r--src/mesa/state_tracker/st_atom.h1
-rw-r--r--src/mesa/state_tracker/st_atom_fs.c27
-rw-r--r--src/mesa/state_tracker/st_atom_vs.c49
-rw-r--r--src/mesa/state_tracker/st_cb_program.c59
-rw-r--r--src/mesa/state_tracker/st_context.h1
-rw-r--r--src/mesa/state_tracker/st_program.h38
7 files changed, 140 insertions, 36 deletions
diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c
index dfebfb4768..85c99bc182 100644
--- a/src/mesa/state_tracker/st_atom.c
+++ b/src/mesa/state_tracker/st_atom.c
@@ -46,6 +46,7 @@ static const struct st_tracked_state *atoms[] =
&st_update_clear_color,
&st_update_depth,
&st_update_clip,
+ &st_update_vs,
&st_update_fs,
&st_update_setup,
&st_update_polygon_stipple,
diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h
index a56483ac39..1b70e27933 100644
--- a/src/mesa/state_tracker/st_atom.h
+++ b/src/mesa/state_tracker/st_atom.h
@@ -49,6 +49,7 @@ 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_vs;
const struct st_tracked_state st_update_setup;
const struct st_tracked_state st_update_polygon_stipple;
const struct st_tracked_state st_update_viewport;
diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c
index 9c6bc1ce2a..6fa4f53c73 100644
--- a/src/mesa/state_tracker/st_atom_fs.c
+++ b/src/mesa/state_tracker/st_atom_fs.c
@@ -32,15 +32,38 @@
#include "st_context.h"
#include "pipe/p_context.h"
#include "st_atom.h"
+#include "st_program.h"
+#include "pipe/tgsi/mesa/mesa_to_tgsi.h"
+#include "pipe/tgsi/core/tgsi_dump.h"
+
+static void compile_fs( struct st_context *st,
+ struct st_fragment_program *fs )
+{
+ /* XXX: fix static allocation of tokens:
+ */
+ tgsi_mesa_compile_fp_program( &fs->Base, fs->tokens, ST_FP_MAX_TOKENS );
+
+ tgsi_dump( fs->tokens, TGSI_DUMP_VERBOSE );
+}
static void update_fs( struct st_context *st )
{
struct pipe_fs_state fs;
+ struct st_fragment_program *fp = st_fragment_program(st->ctx->FragmentProgram._Current);
+
+ memset( &fs, 0, sizeof(fs) );
- fs.fp = st->ctx->FragmentProgram._Current;
+ if (fp->dirty)
+ compile_fs( st, fp );
+
+ fs.inputs_read = fp->Base.Base.InputsRead;
+ fs.tokens = &fp->tokens[0];
- if (memcmp(&fs, &st->state.fs, sizeof(fs)) != 0) {
+ if (memcmp(&fs, &st->state.fs, sizeof(fs)) != 0 ||
+ fp->dirty)
+ {
+ fp->dirty = 0;
st->state.fs = fs;
st->pipe->set_fs_state(st->pipe, &fs);
}
diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c
new file mode 100644
index 0000000000..6a26bfdd19
--- /dev/null
+++ b/src/mesa/state_tracker/st_atom_vs.c
@@ -0,0 +1,49 @@
+/**************************************************************************
+ *
+ * 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 <keith@tungstengraphics.com>
+ */
+
+#include "st_context.h"
+#include "pipe/p_context.h"
+#include "st_atom.h"
+
+
+
+static void update_vs( struct st_context *st )
+{
+}
+
+
+const struct st_tracked_state st_update_vs = {
+ .dirty = {
+ .mesa = 0,
+ .st = ST_NEW_VERTEX_PROGRAM,
+ },
+ .update = update_vs
+};
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 327b627722..18061ca69c 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -52,6 +52,7 @@ static void st_bind_program( GLcontext *ctx,
switch (target) {
case GL_VERTEX_PROGRAM_ARB:
+ st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
break;
case GL_FRAGMENT_PROGRAM_ARB:
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
@@ -66,16 +67,23 @@ static struct gl_program *st_new_program( GLcontext *ctx,
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_VERTEX_PROGRAM_ARB: {
+ struct st_vertex_program *prog = CALLOC_STRUCT(st_vertex_program);
+
+ prog->id = st->program_id++;
+ prog->dirty = 1;
+
+ return _mesa_init_vertex_program( ctx,
+ &prog->Base,
+ target,
+ id );
+ }
case GL_FRAGMENT_PROGRAM_ARB: {
struct st_fragment_program *prog = CALLOC_STRUCT(st_fragment_program);
prog->id = st->program_id++;
+ prog->dirty = 1;
return _mesa_init_fragment_program( ctx,
&prog->Base,
@@ -106,40 +114,25 @@ 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);
+ struct st_context *st = st_context(ctx);
- if (prog == &st->ctx->FragmentProgram._Current->Base)
- {
- struct st_fragment_program *p =
- (struct st_fragment_program *) prog;
+ if (target == GL_FRAGMENT_PROGRAM_ARB) {
+ struct st_fragment_program *p = (struct st_fragment_program *)prog;
+ if (prog == &ctx->FragmentProgram._Current->Base)
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;
- }
-
- /* XXX: Not hooked-up yet. */
- {
- struct tgsi_token tokens[1024];
-
- tgsi_mesa_compile_fp_program( prog, tokens, 1024 );
- tgsi_dump( tokens, TGSI_DUMP_VERBOSE );
- }
- }
+ p->id = st->program_id++;
+ p->param_state = p->Base.Base.Parameters->StateFlags;
}
else if (target == GL_VERTEX_PROGRAM_ARB) {
+ struct st_vertex_program *p = (struct st_vertex_program *)prog;
+
+ if (prog == &ctx->VertexProgram._Current->Base)
+ st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
+
+ p->id = st->program_id++;
+ p->param_state = p->Base.Base.Parameters->StateFlags;
/* Also tell tnl about it:
*/
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index c1d868604c..ef3cdb3b09 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -40,6 +40,7 @@ struct st_fragment_program;
#define ST_NEW_MESA 0x1 /* Mesa state has changed */
#define ST_NEW_FRAGMENT_PROGRAM 0x2
+#define ST_NEW_VERTEX_PROGRAM 0x4
struct st_state_flags {
GLuint mesa;
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index a47059d7a6..b28887946d 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -34,6 +34,12 @@
#ifndef ST_PROGRAM_H
#define ST_PROGRAM_H
+#include "mtypes.h"
+#include "pipe/tgsi/core/tgsi_token.h"
+
+#define ST_FP_MAX_TOKENS 1024
+
+
struct st_fragment_program
{
struct gl_fragment_program Base;
@@ -43,6 +49,11 @@ struct st_fragment_program
* ProgramStringNotify changes.
*/
+
+ struct tgsi_token tokens[ST_FP_MAX_TOKENS];
+ GLboolean dirty;
+
+
#if 0
GLfloat (*cbuffer)[4];
GLuint nr_constants;
@@ -56,13 +67,38 @@ struct st_fragment_program
const GLfloat *values; /* Pointer to tracked values */
} *param;
GLuint nr_params;
+#endif
GLuint param_state;
-#endif
};
+struct st_vertex_program
+{
+ struct gl_vertex_program Base;
+ GLboolean error; /* If program is malformed for any reason. */
+
+ GLuint id; /* String id, for tracking
+ * ProgramStringNotify changes.
+ */
+
+ GLboolean dirty;
+ GLuint param_state;
+};
+
void st_init_cb_program( struct st_context *st );
void st_destroy_cb_program( struct st_context *st );
+static inline struct st_fragment_program *
+st_fragment_program( struct gl_fragment_program *fp )
+{
+ return (struct st_fragment_program *)fp;
+}
+
+static inline struct st_vertex_program *
+st_vertex_program( struct gl_vertex_program *vp )
+{
+ return (struct st_vertex_program *)vp;
+}
+
#endif