summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/tnl/t_vp_build.c81
-rw-r--r--src/mesa/tnl/t_vp_build.h11
2 files changed, 57 insertions, 35 deletions
diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c
index dc2d5e0065a..86c6ccc1c0e 100644
--- a/src/mesa/tnl/t_vp_build.c
+++ b/src/mesa/tnl/t_vp_build.c
@@ -1534,49 +1534,66 @@ static GLuint hash_key( struct state_key *key )
return hash;
}
-void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
+
+/**
+ * Return a vertex program which implements the current fixed-function
+ * transform/lighting/texgen operations.
+ * XXX move this into core mesa (main/)
+ */
+struct gl_vertex_program *
+_mesa_get_fixed_func_vertex_program(GLcontext *ctx)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct gl_vertex_program *prog;
struct state_key *key;
GLuint hash;
- const struct gl_vertex_program *prev = ctx->VertexProgram._Current;
- if (!ctx->VertexProgram._Current ||
- ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) {
- /* Grab all the relevent state and put it in a single structure:
- */
- key = make_state_key(ctx);
- hash = hash_key(key);
+ /* Grab all the relevent state and put it in a single structure:
+ */
+ key = make_state_key(ctx);
+ hash = hash_key(key);
- /* Look for an already-prepared program for this state:
- */
- ctx->VertexProgram._TnlProgram = (struct gl_vertex_program *)
- search_cache( tnl->vp_cache, hash, key, sizeof(*key) );
+ /* Look for an already-prepared program for this state:
+ */
+ prog = (struct gl_vertex_program *)
+ search_cache( tnl->vp_cache, hash, key, sizeof(*key) );
- /* OK, we'll have to build a new one:
- */
- if (!ctx->VertexProgram._TnlProgram) {
- if (0)
- _mesa_printf("Build new TNL program\n");
+ if (!prog) {
+ /* OK, we'll have to build a new one */
+ if (0)
+ _mesa_printf("Build new TNL program\n");
- ctx->VertexProgram._TnlProgram = (struct gl_vertex_program *)
- ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
+ prog = (struct gl_vertex_program *)
+ ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
- create_new_program( key, ctx->VertexProgram._TnlProgram,
- ctx->Const.VertexProgram.MaxTemps );
+ create_new_program( key, prog,
+ ctx->Const.VertexProgram.MaxTemps );
- if (ctx->Driver.ProgramStringNotify)
- ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB,
- &ctx->VertexProgram._TnlProgram->Base );
+#if 0
+ if (ctx->Driver.ProgramStringNotify)
+ ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB,
+ &prog->Base );
+#endif
+ cache_item(tnl->vp_cache, hash, key, prog);
+ }
+ else {
+ /* use cached program */
+ _mesa_free(key);
+ }
- cache_item(tnl->vp_cache, hash, key, ctx->VertexProgram._TnlProgram );
- }
- else {
- FREE(key);
- if (0)
- _mesa_printf("Found existing TNL program for key %x\n", hash);
- }
- ctx->VertexProgram._Current = ctx->VertexProgram._TnlProgram;
+ return prog;
+}
+
+
+void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
+{
+ const struct gl_vertex_program *prev = ctx->VertexProgram._Current;
+
+ if (!ctx->VertexProgram._Current ||
+ ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) {
+ ctx->VertexProgram._Current
+ = ctx->VertexProgram._TnlProgram
+ = _mesa_get_fixed_func_vertex_program(ctx);
}
/* Tell the driver about the change. Could define a new target for
diff --git a/src/mesa/tnl/t_vp_build.h b/src/mesa/tnl/t_vp_build.h
index 5e22fcf8c40..034701d8c46 100644
--- a/src/mesa/tnl/t_vp_build.h
+++ b/src/mesa/tnl/t_vp_build.h
@@ -17,24 +17,29 @@
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * TUNGSTEN GRAPHICS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * TUNGSTEN GRAPHICS 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 _T_ARB_BUILD_H
-#define _T_ARB_BUILD_H
+#ifndef T_VP_BUILD_H
+#define T_VP_BUILD_H
#include "mtypes.h"
#define TNL_FIXED_FUNCTION_STATE_FLAGS (_NEW_PROGRAM | \
_NEW_LIGHT | \
_NEW_TEXTURE | \
+ _NEW_TEXTURE_MATRIX | \
_NEW_TRANSFORM | \
_NEW_FOG | \
_NEW_POINT)
+extern struct gl_vertex_program *
+_mesa_get_fixed_func_vertex_program(GLcontext *ctx);
+
extern void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx );
extern void _tnl_ProgramCacheInit( GLcontext *ctx );