mesa: use new combined PBO validate/map helpers
authorBrian Paul <brianp@vmware.com>
Thu, 3 Sep 2009 17:23:05 +0000 (11:23 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 3 Sep 2009 17:45:17 +0000 (11:45 -0600)
src/mesa/main/colortab.c
src/mesa/main/convolve.c
src/mesa/main/histogram.c
src/mesa/main/polygon.c

index 91c29882ecc831fe8751c49790445b18d90e4aa4..5a7de5f2098d6c5d29c935487550d8226456fba0 100644 (file)
@@ -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);
index 7e0761e68b81715d96e61c799f6e1f539cd375b4..714909f451d15fb1aade161d99177c925b383f9e 100644 (file)
@@ -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,
index f1d01cdb62145bc56853c849c012a720e0d6f9af..ceb0d5a6a86c1970b95a70add996f4e66dd220f1 100644 (file)
@@ -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,
index e327a52415931bf19696f48dbac8fe0e0a5a259d..376a87a396770a8996980b27cd48d9dda9004d4b 100644 (file)
@@ -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);