i965: Shorten sampler loops in key setup.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 9 Jul 2013 22:17:15 +0000 (15:17 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 19 Aug 2013 20:17:00 +0000 (13:17 -0700)
Now that we have the number of samplers available, we don't need to
iterate over all 16.  This should be particularly helpful for vertex
shaders.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/brw_program.h
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_wm.c

index 2a944a0858a5ed86edcb209bb3954eebeadc75e6..a2997e77036b13e23f9858f19cabd1087cdecf6a 100644 (file)
@@ -44,6 +44,7 @@ struct brw_sampler_prog_key_data {
 
 void brw_populate_sampler_prog_key_data(struct gl_context *ctx,
                                        const struct gl_program *prog,
+                                        unsigned sampler_count,
                                        struct brw_sampler_prog_key_data *key);
 bool brw_debug_recompile_sampler_key(struct brw_context *brw,
                                      const struct brw_sampler_prog_key_data *old_key,
index b26a7a5f01b29c134cadd58a692088bf0e0a8ccd..9e18ef0119aee4cbcdcc50f64338c2c47165df47 100644 (file)
@@ -450,7 +450,8 @@ static void brw_upload_vs_prog(struct brw_context *brw)
    }
 
    /* _NEW_TEXTURE */
-   brw_populate_sampler_prog_key_data(ctx, prog, &key.base.tex);
+   brw_populate_sampler_prog_key_data(ctx, prog, brw->vs.sampler_count,
+                                      &key.base.tex);
 
    /* BRW_NEW_VERTICES */
    if (brw->gen < 8 && !brw->is_haswell) {
index 10ca5ff84a5c21f2cedcc835d87602b22551d224..3df2b7df4ce4df3a004fb71fbcae411ecbde8447 100644 (file)
@@ -298,11 +298,12 @@ brw_wm_debug_recompile(struct brw_context *brw,
 void
 brw_populate_sampler_prog_key_data(struct gl_context *ctx,
                                   const struct gl_program *prog,
+                                   unsigned sampler_count,
                                   struct brw_sampler_prog_key_data *key)
 {
    struct brw_context *brw = brw_context(ctx);
 
-   for (int s = 0; s < MAX_SAMPLERS; s++) {
+   for (int s = 0; s < sampler_count; s++) {
       key->swizzles[s] = SWIZZLE_NOOP;
 
       if (!(prog->SamplersUsed & (1 << s)))
@@ -425,7 +426,8 @@ static void brw_wm_populate_key( struct brw_context *brw,
    key->clamp_fragment_color = ctx->Color._ClampFragmentColor;
 
    /* _NEW_TEXTURE */
-   brw_populate_sampler_prog_key_data(ctx, prog, &key->tex);
+   brw_populate_sampler_prog_key_data(ctx, prog, brw->wm.sampler_count,
+                                      &key->tex);
 
    /* _NEW_BUFFERS */
    /*