Parcourir la source

mesa: Cope with the degenerate case of zero length ranges.

Fixes assertion failures on glean's bufferObject test.
tags/mesa-7.7-1
José Fonseca il y a 16 ans
Parent
révision
eb5d9e6f70
1 fichiers modifiés avec 45 ajouts et 4 suppressions
  1. 45
    4
      src/mesa/state_tracker/st_cb_bufferobjects.c

+ 45
- 4
src/mesa/state_tracker/st_cb_bufferobjects.c Voir le fichier

@@ -103,6 +103,17 @@ st_bufferobj_subdata(GLcontext *ctx,
ASSERT(size >= 0);
ASSERT(offset + size <= obj->Size);

if (!size)
return;

/*
* According to ARB_vertex_buffer_object specification, if data is null,
* then the contents of the buffer object's data store is undefined. We just
* ignore, and leave it unchanged.
*/
if (!data)
return;

st_cond_flush_pipe_buffer_write(st_context(ctx), st_obj->buffer,
offset, size, data);
}
@@ -125,6 +136,9 @@ st_bufferobj_get_subdata(GLcontext *ctx,
ASSERT(size >= 0);
ASSERT(offset + size <= obj->Size);

if (!size)
return;

st_cond_flush_pipe_buffer_read(st_context(ctx), st_obj->buffer,
offset, size, data);
}
@@ -222,6 +236,13 @@ st_bufferobj_map(GLcontext *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().
*/
@@ -257,14 +278,26 @@ st_bufferobj_map_range(GLcontext *ctx, GLenum target,
assert(offset < obj->Size);
assert(offset + length <= obj->Size);

obj->Pointer = pipe_buffer_map_range(pipe->screen, st_obj->buffer, offset, length, flags);
/*
* We go out of way here to hide the degenerate yet valid case of zero
* length range from the pipe driver.
*/
if (!length) {
obj->Pointer = &st_bufferobj_zero_length_range;
}
else {
obj->Pointer = pipe_buffer_map_range(pipe->screen, st_obj->buffer, offset, length, flags);
if (obj->Pointer) {
obj->Pointer = (ubyte *) obj->Pointer + offset;
}
}
if (obj->Pointer) {
obj->Pointer = (ubyte *) obj->Pointer + offset;
obj->Offset = offset;
obj->Length = length;
obj->AccessFlags = access;
}
return obj->Pointer;
}

@@ -282,6 +315,9 @@ st_bufferobj_flush_mapped_range(GLcontext *ctx, GLenum target,
assert(length >= 0);
assert(offset + length <= obj->Length);
if (!length)
return;

pipe_buffer_flush_mapped_range(pipe->screen, st_obj->buffer,
obj->Offset + offset, length);
}
@@ -296,7 +332,9 @@ st_bufferobj_unmap(GLcontext *ctx, GLenum target, struct gl_buffer_object *obj)
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_buffer_object *st_obj = st_buffer_object(obj);

pipe_buffer_unmap(pipe->screen, st_obj->buffer);
if(obj->Length)
pipe_buffer_unmap(pipe->screen, st_obj->buffer);

obj->Pointer = NULL;
obj->Offset = 0;
obj->Length = 0;
@@ -319,6 +357,9 @@ st_copy_buffer_subdata(GLcontext *ctx,
struct st_buffer_object *dstObj = st_buffer_object(dst);
ubyte *srcPtr, *dstPtr;

if(!size)
return;

/* buffer should not already be mapped */
assert(!src->Pointer);
assert(!dst->Pointer);

Chargement…
Annuler
Enregistrer