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;
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;
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.
*
* 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:
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;
};
struct xlib_brw_winsys
{
struct brw_winsys_screen base;
- unsigned offset;
+ struct brw_chipset chipset;
+
+ unsigned size;
+ unsigned used;
};
static struct xlib_brw_winsys *
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:
{
struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
- FREE(buf->virtual);
FREE(buf);
}
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 );
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;
}
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);
write ? "read/write" : "read",
write ? data_types[data_type] : "");
+ if (write)
+ buf->modified = 1;
+
buf->map_count++;
return buf->virtual;
}
--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 *
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;
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;
}
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
if (screen == NULL)
goto fail;
+ xlib_brw_winsys(winsys)->chipset = brw_screen(screen)->chipset;
+
screen->flush_frontbuffer = xlib_i965_flush_frontbuffer;
return screen;