summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/brw_state_dump.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-12-14 11:02:48 -0800
committerEric Anholt <eric@anholt.net>2007-12-14 11:04:26 -0800
commit38bad7677e57d629eeffd4ef39a7fc254db12735 (patch)
tree977b9f821b6c8a9ef166e0533c7a2664a72cffcb /src/mesa/drivers/dri/i965/brw_state_dump.c
parent0037ad4186c11267d85fcde378be79eb6acf74f3 (diff)
[965] Replace the state cache suballocator with direct dri_bufmgr use.
The user-space suballocator that was used avoided relocation computations by using the general and surface state base registers and allocating those types of buffers out of pools built on top of single buffer objects. It also avoided calls into the buffer manager for these small state allocations, since only one buffer object was being used. However, the buffer allocation cost appears to be low, and with relocation caching, computing relocations for buffers is essentially free. Additionally, implementing the suballocator required a don't-fence-subdata flag to disable waiting on buffer maps so that writing new data didn't block on rendering using old data, and careful handling when mapping to update old data (which we need to do for unavoidable relocations with FBOs). More importantly, when the suballocator filled, it had no replacement algorithm and just threw out all of the contents and forced them to be recomputed, which is a significant cost. This is the first step, which just changes the buffer type, but doesn't yet improve the hash table to not result in full recompute on overflow. Because the buffers are all allocated out of the general buffer allocator, we can no longer use the general/surface state bases to avoid relocations, and they are set to 0 instead.
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_state_dump.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_state_dump.c122
1 files changed, 86 insertions, 36 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_state_dump.c b/src/mesa/drivers/dri/i965/brw_state_dump.c
index 1e8fc97275..0bdccae0d6 100644
--- a/src/mesa/drivers/dri/i965/brw_state_dump.c
+++ b/src/mesa/drivers/dri/i965/brw_state_dump.c
@@ -41,13 +41,13 @@
* \param index Index of the DWORD being output.
*/
static void
-state_out(char *name, uint32_t *data, uint32_t hw_offset, int index,
+state_out(const char *name, void *data, uint32_t hw_offset, int index,
char *fmt, ...)
{
va_list va;
fprintf(stderr, "%8s: 0x%08x: 0x%08x: ",
- name, hw_offset + index * 4, data[index]);
+ name, hw_offset + index * 4, ((uint32_t *)data)[index]);
va_start(va, fmt);
vfprintf(stderr, fmt, va);
va_end(va);
@@ -55,43 +55,100 @@ state_out(char *name, uint32_t *data, uint32_t hw_offset, int index,
/** Generic, undecoded state buffer debug printout */
static void
-state_struct_out(char *name, dri_bo *buffer, unsigned int pool_offset,
- unsigned int state_size)
+state_struct_out(const char *name, dri_bo *buffer, unsigned int state_size)
{
int i;
- uint32_t *state;
- state = buffer->virtual + pool_offset;
+ if (buffer == NULL)
+ return;
+
+ dri_bo_map(buffer, GL_FALSE);
for (i = 0; i < state_size / 4; i++) {
- state_out(name, state, buffer->offset + pool_offset, i,
+ state_out(name, buffer->virtual, buffer->offset, i,
"dword %d\n", i);
}
+ dri_bo_unmap(buffer);
}
-static void dump_wm_surface_state(struct brw_context *brw, dri_bo *ss_buffer)
+static void dump_wm_surface_state(struct brw_context *brw)
{
int i;
for (i = 0; i < brw->wm.nr_surfaces; i++) {
- unsigned int surfoff = ss_buffer->offset + brw->wm.bind.surf_ss_offset[i];
- struct brw_surface_state *surf =
- (struct brw_surface_state *)(ss_buffer->virtual +
- brw->wm.bind.surf_ss_offset[i]);
- uint32_t *surfvals = (uint32_t *)surf;
+ dri_bo *surf_bo = brw->wm.surf_bo[i];
+ unsigned int surfoff;
+ struct brw_surface_state *surf;
char name[20];
+ dri_bo_map(surf_bo, GL_FALSE);
+ surfoff = surf_bo->offset;
+ surf = (struct brw_surface_state *)(surf_bo->virtual);
+
sprintf(name, "WM SS%d", i);
- state_out(name, surfvals, surfoff, 0, "\n");
- state_out(name, surfvals, surfoff, 1, "offset\n");
- state_out(name, surfvals, surfoff, 2, "%dx%d size, %d mips\n",
+ state_out(name, surf, surfoff, 0, "\n");
+ state_out(name, surf, surfoff, 1, "offset\n");
+ state_out(name, surf, surfoff, 2, "%dx%d size, %d mips\n",
surf->ss2.width + 1, surf->ss2.height + 1, surf->ss2.mip_count);
- state_out(name, surfvals, surfoff, 3, "pitch %d, %stiled\n",
+ state_out(name, surf, surfoff, 3, "pitch %d, %stiled\n",
surf->ss3.pitch + 1, surf->ss3.tiled_surface ? "" : "not ");
- state_out(name, surfvals, surfoff, 4, "mip base %d\n",
+ state_out(name, surf, surfoff, 4, "mip base %d\n",
surf->ss4.min_lod);
+
+ dri_bo_unmap(surf_bo);
+ }
+}
+
+static void dump_sf_viewport_state(struct brw_context *brw)
+{
+ const char *name = "SF VP";
+ struct brw_sf_viewport *vp;
+ uint32_t vp_off;
+
+ if (brw->sf.vp_bo == NULL)
+ return;
+
+ dri_bo_map(brw->sf.vp_bo, GL_FALSE);
+
+ vp = brw->sf.vp_bo->virtual;
+ vp_off = brw->sf.vp_bo->offset;
+
+ state_out(name, vp, vp_off, 0, "m00 = %f\n", vp->viewport.m00);
+ state_out(name, vp, vp_off, 1, "m11 = %f\n", vp->viewport.m11);
+ state_out(name, vp, vp_off, 2, "m22 = %f\n", vp->viewport.m22);
+ state_out(name, vp, vp_off, 3, "m30 = %f\n", vp->viewport.m30);
+ state_out(name, vp, vp_off, 4, "m31 = %f\n", vp->viewport.m31);
+ state_out(name, vp, vp_off, 5, "m32 = %f\n", vp->viewport.m32);
+
+ state_out(name, vp, vp_off, 6, "top left = %d,%d\n",
+ vp->scissor.xmin, vp->scissor.ymin);
+ state_out(name, vp, vp_off, 7, "bottom right = %d,%d\n",
+ vp->scissor.xmax, vp->scissor.ymax);
+
+ dri_bo_unmap(brw->sf.vp_bo);
+}
+
+static void brw_debug_prog(const char *name, dri_bo *prog)
+{
+ unsigned int i;
+ uint32_t *data;
+
+ if (prog == NULL)
+ return;
+
+ dri_bo_map(prog, GL_FALSE);
+
+ data = prog->virtual;
+
+ for (i = 0; i < prog->size / 4 / 4; i++) {
+ fprintf(stderr, "%8s: 0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
+ name, (unsigned int)prog->offset + i * 4 * 4,
+ data[i * 4], data[i * 4 + 1], data[i * 4 + 2], data[i * 4 + 3]);
}
+
+ dri_bo_unmap(prog);
}
+
/**
* Print additional debug information associated with the batchbuffer
* when DEBUG_BATCH is set.
@@ -105,27 +162,20 @@ static void dump_wm_surface_state(struct brw_context *brw, dri_bo *ss_buffer)
void brw_debug_batch(struct intel_context *intel)
{
struct brw_context *brw = brw_context(&intel->ctx);
- dri_bo *ss_buffer, *gs_buffer;
- ss_buffer = brw->pool[BRW_SS_POOL].buffer;
- gs_buffer = brw->pool[BRW_GS_POOL].buffer;
+ state_struct_out("WM bind", brw->wm.bind_bo, 4 * brw->wm.nr_surfaces);
+ dump_wm_surface_state(brw);
- dri_bo_map(ss_buffer, GL_FALSE);
- dri_bo_map(gs_buffer, GL_FALSE);
+ state_struct_out("VS", brw->vs.state_bo, sizeof(struct brw_vs_unit_state));
+ brw_debug_prog("VS prog", brw->vs.prog_bo);
- state_struct_out("WM bind", ss_buffer, brw->wm.bind_ss_offset,
- 4 * brw->wm.nr_surfaces);
- dump_wm_surface_state(brw, ss_buffer);
+ state_struct_out("GS", brw->gs.state_bo, sizeof(struct brw_gs_unit_state));
+ brw_debug_prog("GS prog", brw->gs.prog_bo);
- state_struct_out("VS", gs_buffer, brw->vs.state_gs_offset,
- sizeof(struct brw_vs_unit_state));
- state_struct_out("SF", gs_buffer, brw->sf.state_gs_offset,
- sizeof(struct brw_sf_unit_state));
- state_struct_out("SF viewport", gs_buffer, brw->sf.state_gs_offset,
- sizeof(struct brw_sf_unit_state));
- state_struct_out("WM", gs_buffer, brw->wm.state_gs_offset,
- sizeof(struct brw_wm_unit_state));
+ state_struct_out("SF", brw->sf.state_bo, sizeof(struct brw_sf_unit_state));
+ dump_sf_viewport_state(brw);
+ brw_debug_prog("SF prog", brw->vs.prog_bo);
- dri_bo_unmap(gs_buffer);
- dri_bo_unmap(ss_buffer);
+ state_struct_out("WM", brw->sf.state_bo, sizeof(struct brw_wm_unit_state));
+ brw_debug_prog("WM prog", brw->vs.prog_bo);
}