summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-11-26 13:42:23 -0700
committerBrian Paul <[email protected]>2010-11-26 13:48:49 -0700
commit97ae4dad1cc24c5e969e6b99f07ece68e239964b (patch)
tree6e8b426e5c3bc0bc8a6ed52f990fdd00e0520f13 /src/mesa/state_tracker
parent5822484510b45cac2e16d3b220fd33cef6c41a66 (diff)
st/mesa: fix mapping of zero-sized buffer objects
Fixes http://bugs.freedesktop.org/show_bug.cgi?id=31934
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 27540c36ce7..73c9c2de7a1 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -211,6 +211,13 @@ st_bufferobj_data(struct gl_context *ctx,
/**
+ * Dummy data whose's pointer is used for zero size buffers or ranges.
+ */
+static long st_bufferobj_zero_length = 0;
+
+
+
+/**
* Called via glMapBufferARB().
*/
static void *
@@ -233,10 +240,16 @@ st_bufferobj_map(struct gl_context *ctx, GLenum target, GLenum access,
break;
}
- obj->Pointer = pipe_buffer_map(st_context(ctx)->pipe,
- st_obj->buffer,
- flags,
- &st_obj->transfer);
+ /* Handle zero-size buffers here rather than in drivers */
+ if (obj->Size == 0) {
+ obj->Pointer = &st_bufferobj_zero_length;
+ }
+ else {
+ obj->Pointer = pipe_buffer_map(st_context(ctx)->pipe,
+ st_obj->buffer,
+ flags,
+ &st_obj->transfer);
+ }
if (obj->Pointer) {
obj->Offset = 0;
@@ -247,13 +260,6 @@ st_bufferobj_map(struct gl_context *ctx, GLenum target, GLenum access,
/**
- * Dummy data whose's pointer is used for zero length ranges.
- */
-static long
-st_bufferobj_zero_length_range = 0;
-
-
-/**
* Called via glMapBufferRange().
*/
static void *
@@ -293,7 +299,7 @@ st_bufferobj_map_range(struct gl_context *ctx, GLenum target,
* length range from the pipe driver.
*/
if (!length) {
- obj->Pointer = &st_bufferobj_zero_length_range;
+ obj->Pointer = &st_bufferobj_zero_length;
}
else {
obj->Pointer = pipe_buffer_map_range(pipe,