Don't allow queries/etc of buffer object 0 - it's invisible to users.
Misc clean-ups.
This commit is contained in:
@@ -113,17 +113,17 @@ buffer_object_subdata_range_good( GLcontext * ctx, GLenum target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bufObj = buffer_object_get_target( ctx, target, str );
|
bufObj = buffer_object_get_target( ctx, target, str );
|
||||||
if ( bufObj == NULL ) {
|
if (!bufObj || bufObj->Name == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (GLuint)(offset + size) > bufObj->Size ) {
|
if ((GLuint) (offset + size) > bufObj->Size) {
|
||||||
_mesa_error(ctx, GL_INVALID_VALUE,
|
_mesa_error(ctx, GL_INVALID_VALUE,
|
||||||
"%s(size + offset > buffer size)", str);
|
"%s(size + offset > buffer size)", str);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( bufObj->Pointer ) {
|
if (bufObj->Pointer) {
|
||||||
/* Buffer is currently mapped */
|
/* Buffer is currently mapped */
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "%s", str);
|
_mesa_error(ctx, GL_INVALID_OPERATION, "%s", str);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -242,12 +242,12 @@ _mesa_buffer_data( GLcontext *ctx, GLenum target, GLsizeiptrARB size,
|
|||||||
(void) ctx; (void) target;
|
(void) ctx; (void) target;
|
||||||
|
|
||||||
new_data = _mesa_realloc( bufObj->Data, bufObj->Size, size );
|
new_data = _mesa_realloc( bufObj->Data, bufObj->Size, size );
|
||||||
if ( new_data != NULL ) {
|
if (new_data) {
|
||||||
bufObj->Data = (GLubyte *) new_data;
|
bufObj->Data = (GLubyte *) new_data;
|
||||||
bufObj->Size = size;
|
bufObj->Size = size;
|
||||||
bufObj->Usage = usage;
|
bufObj->Usage = usage;
|
||||||
|
|
||||||
if ( data != NULL ) {
|
if (data) {
|
||||||
_mesa_memcpy( bufObj->Data, data, size );
|
_mesa_memcpy( bufObj->Data, data, size );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,8 +279,7 @@ _mesa_buffer_subdata( GLcontext *ctx, GLenum target, GLintptrARB offset,
|
|||||||
{
|
{
|
||||||
(void) ctx; (void) target;
|
(void) ctx; (void) target;
|
||||||
|
|
||||||
if ( (bufObj->Data != NULL)
|
if (bufObj->Data && ((GLuint) (size + offset) <= bufObj->Size)) {
|
||||||
&& ((GLuint)(size + offset) <= bufObj->Size) ) {
|
|
||||||
_mesa_memcpy( (GLubyte *) bufObj->Data + offset, data, size );
|
_mesa_memcpy( (GLubyte *) bufObj->Data + offset, data, size );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,8 +310,7 @@ _mesa_buffer_get_subdata( GLcontext *ctx, GLenum target, GLintptrARB offset,
|
|||||||
{
|
{
|
||||||
(void) ctx; (void) target;
|
(void) ctx; (void) target;
|
||||||
|
|
||||||
if ( (bufObj->Data != NULL)
|
if (bufObj->Data && ((GLuint) (size + offset) <= bufObj->Size)) {
|
||||||
&& ((GLuint)(size + offset) <= bufObj->Size) ) {
|
|
||||||
_mesa_memcpy( data, (GLubyte *) bufObj->Data + offset, size );
|
_mesa_memcpy( data, (GLubyte *) bufObj->Data + offset, size );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -480,13 +478,13 @@ _mesa_BindBufferARB(GLenum target, GLuint buffer)
|
|||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
|
|
||||||
oldBufObj = buffer_object_get_target( ctx, target, "BindBufferARB" );
|
oldBufObj = buffer_object_get_target( ctx, target, "BindBufferARB" );
|
||||||
if ( (oldBufObj != NULL) && (oldBufObj->Name == buffer) )
|
if (oldBufObj && oldBufObj->Name == buffer)
|
||||||
return; /* rebinding the same buffer object- no change */
|
return; /* rebinding the same buffer object- no change */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get pointer to new buffer object (newBufObj)
|
* Get pointer to new buffer object (newBufObj)
|
||||||
*/
|
*/
|
||||||
if ( buffer == 0 ) {
|
if (buffer == 0) {
|
||||||
/* The spec says there's not a buffer object named 0, but we use
|
/* The spec says there's not a buffer object named 0, but we use
|
||||||
* one internally because it simplifies things.
|
* one internally because it simplifies things.
|
||||||
*/
|
*/
|
||||||
@@ -527,10 +525,10 @@ _mesa_BindBufferARB(GLenum target, GLuint buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Pass BindBuffer call to device driver */
|
/* Pass BindBuffer call to device driver */
|
||||||
if ( (ctx->Driver.BindBuffer != NULL) && (newBufObj != NULL) )
|
if (ctx->Driver.BindBuffer && newBufObj)
|
||||||
(*ctx->Driver.BindBuffer)( ctx, target, newBufObj );
|
(*ctx->Driver.BindBuffer)( ctx, target, newBufObj );
|
||||||
|
|
||||||
if ( oldBufObj != NULL ) {
|
if (oldBufObj) {
|
||||||
oldBufObj->RefCount--;
|
oldBufObj->RefCount--;
|
||||||
assert(oldBufObj->RefCount >= 0);
|
assert(oldBufObj->RefCount >= 0);
|
||||||
if (oldBufObj->RefCount == 0) {
|
if (oldBufObj->RefCount == 0) {
|
||||||
@@ -679,7 +677,7 @@ _mesa_GenBuffersARB(GLsizei n, GLuint *buffer)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( buffer == NULL ) {
|
if (!buffer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -764,7 +762,7 @@ _mesa_BufferDataARB(GLenum target, GLsizeiptrARB size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bufObj = buffer_object_get_target( ctx, target, "BufferDataARB" );
|
bufObj = buffer_object_get_target( ctx, target, "BufferDataARB" );
|
||||||
if ( bufObj == NULL ) {
|
if (!bufObj || bufObj->Name ==0) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glBufferDataARB" );
|
_mesa_error(ctx, GL_INVALID_OPERATION, "glBufferDataARB" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -840,19 +838,19 @@ _mesa_MapBufferARB(GLenum target, GLenum access)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bufObj = buffer_object_get_target( ctx, target, "MapBufferARB" );
|
bufObj = buffer_object_get_target( ctx, target, "MapBufferARB" );
|
||||||
if ( bufObj == NULL ) {
|
if (!bufObj || bufObj->Name == 0) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB" );
|
_mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB" );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( bufObj->Pointer != NULL ) {
|
if (bufObj->Pointer) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB(already mapped)");
|
_mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB(already mapped)");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(ctx->Driver.MapBuffer);
|
ASSERT(ctx->Driver.MapBuffer);
|
||||||
bufObj->Pointer = (*ctx->Driver.MapBuffer)( ctx, target, access, bufObj );
|
bufObj->Pointer = (*ctx->Driver.MapBuffer)( ctx, target, access, bufObj );
|
||||||
if ( bufObj->Pointer == NULL ) {
|
if (!bufObj->Pointer) {
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(access)");
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(access)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -871,17 +869,17 @@ _mesa_UnmapBufferARB(GLenum target)
|
|||||||
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
|
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
|
||||||
|
|
||||||
bufObj = buffer_object_get_target( ctx, target, "UnmapBufferARB" );
|
bufObj = buffer_object_get_target( ctx, target, "UnmapBufferARB" );
|
||||||
if ( bufObj == NULL ) {
|
if (!bufObj || bufObj->Name == 0) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB" );
|
_mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB" );
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( bufObj->Pointer == NULL ) {
|
if (!bufObj->Pointer) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB");
|
_mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ctx->Driver.UnmapBuffer != NULL ) {
|
if (ctx->Driver.UnmapBuffer) {
|
||||||
status = (*ctx->Driver.UnmapBuffer)( ctx, target, bufObj );
|
status = (*ctx->Driver.UnmapBuffer)( ctx, target, bufObj );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -900,7 +898,7 @@ _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params)
|
|||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
|
|
||||||
bufObj = buffer_object_get_target( ctx, target, "GetBufferParameterivARB" );
|
bufObj = buffer_object_get_target( ctx, target, "GetBufferParameterivARB" );
|
||||||
if (!bufObj) {
|
if (!bufObj || bufObj->Name == 0) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "GetBufferParameterivARB" );
|
_mesa_error(ctx, GL_INVALID_OPERATION, "GetBufferParameterivARB" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -938,7 +936,7 @@ _mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bufObj = buffer_object_get_target( ctx, target, "GetBufferPointervARB" );
|
bufObj = buffer_object_get_target( ctx, target, "GetBufferPointervARB" );
|
||||||
if ( bufObj == NULL ) {
|
if (!bufObj || bufObj->Name == 0) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferPointervARB" );
|
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferPointervARB" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user