summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-11-06 08:29:09 +0000
committerKeith Whitwell <[email protected]>2009-11-06 08:29:09 +0000
commit4a3e24522b0538cb3802c59c22d6f3660c4491be (patch)
treee70fc3b0d21e758c1722a9ec40de2fa05bbb1076 /src/gallium
parentb8e63e92102b6ca0b5ce06685590232a3a47d1ea (diff)
i965g: populate wm reloc array earlier
Still have to calculate the reloc background in two places.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/i965/brw_wm_state.c82
1 files changed, 46 insertions, 36 deletions
diff --git a/src/gallium/drivers/i965/brw_wm_state.c b/src/gallium/drivers/i965/brw_wm_state.c
index d8e88237ce0..ee970ac75bc 100644
--- a/src/gallium/drivers/i965/brw_wm_state.c
+++ b/src/gallium/drivers/i965/brw_wm_state.c
@@ -140,40 +140,13 @@ wm_unit_populate_key(struct brw_context *brw, struct brw_wm_unit_key *key)
*/
static enum pipe_error
wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
- struct brw_winsys_buffer **reloc_bufs,
+ struct brw_winsys_reloc *reloc,
+ unsigned nr_reloc,
struct brw_winsys_buffer **bo_out)
{
struct brw_wm_unit_state wm;
- struct brw_winsys_reloc reloc[3];
- unsigned nr_reloc = 0;
enum pipe_error ret;
- /* Emit WM program relocation */
- make_reloc(&reloc[nr_reloc++],
- BRW_USAGE_STATE,
- wm.thread0.grf_reg_count << 1,
- offsetof(struct brw_wm_unit_state, thread0),
- brw->wm.prog_bo);
-
- /* Emit scratch space relocation */
- if (key->total_scratch != 0) {
- make_reloc(&reloc[nr_reloc++],
- BRW_USAGE_SCRATCH,
- wm.thread2.per_thread_scratch_space,
- offsetof(struct brw_wm_unit_state, thread2),
- brw->wm.scratch_bo);
- }
-
- /* Emit sampler state relocation */
- if (key->sampler_count != 0) {
- make_reloc(&reloc[nr_reloc++],
- BRW_USAGE_STATE,
- wm.wm4.stats_enable | (wm.wm4.sampler_count << 2),
- offsetof(struct brw_wm_unit_state, wm4),
- brw->wm.sampler_bo);
- }
-
-
memset(&wm, 0, sizeof(wm));
wm.thread0.grf_reg_count = align(key->total_grf, 16) / 16 - 1;
@@ -243,7 +216,7 @@ wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
wm.wm5.line_stipple = key->line_stipple;
- if (BRW_DEBUG & DEBUG_STATS || key->stats_wm)
+ if ((BRW_DEBUG & DEBUG_STATS) || key->stats_wm)
wm.wm4.stats_enable = 1;
ret = brw_upload_cache(&brw->cache, BRW_WM_UNIT,
@@ -262,11 +235,17 @@ wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
static enum pipe_error upload_wm_unit( struct brw_context *brw )
{
struct brw_wm_unit_key key;
- struct brw_winsys_buffer *reloc_bufs[3];
+ struct brw_winsys_reloc reloc[3];
+ unsigned nr_reloc = 0;
enum pipe_error ret;
+ unsigned grf_reg_count;
+ unsigned per_thread_scratch_space;
+ unsigned stats_enable;
+ unsigned sampler_count;
wm_unit_populate_key(brw, &key);
+
/* Allocate the necessary scratch space if we haven't already. Don't
* bother reducing the allocation later, since we use scratch so
* rarely.
@@ -291,18 +270,49 @@ static enum pipe_error upload_wm_unit( struct brw_context *brw )
}
}
- reloc_bufs[0] = brw->wm.prog_bo;
- reloc_bufs[1] = brw->wm.scratch_bo;
- reloc_bufs[2] = brw->wm.sampler_bo;
+
+ /* XXX: temporary:
+ */
+ grf_reg_count = (align(key.total_grf, 16) / 16 - 1);
+ per_thread_scratch_space = key.total_scratch / 1024 - 1;
+ stats_enable = (BRW_DEBUG & DEBUG_STATS) || key.stats_wm;
+ sampler_count = BRW_IS_IGDNG(brw) ? 0 :(key.sampler_count + 1) / 4;
+
+ /* Emit WM program relocation */
+ make_reloc(&reloc[nr_reloc++],
+ BRW_USAGE_STATE,
+ grf_reg_count << 1,
+ offsetof(struct brw_wm_unit_state, thread0),
+ brw->wm.prog_bo);
+
+ /* Emit scratch space relocation */
+ if (key.total_scratch != 0) {
+ make_reloc(&reloc[nr_reloc++],
+ BRW_USAGE_SCRATCH,
+ per_thread_scratch_space,
+ offsetof(struct brw_wm_unit_state, thread2),
+ brw->wm.scratch_bo);
+ }
+
+ /* Emit sampler state relocation */
+ if (key.sampler_count != 0) {
+ make_reloc(&reloc[nr_reloc++],
+ BRW_USAGE_STATE,
+ stats_enable | (sampler_count << 2),
+ offsetof(struct brw_wm_unit_state, wm4),
+ brw->wm.sampler_bo);
+ }
+
if (brw_search_cache(&brw->cache, BRW_WM_UNIT,
&key, sizeof(key),
- reloc_bufs, 3,
+ reloc, nr_reloc,
NULL,
&brw->wm.state_bo))
return PIPE_OK;
- ret = wm_unit_create_from_key(brw, &key, reloc_bufs,
+ ret = wm_unit_create_from_key(brw, &key,
+ reloc, nr_reloc,
&brw->wm.state_bo);
if (ret)
return ret;