i965: make more effective use of SamplersUsed
authorTimothy Arceri <timothy.arceri@collabora.com>
Tue, 5 Jul 2016 07:02:46 +0000 (17:02 +1000)
committerTimothy Arceri <timothy.arceri@collabora.com>
Tue, 5 Jul 2016 10:18:05 +0000 (20:18 +1000)
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
src/mesa/drivers/dri/i965/brw_cs.c
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_program.h
src/mesa/drivers/dri/i965/brw_tcs.c
src/mesa/drivers/dri/i965/brw_tes.c
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_wm.c

index 45128bc439a4fa1107d18ff7d5a3c01a09796b09..655adc146223b341b3a2c228af08e9620c51a862 100644 (file)
@@ -198,8 +198,7 @@ brw_cs_populate_key(struct brw_context *brw, struct brw_cs_prog_key *key)
    memset(key, 0, sizeof(*key));
 
    /* _NEW_TEXTURE */
-   brw_populate_sampler_prog_key_data(ctx, prog, brw->cs.base.sampler_count,
-                                      &key->tex);
+   brw_populate_sampler_prog_key_data(ctx, prog, &key->tex);
 
    /* The unique compute program ID */
    key->program_string_id = cp->id;
index 1ce74d8b0ef963da3816e35e1415f2763a76ba0b..d9f18c46549d9802d95b058717a33b16deefcf86 100644 (file)
@@ -207,7 +207,6 @@ brw_gs_populate_key(struct brw_context *brw,
                     struct brw_gs_prog_key *key)
 {
    struct gl_context *ctx = &brw->ctx;
-   struct brw_stage_state *stage_state = &brw->gs.base;
    struct brw_geometry_program *gp =
       (struct brw_geometry_program *) brw->geometry_program;
    struct gl_program *prog = &gp->program.Base;
@@ -217,8 +216,7 @@ brw_gs_populate_key(struct brw_context *brw,
    key->program_string_id = gp->id;
 
    /* _NEW_TEXTURE */
-   brw_populate_sampler_prog_key_data(ctx, prog, stage_state->sampler_count,
-                                      &key->tex);
+   brw_populate_sampler_prog_key_data(ctx, prog, &key->tex);
 }
 
 void
index 5874d93162370f06e68c2605889263ba2be4b3cc..317fbe2b9f442429cd07800e29ebf950421e2fd0 100644 (file)
@@ -44,7 +44,6 @@ void brw_setup_tex_for_precompile(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);
 bool brw_debug_recompile_sampler_key(struct brw_context *brw,
                                      const struct brw_sampler_prog_key_data *old_key,
index acfd1e5770bc899f8252405caf4c206b5b8922de..da94bf275c96b1ad0e89becb8b0524d1b2a7cf63 100644 (file)
@@ -351,8 +351,7 @@ brw_upload_tcs_prog(struct brw_context *brw,
       key.program_string_id = tcp->id;
 
       /* _NEW_TEXTURE */
-      brw_populate_sampler_prog_key_data(ctx, prog, stage_state->sampler_count,
-                                         &key.tex);
+      brw_populate_sampler_prog_key_data(ctx, prog, &key.tex);
    } else {
       key.outputs_written = tep->program.Base.InputsRead;
    }
index 001655df872b111614bf85d920cd0628dff0e59a..e14ae865a39ebc2e92bfdbfe116e83148b656579 100644 (file)
@@ -263,8 +263,7 @@ brw_upload_tes_prog(struct brw_context *brw,
    key.patch_inputs_read = per_patch_slots;
 
    /* _NEW_TEXTURE */
-   brw_populate_sampler_prog_key_data(ctx, prog, stage_state->sampler_count,
-                                      &key.tex);
+   brw_populate_sampler_prog_key_data(ctx, prog, &key.tex);
 
    if (!brw_search_cache(&brw->cache, BRW_CACHE_TES_PROG,
                          &key, sizeof(key),
index ec913f0e96cbd0b036de6f8506957463304e31e0..877bcb59e47cdc003e3dbc58927e419df3361337 100644 (file)
@@ -345,8 +345,7 @@ brw_vs_populate_key(struct brw_context *brw,
    }
 
    /* _NEW_TEXTURE */
-   brw_populate_sampler_prog_key_data(ctx, prog, brw->vs.base.sampler_count,
-                                      &key->tex);
+   brw_populate_sampler_prog_key_data(ctx, prog, &key->tex);
 
    /* BRW_NEW_VS_ATTRIB_WORKAROUNDS */
    memcpy(key->gl_attrib_wa_flags, brw->vb.attrib_wa_flags,
index 46839bc526e8b8dbe8e9f1e1924db0107aa4efd2..7b1b83914ad2c157f09738b825e35fced939458c 100644 (file)
@@ -306,16 +306,15 @@ gen6_gather_workaround(GLenum internalformat)
 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);
+   GLbitfield mask = prog->SamplersUsed;
 
-   for (int s = 0; s < sampler_count; s++) {
-      key->swizzles[s] = SWIZZLE_NOOP;
+   while (mask) {
+      const int s = u_bit_scan(&mask);
 
-      if (!(prog->SamplersUsed & (1 << s)))
-        continue;
+      key->swizzles[s] = SWIZZLE_NOOP;
 
       int unit_id = prog->SamplerUnits[s];
       const struct gl_texture_unit *unit = &ctx->Texture.Unit[unit_id];
@@ -506,8 +505,7 @@ brw_wm_populate_key(struct brw_context *brw, struct brw_wm_prog_key *key)
    key->clamp_fragment_color = ctx->Color._ClampFragmentColor;
 
    /* _NEW_TEXTURE */
-   brw_populate_sampler_prog_key_data(ctx, prog, brw->wm.base.sampler_count,
-                                      &key->tex);
+   brw_populate_sampler_prog_key_data(ctx, prog, &key->tex);
 
    /* _NEW_BUFFERS */
    key->nr_color_regions = ctx->DrawBuffer->_NumColorDrawBuffers;