diff options
Diffstat (limited to 'src/mesa/main/convolve.c')
-rw-r--r-- | src/mesa/main/convolve.c | 89 |
1 files changed, 23 insertions, 66 deletions
diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index 714909f451..4d17f533d7 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -744,59 +744,35 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, filter = &ctx->Separable2D; - 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, - format, type, row)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetSeparableFilter(invalid PBO access, width)"); - return; - } - if (!_mesa_validate_pbo_access(1, &ctx->Pack, filter->Height, 1, 1, - format, type, column)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetSeparableFilter(invalid PBO access, height)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, - ctx->Pack.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetSeparableFilter(PBO is mapped)"); - return; - } - row = ADD_POINTERS(buf, row); - column = ADD_POINTERS(buf, column); - } - - /* Row filter */ + /* Get row filter */ + row = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, + filter->Width, 1, 1, + format, type, row, + "glGetConvolutionFilter"); if (row) { GLvoid *dst = _mesa_image_address1d(&ctx->Pack, row, filter->Width, format, type, 0); _mesa_pack_rgba_span_float(ctx, filter->Width, (GLfloat (*)[4]) filter->Filter, format, type, dst, &ctx->Pack, 0x0); + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); } - /* Column filter */ + /* get column filter */ + column = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, + filter->Height, 1, 1, + format, type, row, + "glGetConvolutionFilter"); if (column) { GLvoid *dst = _mesa_image_address1d(&ctx->Pack, column, filter->Height, format, type, 0); GLfloat (*src)[4] = (GLfloat (*)[4]) (filter->Filter + colStart); _mesa_pack_rgba_span_float(ctx, filter->Height, src, format, type, dst, &ctx->Pack, 0x0); + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); } (void) span; /* unused at this time */ - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* Pack filter into PBO */ - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } } @@ -847,41 +823,16 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs ctx->Separable2D.Width = width; ctx->Separable2D.Height = height; - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - /* unpack filter from PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1, - format, type, row)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glSeparableFilter2D(invalid PBO access, width)"); - return; - } - if (!_mesa_validate_pbo_access(1, &ctx->Unpack, height, 1, 1, - format, type, column)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glSeparableFilter2D(invalid PBO access, height)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, - ctx->Unpack.BufferObj); - if (!buf) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glSeparableFilter2D(PBO is mapped)"); - return; - } - row = ADD_POINTERS(buf, row); - column = ADD_POINTERS(buf, column); - } - /* unpack row filter */ + row = _mesa_map_validate_pbo_source(ctx, 1, &ctx->Unpack, + width, 1, 1, + format, type, row, + "glSeperableFilter2D"); if (row) { _mesa_unpack_color_span_float(ctx, width, GL_RGBA, ctx->Separable2D.Filter, format, type, row, &ctx->Unpack, - 0); /* transferOps */ - + 0x0); /* transferOps */ _mesa_scale_and_bias_rgba(width, (GLfloat (*)[4]) ctx->Separable2D.Filter, ctx->Pixel.ConvolutionFilterScale[2][0], @@ -892,9 +843,14 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs ctx->Pixel.ConvolutionFilterBias[2][1], ctx->Pixel.ConvolutionFilterBias[2][2], ctx->Pixel.ConvolutionFilterBias[2][3]); + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); } /* unpack column filter */ + column = _mesa_map_validate_pbo_source(ctx, 1, &ctx->Unpack, + height, 1, 1, + format, type, row, + "glSeperableFilter2D"); if (column) { _mesa_unpack_color_span_float(ctx, height, GL_RGBA, &ctx->Separable2D.Filter[colStart], @@ -911,6 +867,7 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs ctx->Pixel.ConvolutionFilterBias[2][1], ctx->Pixel.ConvolutionFilterBias[2][2], ctx->Pixel.ConvolutionFilterBias[2][3]); + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); } if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { |