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.
This commit is contained in:
Keith Whitwell
2005-11-01 17:25:49 +00:00
parent 6aa6d440d9
commit c3626a91ce
7 changed files with 156 additions and 100 deletions

View File

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