summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2008-01-02 16:55:21 -0800
committerEric Anholt <eric@anholt.net>2008-01-03 15:46:16 -0800
commit8abffada70fcd62e3c2dcbcdc6d00d258805326b (patch)
treed04daf5de22d6bbdb97beda35da6b33f4f1bc6c1 /src/mesa/drivers/dri/i965
parent0ff3eb637bac9e100aab0a109a46e81bea9203a3 (diff)
[intel] Convert relocations to not be cleared out on buffer submit.
We have two consumers of relocations. One is static state buffers, which want the same relocation every time. The other is the batchbuffer, which gets thrown out immediately after submit. This lets us reduce repeated computation for static state buffers, and clean up the code by moving relocations nearer to where the state buffer is computed.
Diffstat (limited to 'src/mesa/drivers/dri/i965')
-rw-r--r--src/mesa/drivers/dri/i965/brw_cc.c31
-rw-r--r--src/mesa/drivers/dri/i965/brw_clip_state.c36
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h9
-rw-r--r--src/mesa/drivers/dri/i965/brw_gs_state.c36
-rw-r--r--src/mesa/drivers/dri/i965/brw_sf_state.c46
-rw-r--r--src/mesa/drivers/dri/i965/brw_state_upload.c4
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_state.c32
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_sampler_state.c31
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_state.c69
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_surface_state.c87
10 files changed, 166 insertions, 215 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_cc.c b/src/mesa/drivers/dri/i965/brw_cc.c
index 02ebfca57d..80aaebdb2f 100644
--- a/src/mesa/drivers/dri/i965/brw_cc.c
+++ b/src/mesa/drivers/dri/i965/brw_cc.c
@@ -147,6 +147,7 @@ static dri_bo *
cc_unit_create_from_key(struct brw_context *brw, struct brw_cc_unit_key *key)
{
struct brw_cc_unit_state cc;
+ dri_bo *bo;
memset(&cc, 0, sizeof(cc));
@@ -248,11 +249,20 @@ cc_unit_create_from_key(struct brw_context *brw, struct brw_cc_unit_key *key)
if (INTEL_DEBUG & DEBUG_STATS)
cc.cc5.statistics_enable = 1;
- return brw_upload_cache(&brw->cache, BRW_CC_UNIT,
- key, sizeof(*key),
- &brw->cc.vp_bo, 1,
- &cc, sizeof(cc),
- NULL, NULL);
+ bo = brw_upload_cache(&brw->cache, BRW_CC_UNIT,
+ key, sizeof(*key),
+ &brw->cc.vp_bo, 1,
+ &cc, sizeof(cc),
+ NULL, NULL);
+
+ /* Emit CC viewport relocation */
+ dri_emit_reloc(bo,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ 0,
+ offsetof(struct brw_cc_unit_state, cc4),
+ brw->cc.vp_bo);
+
+ return bo;
}
static void upload_cc_unit( struct brw_context *brw )
@@ -271,16 +281,6 @@ static void upload_cc_unit( struct brw_context *brw )
brw->cc.state_bo = cc_unit_create_from_key(brw, &key);
}
-static void emit_reloc_cc_unit(struct brw_context *brw)
-{
- /* Emit CC viewport relocation */
- dri_emit_reloc(brw->cc.state_bo,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- 0,
- offsetof(struct brw_cc_unit_state, cc4),
- brw->cc.vp_bo);
-}
-
const struct brw_tracked_state brw_cc_unit = {
.dirty = {
.mesa = _NEW_STENCIL | _NEW_COLOR | _NEW_DEPTH,
@@ -288,7 +288,6 @@ const struct brw_tracked_state brw_cc_unit = {
.cache = CACHE_NEW_CC_VP
},
.update = upload_cc_unit,
- .emit_reloc = emit_reloc_cc_unit,
};
diff --git a/src/mesa/drivers/dri/i965/brw_clip_state.c b/src/mesa/drivers/dri/i965/brw_clip_state.c
index cec717ee26..e6e9fceb14 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_state.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_state.c
@@ -69,6 +69,7 @@ clip_unit_create_from_key(struct brw_context *brw,
struct brw_clip_unit_key *key)
{
struct brw_clip_unit_state clip;
+ dri_bo *bo;
memset(&clip, 0, sizeof(clip));
@@ -106,12 +107,22 @@ clip_unit_create_from_key(struct brw_context *brw,
clip.viewport_ymin = -1;
clip.viewport_ymax = 1;
- brw->clip.thread0_delta = clip.thread0.grf_reg_count << 1;
- return brw_upload_cache(&brw->cache, BRW_CLIP_UNIT,
- key, sizeof(*key),
- &brw->clip.prog_bo, 1,
- &clip, sizeof(clip),
- NULL, NULL);
+ bo = brw_upload_cache(&brw->cache, BRW_CLIP_UNIT,
+ key, sizeof(*key),
+ &brw->clip.prog_bo, 1,
+ &clip, sizeof(clip),
+ NULL, NULL);
+
+ if (!brw->metaops.active) {
+ /* Emit clip program relocation */
+ dri_emit_reloc(bo,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ clip.thread0.grf_reg_count << 1,
+ offsetof(struct brw_clip_unit_state, thread0),
+ brw->clip.prog_bo);
+ }
+
+ return bo;
}
static void upload_clip_unit( struct brw_context *brw )
@@ -130,18 +141,6 @@ static void upload_clip_unit( struct brw_context *brw )
}
}
-static void emit_reloc_clip_unit(struct brw_context *brw)
-{
- if (!brw->metaops.active) {
- /* Emit clip program relocation */
- dri_emit_reloc(brw->clip.state_bo,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- brw->clip.thread0_delta,
- offsetof(struct brw_clip_unit_state, thread0),
- brw->clip.prog_bo);
- }
-}
-
const struct brw_tracked_state brw_clip_unit = {
.dirty = {
.mesa = 0,
@@ -150,5 +149,4 @@ const struct brw_tracked_state brw_clip_unit = {
.cache = CACHE_NEW_CLIP_PROG
},
.update = upload_clip_unit,
- .emit_reloc = emit_reloc_clip_unit,
};
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 05111b351a..5a6ef463ea 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -328,7 +328,6 @@ struct brw_state_pointers {
struct brw_tracked_state {
struct brw_state_flags dirty;
void (*update)( struct brw_context *brw );
- void (*emit_reloc)( struct brw_context *brw );
GLboolean always_update;
};
@@ -540,7 +539,6 @@ struct brw_context
struct {
struct brw_vs_prog_data *prog_data;
- GLuint thread0_delta;
dri_bo *prog_bo;
dri_bo *state_bo;
} vs;
@@ -549,7 +547,6 @@ struct brw_context
struct brw_gs_prog_data *prog_data;
GLboolean prog_active;
- GLuint thread0_delta;
dri_bo *prog_bo;
dri_bo *state_bo;
} gs;
@@ -557,7 +554,6 @@ struct brw_context
struct {
struct brw_clip_prog_data *prog_data;
- GLuint thread0_delta;
dri_bo *prog_bo;
dri_bo *state_bo;
dri_bo *vp_bo;
@@ -567,8 +563,6 @@ struct brw_context
struct {
struct brw_sf_prog_data *prog_data;
- GLuint thread0_delta;
- GLuint sf5_delta;
dri_bo *prog_bo;
dri_bo *state_bo;
dri_bo *vp_bo;
@@ -598,9 +592,6 @@ struct brw_context
dri_bo *bind_bo;
dri_bo *surf_bo[BRW_WM_MAX_SURF];
- GLuint thread0_delta;
- GLuint thread2_delta;
- GLuint wm4_delta;
dri_bo *prog_bo;
dri_bo *state_bo;
} wm;
diff --git a/src/mesa/drivers/dri/i965/brw_gs_state.c b/src/mesa/drivers/dri/i965/brw_gs_state.c
index 5cff15a7a4..bf38fd7385 100644
--- a/src/mesa/drivers/dri/i965/brw_gs_state.c
+++ b/src/mesa/drivers/dri/i965/brw_gs_state.c
@@ -73,6 +73,7 @@ static dri_bo *
gs_unit_create_from_key(struct brw_context *brw, struct brw_gs_unit_key *key)
{
struct brw_gs_unit_state gs;
+ dri_bo *bo;
memset(&gs, 0, sizeof(gs));
@@ -97,12 +98,22 @@ gs_unit_create_from_key(struct brw_context *brw, struct brw_gs_unit_key *key)
if (INTEL_DEBUG & DEBUG_STATS)
gs.thread4.stats_enable = 1;
- brw->gs.thread0_delta = gs.thread0.grf_reg_count << 1;
- return brw_upload_cache(&brw->cache, BRW_GS_UNIT,
- key, sizeof(*key),
- &brw->gs.prog_bo, 1,
- &gs, sizeof(gs),
- NULL, NULL);
+ bo = brw_upload_cache(&brw->cache, BRW_GS_UNIT,
+ key, sizeof(*key),
+ &brw->gs.prog_bo, 1,
+ &gs, sizeof(gs),
+ NULL, NULL);
+
+ if (key->prog_active) {
+ /* Emit GS program relocation */
+ dri_emit_reloc(bo,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ gs.thread0.grf_reg_count << 1,
+ offsetof(struct brw_gs_unit_state, thread0),
+ brw->gs.prog_bo);
+ }
+
+ return bo;
}
static void upload_gs_unit( struct brw_context *brw )
@@ -121,18 +132,6 @@ static void upload_gs_unit( struct brw_context *brw )
}
}
-static void emit_reloc_gs_unit(struct brw_context *brw)
-{
- if (brw->gs.prog_active) {
- /* Emit GS program relocation */
- dri_emit_reloc(brw->gs.state_bo,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- brw->gs.thread0_delta,
- offsetof(struct brw_gs_unit_state, thread0),
- brw->gs.prog_bo);
- }
-}
-
const struct brw_tracked_state brw_gs_unit = {
.dirty = {
.mesa = 0,
@@ -141,5 +140,4 @@ const struct brw_tracked_state brw_gs_unit = {
.cache = CACHE_NEW_GS_PROG
},
.update = upload_gs_unit,
- .emit_reloc = emit_reloc_gs_unit,
};
diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c
index ccea31d8dc..05c6490949 100644
--- a/src/mesa/drivers/dri/i965/brw_sf_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sf_state.c
@@ -157,6 +157,7 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key,
dri_bo **reloc_bufs)
{
struct brw_sf_unit_state sf;
+ dri_bo *bo;
memset(&sf, 0, sizeof(sf));
@@ -242,14 +243,27 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key,
sf.sf6.dest_org_vbias = 0x8;
sf.sf6.dest_org_hbias = 0x8;
- brw->sf.thread0_delta = sf.thread0.grf_reg_count << 1;
- brw->sf.sf5_delta = sf.sf5.front_winding | (sf.sf5.viewport_transform << 1);
+ bo = brw_upload_cache(&brw->cache, BRW_SF_UNIT,
+ key, sizeof(*key),
+ reloc_bufs, 2,
+ &sf, sizeof(sf),
+ NULL, NULL);
- return brw_upload_cache(&brw->cache, BRW_SF_UNIT,
- key, sizeof(*key),
- reloc_bufs, 2,
- &sf, sizeof(sf),
- NULL, NULL);
+ /* Emit SF program relocation */
+ dri_emit_reloc(bo,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ sf.thread0.grf_reg_count << 1,
+ offsetof(struct brw_sf_unit_state, thread0),
+ brw->sf.prog_bo);
+
+ /* Emit SF viewport relocation */
+ dri_emit_reloc(bo,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ sf.sf5.front_winding | (sf.sf5.viewport_transform << 1),
+ offsetof(struct brw_sf_unit_state, sf5),
+ brw->sf.vp_bo);
+
+ return bo;
}
static void upload_sf_unit( struct brw_context *brw )
@@ -272,23 +286,6 @@ static void upload_sf_unit( struct brw_context *brw )
}
}
-static void emit_reloc_sf_unit(struct brw_context *brw)
-{
- /* Emit SF program relocation */
- dri_emit_reloc(brw->sf.state_bo,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- brw->sf.thread0_delta,
- offsetof(struct brw_sf_unit_state, thread0),
- brw->sf.prog_bo);
-
- /* Emit SF viewport relocation */
- dri_emit_reloc(brw->sf.state_bo,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- brw->sf.sf5_delta,
- offsetof(struct brw_sf_unit_state, sf5),
- brw->sf.vp_bo);
-}
-
const struct brw_tracked_state brw_sf_unit = {
.dirty = {
.mesa = (_NEW_POLYGON |
@@ -301,5 +298,4 @@ const struct brw_tracked_state brw_sf_unit = {
CACHE_NEW_SF_PROG)
},
.update = upload_sf_unit,
- .emit_reloc = emit_reloc_sf_unit,
};
diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c
index 94165da816..c8e3fb8ee8 100644
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
@@ -232,8 +232,6 @@ void brw_validate_state( struct brw_context *brw )
/* emit_foo(brw); */
}
- if (atom->emit_reloc != NULL)
- atom->emit_reloc(brw);
accumulate_state(&examined, &atom->dirty);
@@ -252,8 +250,6 @@ void brw_validate_state( struct brw_context *brw )
if (check_state(state, &atom->dirty) || atom->always_update)
atom->update( brw );
- if (atom->emit_reloc != NULL)
- atom->emit_reloc(brw);
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_vs_state.c b/src/mesa/drivers/dri/i965/brw_vs_state.c
index 22e32fe6a7..573be01a2b 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_state.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_state.c
@@ -76,6 +76,7 @@ static dri_bo *
vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key)
{
struct brw_vs_unit_state vs;
+ dri_bo *bo;
memset(&vs, 0, sizeof(vs));
@@ -107,12 +108,20 @@ vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key)
*/
vs.vs6.vs_enable = 1;
- brw->vs.thread0_delta = vs.thread0.grf_reg_count << 1;
- return brw_upload_cache(&brw->cache, BRW_VS_UNIT,
- key, sizeof(*key),
- &brw->vs.prog_bo, 1,
- &vs, sizeof(vs),
- NULL, NULL);
+ bo = brw_upload_cache(&brw->cache, BRW_VS_UNIT,
+ key, sizeof(*key),
+ &brw->vs.prog_bo, 1,
+ &vs, sizeof(vs),
+ NULL, NULL);
+
+ /* Emit VS program relocation */
+ dri_emit_reloc(bo,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ vs.thread0.grf_reg_count << 1,
+ offsetof(struct brw_vs_unit_state, thread0),
+ brw->vs.prog_bo);
+
+ return bo;
}
static void upload_vs_unit( struct brw_context *brw )
@@ -131,16 +140,6 @@ static void upload_vs_unit( struct brw_context *brw )
}
}
-static void emit_reloc_vs_unit(struct brw_context *brw)
-{
- /* Emit VS program relocation */
- dri_emit_reloc(brw->vs.state_bo,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- brw->vs.thread0_delta,
- offsetof(struct brw_vs_unit_state, thread0),
- brw->vs.prog_bo);
-}
-
const struct brw_tracked_state brw_vs_unit = {
.dirty = {
.mesa = _NEW_TRANSFORM,
@@ -149,5 +148,4 @@ const struct brw_tracked_state brw_vs_unit = {
.cache = CACHE_NEW_VS_PROG
},
.update = upload_vs_unit,
- .emit_reloc = emit_reloc_vs_unit,
};
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 0f59584c6e..0c75021324 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
@@ -296,27 +296,19 @@ static void upload_wm_samplers( struct brw_context *brw )
brw->wm.sdc_bo, key.sampler_count,
&sampler, sizeof(sampler),
NULL, NULL);
- }
-}
-static void emit_reloc_wm_samplers(struct brw_context *brw)
-{
- GLuint unit;
-
- if (brw->wm.sampler_count == 0)
- return;
+ /* Emit SDC relocations */
+ for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
+ if (!brw->attribs.Texture->Unit[i]._ReallyEnabled)
+ continue;
- /* Emit SDC relocations */
- for (unit = 0; unit < BRW_MAX_TEX_UNIT; unit++) {
- if (!brw->attribs.Texture->Unit[unit]._ReallyEnabled)
- continue;
-
- dri_emit_reloc(brw->wm.sampler_bo,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- 0,
- unit * sizeof(struct brw_sampler_state) +
- offsetof(struct brw_sampler_state, ss2),
- brw->wm.sdc_bo[unit]);
+ dri_emit_reloc(brw->wm.sampler_bo,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ 0,
+ i * sizeof(struct brw_sampler_state) +
+ offsetof(struct brw_sampler_state, ss2),
+ brw->wm.sdc_bo[i]);
+ }
}
}
@@ -327,7 +319,6 @@ const struct brw_tracked_state brw_wm_samplers = {
.cache = 0
},
.update = upload_wm_samplers,
- .emit_reloc = emit_reloc_wm_samplers,
};
diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c
index c273525102..6e430645d6 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_state.c
@@ -112,6 +112,7 @@ wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
dri_bo **reloc_bufs)
{
struct brw_wm_unit_state wm;
+ dri_bo *bo;
memset(&wm, 0, sizeof(wm));
@@ -186,15 +187,38 @@ wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
if (INTEL_DEBUG & DEBUG_STATS || key->stats_wm)
wm.wm4.stats_enable = 1;
- brw->wm.thread0_delta = wm.thread0.grf_reg_count << 1;
- brw->wm.thread2_delta = wm.thread2.per_thread_scratch_space;
- brw->wm.wm4_delta = wm.wm4.stats_enable | (wm.wm4.sampler_count << 2);
+ bo = brw_upload_cache(&brw->cache, BRW_WM_UNIT,
+ key, sizeof(*key),
+ reloc_bufs, 3,
+ &wm, sizeof(wm),
+ NULL, NULL);
- return brw_upload_cache(&brw->cache, BRW_WM_UNIT,
- key, sizeof(*key),
- reloc_bufs, 3,
- &wm, sizeof(wm),
- NULL, NULL);
+ /* Emit WM program relocation */
+ dri_emit_reloc(bo,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ 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) {
+ dri_emit_reloc(bo,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE,
+ wm.thread2.per_thread_scratch_space,
+ offsetof(struct brw_wm_unit_state, thread2),
+ brw->wm.scratch_buffer);
+ }
+
+ /* Emit sampler state relocation */
+ if (key->sampler_count != 0) {
+ dri_emit_reloc(bo,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ wm.wm4.stats_enable | (wm.wm4.sampler_count << 2),
+ offsetof(struct brw_wm_unit_state, wm4),
+ brw->wm.sampler_bo);
+ }
+
+ return bo;
}
@@ -240,34 +264,6 @@ static void upload_wm_unit( struct brw_context *brw )
}
}
-static void emit_reloc_wm_unit(struct brw_context *brw)
-{
- /* Emit WM program relocation */
- dri_emit_reloc(brw->wm.state_bo,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- brw->wm.thread0_delta,
- offsetof(struct brw_wm_unit_state, thread0),
- brw->wm.prog_bo);
-
- /* Emit scratch space relocation */
- if (brw->wm.scratch_buffer != NULL) {
- dri_emit_reloc(brw->wm.state_bo,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE,
- brw->wm.thread2_delta,
- offsetof(struct brw_wm_unit_state, thread2),
- brw->wm.scratch_buffer);
- }
-
- /* Emit sampler state relocation */
- if (brw->wm.sampler_bo != NULL) {
- dri_emit_reloc(brw->wm.state_bo,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- brw->wm.wm4_delta,
- offsetof(struct brw_wm_unit_state, wm4),
- brw->wm.sampler_bo);
- }
-}
-
const struct brw_tracked_state brw_wm_unit = {
.dirty = {
.mesa = (_NEW_POLYGON |
@@ -284,6 +280,5 @@ const struct brw_tracked_state brw_wm_unit = {
CACHE_NEW_SAMPLER)
},
.update = upload_wm_unit,
- .emit_reloc = emit_reloc_wm_unit,
};
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 0984068d35..cf253391b5 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -154,6 +154,7 @@ brw_create_texture_surface( struct brw_context *brw,
struct brw_wm_surface_key *key )
{
struct brw_surface_state surf;
+ dri_bo *bo;
memset(&surf, 0, sizeof(surf));
@@ -187,11 +188,20 @@ brw_create_texture_surface( struct brw_context *brw,
surf.ss0.cube_neg_z = 1;
}
- return brw_upload_cache( &brw->cache, BRW_SS_SURFACE,
- key, sizeof(*key),
- &key->bo, 1,
- &surf, sizeof(surf),
- NULL, NULL );
+ bo = brw_upload_cache(&brw->cache, BRW_SS_SURFACE,
+ key, sizeof(*key),
+ &key->bo, 1,
+ &surf, sizeof(surf),
+ NULL, NULL);
+
+ /* Emit relocation to surface contents */
+ dri_emit_reloc(bo,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ 0,
+ offsetof(struct brw_surface_state, ss1),
+ key->bo);
+
+ return bo;
}
static void
@@ -307,7 +317,15 @@ brw_update_region_surface(struct brw_context *brw, struct intel_region *region,
&surf, sizeof(surf),
NULL, NULL);
- brw->wm.nr_surfaces = 1;
+ if (region_bo != NULL) {
+ dri_emit_reloc(brw->wm.surf_bo[unit],
+ DRM_BO_FLAG_MEM_TT |
+ DRM_BO_FLAG_READ |
+ DRM_BO_FLAG_WRITE,
+ 0,
+ offsetof(struct brw_surface_state, ss1),
+ region_bo);
+ }
}
}
@@ -343,6 +361,19 @@ brw_wm_get_binding_table(struct brw_context *brw)
data, data_size,
NULL, NULL);
+ /* Emit binding table relocations to surface state */
+ for (i = 0; i < BRW_WM_MAX_SURF; i++) {
+ if (brw->wm.surf_bo[i] != NULL) {
+ dri_emit_reloc(bind_bo,
+ DRM_BO_FLAG_MEM_TT |
+ DRM_BO_FLAG_READ |
+ DRM_BO_FLAG_WRITE,
+ 0,
+ i * 4,
+ brw->wm.surf_bo[i]);
+ }
+ }
+
free(data);
}
@@ -356,6 +387,7 @@ static void upload_wm_surfaces(struct brw_context *brw )
GLuint i;
brw_update_region_surface(brw, brw->state.draw_region, 0);
+ brw->wm.nr_surfaces = 1;
for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
struct gl_texture_unit *texUnit = &brw->attribs.Texture->Unit[i];
@@ -385,48 +417,6 @@ static void upload_wm_surfaces(struct brw_context *brw )
brw->wm.bind_bo = brw_wm_get_binding_table(brw);
}
-static void emit_reloc_wm_surfaces(struct brw_context *brw)
-{
- int unit, i;
-
- /* Emit SS framebuffer relocation */
- if (brw->state.draw_region != NULL) {
- dri_emit_reloc(brw->wm.surf_bo[0],
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE,
- 0,
- offsetof(struct brw_surface_state, ss1),
- brw->state.draw_region->buffer);
- }
-
- /* Emit SS relocations for texture buffers */
- for (unit = 0; unit < BRW_MAX_TEX_UNIT; unit++) {
- struct gl_texture_unit *texUnit = &brw->attribs.Texture->Unit[unit];
- struct gl_texture_object *tObj = texUnit->_Current;
- struct intel_texture_object *intelObj = intel_texture_object(tObj);
-
- if (texUnit->_ReallyEnabled && intelObj->mt != NULL) {
- dri_emit_reloc(brw->wm.surf_bo[unit + 1],
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- 0,
- offsetof(struct brw_surface_state, ss1),
- intelObj->mt->region->buffer);
- }
- }
-
- /* Emit binding table relocations to surface state */
- for (i = 0; i < BRW_WM_MAX_SURF; i++) {
- if (brw->wm.surf_bo[i] != NULL) {
- dri_emit_reloc(brw->wm.bind_bo,
- DRM_BO_FLAG_MEM_TT |
- DRM_BO_FLAG_READ |
- DRM_BO_FLAG_WRITE,
- 0,
- i * 4,
- brw->wm.surf_bo[i]);
- }
- }
-}
-
const struct brw_tracked_state brw_wm_surfaces = {
.dirty = {
.mesa = _NEW_COLOR | _NEW_TEXTURE | _NEW_BUFFERS,
@@ -434,7 +424,6 @@ const struct brw_tracked_state brw_wm_surfaces = {
.cache = 0
},
.update = upload_wm_surfaces,
- .emit_reloc = emit_reloc_wm_surfaces,
};