summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-11-05 17:43:57 +0000
committerKeith Whitwell <[email protected]>2009-11-05 19:57:28 +0000
commitb229ee342f2cef5396a251525d5b499760280933 (patch)
treedb8d942fa43a2595456dd3441bba65570844e957 /src
parenta70e6178d4841f490ff318b6017a1ddacfadf752 (diff)
brw: push more dumping into the winsys
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/i965/brw_batchbuffer.c22
-rw-r--r--src/gallium/drivers/i965/brw_vs_emit.c2
-rw-r--r--src/gallium/drivers/i965/brw_winsys.h8
-rw-r--r--src/gallium/winsys/drm/i965/xlib/xlib_i965.c111
4 files changed, 93 insertions, 50 deletions
diff --git a/src/gallium/drivers/i965/brw_batchbuffer.c b/src/gallium/drivers/i965/brw_batchbuffer.c
index e5f73bd6a31..76a7d2d2afc 100644
--- a/src/gallium/drivers/i965/brw_batchbuffer.c
+++ b/src/gallium/drivers/i965/brw_batchbuffer.c
@@ -54,7 +54,7 @@ brw_batchbuffer_reset(struct brw_batchbuffer *batch)
batch->map = batch->malloc_buffer;
else
batch->map = batch->sws->bo_map(batch->buf,
- BRW_DATA_OTHER,
+ BRW_DATA_BATCH_BUFFER,
GL_TRUE);
batch->size = BRW_BATCH_SIZE;
@@ -136,7 +136,7 @@ _brw_batchbuffer_flush(struct brw_batchbuffer *batch,
if (batch->use_malloc_buffer) {
batch->sws->bo_subdata(batch->buf,
- BRW_DATA_OTHER,
+ BRW_DATA_BATCH_BUFFER,
0, used,
batch->map );
batch->map = NULL;
@@ -150,19 +150,6 @@ _brw_batchbuffer_flush(struct brw_batchbuffer *batch,
batch->sws->bo_exec(batch->buf, used );
- if (1 /*BRW_DEBUG & DEBUG_BATCH*/) {
- void *ptr = batch->sws->bo_map(batch->buf,
- BRW_DATA_OTHER,
- GL_FALSE);
-
- intel_decode(ptr,
- used / 4,
- batch->buf->offset[0],
- batch->chipset.pci_id);
-
- batch->sws->bo_unmap(batch->buf);
- }
-
if (BRW_DEBUG & DEBUG_SYNC) {
/* Abuse map/unmap to achieve wait-for-fence.
*
@@ -170,10 +157,7 @@ _brw_batchbuffer_flush(struct brw_batchbuffer *batch,
* interface.
*/
debug_printf("waiting for idle\n");
- batch->sws->bo_map(batch->buf,
- BRW_DATA_OTHER,
- GL_TRUE);
- batch->sws->bo_unmap(batch->buf);
+ batch->sws->bo_wait_idle(batch->buf);
}
/* Reset the buffer:
diff --git a/src/gallium/drivers/i965/brw_vs_emit.c b/src/gallium/drivers/i965/brw_vs_emit.c
index d86e2104d8d..3217777acba 100644
--- a/src/gallium/drivers/i965/brw_vs_emit.c
+++ b/src/gallium/drivers/i965/brw_vs_emit.c
@@ -1624,8 +1624,6 @@ void brw_vs_emit(struct brw_vs_compile *c)
post_vs_emit(c, end_inst, last_inst);
if (BRW_DEBUG & DEBUG_VS) {
- int i;
-
debug_printf("vs-native:\n");
brw_disasm(stderr, p->store, p->nr_insn);
}
diff --git a/src/gallium/drivers/i965/brw_winsys.h b/src/gallium/drivers/i965/brw_winsys.h
index f61c541ad15..e041b0acafc 100644
--- a/src/gallium/drivers/i965/brw_winsys.h
+++ b/src/gallium/drivers/i965/brw_winsys.h
@@ -105,6 +105,8 @@ enum brw_buffer_data_type {
BRW_DATA_GS_CLIP_PROG,
BRW_DATA_SS_SURFACE,
BRW_DATA_SS_SURF_BIND,
+ BRW_DATA_CONSTANT_BUFFER,
+ BRW_DATA_BATCH_BUFFER,
BRW_DATA_OTHER,
BRW_DATA_MAX
};
@@ -176,6 +178,12 @@ struct brw_winsys_screen {
void (*bo_unmap)(struct brw_winsys_buffer *buffer);
/*@}*/
+
+ /* Wait for buffer to go idle. Similar to map+unmap, but doesn't
+ * mark buffer contents as dirty.
+ */
+ void (*bo_wait_idle)(struct brw_winsys_buffer *buffer);
+
/**
* Destroy the winsys.
*/
diff --git a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c
index d129067ba37..5aec332761a 100644
--- a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c
+++ b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c
@@ -51,14 +51,19 @@ extern int brw_disasm (FILE *file,
const struct brw_instruction *inst,
unsigned count );
+extern int intel_decode(const uint32_t *data,
+ int count,
+ uint32_t hw_offset,
+ uint32_t devid);
+
struct xlib_brw_buffer
{
struct brw_winsys_buffer base;
+ char *virtual;
unsigned offset;
unsigned type;
- char *virtual;
- unsigned cheesy_refcount;
int map_count;
+ boolean modified;
};
@@ -68,7 +73,10 @@ struct xlib_brw_buffer
struct xlib_brw_winsys
{
struct brw_winsys_screen base;
- unsigned offset;
+ struct brw_chipset chipset;
+
+ unsigned size;
+ unsigned used;
};
static struct xlib_brw_winsys *
@@ -157,14 +165,15 @@ xlib_brw_bo_alloc( struct brw_winsys_screen *sws,
pipe_reference_init(&buf->base.reference, 1);
- buf->offset = align(xbw->offset, alignment);
+ buf->offset = align(xbw->used, alignment);
buf->type = type;
buf->virtual = MALLOC(size);
buf->base.offset = &buf->offset; /* hmm, cheesy */
buf->base.size = size;
+ buf->base.sws = sws;
- xbw->offset = align(xbw->offset, alignment) + size;
- if (xbw->offset > MAX_VRAM)
+ xbw->used = align(xbw->used, alignment) + size;
+ if (xbw->used > MAX_VRAM)
goto err;
/* XXX: possibly rentrant call to bo_destroy:
@@ -184,7 +193,6 @@ xlib_brw_bo_destroy( struct brw_winsys_buffer *buffer )
{
struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
- FREE(buf->virtual);
FREE(buf);
}
@@ -217,19 +225,11 @@ xlib_brw_bo_exec( struct brw_winsys_buffer *buffer,
return 0;
}
-static int
-xlib_brw_bo_subdata(struct brw_winsys_buffer *buffer,
- enum brw_buffer_data_type data_type,
- size_t offset,
- size_t size,
- const void *data)
+static void dump_data( struct xlib_brw_winsys *xbw,
+ enum brw_buffer_data_type data_type,
+ const void *data,
+ size_t size )
{
- struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
-
- debug_printf("%s buf %p off %d sz %d data %p %s\n",
- __FUNCTION__,
- (void *)buffer, offset, size, data, data_types[data_type]);
-
switch (data_type) {
case BRW_DATA_GS_CC_VP:
brw_dump_cc_viewport( data );
@@ -278,12 +278,39 @@ xlib_brw_bo_subdata(struct brw_winsys_buffer *buffer,
break;
case BRW_DATA_OTHER:
break;
+ case BRW_DATA_BATCH_BUFFER:
+ intel_decode(data, size / 4, 0, xbw->chipset.pci_id);
+ break;
+ case BRW_DATA_CONSTANT_BUFFER:
+ break;
default:
assert(0);
break;
}
+}
+
+
+static int
+xlib_brw_bo_subdata(struct brw_winsys_buffer *buffer,
+ enum brw_buffer_data_type data_type,
+ size_t offset,
+ size_t size,
+ const void *data)
+{
+ struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
+ struct xlib_brw_winsys *xbw = xlib_brw_winsys(buffer->sws);
+
+ debug_printf("%s buf %p off %d sz %d %s\n",
+ __FUNCTION__,
+ (void *)buffer, offset, size, data_types[data_type]);
+
+ if (1)
+ dump_data( xbw, data_type, data, size );
+ assert(buf->base.size >= offset + size);
memcpy(buf->virtual + offset, data, size);
+
+
return 0;
}
@@ -324,7 +351,7 @@ xlib_brw_check_aperture_space( struct brw_winsys_screen *iws,
static void *
xlib_brw_bo_map(struct brw_winsys_buffer *buffer,
enum brw_buffer_data_type data_type,
- boolean write)
+ boolean write)
{
struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
@@ -332,6 +359,9 @@ xlib_brw_bo_map(struct brw_winsys_buffer *buffer,
write ? "read/write" : "read",
write ? data_types[data_type] : "");
+ if (write)
+ buf->modified = 1;
+
buf->map_count++;
return buf->virtual;
}
@@ -345,14 +375,30 @@ xlib_brw_bo_unmap(struct brw_winsys_buffer *buffer)
--buf->map_count;
assert(buf->map_count >= 0);
+
+ if (buf->map_count == 0 &&
+ buf->modified) {
+
+ buf->modified = 0;
+
+ /* Consider dumping new buffer contents here.
+ */
+ }
+}
+
+
+static void
+xlib_brw_bo_wait_idle( struct brw_winsys_buffer *buffer )
+{
}
static void
-xlib_brw_winsys_destroy( struct brw_winsys_screen *screen )
+xlib_brw_winsys_destroy( struct brw_winsys_screen *sws )
{
- /* XXX: free all buffers */
- FREE(screen);
+ struct xlib_brw_winsys *xbw = xlib_brw_winsys(sws);
+
+ FREE(xbw);
}
static struct brw_winsys_screen *
@@ -364,6 +410,8 @@ xlib_create_brw_winsys_screen( void )
if (!ws)
return NULL;
+ ws->used = 0;
+
ws->base.destroy = xlib_brw_winsys_destroy;
ws->base.bo_alloc = xlib_brw_bo_alloc;
ws->base.bo_destroy = xlib_brw_bo_destroy;
@@ -375,6 +423,7 @@ xlib_create_brw_winsys_screen( void )
ws->base.check_aperture_space = xlib_brw_check_aperture_space;
ws->base.bo_map = xlib_brw_bo_map;
ws->base.bo_unmap = xlib_brw_bo_unmap;
+ ws->base.bo_wait_idle = xlib_brw_bo_wait_idle;
return &ws->base;
}
@@ -388,12 +437,14 @@ static void
xlib_i965_display_surface(struct xmesa_buffer *xm_buffer,
struct pipe_surface *surf)
{
- /* struct brw_texture *texture = brw_texture(surf->texture); */
-
- debug_printf("%s tex %p, sz %dx%d\n", __FUNCTION__,
- (void *)surf->texture,
- surf->texture->width[0],
- surf->texture->height[0]);
+ struct brw_surface *surface = brw_surface(surf);
+ struct xlib_brw_buffer *bo = xlib_brw_buffer(surface->bo);
+
+ debug_printf("%s offset %x+%x sz %dx%d\n", __FUNCTION__,
+ bo->offset,
+ surface->draw_offset,
+ surf->width,
+ surf->height);
}
static void
@@ -419,6 +470,8 @@ xlib_create_i965_screen( void )
if (screen == NULL)
goto fail;
+ xlib_brw_winsys(winsys)->chipset = brw_screen(screen)->chipset;
+
screen->flush_frontbuffer = xlib_i965_flush_frontbuffer;
return screen;