Commit 2daa4137 authored by Brian Paul's avatar Brian Paul

Remove redundant error checking.

Added _mesa_buffer_unmap().
Minor clean-ups.
parent 9ae96a5c
/*
* Mesa 3-D graphics library
* Version: 6.2
* Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
......@@ -123,7 +123,8 @@ buffer_object_subdata_range_good( GLcontext * ctx, GLenum target,
return NULL;
}
if ( bufObj->Pointer != NULL ) {
if ( bufObj->Pointer ) {
/* Buffer is currently mapped */
_mesa_error(ctx, GL_INVALID_OPERATION, "%s", str);
return NULL;
}
......@@ -318,16 +319,16 @@ _mesa_buffer_get_subdata( GLcontext *ctx, GLenum target, GLintptrARB offset,
/**
* 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
*
......@@ -335,10 +336,41 @@ _mesa_buffer_get_subdata( GLcontext *ctx, GLenum target, GLintptrARB offset,
*/
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;
}
......@@ -383,6 +415,10 @@ _mesa_init_buffer_objects( GLcontext *ctx )
* 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
......@@ -755,15 +791,10 @@ _mesa_BufferSubDataARB(GLenum target, GLintptrARB offset,
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 );
}
......@@ -780,15 +811,10 @@ _mesa_GetBufferSubDataARB(GLenum target, GLintptrARB offset,
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 );
}
......
/*
* Mesa 3-D graphics library
* Version: 6.1
* Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
......@@ -73,6 +73,9 @@ extern void *
_mesa_buffer_map( GLcontext *ctx, GLenum target, GLenum access,
struct gl_buffer_object * bufObj );
extern GLboolean
_mesa_buffer_unmap( GLcontext *ctx, GLenum target,
struct gl_buffer_object * bufObj );
extern GLboolean
_mesa_validate_pbo_access(const struct gl_pixelstore_attrib *pack,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment