summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2014-07-26 11:27:57 -0700
committerKenneth Graunke <[email protected]>2014-08-02 05:14:42 -0700
commit8fbc96ca74012d3f94564d88692e170bc4ef7937 (patch)
tree0866eb8be26943eae1bafe25225493147ec6f628
parent378eea970824821ffb0d38c27e214af94ec0aca9 (diff)
i965: Shift brw_upload_sampler_state_table away from structures.
The Gen4-6 and Gen7+ code is virtually identical, but both use different structure types. Switching to use a uint32_t pointer and operate on the number of DWords will make it possible to share code. It turns out that SURFACE_STATE is the same number of DWords on every platform currently; it will be easy to handle a change there, though. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Topi Pohjolainen <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_sampler_state.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_sampler_state.c b/src/mesa/drivers/dri/i965/brw_sampler_state.c
index 587da1a3670..a14b5b38255 100644
--- a/src/mesa/drivers/dri/i965/brw_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sampler_state.c
@@ -380,7 +380,6 @@ brw_upload_sampler_state_table(struct brw_context *brw,
struct brw_stage_state *stage_state)
{
struct gl_context *ctx = &brw->ctx;
- struct brw_sampler_state *samplers;
uint32_t sampler_count = stage_state->sampler_count;
GLbitfield SamplersUsed = prog->SamplersUsed;
@@ -388,21 +387,29 @@ brw_upload_sampler_state_table(struct brw_context *brw,
if (sampler_count == 0)
return;
- samplers = brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
- sampler_count * sizeof(*samplers),
- 32, &stage_state->sampler_offset);
- memset(samplers, 0, sampler_count * sizeof(*samplers));
+ /* SAMPLER_STATE is 4 DWords on all platforms. */
+ const int dwords = 4;
+ const int size_in_bytes = dwords * sizeof(uint32_t);
+
+ uint32_t *sampler_state = brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
+ sampler_count * size_in_bytes,
+ 32, &stage_state->sampler_offset);
+ memset(sampler_state, 0, sampler_count * size_in_bytes);
+
+ uint32_t batch_offset_for_sampler_state = stage_state->sampler_offset;
for (unsigned s = 0; s < sampler_count; s++) {
if (SamplersUsed & (1 << s)) {
const unsigned unit = prog->SamplerUnits[s];
if (ctx->Texture.Unit[unit]._Current) {
- uint32_t batch_offset_for_sampler_state =
- stage_state->sampler_offset + s * sizeof(*samplers);
- brw_update_sampler_state(brw, unit, &samplers[s],
+ brw_update_sampler_state(brw, unit,
+ (struct brw_sampler_state *) sampler_state,
batch_offset_for_sampler_state);
}
}
+
+ sampler_state += dwords;
+ batch_offset_for_sampler_state += size_in_bytes;
}
brw->state.dirty.cache |= CACHE_NEW_SAMPLER;