From: Brian Paul Date: Wed, 12 Aug 2009 19:46:16 +0000 (-0600) Subject: mesa: use _mesa_is_bufferobj() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=434ec3ada841915a00ffc23f699401eb3e7b37ee;p=mesa.git mesa: use _mesa_is_bufferobj() --- diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c index f5b7d1e1385..2462a1b0037 100644 --- a/src/mesa/main/api_arrayelt.c +++ b/src/mesa/main/api_arrayelt.c @@ -28,6 +28,7 @@ #include "glheader.h" #include "api_arrayelt.h" +#include "bufferobj.h" #include "context.h" #include "imports.h" #include "macros.h" @@ -1071,7 +1072,7 @@ void _ae_destroy_context( GLcontext *ctx ) static void check_vbo( AEcontext *actx, struct gl_buffer_object *vbo ) { - if (vbo->Name && !vbo->Pointer) { + if (_mesa_is_bufferobj(vbo) && !_mesa_bufferobj_mapped(vbo)) { GLuint i; for (i = 0; i < actx->nr_vbos; i++) if (actx->vbo[i] == vbo) diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index b2f11ffbfe3..33f4dd152a7 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -24,6 +24,7 @@ #include "glheader.h" #include "api_validate.h" +#include "bufferobj.h" #include "context.h" #include "imports.h" #include "mtypes.h" @@ -62,7 +63,7 @@ max_buffer_index(GLcontext *ctx, GLuint count, GLenum type, GLuint max = 0; GLuint i; - if (elementBuf->Name) { + if (_mesa_is_bufferobj(elementBuf)) { /* elements are in a user-defined buffer object. need to map it */ map = ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER, GL_READ_ONLY, elementBuf); @@ -164,7 +165,7 @@ _mesa_validate_DrawElements(GLcontext *ctx, return GL_FALSE; /* Vertex buffer object tests */ - if (ctx->Array.ElementArrayBufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) { /* use indices in the buffer object */ /* make sure count doesn't go outside buffer bounds */ if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) { @@ -237,7 +238,7 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode, return GL_FALSE; /* Vertex buffer object tests */ - if (ctx->Array.ElementArrayBufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) { /* use indices in the buffer object */ /* make sure count doesn't go outside buffer bounds */ if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) { diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index bd9cf438b4f..36304065eb7 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -179,7 +179,7 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table, GLfloat bScale, GLfloat bBias, GLfloat aScale, GLfloat aBias) { - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { /* Get/unpack the color table data from a PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(1, &ctx->Unpack, count, 1, 1, @@ -279,7 +279,7 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table, } } - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, ctx->Unpack.BufferObj); } @@ -696,7 +696,7 @@ _mesa_GetColorTable( GLenum target, GLenum format, return; } - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* pack color table into PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(1, &ctx->Pack, table->Size, 1, 1, @@ -720,7 +720,7 @@ _mesa_GetColorTable( GLenum target, GLenum format, _mesa_pack_rgba_span_float(ctx, table->Size, rgba, format, type, data, &ctx->Pack, 0x0); - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, ctx->Pack.BufferObj); } diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index 814c6a0a5a6..69dba72ed38 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -144,7 +144,7 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G ctx->Convolution1D.Width = width; ctx->Convolution1D.Height = 1; - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { /* unpack filter from PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1, @@ -173,7 +173,7 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G format, type, image, &ctx->Unpack, 0); /* transferOps */ - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, ctx->Unpack.BufferObj); } @@ -242,7 +242,7 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G ctx->Convolution2D.Width = width; ctx->Convolution2D.Height = height; - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { /* unpack filter from PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, @@ -276,7 +276,7 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G 0); /* transferOps */ } - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, ctx->Unpack.BufferObj); } @@ -598,7 +598,7 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, return; } - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* Pack the filter into a PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(2, &ctx->Pack, @@ -629,7 +629,7 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, format, type, dst, &ctx->Pack, 0x0); } - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, ctx->Pack.BufferObj); } @@ -802,7 +802,7 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, filter = &ctx->Separable2D; - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* Pack filter into PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(1, &ctx->Pack, filter->Width, 1, 1, @@ -850,7 +850,7 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, (void) span; /* unused at this time */ - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* Pack filter into PBO */ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, ctx->Unpack.BufferObj); @@ -905,7 +905,7 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs ctx->Separable2D.Width = width; ctx->Separable2D.Height = height; - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { /* unpack filter from PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1, @@ -971,7 +971,7 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs ctx->Pixel.ConvolutionFilterBias[2][3]); } - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, ctx->Unpack.BufferObj); } diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 49f202daa1c..4133f15dc72 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -690,7 +690,7 @@ unpack_image(GLuint dimensions, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels, const struct gl_pixelstore_attrib *unpack) { - if (unpack->BufferObj->Name == 0) { + if (!_mesa_is_bufferobj(unpack->BufferObj)) { /* no PBO */ return _mesa_unpack_image(dimensions, width, height, depth, format, type, pixels, unpack); diff --git a/src/mesa/main/histogram.c b/src/mesa/main/histogram.c index 5fee4fd0e34..726a50d3b1b 100644 --- a/src/mesa/main/histogram.c +++ b/src/mesa/main/histogram.c @@ -649,7 +649,7 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo return; } - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* pack min/max values into a PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(1, &ctx->Pack, 2, 1, 1, @@ -687,7 +687,7 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo format, type, values, &ctx->Pack, 0x0); } - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, ctx->Pack.BufferObj); } @@ -733,7 +733,7 @@ _mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, G return; } - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* pack min/max values into a PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(1, &ctx->Pack, ctx->Histogram.Width, 1, 1, @@ -761,7 +761,7 @@ _mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, G (CONST GLuint (*)[4]) ctx->Histogram.Count, format, type, values, &ctx->Pack); - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, ctx->Pack.BufferObj); } diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index d9f3e476e81..25f55a422fa 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -158,7 +158,7 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ) FLUSH_VERTICES(ctx, _NEW_PIXEL); - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { /* unpack pixelmap from PBO */ GLubyte *buf; /* Note, need to use DefaultPacking and Unpack's buffer object */ @@ -188,7 +188,7 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ) store_pixelmap(ctx, map, mapsize, values); - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, ctx->Unpack.BufferObj); } @@ -217,7 +217,7 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values ) FLUSH_VERTICES(ctx, _NEW_PIXEL); - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { /* unpack pixelmap from PBO */ GLubyte *buf; /* Note, need to use DefaultPacking and Unpack's buffer object */ @@ -259,7 +259,7 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values ) } } - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, ctx->Unpack.BufferObj); } @@ -290,7 +290,7 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values ) FLUSH_VERTICES(ctx, _NEW_PIXEL); - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { /* unpack pixelmap from PBO */ GLubyte *buf; /* Note, need to use DefaultPacking and Unpack's buffer object */ @@ -333,7 +333,7 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values ) } } - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, ctx->Unpack.BufferObj); } @@ -359,7 +359,7 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values ) mapsize = pm->Size; - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* pack pixelmap into PBO */ GLubyte *buf; /* Note, need to use DefaultPacking and Pack's buffer object */ @@ -397,7 +397,7 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values ) MEMCPY(values, pm->Map, mapsize * sizeof(GLfloat)); } - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, ctx->Pack.BufferObj); } @@ -420,7 +420,7 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values ) } mapsize = pm->Size; - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* pack pixelmap into PBO */ GLubyte *buf; /* Note, need to use DefaultPacking and Pack's buffer object */ @@ -458,7 +458,7 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values ) } } - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, ctx->Pack.BufferObj); } @@ -481,7 +481,7 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values ) } mapsize = pm ? pm->Size : 0; - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* pack pixelmap into PBO */ GLubyte *buf; /* Note, need to use DefaultPacking and Pack's buffer object */ @@ -528,7 +528,7 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values ) } } - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, ctx->Pack.BufferObj); } diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c index 564250b881c..d11c9424d5e 100644 --- a/src/mesa/main/polygon.c +++ b/src/mesa/main/polygon.c @@ -193,7 +193,7 @@ _mesa_PolygonMode( GLenum face, GLenum mode ) void _mesa_polygon_stipple(GLcontext *ctx, const GLubyte *pattern) { - if (ctx->Unpack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { /* Get/unpack the stipple pattern from a PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(2, &ctx->Unpack, 32, 32, 1, @@ -258,7 +258,7 @@ _mesa_GetPolygonStipple( GLubyte *dest ) /* XXX someday we may put this code into a separate function and call * it with ctx->Driver.GetPolygonStipple(). */ - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* Put/pack the stipple pattern into a PBO */ GLubyte *buf; if (!_mesa_validate_pbo_access(2, &ctx->Pack, 32, 32, 1, diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index 18958fd4386..feea1d375f6 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -190,7 +190,7 @@ _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, if (width == 0 || height == 0) return; /* nothing to do */ - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { if (!_mesa_validate_pbo_access(2, &ctx->Pack, width, height, 1, format, type, pixels)) { _mesa_error(ctx, GL_INVALID_OPERATION, diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 02409d80098..5557b694e37 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -30,6 +30,7 @@ #include "glheader.h" +#include "bufferobj.h" #include "context.h" #include "image.h" #include "texcompress.h" @@ -116,7 +117,7 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level, { const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2; - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* Packing texture image into a PBO. * Map the (potentially) VRAM-based buffer into our process space so * we can write into it with the code below. @@ -296,7 +297,7 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level, } /* img */ } - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, ctx->Pack.BufferObj); } @@ -316,7 +317,7 @@ _mesa_get_compressed_teximage(GLcontext *ctx, GLenum target, GLint level, { GLuint size; - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* pack texture image into a PBO */ GLubyte *buf; if ((const GLubyte *) img + texImage->CompressedSize > @@ -349,7 +350,7 @@ _mesa_get_compressed_teximage(GLcontext *ctx, GLenum target, GLint level, /* just memcpy, no pixelstore or pixel transfer */ _mesa_memcpy(img, texImage->Data, size); - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, ctx->Pack.BufferObj); } diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 83f025f86f8..c758462a46a 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2332,7 +2332,7 @@ getteximage_error_check(GLcontext *ctx, GLenum target, GLint level, return GL_TRUE; } - if (ctx->Pack.BufferObj->Name) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* packing texture image into a PBO */ const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2; if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width, diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index bfced1b3f4f..a22db628d3e 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -3138,7 +3138,7 @@ _mesa_validate_pbo_teximage(GLcontext *ctx, GLuint dimensions, { GLubyte *buf; - if (unpack->BufferObj->Name == 0) { + if (!_mesa_is_bufferobj(unpack->BufferObj)) { /* no PBO */ return pixels; } @@ -3174,7 +3174,7 @@ _mesa_validate_pbo_compressed_teximage(GLcontext *ctx, { GLubyte *buf; - if (packing->BufferObj->Name == 0) { + if (!_mesa_is_bufferobj(packing->BufferObj)) { /* not using a PBO - return pointer unchanged */ return pixels; } @@ -3204,7 +3204,7 @@ void _mesa_unmap_teximage_pbo(GLcontext *ctx, const struct gl_pixelstore_attrib *unpack) { - if (unpack->BufferObj->Name) { + if (_mesa_is_bufferobj(unpack->BufferObj)) { ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, unpack->BufferObj); }