GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object * bufObj;
GLbitfield accessFlags;
+ void *map;
+
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
switch (access) {
}
ASSERT(ctx->Driver.MapBuffer);
- bufObj->Pointer = ctx->Driver.MapBuffer( ctx, target, access, bufObj );
- if (!_mesa_bufferobj_mapped(bufObj)) {
+ map = ctx->Driver.MapBuffer( ctx, target, access, bufObj );
+ if (!map) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(access)");
}
- bufObj->AccessFlags = accessFlags;
- bufObj->Offset = 0;
- bufObj->Length = bufObj->Size;
+ if (map) {
+ /* The driver callback should have set these fields.
+ * This is important because other modules (like VBO) might call
+ * the driver function directly.
+ */
+ ASSERT(bufObj->Pointer == map);
+ ASSERT(bufObj->Length == bufObj->Size);
+ ASSERT(bufObj->Offset == 0);
+ bufObj->AccessFlags = accessFlags;
+ }
if (access == GL_WRITE_ONLY_ARB || access == GL_READ_WRITE_ARB)
bufObj->Written = GL_TRUE;
{
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ void *map;
+
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
if (!ctx->Extensions.ARB_map_buffer_range) {
}
ASSERT(ctx->Driver.MapBufferRange);
- bufObj->Pointer = ctx->Driver.MapBufferRange(ctx, target, offset, length,
- access, bufObj);
-
- bufObj->Offset = offset;
- bufObj->Length = length;
- bufObj->AccessFlags = access;
+ map = ctx->Driver.MapBufferRange(ctx, target, offset, length,
+ access, bufObj);
+ if (map) {
+ /* The driver callback should have set all these fields.
+ * This is important because other modules (like VBO) might call
+ * the driver function directly.
+ */
+ ASSERT(bufObj->Pointer == map);
+ ASSERT(bufObj->Length == length);
+ ASSERT(bufObj->Offset == offset);
+ ASSERT(bufObj->AccessFlags == access);
+ }
- return bufObj->Pointer;
+ return map;
}