summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/drm
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-11-30 13:39:21 +0000
committerKeith Whitwell <[email protected]>2009-11-30 15:37:27 +0000
commitcddc7e3a9cd321247c2298ef1b94cced1122a8e5 (patch)
treec2b8bb745618e8e8339d7a642093c50013060f08 /src/gallium/winsys/drm
parent4490122d0cae360d1552cea7d7d860de352f13f6 (diff)
brw: add dumping to gem winsys
Diffstat (limited to 'src/gallium/winsys/drm')
-rw-r--r--src/gallium/winsys/drm/i965/gem/i965_drm_api.c21
-rw-r--r--src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c133
-rw-r--r--src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h2
-rw-r--r--src/gallium/winsys/drm/i965/xlib/xlib_i965.c91
4 files changed, 146 insertions, 101 deletions
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c b/src/gallium/winsys/drm/i965/gem/i965_drm_api.c
index 191a733c368..5d5dfdae464 100644
--- a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c
+++ b/src/gallium/winsys/drm/i965/gem/i965_drm_api.c
@@ -44,6 +44,9 @@ i965_libdrm_buffer_from_handle(struct i965_libdrm_winsys *idws,
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);
@@ -89,6 +92,9 @@ i965_libdrm_texture_from_shared_handle(struct drm_api *api,
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;
@@ -106,6 +112,10 @@ i965_libdrm_shared_handle_from_texture(struct drm_api *api,
{
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;
@@ -129,6 +139,10 @@ i965_libdrm_local_handle_from_texture(struct drm_api *api,
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;
@@ -142,6 +156,9 @@ i965_libdrm_winsys_destroy(struct brw_winsys_screen *iws)
{
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);
@@ -154,6 +171,8 @@ i965_libdrm_create_screen(struct drm_api *api, int drmFD,
struct i965_libdrm_winsys *idws;
unsigned int deviceID;
+ debug_printf("%s\n", __FUNCTION__);
+
if (arg != NULL) {
switch(arg->mode) {
case DRM_CREATE_NORMAL:
@@ -194,6 +213,8 @@ i965_libdrm_create_context(struct drm_api *api, struct pipe_screen *screen)
static void
destroy(struct drm_api *api)
{
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
}
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c b/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c
index 1f3f19ab725..d4a0c97262a 100644
--- a/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c
+++ b/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c
@@ -5,16 +5,59 @@
#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
@@ -27,6 +70,9 @@ i965_libdrm_bo_alloc(struct brw_winsys_screen *sws,
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;
@@ -79,6 +125,9 @@ i965_libdrm_bo_destroy(struct brw_winsys_buffer *buffer)
{
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);
}
@@ -95,6 +144,12 @@ i965_libdrm_bo_emit_reloc(struct brw_winsys_buffer *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;
@@ -104,7 +159,11 @@ i965_libdrm_bo_emit_reloc(struct brw_winsys_buffer *buffer,
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;
@@ -112,11 +171,7 @@ i965_libdrm_bo_emit_reloc(struct brw_winsys_buffer *buffer,
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;
@@ -137,6 +192,11 @@ i965_libdrm_bo_emit_reloc(struct brw_winsys_buffer *buffer,
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;
@@ -152,6 +212,9 @@ i965_libdrm_bo_exec(struct brw_winsys_buffer *buffer,
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)
@@ -171,10 +234,20 @@ i965_libdrm_bo_subdata(struct brw_winsys_buffer *buffer,
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);
@@ -194,6 +267,9 @@ i965_libdrm_bo_is_busy(struct brw_winsys_buffer *buffer)
{
struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
return drm_intel_bo_busy(buf->bo);
}
@@ -204,6 +280,9 @@ i965_libdrm_bo_references(struct brw_winsys_buffer *a,
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);
@@ -220,6 +299,9 @@ i965_libdrm_check_aperture_space(struct brw_winsys_screen *iws,
static drm_intel_bo *bos[128];
int i;
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
if (count > Elements(bos)) {
assert(0);
return FALSE;
@@ -243,6 +325,12 @@ i965_libdrm_bo_map(struct brw_winsys_buffer *buffer,
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);
@@ -256,6 +344,7 @@ i965_libdrm_bo_map(struct brw_winsys_buffer *buffer,
}
}
+ buf->data_type = data_type;
buf->map_count++;
return buf->bo->virtual;
}
@@ -265,7 +354,18 @@ i965_libdrm_bo_flush_range(struct brw_winsys_buffer *buffer,
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
@@ -273,6 +373,9 @@ i965_libdrm_bo_unmap(struct brw_winsys_buffer *buffer)
{
struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
+ if (BRW_DUMP)
+ debug_printf("%s\n", __FUNCTION__);
+
if (--buf->map_count > 0)
return;
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h b/src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h
index 79457112636..5b556b18f0f 100644
--- a/src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h
+++ b/src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h
@@ -52,6 +52,8 @@ struct i965_libdrm_buffer {
boolean flinked;
unsigned flink;
+ unsigned data_type; /* valid while mapped */
+
unsigned cheesy_refcount;
};
diff --git a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c
index 9d2bfae090d..e712de6307e 100644
--- a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c
+++ b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c
@@ -228,89 +228,7 @@ xlib_brw_bo_exec( struct brw_winsys_buffer *buffer,
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
@@ -346,10 +264,11 @@ xlib_brw_bo_subdata(struct brw_winsys_buffer *buffer,
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;