Only use the active part of the state key and ignore all the texture units
beyond Const.MaxTextureUnits. For instance on my i915, this reduces
sizeof(struct state_key) from 196 to 100 bytes.
---
 src/mesa/main/texenvprogram.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index 3851937..2dee25e 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -363,7 +363,7 @@ static GLbitfield get_fp_input_mask( GLcontext *ctx )
  * Examine current texture environment state and generate a unique
  * key to identify it.
  */
-static void make_state_key( GLcontext *ctx,  struct state_key *key )
+static GLuint make_state_key( GLcontext *ctx,  struct state_key *key )
 {
    GLuint i, j;
    GLbitfield inputs_referenced = FRAG_BIT_COL0;
@@ -438,6 +438,8 @@ static void make_state_key( GLcontext *ctx,  struct 
state_key *key )
    }
 
    key->inputs_available = (inputs_available & inputs_referenced);
+
+   return sizeof (*key) - sizeof (key->unit) + ctx->Const.MaxTextureUnits * 
sizeof(key->unit[0]);
 }
 
 /**
@@ -1497,12 +1499,13 @@ _mesa_get_fixed_func_fragment_program(GLcontext *ctx)
 {
    struct gl_fragment_program *prog;
    struct state_key key;
+   GLuint size;
        
-   make_state_key(ctx, &key);
+   size = make_state_key(ctx, &key);
       
    prog = (struct gl_fragment_program *)
       _mesa_search_program_cache(ctx->FragmentProgram.Cache,
-                                 &key, sizeof(key));
+                                 &key, size);
 
    if (!prog) {
       prog = (struct gl_fragment_program *) 
@@ -1511,7 +1514,7 @@ _mesa_get_fixed_func_fragment_program(GLcontext *ctx)
       create_new_program(ctx, &key, prog);
 
       _mesa_program_cache_insert(ctx, ctx->FragmentProgram.Cache,
-                                 &key, sizeof(key), &prog->Base);
+                                 &key, size, &prog->Base);
    }
 
    return prog;
-- 
1.6.3.3


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to