/*
* Mesa 3-D graphics library
- * Version: 6.2
+ * Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
return NULL;
}
- if ( bufObj->Pointer != NULL ) {
+ if ( bufObj->Pointer ) {
+ /* Buffer is currently mapped */
_mesa_error(ctx, GL_INVALID_OPERATION, "%s", str);
return NULL;
}
/**
- * Maps the private data buffer into the processor's address space.
+ * Fallback function called via ctx->Driver.MapBuffer().
+ * Hardware drivers that really implement buffer objects should never use
+ * function.
*
- * This function is intended to be called by \c dd_function_table::MapBuffer.
- * This function need not set GL error codes. The input parameters will have
- * been tested before calling.
+ * The input parameters will have been already tested for errors.
*
* \param ctx GL context.
* \param target Buffer object target on which to operate.
* \param access Information about how the buffer will be accessed.
- * \param bufObj Object to be used.
+ * \param bufObj Object to be mapped.
* \return A pointer to the object's internal data store that can be accessed
* by the processor
*
*/
void *
_mesa_buffer_map( GLcontext *ctx, GLenum target, GLenum access,
- struct gl_buffer_object * bufObj )
+ struct gl_buffer_object *bufObj )
+{
+ (void) ctx;
+ (void) target;
+ (void) access;
+ ASSERT(!bufObj->OnCard);
+ /* Just return a direct pointer to the data */
+ if (bufObj->Pointer) {
+ /* already mapped! */
+ return NULL;
+ }
+ bufObj->Pointer = bufObj->Data;
+ return bufObj->Pointer;
+}
+
+
+/**
+ * Fallback function called via ctx->Driver.MapBuffer().
+ * Hardware drivers that really implement buffer objects should never use
+ * function.
+ *
+ * The input parameters will have been already tested for errors.
+ *
+ * \sa glUnmapBufferARB, dd_function_table::UnmapBuffer
+ */
+GLboolean
+_mesa_buffer_unmap( GLcontext *ctx, GLenum target,
+ struct gl_buffer_object *bufObj )
{
- (void) ctx; (void) target; (void) access;
- return bufObj->Data;
+ (void) ctx;
+ (void) target;
+ ASSERT(!bufObj->OnCard);
+ /* XXX we might assert here that bufObj->Pointer is non-null */
+ bufObj->Pointer = NULL;
+ return GL_TRUE;
}
* glGetTexImage, etc) we call this function to check that we're not
* going to read out of bounds.
*
+ * XXX This would also be a convenient time to check that the PBO isn't
+ * currently mapped. Whoever calls this function should check for that.
+ * Remember, we can't use a PBO when it's mapped!
+ *
* \param width width of image to read/write
* \param height height of image to read/write
* \param depth depth of image to read/write
bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,
"BufferSubDataARB" );
if (!bufObj) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferSubDataARB" );
+ /* error already recorded */
return;
}
- if (bufObj->Pointer) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferSubDataARB(buffer is mapped)" );
- return;
- }
-
ASSERT(ctx->Driver.BufferSubData);
(*ctx->Driver.BufferSubData)( ctx, target, offset, size, data, bufObj );
}
bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,
"GetBufferSubDataARB" );
if (!bufObj) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferSubDataARB" );
+ /* error already recorded */
return;
}
- if (bufObj->Pointer) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferSubDataARB(buffer is mapped)" );
- return;
- }
-
ASSERT(ctx->Driver.GetBufferSubData);
(*ctx->Driver.GetBufferSubData)( ctx, target, offset, size, data, bufObj );
}