Mesa (master): intel: For batch, use GTT mapping instead of writing to a malloc and copying.
Eric Anholt
anholt at kemper.freedesktop.org
Tue Nov 2 21:25:27 UTC 2010
Module: Mesa
Branch: master
Commit: 689def8bbcd2851adc89bebc84fd99bd627ff173
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=689def8bbcd2851adc89bebc84fd99bd627ff173
Author: Eric Anholt <eric at anholt.net>
Date: Mon Sep 20 14:10:20 2010 -0700
intel: For batch, use GTT mapping instead of writing to a malloc and copying.
No measurable performance difference on cairo-perf-trace, but
simplifies the code and should have cache benefit in general.
---
src/mesa/drivers/dri/intel/intel_batchbuffer.c | 20 +++++++++-----------
src/mesa/drivers/dri/intel/intel_batchbuffer.h | 2 --
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
index 9b39823..aaf3a57 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
@@ -44,7 +44,9 @@ intel_batchbuffer_reset(struct intel_batchbuffer *batch)
batch->buf = drm_intel_bo_alloc(intel->bufmgr, "batchbuffer",
intel->maxBatchSize, 4096);
- batch->map = batch->buffer;
+ drm_intel_gem_bo_map_gtt(batch->buf);
+ batch->map = batch->buf->virtual;
+
batch->size = intel->maxBatchSize;
batch->ptr = batch->map;
batch->reserved_space = BATCH_RESERVED;
@@ -58,7 +60,6 @@ intel_batchbuffer_alloc(struct intel_context *intel)
struct intel_batchbuffer *batch = calloc(sizeof(*batch), 1);
batch->intel = intel;
- batch->buffer = malloc(intel->maxBatchSize);
intel_batchbuffer_reset(batch);
return batch;
@@ -67,8 +68,11 @@ intel_batchbuffer_alloc(struct intel_context *intel)
void
intel_batchbuffer_free(struct intel_batchbuffer *batch)
{
- free (batch->buffer);
- drm_intel_bo_unreference(batch->buf);
+ if (batch->map) {
+ drm_intel_gem_bo_unmap_gtt(batch->buf);
+ batch->map = NULL;
+ }
+ dri_bo_unreference(batch->buf);
batch->buf = NULL;
free(batch);
}
@@ -84,13 +88,7 @@ do_flush_locked(struct intel_batchbuffer *batch, GLuint used)
int ret = 0;
int x_off = 0, y_off = 0;
- drm_intel_bo_subdata(batch->buf, 0, used, batch->buffer);
- if (batch->state_batch_offset != batch->size) {
- drm_intel_bo_subdata(batch->buf,
- batch->state_batch_offset,
- batch->size - batch->state_batch_offset,
- batch->buffer + batch->state_batch_offset);
- }
+ drm_intel_gem_bo_unmap_gtt(batch->buf);
batch->ptr = NULL;
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.h b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
index ae53f45..428c027 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.h
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
@@ -17,8 +17,6 @@ struct intel_batchbuffer
drm_intel_bo *buf;
- GLubyte *buffer;
-
GLubyte *map;
GLubyte *ptr;
More information about the mesa-commit
mailing list