Mesa (master): radeon: Hack up an implementation of MapBufferRange

Ian Romanick idr at kemper.freedesktop.org
Tue Aug 23 14:52:59 PDT 2011


Module: Mesa
Branch: master
Commit: cccc7412c22a704d85203d7bb9c8e73d45cccf49
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cccc7412c22a704d85203d7bb9c8e73d45cccf49

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Sun Aug 21 18:32:09 2011 -0700

radeon: Hack up an implementation of MapBufferRange

This doesn't implement any of the "cool" features of MapBufferRange.
Adding this function is necessary for the next commit in the series.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
Acked-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Alex Deucher <alexdeucher at gmail.com>
Cc: Maciej Cencora <m.cencora at gmail.com>

---

 .../drivers/dri/radeon/radeon_buffer_objects.c     |   33 ++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c b/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
index ee63436..e106d98 100644
--- a/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
+++ b/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
@@ -198,6 +198,38 @@ radeonMapBuffer(struct gl_context * ctx,
 
 
 /**
+ * Called via glMapBufferRange()
+ */
+static void *
+radeonMapBufferRange(struct gl_context * ctx,
+		     GLintptr offset, GLsizeiptr length,
+		     GLbitfield access, struct gl_buffer_object *obj)
+{
+    struct radeon_buffer_object *radeon_obj = get_radeon_buffer_object(obj);
+    const GLboolean write_only =
+       (access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == GL_MAP_WRITE_BIT;
+
+    if (write_only) {
+        ctx->Driver.Flush(ctx);
+    }
+
+    if (radeon_obj->bo == NULL) {
+        obj->Pointer = NULL;
+        return NULL;
+    }
+
+    obj->Offset = offset;
+    obj->Length = length;
+    obj->AccessFlags = access;
+
+    radeon_bo_map(radeon_obj->bo, write_only);
+
+    obj->Pointer = radeon_obj->bo->ptr + offset;
+    return obj->Pointer;
+}
+
+
+/**
  * Called via glUnmapBufferARB()
  */
 static GLboolean
@@ -226,5 +258,6 @@ radeonInitBufferObjectFuncs(struct dd_function_table *functions)
     functions->BufferSubData = radeonBufferSubData;
     functions->GetBufferSubData = radeonGetBufferSubData;
     functions->MapBuffer = radeonMapBuffer;
+    functions->MapBufferRange = radeonMapBufferRange;
     functions->UnmapBuffer = radeonUnmapBuffer;
 }



More information about the mesa-commit mailing list