summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2005-11-01 17:25:49 +0000
committerKeith Whitwell <[email protected]>2005-11-01 17:25:49 +0000
commitc3626a91cee5034528f3f92c802a8e5947ea5f92 (patch)
treefd16d99ef237e31067e9f7a74bc2cee471bcc7e9 /src/mesa/main
parent6aa6d440d9d312cb984020e746aa80c3dbf6ea2c (diff)
Several fp and vp tweaks:
- Renumber VERT_RESULT_* values so that they match the numbers of the corresponding FRAG_ATTRIB_ values. - Add ctx->VertexProgram._Current and FragmentProgram._Current values which point to either the current client-supplied program if enabled, or otherwise to the current mesa-internal program. Thus this program is always the correct one for the current state, providing that the mesa flags to turn on automatic generation are enabled. - Add callbacks to ctx->Driver.BindProgram() in texenvprogram.c and t_vp_build.c so that the driver knows when the generated program changes. This is cleaner than trying to code all the possible _NEW_* flags into the driver, and more precise as well. - Add a UsesKill flag to identify fragment programs with that instruction, as these can require special treatment. - Move the FRAG_OUTPUT values to mtypes.h, near to similar defn's.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/mtypes.h43
-rw-r--r--src/mesa/main/texenvprogram.c49
2 files changed, 58 insertions, 34 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index aadd0a7e7fb..d77759df252 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -195,18 +195,18 @@ enum
#define VERT_RESULT_HPOS 0
#define VERT_RESULT_COL0 1
#define VERT_RESULT_COL1 2
-#define VERT_RESULT_BFC0 3
-#define VERT_RESULT_BFC1 4
-#define VERT_RESULT_FOGC 5
-#define VERT_RESULT_PSIZ 6
-#define VERT_RESULT_TEX0 7
-#define VERT_RESULT_TEX1 8
-#define VERT_RESULT_TEX2 9
-#define VERT_RESULT_TEX3 10
-#define VERT_RESULT_TEX4 11
-#define VERT_RESULT_TEX5 12
-#define VERT_RESULT_TEX6 13
-#define VERT_RESULT_TEX7 14
+#define VERT_RESULT_FOGC 3
+#define VERT_RESULT_TEX0 4
+#define VERT_RESULT_TEX1 5
+#define VERT_RESULT_TEX2 6
+#define VERT_RESULT_TEX3 7
+#define VERT_RESULT_TEX4 8
+#define VERT_RESULT_TEX5 9
+#define VERT_RESULT_TEX6 10
+#define VERT_RESULT_TEX7 11
+#define VERT_RESULT_PSIZ 12
+#define VERT_RESULT_BFC0 13
+#define VERT_RESULT_BFC1 14
#define VERT_RESULT_MAX 15
@@ -226,7 +226,9 @@ enum
FRAG_ATTRIB_TEX4 = 8,
FRAG_ATTRIB_TEX5 = 9,
FRAG_ATTRIB_TEX6 = 10,
- FRAG_ATTRIB_TEX7 = 11
+ FRAG_ATTRIB_TEX7 = 11,
+
+ FRAG_ATTRIB_MAX = 12
};
/*
@@ -257,6 +259,14 @@ enum
/*@}*/
+/* Fragment program results
+ */
+#define FRAG_OUTPUT_COLR 0
+#define FRAG_OUTPUT_COLH 1
+#define FRAG_OUTPUT_DEPR 2
+#define FRAG_OUTPUT_MAX 3
+
+
/**
* Indexes for all renderbuffers
*/
@@ -1791,6 +1801,7 @@ struct fragment_program
GLuint NumNativeTexIndirections;
GLenum FogOption;
struct program_parameter_list *Parameters; /**< array [NumParameters] */
+ GLboolean UsesKill;
#ifdef USE_TCC
char c_str[4096]; /* experimental... */
@@ -1835,6 +1846,9 @@ struct gl_vertex_program_state
GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */
GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */
struct vertex_program *Current; /**< ptr to currently bound program */
+ struct vertex_program *_Current; /**< ptr to currently bound
+ program, including internal
+ (t_vp_build.c) programs */
GLenum TrackMatrix[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
GLenum TrackMatrixTransform[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
@@ -1865,7 +1879,8 @@ struct gl_fragment_program_state
GLboolean _Enabled; /* Really enabled? */
GLboolean _Active; /* Really really enabled? */
struct fragment_program *Current; /* ptr to currently bound program */
- struct fragment_program *_Current; /* ptr to currently active program */
+ struct fragment_program *_Current; /* ptr to currently active program
+ (including internal programs) */
struct fp_machine Machine; /* machine state */
GLfloat Parameters[MAX_NV_FRAGMENT_PROGRAM_PARAMS][4]; /* Env params */
diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index 18d704ce1b6..43dda28f263 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -1130,32 +1130,41 @@ void _mesa_UpdateTexEnvProgram( GLcontext *ctx )
{
struct state_key *key;
GLuint hash;
+ struct fragment_program *prev = ctx->FragmentProgram._Current;
- if (ctx->FragmentProgram._Enabled)
- return;
-
- key = make_state_key(ctx);
- hash = hash_key(key);
-
- ctx->FragmentProgram._Current = ctx->_TexEnvProgram =
- (struct fragment_program *)
- search_cache(ctx->Texture.env_fp_cache, hash, key, sizeof(*key));
+ if (!ctx->FragmentProgram._Enabled) {
+ key = make_state_key(ctx);
+ hash = hash_key(key);
+
+ ctx->FragmentProgram._Current = ctx->_TexEnvProgram =
+ (struct fragment_program *)
+ search_cache(ctx->Texture.env_fp_cache, hash, key, sizeof(*key));
- if (!ctx->_TexEnvProgram) {
- if (0) _mesa_printf("Building new texenv proggy for key %x\n", hash);
+ if (!ctx->_TexEnvProgram) {
+ if (1) _mesa_printf("Building new texenv proggy for key %x\n", hash);
- ctx->FragmentProgram._Current = ctx->_TexEnvProgram =
- (struct fragment_program *)
- ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
+ ctx->FragmentProgram._Current = ctx->_TexEnvProgram =
+ (struct fragment_program *)
+ ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
- create_new_program(key, ctx, ctx->_TexEnvProgram);
+ create_new_program(key, ctx, ctx->_TexEnvProgram);
- cache_item(&ctx->Texture.env_fp_cache, hash, key, ctx->_TexEnvProgram);
- } else {
- FREE(key);
- if (0) _mesa_printf("Found existing texenv program for key %x\n", hash);
+ cache_item(&ctx->Texture.env_fp_cache, hash, key, ctx->_TexEnvProgram);
+ } else {
+ FREE(key);
+ if (1) _mesa_printf("Found existing texenv program for key %x\n", hash);
+ }
+ }
+ else {
+ ctx->FragmentProgram._Current = ctx->FragmentProgram.Current;
}
-
+
+ /* Tell the driver about the change. Could define a new target for
+ * this?
+ */
+ if (ctx->FragmentProgram._Current != prev)
+ ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, (struct program *)
+ ctx->FragmentProgram._Current);
}
void _mesa_TexEnvProgramCacheDestroy( GLcontext *ctx )