i915g: Switch to mapping the batch buffer instead of using subdata

This commit is contained in:
Jakob Bornecrantz 2009-08-05 23:56:08 +01:00
parent 246f58d922
commit 66b00380a2
3 changed files with 27 additions and 11 deletions

View file

@ -23,10 +23,8 @@ intel_be_batchbuffer_alloc(struct intel_be_context *intel)
batch->base.relocs = 0;
batch->base.max_relocs = 500;/*INTEL_DEFAULT_RELOCS;*/
batch->base.map = malloc(batch->base.actual_size);
memset(batch->base.map, 0, batch->base.actual_size);
batch->base.ptr = batch->base.map;
batch->intel = intel;
batch->device = intel->device;
intel_be_batchbuffer_reset(batch);
@ -41,16 +39,17 @@ intel_be_batchbuffer_reset(struct intel_be_batchbuffer *batch)
if (batch->bo)
drm_intel_bo_unreference(batch->bo);
batch->bo = drm_intel_bo_alloc(dev->pools.gem,
"gallium3d_batch_buffer",
batch->base.actual_size,
4096);
drm_intel_bo_map(batch->bo, TRUE);
batch->base.map = batch->bo->virtual;
memset(batch->base.map, 0, batch->base.actual_size);
batch->base.ptr = batch->base.map;
batch->base.size = batch->base.actual_size - BATCH_RESERVED;
batch->base.relocs = 0;
batch->bo = drm_intel_bo_alloc(dev->pools.gem,
"gallium3d_batch_buffer",
batch->base.actual_size, 0);
}
int
@ -88,6 +87,7 @@ intel_be_batchbuffer_flush(struct intel_be_batchbuffer *batch,
struct i915_batchbuffer *i915 = &batch->base;
unsigned used = 0;
int ret = 0;
int i;
assert(i915_batchbuffer_space(i915) >= 0);
@ -105,11 +105,25 @@ intel_be_batchbuffer_flush(struct intel_be_batchbuffer *batch,
used = batch->base.ptr - batch->base.map;
drm_intel_bo_subdata(batch->bo, 0, used, batch->base.map);
ret = drm_intel_bo_exec(batch->bo, used, NULL, 0, 0);
drm_intel_bo_unmap(batch->bo);
/* Do the sending to HW */
ret = drm_intel_bo_exec(batch->bo, used, NULL, 0, 0);
assert(ret == 0);
if (batch->device->dump_cmd) {
unsigned *ptr;
drm_intel_bo_map(batch->bo, FALSE);
ptr = (unsigned*)batch->bo->virtual;
debug_printf("%s:\n", __func__);
for (i = 0; i < used / 4; i++, ptr++) {
debug_printf("\t%08x: %08x\n", i*4, *ptr);
}
drm_intel_bo_unmap(batch->bo);
}
intel_be_batchbuffer_reset(batch);
if (fence) {

View file

@ -340,6 +340,7 @@ intel_be_init_device(struct intel_be_device *dev, int fd, unsigned id)
dev->pools.gem = drm_intel_bufmgr_gem_init(dev->fd, dev->max_batch_size);
dev->softpipe = debug_get_bool_option("INTEL_SOFTPIPE", FALSE);
dev->dump_cmd = debug_get_bool_option("INTEL_DUMP_CMD", FALSE);
return true;
}

View file

@ -19,6 +19,7 @@ struct intel_be_device
struct pipe_winsys base;
boolean softpipe;
boolean dump_cmd;
int fd; /**< Drm file discriptor */