[Intel-gfx] [PATCH v2 2/2] i965: Add calls to nonblocking maps
Ben Widawsky
ben at bwidawsk.net
Mon Sep 26 03:35:32 CEST 2011
When mapping a range of a buffer that has the UNSYNCHRONIZED_BIT, and is
only writable, we can take some shortcuts and let people shoot their
feet.
Cc: Eric Anholt <eric at anholt.net>
Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
src/mesa/drivers/dri/intel/intel_buffer_objects.c | 34 ++++++++++++++------
src/mesa/drivers/dri/intel/intel_buffer_objects.h | 8 ++++-
2 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
index 78e3468..13a24b9 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
@@ -359,15 +359,21 @@ intel_bufferobj_map_range(struct gl_context * ctx,
"range map",
length, 64);
drm_intel_gem_bo_map_gtt(intel_obj->range_map_bo);
- intel_obj->mapped_gtt = true;
+ intel_obj->mapped_type = BO_MAP_TYPE_GTT;
obj->Pointer = intel_obj->range_map_bo->virtual;
} else if (!(access & GL_MAP_READ_BIT)) { /* Write only */
- drm_intel_gem_bo_map_gtt(intel_obj->buffer);
- intel_obj->mapped_gtt = true;
- obj->Pointer = intel_obj->buffer->virtual + offset;
+ if (access & GL_MAP_UNSYNCHRONIZED_BIT) {
+ drm_intel_gem_bo_map_nonblocking(intel_obj->buffer);
+ intel_obj->mapped_type = BO_MAP_TYPE_NONBLOCKING;
+ obj->Pointer = intel_obj->buffer->virtual + offset;
+ } else {
+ drm_intel_gem_bo_map_gtt(intel_obj->buffer);
+ intel_obj->mapped_type = BO_MAP_TYPE_GTT;
+ obj->Pointer = intel_obj->buffer->virtual + offset;
+ }
} else { /* R/W or RO */
drm_intel_bo_map(intel_obj->buffer, (access & GL_MAP_WRITE_BIT) != 0);
- intel_obj->mapped_gtt = false;
+ intel_obj->mapped_type = BO_MAP_TYPE_CPU;
obj->Pointer = intel_obj->buffer->virtual + offset;
}
@@ -426,10 +432,12 @@ intel_bufferobj_unmap(struct gl_context * ctx, struct gl_buffer_object *obj)
if (intel_obj->sys_buffer != NULL) {
/* always keep the mapping around. */
} else if (intel_obj->range_map_bo != NULL) {
- if (intel_obj->mapped_gtt) {
+ switch (intel_obj->mapped_type) {
+ case BO_MAP_TYPE_GTT:
drm_intel_gem_bo_unmap_gtt(intel_obj->range_map_bo);
- } else {
- drm_intel_bo_unmap(intel_obj->range_map_bo);
+ break;
+ default:
+ return GL_FALSE;
}
if (intel_obj->needs_flush_at_unmap) {
@@ -448,10 +456,16 @@ intel_bufferobj_unmap(struct gl_context * ctx, struct gl_buffer_object *obj)
intel_batchbuffer_emit_mi_flush(intel);
intel_obj->range_map_bo = NULL;
} else if (intel_obj->buffer != NULL) {
- if (intel_obj->mapped_gtt) {
+ switch (intel_obj->mapped_type) {
+ case BO_MAP_TYPE_GTT:
drm_intel_gem_bo_unmap_gtt(intel_obj->buffer);
- } else {
+ break;
+ case BO_MAP_TYPE_CPU:
drm_intel_bo_unmap(intel_obj->buffer);
+ break;
+ case BO_MAP_TYPE_NONBLOCKING:
+ drm_intel_gem_bo_unmap_nonblocking(intel_obj->buffer);
+ break;
}
}
diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.h b/src/mesa/drivers/dri/intel/intel_buffer_objects.h
index 24a1636..fd43bd5 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.h
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.h
@@ -33,6 +33,12 @@
struct intel_context;
struct gl_buffer_object;
+enum {
+ BO_MAP_TYPE_NONE=0,
+ BO_MAP_TYPE_GTT,
+ BO_MAP_TYPE_CPU,
+ BO_MAP_TYPE_NONBLOCKING
+};
/**
* Intel vertex/pixel buffer object, derived from Mesa's gl_buffer_object.
@@ -48,8 +54,8 @@ struct intel_buffer_object
drm_intel_bo *range_map_bo;
bool needs_flush_at_unmap;
+ int mapped_type;
- GLboolean mapped_gtt;
GLboolean source;
};
--
1.7.6.4
More information about the Intel-gfx
mailing list