From: Brian Paul Date: Thu, 3 Sep 2009 17:23:05 +0000 (-0600) Subject: mesa: use new combined PBO validate/map helpers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=95027a00870bc1d12ea24dfb092a0cad6cbd5035;p=mesa.git mesa: use new combined PBO validate/map helpers --- diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index 91c29882ecc..5a7de5f2098 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -179,21 +179,12 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table, GLfloat bScale, GLfloat bBias, GLfloat aScale, GLfloat aBias) { - if (!_mesa_validate_pbo_access(1, &ctx->Unpack, count, 1, 1, - format, type, data)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glColor[Sub]Table(bad PBO access)"); + data = _mesa_map_validate_pbo_source(ctx, + 1, &ctx->Unpack, count, 1, 1, + format, type, data, + "glColor[Sub]Table"); + if (!data) return; - } - - data = _mesa_map_pbo_source(ctx, &ctx->Unpack, data); - if (!data) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glColor[Sub]Table(PBO mapped)"); - } - return; - } { /* convert user-provided data to GLfloat values */ @@ -688,22 +679,12 @@ _mesa_GetColorTable( GLenum target, GLenum format, return; } - if (!_mesa_validate_pbo_access(1, &ctx->Pack, table->Size, 1, 1, - format, type, data)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetColorTable(invalid PBO access)"); + data = _mesa_map_validate_pbo_dest(ctx, + 1, &ctx->Pack, table->Size, 1, 1, + format, type, data, + "glGetColorTable"); + if (!data) return; - } - - data = _mesa_map_pbo_dest(ctx, &ctx->Pack, data); - if (!data) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetColorTable(PBO is mapped)"); - } - return; - } _mesa_pack_rgba_span_float(ctx, table->Size, rgba, format, type, data, &ctx->Pack, 0x0); diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index 7e0761e68b8..714909f451d 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -144,21 +144,12 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G ctx->Convolution1D.Width = width; ctx->Convolution1D.Height = 1; - if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1, - format, type, image)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glConvolutionFilter1D(invalid PBO access)"); + image = _mesa_map_validate_pbo_source(ctx, + 1, &ctx->Unpack, width, 1, 1, + format, type, image, + "glConvolutionFilter1D"); + if (!image) return; - } - - image = _mesa_map_pbo_source(ctx, &ctx->Unpack, image); - if (!image) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glConvolutionFilter1D(PBO is mapped)"); - } - return; - } _mesa_unpack_color_span_float(ctx, width, GL_RGBA, ctx->Convolution1D.Filter, @@ -231,21 +222,12 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G ctx->Convolution2D.Width = width; ctx->Convolution2D.Height = height; - if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, - format, type, image)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glConvolutionFilter2D(invalid PBO access)"); + image = _mesa_map_validate_pbo_source(ctx, + 2, &ctx->Unpack, width, height, 1, + format, type, image, + "glConvolutionFilter2D"); + if (!image) return; - } - - image = _mesa_map_pbo_source(ctx, &ctx->Unpack, image); - if (!image) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glConvolutionFilter2D(PBO is mapped)"); - } - return; - } /* Unpack filter image. We always store filters in RGBA format. */ for (i = 0; i < height; i++) { @@ -576,22 +558,12 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, return; } - if (!_mesa_validate_pbo_access(2, &ctx->Pack, - filter->Width, filter->Height, - 1, format, type, image)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetConvolutionFilter(invalid PBO access)"); - return; - } - - image = _mesa_map_pbo_dest(ctx, &ctx->Pack, image); - if (!image) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetConvolutionFilter(PBO is mapped)"); - } + image = _mesa_map_validate_pbo_dest(ctx, 2, &ctx->Pack, + filter->Width, filter->Height, 1, + format, type, image, + "glGetConvolutionFilter"); + if (!image) return; - } for (row = 0; row < filter->Height; row++) { GLvoid *dst = _mesa_image_address2d(&ctx->Pack, image, filter->Width, diff --git a/src/mesa/main/histogram.c b/src/mesa/main/histogram.c index f1d01cdb621..ceb0d5a6a86 100644 --- a/src/mesa/main/histogram.c +++ b/src/mesa/main/histogram.c @@ -649,21 +649,11 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo return; } - if (!_mesa_validate_pbo_access(1, &ctx->Pack, 2, 1, 1, - format, type, values)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetMinMax(invalid PBO access)"); - return; - } - values = _mesa_map_pbo_dest(ctx, &ctx->Pack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION,"glGetMinMax(PBO is mapped)"); - } + values = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, 2, 1, 1, + format, type, values, "glGetMinmax"); + if (!values) return; - } { GLfloat minmax[2][4]; @@ -722,20 +712,12 @@ _mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, G return; } - if (!_mesa_validate_pbo_access(1, &ctx->Pack, ctx->Histogram.Width, 1, 1, - format, type, values)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetHistogram(invalid PBO access)"); + values = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, + ctx->Histogram.Width, 1, 1, + format, type, values, + "glGetHistogram"); + if (!values) return; - } - - values = _mesa_map_pbo_dest(ctx, &ctx->Pack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - _mesa_error(ctx,GL_INVALID_OPERATION,"glGetHistogram(PBO is mapped)"); - } - return; - } pack_histogram(ctx, ctx->Histogram.Width, (CONST GLuint (*)[4]) ctx->Histogram.Count, diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c index e327a524159..376a87a3967 100644 --- a/src/mesa/main/polygon.c +++ b/src/mesa/main/polygon.c @@ -193,21 +193,12 @@ _mesa_PolygonMode( GLenum face, GLenum mode ) void _mesa_polygon_stipple(GLcontext *ctx, const GLubyte *pattern) { - if (!_mesa_validate_pbo_access(2, &ctx->Unpack, 32, 32, 1, - GL_COLOR_INDEX, GL_BITMAP, pattern)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPolygonStipple(bad PBO access)"); + pattern = _mesa_map_validate_pbo_source(ctx, 2, + &ctx->Unpack, 32, 32, 1, + GL_COLOR_INDEX, GL_BITMAP, pattern, + "glPolygonStipple"); + if (!pattern) return; - } - - pattern = _mesa_map_pbo_source(ctx, &ctx->Unpack, pattern); - if (!pattern) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPolygonStipple(PBO mapped)"); - } - return; - } _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack); @@ -248,21 +239,12 @@ _mesa_GetPolygonStipple( GLubyte *dest ) if (MESA_VERBOSE&VERBOSE_API) _mesa_debug(ctx, "glGetPolygonStipple\n"); - if (!_mesa_validate_pbo_access(2, &ctx->Pack, 32, 32, 1, - GL_COLOR_INDEX, GL_BITMAP, dest)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPolygonStipple(bad PBO access)"); + dest = _mesa_map_validate_pbo_dest(ctx, 2, + &ctx->Pack, 32, 32, 1, + GL_COLOR_INDEX, GL_BITMAP, dest, + "glGetPolygonStipple"); + if (!dest) return; - } - - dest = _mesa_map_pbo_dest(ctx, &ctx->Pack, dest); - if (!dest) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPolygonStipple(PBO mapped)"); - } - return; - } _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack);