*/
#include "main/mtypes.h"
+#include "intel_batchbuffer.h"
#include "brw_context.h"
#include "brw_defines.h"
-/**
- * Prints out a header, the contents, and the message associated with
- * the hardware state data given.
- *
- * \param name Name of the state object
- * \param data Pointer to the base of the state object
- * \param hw_offset Hardware offset of the base of the state data.
- * \param index Index of the DWORD being output.
- */
static void
-state_out(const char *name, void *data, uint32_t hw_offset, int index,
- char *fmt, ...)
-{
- va_list va;
+batch_out(struct brw_context *brw, const char *name, uint32_t offset,
+ int index, char *fmt, ...) PRINTFLIKE(5, 6);
- fprintf(stderr, "%8s: 0x%08x: 0x%08x: ",
- name, hw_offset + index * 4, ((uint32_t *)data)[index]);
- va_start(va, fmt);
- vfprintf(stderr, fmt, va);
- va_end(va);
-}
-
-/** Generic, undecoded state buffer debug printout */
static void
-state_struct_out(const char *name, drm_intel_bo *buffer, unsigned int state_size)
+batch_out(struct brw_context *brw, const char *name, uint32_t offset,
+ int index, char *fmt, ...)
{
- int i;
-
- if (buffer == NULL)
- return;
-
- drm_intel_bo_map(buffer, GL_FALSE);
- for (i = 0; i < state_size / 4; i++) {
- state_out(name, buffer->virtual, buffer->offset, i,
- "dword %d\n", i);
- }
- drm_intel_bo_unmap(buffer);
+ uint32_t *data = brw->batch.bo->virtual + offset;
+ va_list va;
+
+ fprintf(stderr, "0x%08x: 0x%08x: %8s: ",
+ offset + index * 4, data[index], name);
+ va_start(va, fmt);
+ vfprintf(stderr, fmt, va);
+ va_end(va);
}
static const char *
}
}
-static void dump_wm_surface_state(struct brw_context *brw)
+static void dump_vs_state(struct brw_context *brw, uint32_t offset)
{
- int i;
+ const char *name = "VS_STATE";
+ struct brw_vs_unit_state *vs = brw->batch.bo->virtual + offset;
+
+ batch_out(brw, name, offset, 0, "thread0\n");
+ batch_out(brw, name, offset, 1, "thread1\n");
+ batch_out(brw, name, offset, 2, "thread2\n");
+ batch_out(brw, name, offset, 3, "thread3\n");
+ batch_out(brw, name, offset, 4, "thread4: %d threads\n",
+ vs->thread4.max_threads + 1);
+ batch_out(brw, name, offset, 5, "vs5\n");
+ batch_out(brw, name, offset, 6, "vs6\n");
+}
- for (i = 0; i < brw->wm.nr_surfaces; i++) {
- drm_intel_bo *surf_bo = brw->wm.surf_bo[i];
- unsigned int surfoff;
- struct brw_surface_state *surf;
- char name[20];
+static void dump_gs_state(struct brw_context *brw, uint32_t offset)
+{
+ const char *name = "GS_STATE";
+ struct brw_gs_unit_state *gs = brw->batch.bo->virtual + offset;
+
+ batch_out(brw, name, offset, 0, "thread0\n");
+ batch_out(brw, name, offset, 1, "thread1\n");
+ batch_out(brw, name, offset, 2, "thread2\n");
+ batch_out(brw, name, offset, 3, "thread3\n");
+ batch_out(brw, name, offset, 4, "thread4: %d threads\n",
+ gs->thread4.max_threads + 1);
+ batch_out(brw, name, offset, 5, "vs5\n");
+ batch_out(brw, name, offset, 6, "vs6\n");
+}
- if (surf_bo == NULL) {
- fprintf(stderr, "WM SURF%d: NULL\n", i);
- continue;
- }
- drm_intel_bo_map(surf_bo, GL_FALSE);
- surfoff = surf_bo->offset + brw->wm.surf_offset[i];
- surf = (struct brw_surface_state *)(surf_bo->virtual + brw->wm.surf_offset[i]);
-
- sprintf(name, "WM SURF%d", i);
- state_out(name, surf, surfoff, 0, "%s %s\n",
- get_965_surfacetype(surf->ss0.surface_type),
- get_965_surface_format(surf->ss0.surface_format));
- 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, surf, surfoff, 3, "pitch %d, %stiled\n",
- surf->ss3.pitch + 1, surf->ss3.tiled_surface ? "" : "not ");
- state_out(name, surf, surfoff, 4, "mip base %d\n",
- surf->ss4.min_lod);
- state_out(name, surf, surfoff, 5, "x,y offset: %d,%d\n",
- surf->ss5.x_offset, surf->ss5.y_offset);
-
- drm_intel_bo_unmap(surf_bo);
- }
+static void dump_clip_state(struct brw_context *brw, uint32_t offset)
+{
+ const char *name = "CLIP_STATE";
+ struct brw_clip_unit_state *clip = brw->batch.bo->virtual + offset;
+
+ batch_out(brw, name, offset, 0, "thread0\n");
+ batch_out(brw, name, offset, 1, "thread1\n");
+ batch_out(brw, name, offset, 2, "thread2\n");
+ batch_out(brw, name, offset, 3, "thread3\n");
+ batch_out(brw, name, offset, 4, "thread4: %d threads\n",
+ clip->thread4.max_threads + 1);
+ batch_out(brw, name, offset, 5, "clip5\n");
+ batch_out(brw, name, offset, 6, "clip6\n");
+ batch_out(brw, name, offset, 7, "vp xmin %f\n", clip->viewport_xmin);
+ batch_out(brw, name, offset, 8, "vp xmax %f\n", clip->viewport_xmax);
+ batch_out(brw, name, offset, 9, "vp ymin %f\n", clip->viewport_ymin);
+ batch_out(brw, name, offset, 10, "vp ymax %f\n", clip->viewport_ymax);
}
+static void dump_sf_state(struct brw_context *brw, uint32_t offset)
+{
+ const char *name = "SF_STATE";
+ struct brw_sf_unit_state *sf = brw->batch.bo->virtual + offset;
+
+ batch_out(brw, name, offset, 0, "thread0\n");
+ batch_out(brw, name, offset, 1, "thread1\n");
+ batch_out(brw, name, offset, 2, "thread2\n");
+ batch_out(brw, name, offset, 3, "thread3\n");
+ batch_out(brw, name, offset, 4, "thread4: %d threads\n",
+ sf->thread4.max_threads + 1);
+ batch_out(brw, name, offset, 5, "sf5: viewport offset\n");
+ batch_out(brw, name, offset, 6, "sf6\n");
+ batch_out(brw, name, offset, 7, "sf7\n");
+}
-static void dump_wm_sampler_state(struct brw_context *brw)
+static void dump_wm_state(struct brw_context *brw, uint32_t offset)
{
- struct gl_context *ctx = &brw->intel.ctx;
- int i;
+ const char *name = "WM_STATE";
+ struct brw_wm_unit_state *wm = brw->batch.bo->virtual + offset;
+
+ batch_out(brw, name, offset, 0, "thread0\n");
+ batch_out(brw, name, offset, 1, "thread1\n");
+ batch_out(brw, name, offset, 2, "thread2\n");
+ batch_out(brw, name, offset, 3, "thread3\n");
+ batch_out(brw, name, offset, 4, "wm4\n");
+ batch_out(brw, name, offset, 5, "wm5: %s%s%s%s%s%s, %d threads\n",
+ wm->wm5.enable_8_pix ? "8pix" : "",
+ wm->wm5.enable_16_pix ? "16pix" : "",
+ wm->wm5.program_uses_depth ? ", uses depth" : "",
+ wm->wm5.program_computes_depth ? ", computes depth" : "",
+ wm->wm5.program_uses_killpixel ? ", kills" : "",
+ wm->wm5.thread_dispatch_enable ? "" : ", no dispatch",
+ wm->wm5.max_threads + 1);
+ batch_out(brw, name, offset, 6, "depth offset constant %f\n",
+ wm->global_depth_offset_constant);
+ batch_out(brw, name, offset, 7, "depth offset scale %f\n",
+ wm->global_depth_offset_scale);
+ batch_out(brw, name, offset, 8, "wm8: kernel 1 (gen5+)\n");
+ batch_out(brw, name, offset, 9, "wm9: kernel 2 (gen5+)\n");
+ batch_out(brw, name, offset, 10, "wm10: kernel 3 (gen5+)\n");
+}
- if (!brw->wm.sampler_bo) {
- fprintf(stderr, "WM_SAMPLER: NULL\n");
- return;
+static void dump_surface_state(struct brw_context *brw, uint32_t offset)
+{
+ const char *name = "SURF";
+ uint32_t *surf = brw->batch.bo->virtual + offset;
+
+ batch_out(brw, name, offset, 0, "%s %s\n",
+ get_965_surfacetype(GET_FIELD(surf[0], BRW_SURFACE_TYPE)),
+ get_965_surface_format(GET_FIELD(surf[0], BRW_SURFACE_FORMAT)));
+ batch_out(brw, name, offset, 1, "offset\n");
+ batch_out(brw, name, offset, 2, "%dx%d size, %d mips\n",
+ GET_FIELD(surf[2], BRW_SURFACE_WIDTH) + 1,
+ GET_FIELD(surf[2], BRW_SURFACE_HEIGHT) + 1,
+ GET_FIELD(surf[2], BRW_SURFACE_LOD));
+ batch_out(brw, name, offset, 3, "pitch %d, %s tiled\n",
+ GET_FIELD(surf[3], BRW_SURFACE_PITCH) + 1,
+ (surf[3] & BRW_SURFACE_TILED) ?
+ ((surf[3] & BRW_SURFACE_TILED_Y) ? "Y" : "X") : "not");
+ batch_out(brw, name, offset, 4, "mip base %d\n",
+ GET_FIELD(surf[4], BRW_SURFACE_MIN_LOD));
+ batch_out(brw, name, offset, 5, "x,y offset: %d,%d\n",
+ GET_FIELD(surf[5], BRW_SURFACE_X_OFFSET),
+ GET_FIELD(surf[5], BRW_SURFACE_Y_OFFSET));
+}
+
+static void dump_gen7_surface_state(struct brw_context *brw, uint32_t offset)
+{
+ const char *name = "SURF";
+ uint32_t *surf = brw->batch.bo->virtual + offset;
+
+ batch_out(brw, name, offset, 0, "%s %s\n",
+ get_965_surfacetype(GET_FIELD(surf[0], BRW_SURFACE_TYPE)),
+ get_965_surface_format(GET_FIELD(surf[0], BRW_SURFACE_FORMAT)));
+ batch_out(brw, name, offset, 1, "offset\n");
+ batch_out(brw, name, offset, 2, "%dx%d size, %d mips\n",
+ GET_FIELD(surf[2], GEN7_SURFACE_WIDTH) + 1,
+ GET_FIELD(surf[2], GEN7_SURFACE_HEIGHT) + 1,
+ surf[5] & INTEL_MASK(3, 0));
+ batch_out(brw, name, offset, 3, "pitch %d, %stiled\n",
+ (surf[3] & INTEL_MASK(17, 0)) + 1,
+ (surf[0] & (1 << 14)) ? "" : "not ");
+ batch_out(brw, name, offset, 4, "mip base %d\n",
+ GET_FIELD(surf[5], GEN7_SURFACE_MIN_LOD));
+ batch_out(brw, name, offset, 5, "x,y offset: %d,%d\n",
+ GET_FIELD(surf[5], BRW_SURFACE_X_OFFSET),
+ GET_FIELD(surf[5], BRW_SURFACE_Y_OFFSET));
+}
+
+static void
+dump_sdc(struct brw_context *brw, uint32_t offset)
+{
+ const char *name = "SDC";
+
+ if (brw->gen >= 5 && brw->gen <= 6) {
+ struct gen5_sampler_default_color *sdc = (brw->batch.bo->virtual +
+ offset);
+ batch_out(brw, name, offset, 0, "unorm rgba\n");
+ batch_out(brw, name, offset, 1, "r %f\n", sdc->f[0]);
+ batch_out(brw, name, offset, 2, "b %f\n", sdc->f[1]);
+ batch_out(brw, name, offset, 3, "g %f\n", sdc->f[2]);
+ batch_out(brw, name, offset, 4, "a %f\n", sdc->f[3]);
+ batch_out(brw, name, offset, 5, "half float rg\n");
+ batch_out(brw, name, offset, 6, "half float ba\n");
+ batch_out(brw, name, offset, 7, "u16 rg\n");
+ batch_out(brw, name, offset, 8, "u16 ba\n");
+ batch_out(brw, name, offset, 9, "s16 rg\n");
+ batch_out(brw, name, offset, 10, "s16 ba\n");
+ batch_out(brw, name, offset, 11, "s8 rgba\n");
+ } else {
+ struct brw_sampler_default_color *sdc = (brw->batch.bo->virtual +
+ offset);
+ batch_out(brw, name, offset, 0, "r %f\n", sdc->color[0]);
+ batch_out(brw, name, offset, 1, "g %f\n", sdc->color[1]);
+ batch_out(brw, name, offset, 2, "b %f\n", sdc->color[2]);
+ batch_out(brw, name, offset, 3, "a %f\n", sdc->color[3]);
}
+}
- drm_intel_bo_map(brw->wm.sampler_bo, GL_FALSE);
- for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
- unsigned int offset;
- struct brw_sampler_state *samp;
- char name[20];
+static void dump_sampler_state(struct brw_context *brw,
+ uint32_t offset, uint32_t size)
+{
+ int i;
+ struct brw_sampler_state *samp = brw->batch.bo->virtual + offset;
- if (!ctx->Texture.Unit[i]._ReallyEnabled) {
- fprintf(stderr, "WM SAMP%d: disabled\n", i);
- continue;
- }
+ assert(brw->gen < 7);
- offset = brw->wm.sampler_bo->offset +
- i * sizeof(struct brw_sampler_state);
- samp = (struct brw_sampler_state *)(brw->wm.sampler_bo->virtual +
- i * sizeof(struct brw_sampler_state));
+ for (i = 0; i < size / sizeof(*samp); i++) {
+ char name[20];
sprintf(name, "WM SAMP%d", i);
- state_out(name, samp, offset, 0, "filtering\n");
- state_out(name, samp, offset, 1, "wrapping, lod\n");
- state_out(name, samp, offset, 2, "default color pointer\n");
- state_out(name, samp, offset, 3, "chroma key, aniso\n");
+ batch_out(brw, name, offset, 0, "filtering\n");
+ batch_out(brw, name, offset, 1, "wrapping, lod\n");
+ batch_out(brw, name, offset, 2, "default color pointer\n");
+ batch_out(brw, name, offset, 3, "chroma key, aniso\n");
+
+ samp++;
+ offset += sizeof(*samp);
}
- drm_intel_bo_unmap(brw->wm.sampler_bo);
}
-static void dump_sf_viewport_state(struct brw_context *brw)
+static void dump_gen7_sampler_state(struct brw_context *brw,
+ uint32_t offset, uint32_t size)
{
- const char *name = "SF VP";
- struct brw_sf_viewport *vp;
- uint32_t vp_off;
+ struct gen7_sampler_state *samp = brw->batch.bo->virtual + offset;
+ int i;
- if (brw->sf.vp_bo == NULL)
- return;
+ assert(brw->gen >= 7);
- drm_intel_bo_map(brw->sf.vp_bo, GL_FALSE);
+ for (i = 0; i < size / sizeof(*samp); i++) {
+ char name[20];
- vp = brw->sf.vp_bo->virtual;
- vp_off = brw->sf.vp_bo->offset;
+ sprintf(name, "WM SAMP%d", i);
+ batch_out(brw, name, offset, 0, "filtering\n");
+ batch_out(brw, name, offset, 1, "wrapping, lod\n");
+ batch_out(brw, name, offset, 2, "default color pointer\n");
+ batch_out(brw, name, offset, 3, "chroma key, aniso\n");
- 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);
+ samp++;
+ offset += sizeof(*samp);
+ }
+}
- state_out(name, vp, vp_off, 6, "top left = %d,%d\n",
+
+static void dump_sf_viewport_state(struct brw_context *brw,
+ uint32_t offset)
+{
+ const char *name = "SF VP";
+ struct brw_sf_viewport *vp = brw->batch.bo->virtual + offset;
+
+ assert(brw->gen < 7);
+
+ batch_out(brw, name, offset, 0, "m00 = %f\n", vp->viewport.m00);
+ batch_out(brw, name, offset, 1, "m11 = %f\n", vp->viewport.m11);
+ batch_out(brw, name, offset, 2, "m22 = %f\n", vp->viewport.m22);
+ batch_out(brw, name, offset, 3, "m30 = %f\n", vp->viewport.m30);
+ batch_out(brw, name, offset, 4, "m31 = %f\n", vp->viewport.m31);
+ batch_out(brw, name, offset, 5, "m32 = %f\n", vp->viewport.m32);
+
+ batch_out(brw, name, offset, 6, "top left = %d,%d\n",
vp->scissor.xmin, vp->scissor.ymin);
- state_out(name, vp, vp_off, 7, "bottom right = %d,%d\n",
+ batch_out(brw, name, offset, 7, "bottom right = %d,%d\n",
vp->scissor.xmax, vp->scissor.ymax);
-
- drm_intel_bo_unmap(brw->sf.vp_bo);
}
-static void dump_clip_viewport_state(struct brw_context *brw)
+static void dump_clip_viewport_state(struct brw_context *brw,
+ uint32_t offset)
{
const char *name = "CLIP VP";
- struct brw_clipper_viewport *vp;
- uint32_t vp_off;
+ struct brw_clipper_viewport *vp = brw->batch.bo->virtual + offset;
- if (brw->clip.vp_bo == NULL)
- return;
+ assert(brw->gen < 7);
- drm_intel_bo_map(brw->clip.vp_bo, GL_FALSE);
-
- vp = brw->clip.vp_bo->virtual;
- vp_off = brw->clip.vp_bo->offset;
+ batch_out(brw, name, offset, 0, "xmin = %f\n", vp->xmin);
+ batch_out(brw, name, offset, 1, "xmax = %f\n", vp->xmax);
+ batch_out(brw, name, offset, 2, "ymin = %f\n", vp->ymin);
+ batch_out(brw, name, offset, 3, "ymax = %f\n", vp->ymax);
+}
- state_out(name, vp, vp_off, 0, "xmin = %f\n", vp->xmin);
- state_out(name, vp, vp_off, 1, "xmax = %f\n", vp->xmax);
- state_out(name, vp, vp_off, 2, "ymin = %f\n", vp->ymin);
- state_out(name, vp, vp_off, 3, "ymax = %f\n", vp->ymax);
- drm_intel_bo_unmap(brw->clip.vp_bo);
+static void dump_sf_clip_viewport_state(struct brw_context *brw,
+ uint32_t offset)
+{
+ const char *name = "SF_CLIP VP";
+ struct gen7_sf_clip_viewport *vp = brw->batch.bo->virtual + offset;
+
+ assert(brw->gen >= 7);
+
+ batch_out(brw, name, offset, 0, "m00 = %f\n", vp->viewport.m00);
+ batch_out(brw, name, offset, 1, "m11 = %f\n", vp->viewport.m11);
+ batch_out(brw, name, offset, 2, "m22 = %f\n", vp->viewport.m22);
+ batch_out(brw, name, offset, 3, "m30 = %f\n", vp->viewport.m30);
+ batch_out(brw, name, offset, 4, "m31 = %f\n", vp->viewport.m31);
+ batch_out(brw, name, offset, 5, "m32 = %f\n", vp->viewport.m32);
+ batch_out(brw, name, offset, 6, "guardband xmin = %f\n", vp->guardband.xmin);
+ batch_out(brw, name, offset, 7, "guardband xmax = %f\n", vp->guardband.xmax);
+ batch_out(brw, name, offset, 8, "guardband ymin = %f\n", vp->guardband.ymin);
+ batch_out(brw, name, offset, 9, "guardband ymax = %f\n", vp->guardband.ymax);
}
-static void dump_cc_viewport_state(struct brw_context *brw)
+
+static void dump_cc_viewport_state(struct brw_context *brw, uint32_t offset)
{
const char *name = "CC VP";
- struct brw_cc_viewport *vp;
- uint32_t vp_off;
+ struct brw_cc_viewport *vp = brw->batch.bo->virtual + offset;
- if (brw->cc.vp_bo == NULL)
- return;
+ batch_out(brw, name, offset, 0, "min_depth = %f\n", vp->min_depth);
+ batch_out(brw, name, offset, 1, "max_depth = %f\n", vp->max_depth);
+}
- drm_intel_bo_map(brw->cc.vp_bo, GL_FALSE);
+static void dump_depth_stencil_state(struct brw_context *brw, uint32_t offset)
+{
+ const char *name = "D_S";
+ struct gen6_depth_stencil_state *ds = brw->batch.bo->virtual + offset;
+
+ batch_out(brw, name, offset, 0,
+ "stencil %sable, func %d, write %sable\n",
+ ds->ds0.stencil_enable ? "en" : "dis",
+ ds->ds0.stencil_func,
+ ds->ds0.stencil_write_enable ? "en" : "dis");
+ batch_out(brw, name, offset, 1,
+ "stencil test mask 0x%x, write mask 0x%x\n",
+ ds->ds1.stencil_test_mask, ds->ds1.stencil_write_mask);
+ batch_out(brw, name, offset, 2,
+ "depth test %sable, func %d, write %sable\n",
+ ds->ds2.depth_test_enable ? "en" : "dis",
+ ds->ds2.depth_test_func,
+ ds->ds2.depth_write_enable ? "en" : "dis");
+}
- vp = brw->cc.vp_bo->virtual;
- vp_off = brw->cc.vp_bo->offset;
+static void dump_cc_state_gen4(struct brw_context *brw, uint32_t offset)
+{
+ const char *name = "CC";
- state_out(name, vp, vp_off, 0, "min_depth = %f\n", vp->min_depth);
- state_out(name, vp, vp_off, 1, "max_depth = %f\n", vp->max_depth);
- drm_intel_bo_unmap(brw->cc.vp_bo);
+ batch_out(brw, name, offset, 0, "cc0\n");
+ batch_out(brw, name, offset, 1, "cc1\n");
+ batch_out(brw, name, offset, 2, "cc2\n");
+ batch_out(brw, name, offset, 3, "cc3\n");
+ batch_out(brw, name, offset, 4, "cc4: viewport offset\n");
+ batch_out(brw, name, offset, 5, "cc5\n");
+ batch_out(brw, name, offset, 6, "cc6\n");
+ batch_out(brw, name, offset, 7, "cc7\n");
}
-static void dump_depth_stencil_state(struct brw_context *brw)
+static void dump_cc_state_gen6(struct brw_context *brw, uint32_t offset)
{
- const char *name = "DEPTH STENCIL";
- struct gen6_depth_stencil_state *ds;
- uint32_t ds_off;
-
- if (brw->cc.depth_stencil_state_bo == NULL)
- return;
-
- drm_intel_bo_map(brw->cc.depth_stencil_state_bo, GL_FALSE);
-
- ds = brw->cc.depth_stencil_state_bo->virtual;
- ds_off = brw->cc.depth_stencil_state_bo->offset;
-
- state_out(name, ds, ds_off, 0, "stencil %sable, func %d, write %sable\n",
- ds->ds0.stencil_enable ? "en" : "dis",
- ds->ds0.stencil_func,
- ds->ds0.stencil_write_enable ? "en" : "dis");
- state_out(name, ds, ds_off, 1, "stencil test mask 0x%x, write mask 0x%x\n",
- ds->ds1.stencil_test_mask, ds->ds1.stencil_write_mask);
- state_out(name, ds, ds_off, 2, "depth test %sable, func %d, write %sable\n",
- ds->ds2.depth_test_enable ? "en" : "dis",
- ds->ds2.depth_test_func,
- ds->ds2.depth_write_enable ? "en" : "dis");
- drm_intel_bo_unmap(brw->cc.depth_stencil_state_bo);
+ const char *name = "CC";
+ struct gen6_color_calc_state *cc = brw->batch.bo->virtual + offset;
+
+ batch_out(brw, name, offset, 0,
+ "alpha test format %s, round disable %d, stencil ref %d, "
+ "bf stencil ref %d\n",
+ cc->cc0.alpha_test_format ? "FLOAT32" : "UNORM8",
+ cc->cc0.round_disable,
+ cc->cc0.stencil_ref,
+ cc->cc0.bf_stencil_ref);
+ batch_out(brw, name, offset, 1, "\n");
+ batch_out(brw, name, offset, 2, "constant red %f\n", cc->constant_r);
+ batch_out(brw, name, offset, 3, "constant green %f\n", cc->constant_g);
+ batch_out(brw, name, offset, 4, "constant blue %f\n", cc->constant_b);
+ batch_out(brw, name, offset, 5, "constant alpha %f\n", cc->constant_a);
}
-static void dump_cc_state(struct brw_context *brw)
+static void dump_blend_state(struct brw_context *brw, uint32_t offset)
{
- const char *name = "CC";
- struct gen6_color_calc_state *cc;
- uint32_t cc_off;
-
- if (brw->cc.state_bo == NULL)
- return;
-
- drm_intel_bo_map(brw->cc.state_bo, GL_FALSE);
- cc = brw->cc.state_bo->virtual;
- cc_off = brw->cc.state_bo->offset;
-
- state_out(name, cc, cc_off, 0, "alpha test format %s, round disable %d, stencil ref %d,"
- "bf stencil ref %d\n",
- cc->cc0.alpha_test_format ? "FLOAT32" : "UNORM8",
- cc->cc0.round_disable,
- cc->cc0.stencil_ref,
- cc->cc0.bf_stencil_ref);
- state_out(name, cc, cc_off, 1, "\n");
- state_out(name, cc, cc_off, 2, "constant red %f\n", cc->constant_r);
- state_out(name, cc, cc_off, 3, "constant green %f\n", cc->constant_g);
- state_out(name, cc, cc_off, 4, "constant blue %f\n", cc->constant_b);
- state_out(name, cc, cc_off, 5, "constant alpha %f\n", cc->constant_a);
-
- drm_intel_bo_unmap(brw->cc.state_bo);
+ const char *name = "BLEND";
+ batch_out(brw, name, offset, 0, "\n");
+ batch_out(brw, name, offset, 1, "\n");
}
-static void dump_blend_state(struct brw_context *brw)
+static void
+dump_scissor(struct brw_context *brw, uint32_t offset)
{
- const char *name = "BLEND";
- struct gen6_blend_state *blend;
- uint32_t blend_off;
+ const char *name = "SCISSOR";
+ struct gen6_scissor_rect *scissor = brw->batch.bo->virtual + offset;
- if (brw->cc.blend_state_bo == NULL)
- return;
+ batch_out(brw, name, offset, 0, "xmin %d, ymin %d\n",
+ scissor->xmin, scissor->ymin);
+ batch_out(brw, name, offset, 1, "xmax %d, ymax %d\n",
+ scissor->xmax, scissor->ymax);
+}
- drm_intel_bo_map(brw->cc.blend_state_bo, GL_FALSE);
+static void
+dump_vs_constants(struct brw_context *brw, uint32_t offset, uint32_t size)
+{
+ const char *name = "VS_CONST";
+ uint32_t *as_uint = brw->batch.bo->virtual + offset;
+ float *as_float = brw->batch.bo->virtual + offset;
+ int i;
- blend = brw->cc.blend_state_bo->virtual;
- blend_off = brw->cc.blend_state_bo->offset;
+ for (i = 0; i < size / 4; i += 4) {
+ batch_out(brw, name, offset, i, "%3d: (% f % f % f % f) (0x%08x 0x%08x 0x%08x 0x%08x)\n",
+ i / 4,
+ as_float[i], as_float[i + 1], as_float[i + 2], as_float[i + 3],
+ as_uint[i], as_uint[i + 1], as_uint[i + 2], as_uint[i + 3]);
+ }
+}
- state_out(name, blend, blend_off, 0, "\n");
- state_out(name, blend, blend_off, 1, "\n");
+static void
+dump_wm_constants(struct brw_context *brw, uint32_t offset, uint32_t size)
+{
+ const char *name = "WM_CONST";
+ uint32_t *as_uint = brw->batch.bo->virtual + offset;
+ float *as_float = brw->batch.bo->virtual + offset;
+ int i;
+
+ for (i = 0; i < size / 4; i += 4) {
+ batch_out(brw, name, offset, i, "%3d: (% f % f % f % f) (0x%08x 0x%08x 0x%08x 0x%08x)\n",
+ i / 4,
+ as_float[i], as_float[i + 1], as_float[i + 2], as_float[i + 3],
+ as_uint[i], as_uint[i + 1], as_uint[i + 2], as_uint[i + 3]);
+ }
+}
+
+static void dump_binding_table(struct brw_context *brw, uint32_t offset,
+ uint32_t size)
+{
+ char name[20];
+ int i;
+ uint32_t *data = brw->batch.bo->virtual + offset;
- drm_intel_bo_unmap(brw->cc.blend_state_bo);
+ for (i = 0; i < size / 4; i++) {
+ if (data[i] == 0)
+ continue;
+ sprintf(name, "BIND%d", i);
+ batch_out(brw, name, offset, i, "surface state address\n");
+ }
}
-static void brw_debug_prog(const char *name, drm_intel_bo *prog)
+static void
+dump_prog_cache(struct brw_context *brw)
{
- unsigned int i;
+ struct brw_cache *cache = &brw->cache;
+ unsigned int b, i;
uint32_t *data;
- if (prog == NULL)
- return;
+ drm_intel_bo_map(brw->cache.bo, false);
+
+ for (b = 0; b < cache->size; b++) {
+ struct brw_cache_item *item;
+
+ for (item = cache->items[b]; item; item = item->next) {
+ const char *name;
+ uint32_t offset = item->offset;
+
+ data = brw->cache.bo->virtual + item->offset;
+
+ switch (item->cache_id) {
+ case BRW_VS_PROG:
+ name = "VS kernel";
+ break;
+ case BRW_GS_PROG:
+ name = "GS kernel";
+ break;
+ case BRW_CLIP_PROG:
+ name = "CLIP kernel";
+ break;
+ case BRW_SF_PROG:
+ name = "SF kernel";
+ break;
+ case BRW_WM_PROG:
+ name = "WM kernel";
+ break;
+ default:
+ name = "unknown";
+ break;
+ }
+
+ for (i = 0; i < item->size / 4 / 4; i++) {
+ fprintf(stderr, "0x%08x: %8s: 0x%08x 0x%08x 0x%08x 0x%08x ",
+ offset + i * 4 * 4,
+ name,
+ data[i * 4], data[i * 4 + 1], data[i * 4 + 2], data[i * 4 + 3]);
+
+ brw_disasm(stderr, (void *)(data + i * 4), brw->gen);
+ }
+ }
+ }
+
+ drm_intel_bo_unmap(brw->cache.bo);
+}
- drm_intel_bo_map(prog, GL_FALSE);
+static void
+dump_state_batch(struct brw_context *brw)
+{
+ int i;
- data = prog->virtual;
+ for (i = 0; i < brw->state_batch_count; i++) {
+ uint32_t offset = brw->state_batch_list[i].offset;
+ uint32_t size = brw->state_batch_list[i].size;
- 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]);
- /* Stop at the end of the program. It'd be nice to keep track of the actual
- * intended program size instead of guessing like this.
- */
- if (data[i * 4 + 0] == 0 &&
- data[i * 4 + 1] == 0 &&
- data[i * 4 + 2] == 0 &&
- data[i * 4 + 3] == 0)
+ switch (brw->state_batch_list[i].type) {
+ case AUB_TRACE_VS_STATE:
+ dump_vs_state(brw, offset);
+ break;
+ case AUB_TRACE_GS_STATE:
+ dump_gs_state(brw, offset);
+ break;
+ case AUB_TRACE_CLIP_STATE:
+ dump_clip_state(brw, offset);
+ break;
+ case AUB_TRACE_SF_STATE:
+ dump_sf_state(brw, offset);
+ break;
+ case AUB_TRACE_WM_STATE:
+ dump_wm_state(brw, offset);
+ break;
+ case AUB_TRACE_CLIP_VP_STATE:
+ dump_clip_viewport_state(brw, offset);
+ break;
+ case AUB_TRACE_SF_VP_STATE:
+ if (brw->gen >= 7) {
+ dump_sf_clip_viewport_state(brw, offset);
+ } else {
+ dump_sf_viewport_state(brw, offset);
+ }
+ break;
+ case AUB_TRACE_CC_VP_STATE:
+ dump_cc_viewport_state(brw, offset);
+ break;
+ case AUB_TRACE_DEPTH_STENCIL_STATE:
+ dump_depth_stencil_state(brw, offset);
+ break;
+ case AUB_TRACE_CC_STATE:
+ if (brw->gen >= 6)
+ dump_cc_state_gen6(brw, offset);
+ else
+ dump_cc_state_gen4(brw, offset);
+ break;
+ case AUB_TRACE_BLEND_STATE:
+ dump_blend_state(brw, offset);
+ break;
+ case AUB_TRACE_BINDING_TABLE:
+ dump_binding_table(brw, offset, size);
+ break;
+ case AUB_TRACE_SURFACE_STATE:
+ if (brw->gen < 7) {
+ dump_surface_state(brw, offset);
+ } else {
+ dump_gen7_surface_state(brw, offset);
+ }
break;
+ case AUB_TRACE_SAMPLER_STATE:
+ if (brw->gen < 7) {
+ dump_sampler_state(brw, offset, size);
+ } else {
+ dump_gen7_sampler_state(brw, offset, size);
+ }
+ break;
+ case AUB_TRACE_SAMPLER_DEFAULT_COLOR:
+ dump_sdc(brw, offset);
+ break;
+ case AUB_TRACE_SCISSOR_STATE:
+ dump_scissor(brw, offset);
+ break;
+ case AUB_TRACE_VS_CONSTANTS:
+ dump_vs_constants(brw, offset, size);
+ break;
+ case AUB_TRACE_WM_CONSTANTS:
+ dump_wm_constants(brw, offset, size);
+ break;
+ default:
+ break;
+ }
}
-
- drm_intel_bo_unmap(prog);
}
-
/**
* Print additional debug information associated with the batchbuffer
* when DEBUG_BATCH is set.
* The buffer offsets printed rely on the buffer containing the last offset
* it was validated at.
*/
-void brw_debug_batch(struct intel_context *intel)
+void brw_debug_batch(struct brw_context *brw)
{
- struct brw_context *brw = brw_context(&intel->ctx);
-
- state_struct_out("WM bind", brw->wm.bind_bo, 4 * brw->wm.nr_surfaces);
- dump_wm_surface_state(brw);
- dump_wm_sampler_state(brw);
-
- if (intel->gen < 6)
- state_struct_out("VS", brw->vs.state_bo, sizeof(struct brw_vs_unit_state));
- brw_debug_prog("VS prog", brw->vs.prog_bo);
+ drm_intel_bo_map(brw->batch.bo, false);
+ dump_state_batch(brw);
+ drm_intel_bo_unmap(brw->batch.bo);
- if (intel->gen < 6)
- state_struct_out("GS", brw->gs.state_bo, sizeof(struct brw_gs_unit_state));
- brw_debug_prog("GS prog", brw->gs.prog_bo);
-
- if (intel->gen < 6) {
- state_struct_out("SF", brw->sf.state_bo, sizeof(struct brw_sf_unit_state));
- brw_debug_prog("SF prog", brw->sf.prog_bo);
- }
- dump_sf_viewport_state(brw);
-
- if (intel->gen < 6)
- state_struct_out("WM", brw->wm.state_bo, sizeof(struct brw_wm_unit_state));
- brw_debug_prog("WM prog", brw->wm.prog_bo);
-
- if (intel->gen >= 6) {
- dump_cc_viewport_state(brw);
- dump_clip_viewport_state(brw);
- dump_depth_stencil_state(brw);
- dump_cc_state(brw);
- dump_blend_state(brw);
- }
+ if (0)
+ dump_prog_cache(brw);
}