glNormal3f(0.0, 0.0, -1.0);
+#if 0
/* draw back face */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++) {
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
}
glEnd();
+#endif
}
glCallList(gear1);
glPopMatrix();
+#if 0
glPushMatrix();
glTranslatef(3.1, -2.0, 0.0);
glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
glCallList(gear3);
glPopMatrix();
+#endif
glPopMatrix();
Frames++;
+ if (Frames == 2)
+ exit(0);
+
{
GLint t = glutGet(GLUT_ELAPSED_TIME);
if (t - T0 >= 5000) {
brw_screen_texture.c \
brw_screen_surface.c \
brw_batchbuffer.c \
+ brw_winsys_debug.c \
intel_decode.c
include ../../Makefile.template
#include "util/u_memory.h"
#include "brw_batchbuffer.h"
-//#include "brw_decode.h"
#include "brw_reg.h"
#include "brw_winsys.h"
#include "brw_debug.h"
#include "brw_structs.h"
-#include "intel_decode.h"
#define ALWAYS_EMIT_MI_FLUSH 1
*/
int brw_upload_cs_urb_state(struct brw_context *brw);
-/* brw_disasm.c */
-int brw_disasm_insn (FILE *file, const struct brw_instruction *inst);
-int brw_disasm (FILE *file,
- const struct brw_instruction *inst,
- unsigned count);
/*======================================================================
* Inline conversion functions. These are better-typed than the
#include <unistd.h>
#include <stdarg.h>
-#include "brw_context.h"
+#include "brw_disasm.h"
+#include "brw_structs.h"
+#include "brw_reg.h"
#include "brw_defines.h"
struct {
#include "brw_defines.h"
#include "brw_eu.h"
#include "brw_debug.h"
+#include "brw_disasm.h"
{ NULL, 0 }
};
+static const struct debug_named_value dump_names[] = {
+ { "asm", DUMP_ASM},
+ { "state", DUMP_STATE},
+ { "batch", DUMP_BATCH},
+ { NULL, 0 }
+};
+
int BRW_DEBUG = 0;
+int BRW_DUMP = 0;
+
#endif
BRW_DEBUG = debug_get_flags_option("BRW_DEBUG", debug_names, 0);
BRW_DEBUG |= debug_get_flags_option("INTEL_DEBUG", debug_names, 0);
BRW_DEBUG |= DEBUG_STATS | DEBUG_MIN_URB | DEBUG_WM;
+
+ BRW_DUMP = debug_get_flags_option("BRW_DUMP", dump_names, 0);
#endif
memset(&chipset, 0, sizeof chipset);
#include "brw_context.h"
#include "brw_vs.h"
#include "brw_debug.h"
+#include "brw_disasm.h"
/* Choose one of the 4 vec4's which can be packed into each 16-wide reg.
*/
};
+
/* Relocations to be applied with subdata in a call to sws->bo_subdata, below.
*
* Effectively this encodes:
struct brw_winsys_buffer *buffer);
+/*************************************************************************
+ * Cooperative dumping between winsys and driver. TODO: make this
+ * driver-only by wrapping calls to winsys->bo_subdata().
+ */
+
+#ifdef DEBUG
+extern int BRW_DUMP;
+#else
+#define BRW_DUMP 0
+#endif
+
+#define DUMP_ASM 0x1
+#define DUMP_STATE 0x2
+#define DUMP_BATCH 0x4
+
+void brw_dump_data( unsigned pci_id,
+ enum brw_buffer_data_type data_type,
+ unsigned offset,
+ const void *data,
+ size_t size );
#endif
--- /dev/null
+#include "brw_winsys.h"
+#include "brw_disasm.h"
+#include "brw_structs_dump.h"
+#include "brw_structs.h"
+#include "intel_decode.h"
+
+
+void brw_dump_data( unsigned pci_id,
+ enum brw_buffer_data_type data_type,
+ unsigned offset,
+ const void *data,
+ size_t size )
+{
+ if (BRW_DUMP & DUMP_ASM) {
+ switch (data_type) {
+ case BRW_DATA_GS_WM_PROG:
+ case BRW_DATA_GS_SF_PROG:
+ case BRW_DATA_GS_VS_PROG:
+ case BRW_DATA_GS_GS_PROG:
+ case BRW_DATA_GS_CLIP_PROG:
+ brw_disasm( stderr, data, size / sizeof(struct brw_instruction) );
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (BRW_DUMP & DUMP_STATE) {
+ switch (data_type) {
+ case BRW_DATA_GS_CC_VP:
+ brw_dump_cc_viewport( data );
+ break;
+ case BRW_DATA_GS_CC_UNIT:
+ brw_dump_cc_unit_state( data );
+ break;
+ case BRW_DATA_GS_SAMPLER_DEFAULT_COLOR:
+ brw_dump_sampler_default_color( data );
+ break;
+ case BRW_DATA_GS_SAMPLER:
+ brw_dump_sampler_state( data );
+ break;
+ case BRW_DATA_GS_WM_UNIT:
+ brw_dump_wm_unit_state( data );
+ break;
+ case BRW_DATA_GS_SF_VP:
+ brw_dump_sf_viewport( data );
+ break;
+ case BRW_DATA_GS_SF_UNIT:
+ brw_dump_sf_unit_state( data );
+ break;
+ case BRW_DATA_GS_VS_UNIT:
+ brw_dump_vs_unit_state( data );
+ break;
+ case BRW_DATA_GS_GS_UNIT:
+ brw_dump_gs_unit_state( data );
+ break;
+ case BRW_DATA_GS_CLIP_VP:
+ brw_dump_clipper_viewport( data );
+ break;
+ case BRW_DATA_GS_CLIP_UNIT:
+ brw_dump_clip_unit_state( data );
+ break;
+ case BRW_DATA_SS_SURFACE:
+ brw_dump_surface_state( data );
+ break;
+ case BRW_DATA_SS_SURF_BIND:
+ break;
+ case BRW_DATA_OTHER:
+ break;
+ case BRW_DATA_CONSTANT_BUFFER:
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (BRW_DUMP & DUMP_BATCH) {
+ switch (data_type) {
+ case BRW_DATA_BATCH_BUFFER:
+ intel_decode(data, size / 4, offset, pci_id);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
#include "brw_context.h"
#include "brw_wm.h"
#include "brw_debug.h"
+#include "brw_disasm.h"
/* Not quite sure how correct this is - need to understand horiz
* vs. vertical strides a little better.
struct i965_libdrm_buffer *buf = CALLOC_STRUCT(i965_libdrm_buffer);
uint32_t tile = 0, swizzle = 0;
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
if (!buf)
return NULL;
pipe_reference_init(&buf->base.reference, 1);
struct i965_libdrm_winsys *idws = i965_libdrm_winsys(brw_screen(screen)->sws);
struct i965_libdrm_buffer *buffer;
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
buffer = i965_libdrm_buffer_from_handle(idws, name, handle);
if (!buffer)
return NULL;
{
struct i965_libdrm_buffer *buf = NULL;
struct brw_winsys_buffer *buffer = NULL;
+
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
if (!brw_texture_get_winsys_buffer(texture, &buffer, pitch))
return FALSE;
unsigned *handle)
{
struct brw_winsys_buffer *buffer = NULL;
+
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
if (!brw_texture_get_winsys_buffer(texture, &buffer, pitch))
return FALSE;
{
struct i965_libdrm_winsys *idws = i965_libdrm_winsys(iws);
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
drm_intel_bufmgr_destroy(idws->gem);
FREE(idws);
struct i965_libdrm_winsys *idws;
unsigned int deviceID;
+ debug_printf("%s\n", __FUNCTION__);
+
if (arg != NULL) {
switch(arg->mode) {
case DRM_CREATE_NORMAL:
static void
destroy(struct drm_api *api)
{
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
}
#include "i915_drm.h"
#include "intel_bufmgr.h"
+
+
const char *names[BRW_BUFFER_TYPE_MAX] = {
- "texture",
- "scanout",
- "vertex",
- "curbe",
- "query",
- "shader_constants",
- "wm_scratch",
- "batch",
- "state_cache",
+ "TEXTURE",
+ "SCANOUT",
+ "VERTEX",
+ "CURBE",
+ "QUERY",
+ "SHADER_CONSTANTS",
+ "WM_SCRATCH",
+ "BATCH",
+ "GENERAL_STATE",
+ "SURFACE_STATE",
+ "PIXEL",
+ "GENERIC",
+};
+
+const char *usages[BRW_USAGE_MAX] = {
+ "STATE",
+ "QUERY_RESULT",
+ "RENDER_TARGET",
+ "DEPTH_BUFFER",
+ "BLIT_SOURCE",
+ "BLIT_DEST",
+ "SAMPLER",
+ "VERTEX",
+ "SCRATCH"
+};
+
+
+const char *data_types[BRW_DATA_MAX] =
+{
+ "GS: CC_VP",
+ "GS: CC_UNIT",
+ "GS: WM_PROG",
+ "GS: SAMPLER_DEFAULT_COLOR",
+ "GS: SAMPLER",
+ "GS: WM_UNIT",
+ "GS: SF_PROG",
+ "GS: SF_VP",
+ "GS: SF_UNIT",
+ "GS: VS_UNIT",
+ "GS: VS_PROG",
+ "GS: GS_UNIT",
+ "GS: GS_PROG",
+ "GS: CLIP_VP",
+ "GS: CLIP_UNIT",
+ "GS: CLIP_PROG",
+ "SS: SURFACE",
+ "SS: SURF_BIND",
+ "CONSTANT DATA",
+ "BATCH DATA",
+ "(untyped)"
};
static enum pipe_error
struct i965_libdrm_winsys *idws = i965_libdrm_winsys(sws);
struct i965_libdrm_buffer *buf;
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
buf = CALLOC_STRUCT(i965_libdrm_buffer);
if (!buf)
return PIPE_ERROR_OUT_OF_MEMORY;
{
struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
drm_intel_bo_unreference(buf->bo);
FREE(buffer);
}
int read, write;
int ret;
+ if (BRW_DUMP)
+ debug_printf("%s buf %p offset %x delta %x buf2 %p/%s/%s\n",
+ __FUNCTION__, (void *)buffer,
+ offset, delta,
+ (void *)buffer2, names[buf2->data_type], usages[usage]);
+
switch (usage) {
case BRW_USAGE_STATE:
read = I915_GEM_DOMAIN_INSTRUCTION;
read = I915_GEM_DOMAIN_INSTRUCTION;
write = I915_GEM_DOMAIN_INSTRUCTION;
break;
- case BRW_USAGE_BLIT_DEST:
+ case BRW_USAGE_RENDER_TARGET:
+ read = I915_GEM_DOMAIN_RENDER;
+ write = 0;
+ break;
+ case BRW_USAGE_DEPTH_BUFFER:
read = I915_GEM_DOMAIN_RENDER;
write = I915_GEM_DOMAIN_RENDER;
break;
read = 0;
write = I915_GEM_DOMAIN_RENDER;
break;
- case BRW_USAGE_RENDER_TARGET:
- read = I915_GEM_DOMAIN_RENDER;
- write = 0;
- break;
- case BRW_USAGE_DEPTH_BUFFER:
+ case BRW_USAGE_BLIT_DEST:
read = I915_GEM_DOMAIN_RENDER;
write = I915_GEM_DOMAIN_RENDER;
break;
return -1;
}
+ /* Needed??
+ ((uint32_t *)buf->bo->virtual)[offset/4] = (delta +
+ buf2->bo->offset);
+ */
+
ret = dri_bo_emit_reloc( buf->bo, read, write, delta, offset, buf2->bo );
if (ret)
return -1;
struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
int ret;
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
if (idws->send_cmd) {
ret = dri_bo_exec(buf->bo, bytes_used, NULL, 0, 0);
if (ret)
unsigned nr_reloc)
{
struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+ struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
int ret, i;
(void)data_type;
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
+ if (BRW_DUMP)
+ brw_dump_data( idws->id,
+ data_type,
+ buf->bo->offset + offset,
+ data, size );
+
/* XXX: use bo_map_gtt/memcpy/unmap_gtt under some circumstances???
*/
ret = drm_intel_bo_subdata(buf->bo, offset, size, (void*)data);
{
struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
return drm_intel_bo_busy(buf->bo);
}
struct i965_libdrm_buffer *bufa = i965_libdrm_buffer(a);
struct i965_libdrm_buffer *bufb = i965_libdrm_buffer(b);
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
/* XXX: can't find this func:
*/
return drm_intel_bo_references(bufa->bo, bufb->bo);
static drm_intel_bo *bos[128];
int i;
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
if (count > Elements(bos)) {
assert(0);
return FALSE;
struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
int ret;
+
+ if (BRW_DUMP)
+ debug_printf("%s %p %s %s\n", __FUNCTION__, (void *)buffer,
+ write ? "read/write" : "read",
+ write ? data_types[data_type] : "");
+
if (!buf->map_count) {
if (buf->map_gtt) {
ret = drm_intel_gem_bo_map_gtt(buf->bo);
}
}
+ buf->data_type = data_type;
buf->map_count++;
return buf->bo->virtual;
}
unsigned offset,
unsigned length)
{
+ struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+ struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
+ if (BRW_DUMP)
+ debug_printf("%s offset %d len %d\n", __FUNCTION__, offset, length);
+
+ if (BRW_DUMP)
+ brw_dump_data( idws->id,
+ buf->data_type,
+ buf->bo->offset + offset,
+ buf->bo->virtual + offset,
+ length );
}
static void
{
struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
if (--buf->map_count > 0)
return;
boolean flinked;
unsigned flink;
+ unsigned data_type; /* valid while mapped */
+
unsigned cheesy_refcount;
};
return 0;
}
-static void dump_data( struct xlib_brw_winsys *xbw,
- enum brw_buffer_data_type data_type,
- unsigned offset,
- const void *data,
- size_t size )
-{
- static int DUMP_ASM = 0;
- static int DUMP_STATE = 0;
- static int DUMP_BATCH = 1;
-
- if (DUMP_ASM) {
- switch (data_type) {
- case BRW_DATA_GS_WM_PROG:
- case BRW_DATA_GS_SF_PROG:
- case BRW_DATA_GS_VS_PROG:
- case BRW_DATA_GS_GS_PROG:
- case BRW_DATA_GS_CLIP_PROG:
- brw_disasm( stderr, data, size / sizeof(struct brw_instruction) );
- break;
- default:
- break;
- }
- }
-
- if (DUMP_STATE) {
- switch (data_type) {
- case BRW_DATA_GS_CC_VP:
- brw_dump_cc_viewport( data );
- break;
- case BRW_DATA_GS_CC_UNIT:
- brw_dump_cc_unit_state( data );
- break;
- case BRW_DATA_GS_SAMPLER_DEFAULT_COLOR:
- brw_dump_sampler_default_color( data );
- break;
- case BRW_DATA_GS_SAMPLER:
- brw_dump_sampler_state( data );
- break;
- case BRW_DATA_GS_WM_UNIT:
- brw_dump_wm_unit_state( data );
- break;
- case BRW_DATA_GS_SF_VP:
- brw_dump_sf_viewport( data );
- break;
- case BRW_DATA_GS_SF_UNIT:
- brw_dump_sf_unit_state( data );
- break;
- case BRW_DATA_GS_VS_UNIT:
- brw_dump_vs_unit_state( data );
- break;
- case BRW_DATA_GS_GS_UNIT:
- brw_dump_gs_unit_state( data );
- break;
- case BRW_DATA_GS_CLIP_VP:
- brw_dump_clipper_viewport( data );
- break;
- case BRW_DATA_GS_CLIP_UNIT:
- brw_dump_clip_unit_state( data );
- break;
- case BRW_DATA_SS_SURFACE:
- brw_dump_surface_state( data );
- break;
- case BRW_DATA_SS_SURF_BIND:
- break;
- case BRW_DATA_OTHER:
- break;
- case BRW_DATA_CONSTANT_BUFFER:
- break;
- default:
- break;
- }
- }
- if (DUMP_BATCH) {
- switch (data_type) {
- case BRW_DATA_BATCH_BUFFER:
- intel_decode(data, size / 4, offset, xbw->chipset.pci_id);
- break;
- default:
- break;
- }
- }
-}
static int
xlib_brw_buffer(reloc[i].bo)->offset + reloc[i].delta;
}
- if (1)
- dump_data( xbw, data_type,
- buf->offset + offset,
- buf->virtual + offset, size );
+ if (BRW_DUMP)
+ brw_dump_data( xbw->chipset.pci_id,
+ data_type,
+ buf->offset + offset,
+ buf->virtual + offset, size );
return 0;