i915g: pwrite batchbuffer instead of map
authorJakob Bornecrantz <wallbraker@gmail.com>
Tue, 8 Sep 2009 20:30:48 +0000 (21:30 +0100)
committerJakob Bornecrantz <jakob@vmware.com>
Tue, 8 Sep 2009 23:43:36 +0000 (00:43 +0100)
src/gallium/winsys/drm/intel/gem/intel_drm_batchbuffer.c

index 5ca3ad9762dc75e4d70984e7c1a5e54bc3a7d1a3..ebd1b607b78f48e79b9a467a12043159832d2c3f 100644 (file)
@@ -13,6 +13,7 @@
 #define INTEL_BATCH_CLIPRECTS    0x2
 
 #undef INTEL_RUN_SYNC
+#undef INTEL_MAP_BATCHBUFFER
 
 struct intel_drm_batchbuffer
 {
@@ -40,8 +41,11 @@ intel_drm_batchbuffer_reset(struct intel_drm_batchbuffer *batch)
                                   "gallium3d_batchbuffer",
                                   batch->actual_size,
                                   4096);
+
+#ifdef INTEL_MAP_BATCHBUFFER
    drm_intel_bo_map(batch->bo, TRUE);
    batch->base.map = batch->bo->virtual;
+#endif
 
    memset(batch->base.map, 0, batch->actual_size);
    batch->base.ptr = batch->base.map;
@@ -55,7 +59,13 @@ intel_drm_batchbuffer_create(struct intel_winsys *iws)
    struct intel_drm_winsys *idws = intel_drm_winsys(iws);
    struct intel_drm_batchbuffer *batch = CALLOC_STRUCT(intel_drm_batchbuffer);
 
+   batch->actual_size = idws->max_batch_size;
+
+#ifdef INTEL_MAP_BATCHBUFFER
    batch->base.map = NULL;
+#else
+   batch->base.map = MALLOC(batch->actual_size);
+#endif
    batch->base.ptr = NULL;
    batch->base.size = 0;
 
@@ -64,8 +74,6 @@ intel_drm_batchbuffer_create(struct intel_winsys *iws)
 
    batch->base.iws = iws;
 
-   batch->actual_size = idws->max_batch_size;
-
    intel_drm_batchbuffer_reset(batch);
 
    return &batch->base;
@@ -156,7 +164,11 @@ intel_drm_batchbuffer_flush(struct intel_batchbuffer *ibatch,
 
    used = batch->base.ptr - batch->base.map;
 
+#ifdef INTEL_MAP_BATCHBUFFER
    drm_intel_bo_unmap(batch->bo);
+#else
+   drm_intel_bo_subdata(batch->bo, 0, used, batch->base.map);
+#endif
 
    /* Do the sending to HW */
    ret = drm_intel_bo_exec(batch->bo, used, NULL, 0, 0);
@@ -202,7 +214,10 @@ intel_drm_batchbuffer_destroy(struct intel_batchbuffer *ibatch)
    if (batch->bo)
       drm_intel_bo_unreference(batch->bo);
 
-   free(batch);
+#ifndef INTEL_MAP_BATCHBUFFER
+   FREE(batch->base.map);
+#endif
+   FREE(batch);
 }
 
 void intel_drm_winsys_init_batchbuffer_functions(struct intel_drm_winsys *idws)