i915g: Switch to mapping the batch buffer instead of using subdata
authorJakob Bornecrantz <jakob@vmware.com>
Wed, 5 Aug 2009 22:56:08 +0000 (23:56 +0100)
committerJakob Bornecrantz <jakob@vmware.com>
Wed, 5 Aug 2009 23:52:13 +0000 (00:52 +0100)
src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c
src/gallium/winsys/drm/intel/gem/intel_be_device.c
src/gallium/winsys/drm/intel/gem/intel_be_device.h

index d5e63c3bae5cf628cd9499b6a8c008fb2cdedf2c..ef4d39348a25e10f6030cbdc92e943ebbf748cc7 100644 (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) {
index c7e88271ec695663542d856173a716ff99b24d3b..512bd41d648a18a724981b93d8a6c487e3a3ee7e 100644 (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;
 }
index 3f3f2a76a3d2c33e3f7022e9067c93e2816005f2..c397048f8c56f040fcc47d96f07febeaa89901e5 100644 (file)
@@ -19,6 +19,7 @@ struct intel_be_device
        struct pipe_winsys base;
 
        boolean softpipe;
+       boolean dump_cmd;
 
        int fd; /**< Drm file discriptor */