From: Brian Date: Mon, 29 Oct 2007 17:23:02 +0000 (-0600) Subject: Refactor _mesa_UpdateTexEnvProgram() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=83ce6c51d7189094cf2a13fdcc0882a051a3bd41;p=mesa.git Refactor _mesa_UpdateTexEnvProgram() Will be replaced by _mesa_get_fixed_func_fragment_program(). --- diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 21a290402f5..d8f3314c70a 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -1234,6 +1234,39 @@ static GLuint hash_key( const struct state_key *key ) } +/** + * Return a fragment program which implements the current + * fixed-function texture, fog and color-sum operations. + */ +struct gl_fragment_program * +_mesa_get_fixed_func_fragment_program(GLcontext *ctx) +{ + struct gl_fragment_program *prog; + struct state_key key; + GLuint hash; + + make_state_key(ctx, &key); + hash = hash_key(&key); + + prog = search_cache(&ctx->Texture.env_fp_cache, hash, &key, sizeof(key)); + + if (!prog) { + if (0) + _mesa_printf("Building new texenv proggy for key %x\n", hash); + + prog = (struct gl_fragment_program *) + ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); + + create_new_program(ctx, &key, prog); + + cache_item(&ctx->Texture.env_fp_cache, hash, &key, prog); + } + + return prog; +} + + + /** * If _MaintainTexEnvProgram is set we'll generate a fragment program that * implements the current texture env/combine mode. @@ -1242,8 +1275,6 @@ static GLuint hash_key( const struct state_key *key ) void _mesa_UpdateTexEnvProgram( GLcontext *ctx ) { - struct state_key key; - GLuint hash; const struct gl_fragment_program *prev = ctx->FragmentProgram._Current; ASSERT(ctx->FragmentProgram._MaintainTexEnvProgram); @@ -1252,38 +1283,11 @@ _mesa_UpdateTexEnvProgram( GLcontext *ctx ) if (!ctx->FragmentProgram._Enabled && (!ctx->Shader.CurrentProgram || !ctx->Shader.CurrentProgram->FragmentProgram) ) { - make_state_key(ctx, &key); - hash = hash_key(&key); - - ctx->FragmentProgram._Current = - ctx->FragmentProgram._TexEnvProgram = - search_cache(&ctx->Texture.env_fp_cache, hash, &key, sizeof(key)); - - if (!ctx->FragmentProgram._TexEnvProgram) { - if (0) - _mesa_printf("Building new texenv proggy for key %x\n", hash); - /* create new tex env program */ - ctx->FragmentProgram._Current = - ctx->FragmentProgram._TexEnvProgram = - (struct gl_fragment_program *) - ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); - - create_new_program(ctx, &key, ctx->FragmentProgram._TexEnvProgram); - - cache_item(&ctx->Texture.env_fp_cache, hash, &key, - ctx->FragmentProgram._TexEnvProgram); - } - else { - if (0) - _mesa_printf("Found existing texenv program for key %x\n", hash); - } + ctx->FragmentProgram._Current + = ctx->FragmentProgram._TexEnvProgram + = _mesa_get_fixed_func_fragment_program(ctx); } -#if 0 - else { - ctx->FragmentProgram._Current = ctx->FragmentProgram.Current; - } -#endif /* Tell the driver about the change. Could define a new target for * this? diff --git a/src/mesa/main/texenvprogram.h b/src/mesa/main/texenvprogram.h index 6f017767c82..ac73910cb52 100644 --- a/src/mesa/main/texenvprogram.h +++ b/src/mesa/main/texenvprogram.h @@ -34,6 +34,9 @@ #include "mtypes.h" +extern struct gl_fragment_program * +_mesa_get_fixed_func_fragment_program(GLcontext *ctx); + extern void _mesa_UpdateTexEnvProgram( GLcontext *ctx ); extern void _mesa_TexEnvProgramCacheInit( GLcontext *ctx ); extern void _mesa_TexEnvProgramCacheDestroy( GLcontext *ctx );