From: Timothy Arceri Date: Tue, 5 Jul 2016 07:02:46 +0000 (+1000) Subject: i965: make more effective use of SamplersUsed X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8f1ca0ee3ff9e192540325ae42df9577b1ccdf7f;p=mesa.git i965: make more effective use of SamplersUsed Reviewed-by: Samuel Iglesias Gonsálvez --- diff --git a/src/mesa/drivers/dri/i965/brw_cs.c b/src/mesa/drivers/dri/i965/brw_cs.c index 45128bc439a..655adc14622 100644 --- a/src/mesa/drivers/dri/i965/brw_cs.c +++ b/src/mesa/drivers/dri/i965/brw_cs.c @@ -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; diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index 1ce74d8b0ef..d9f18c46549 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -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 diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h index 5874d931623..317fbe2b9f4 100644 --- a/src/mesa/drivers/dri/i965/brw_program.h +++ b/src/mesa/drivers/dri/i965/brw_program.h @@ -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, diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c index acfd1e5770b..da94bf275c9 100644 --- a/src/mesa/drivers/dri/i965/brw_tcs.c +++ b/src/mesa/drivers/dri/i965/brw_tcs.c @@ -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; } diff --git a/src/mesa/drivers/dri/i965/brw_tes.c b/src/mesa/drivers/dri/i965/brw_tes.c index 001655df872..e14ae865a39 100644 --- a/src/mesa/drivers/dri/i965/brw_tes.c +++ b/src/mesa/drivers/dri/i965/brw_tes.c @@ -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), diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index ec913f0e96c..877bcb59e47 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -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, diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 46839bc526e..7b1b83914ad 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -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;