summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2013-07-09 15:09:05 -0700
committerKenneth Graunke <[email protected]>2013-08-19 13:17:00 -0700
commitd0401d09ce19e47e01a3f1c86c10894515de26ad (patch)
tree41fa10ed9a179a7f3a4b6cb38a4a2f09ae33e771 /src/mesa/drivers
parentc6e572275b60f0221691b9b97650b9b41b89a5a2 (diff)
i965: Make sampler counts available for the entire drawing operation.
Previously, we computed sampler counts when generating the SAMPLER_STATE table. By computing it earlier, we should be able to shorten a bunch of loops. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Paul Berry <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h2
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.c7
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_sampler_state.c19
-rw-r--r--src/mesa/drivers/dri/i965/gen7_sampler_state.c12
4 files changed, 20 insertions, 20 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index fbe00b12fb8..d7de0bf79b2 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -818,7 +818,7 @@ struct brw_context
/** Upload a SAMPLER_STATE table. */
void (*upload_sampler_state_table)(struct brw_context *brw,
struct gl_program *prog,
- uint32_t *sampler_count,
+ uint32_t sampler_count,
uint32_t *sst_offset,
uint32_t *sdc_offset);
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 6170d0728e1..424d39fb8c2 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -371,6 +371,13 @@ static bool brw_try_draw_prims( struct gl_context *ctx,
if (ctx->NewState)
_mesa_update_state( ctx );
+ /* Find the highest sampler unit used by each shader program. A bit-count
+ * won't work since ARB programs use the texture unit number as the sampler
+ * index.
+ */
+ brw->wm.sampler_count = _mesa_fls(ctx->FragmentProgram._Current->Base.SamplersUsed);
+ brw->vs.sampler_count = _mesa_fls(ctx->VertexProgram._Current->Base.SamplersUsed);
+
/* We have to validate the textures *before* checking for fallbacks;
* otherwise, the software fallback won't be able to rely on the
* texture state, the firstLevel and lastLevel fields won't be
diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
index a03953f17cd..f2117a48e1a 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
@@ -369,7 +369,7 @@ static void brw_update_sampler_state(struct brw_context *brw,
static void
brw_upload_sampler_state_table(struct brw_context *brw,
struct gl_program *prog,
- uint32_t *sampler_count,
+ uint32_t sampler_count,
uint32_t *sst_offset,
uint32_t *sdc_offset)
{
@@ -378,20 +378,15 @@ brw_upload_sampler_state_table(struct brw_context *brw,
GLbitfield SamplersUsed = prog->SamplersUsed;
- /* ARB programs use the texture unit number as the sampler index, so we
- * need to find the highest unit used. A bit-count will not work.
- */
- *sampler_count = _mesa_fls(SamplersUsed);
-
- if (*sampler_count == 0)
+ if (sampler_count == 0)
return;
samplers = brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
- *sampler_count * sizeof(*samplers),
+ sampler_count * sizeof(*samplers),
32, sst_offset);
- memset(samplers, 0, *sampler_count * sizeof(*samplers));
+ memset(samplers, 0, sampler_count * sizeof(*samplers));
- for (unsigned s = 0; s < *sampler_count; s++) {
+ for (unsigned s = 0; s < sampler_count; s++) {
if (SamplersUsed & (1 << s)) {
const unsigned unit = prog->SamplerUnits[s];
if (ctx->Texture.Unit[unit]._ReallyEnabled)
@@ -409,7 +404,7 @@ brw_upload_fs_samplers(struct brw_context *brw)
/* BRW_NEW_FRAGMENT_PROGRAM */
struct gl_program *fs = (struct gl_program *) brw->fragment_program;
brw->vtbl.upload_sampler_state_table(brw, fs,
- &brw->wm.sampler_count,
+ brw->wm.sampler_count,
&brw->wm.sampler_offset,
brw->wm.sdc_offset);
}
@@ -430,7 +425,7 @@ brw_upload_vs_samplers(struct brw_context *brw)
/* BRW_NEW_VERTEX_PROGRAM */
struct gl_program *vs = (struct gl_program *) brw->vertex_program;
brw->vtbl.upload_sampler_state_table(brw, vs,
- &brw->vs.sampler_count,
+ brw->vs.sampler_count,
&brw->vs.sampler_offset,
brw->vs.sdc_offset);
}
diff --git a/src/mesa/drivers/dri/i965/gen7_sampler_state.c b/src/mesa/drivers/dri/i965/gen7_sampler_state.c
index 5701f4d8f04..193b5b12752 100644
--- a/src/mesa/drivers/dri/i965/gen7_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sampler_state.c
@@ -187,7 +187,7 @@ gen7_update_sampler_state(struct brw_context *brw, int unit, int ss_index,
static void
gen7_upload_sampler_state_table(struct brw_context *brw,
struct gl_program *prog,
- uint32_t *sampler_count,
+ uint32_t sampler_count,
uint32_t *sst_offset,
uint32_t *sdc_offset)
{
@@ -196,17 +196,15 @@ gen7_upload_sampler_state_table(struct brw_context *brw,
GLbitfield SamplersUsed = prog->SamplersUsed;
- *sampler_count = _mesa_fls(SamplersUsed);
-
- if (*sampler_count == 0)
+ if (sampler_count == 0)
return;
samplers = brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
- *sampler_count * sizeof(*samplers),
+ sampler_count * sizeof(*samplers),
32, sst_offset);
- memset(samplers, 0, *sampler_count * sizeof(*samplers));
+ memset(samplers, 0, sampler_count * sizeof(*samplers));
- for (unsigned s = 0; s < *sampler_count; s++) {
+ for (unsigned s = 0; s < sampler_count; s++) {
if (SamplersUsed & (1 << s)) {
const unsigned unit = prog->SamplerUnits[s];
if (ctx->Texture.Unit[unit]._ReallyEnabled)