diff options
author | Brian Paul <[email protected]> | 2009-09-03 10:41:14 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-09-03 11:45:17 -0600 |
commit | 203f395aaf717a6faf21a76979cc24d544ae148b (patch) | |
tree | 7ea47b4217909be8134d7d32007ff629dd783bcd /src/mesa/main/convolve.c | |
parent | 1b448c7a5cafa68eeead2a4c45f4362a9883383b (diff) |
mesa: use new _mesa_map_pbo_source/dest() functions in more places
This trims down the code a bit. The next step would be to combine
the validate and map operations into one helper...
Diffstat (limited to 'src/mesa/main/convolve.c')
-rw-r--r-- | src/mesa/main/convolve.c | 100 |
1 files changed, 35 insertions, 65 deletions
diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index 69dba72ed38..7e0761e68b8 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -144,27 +144,19 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G ctx->Convolution1D.Width = width; ctx->Convolution1D.Height = 1; - 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, image)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glConvolutionFilter1D(invalid PBO access)"); - 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 */ + if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1, + format, type, image)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glConvolutionFilter1D(invalid PBO access)"); + 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; } - image = ADD_POINTERS(buf, image); - } - else if (!image) { return; } @@ -173,10 +165,7 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G format, type, image, &ctx->Unpack, 0); /* transferOps */ - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); _mesa_scale_and_bias_rgba(width, (GLfloat (*)[4]) ctx->Convolution1D.Filter, @@ -242,27 +231,19 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G ctx->Convolution2D.Width = width; ctx->Convolution2D.Height = height; - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - /* unpack filter from PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, - format, type, image)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glConvolutionFilter2D(invalid PBO access)"); - 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 */ + if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, + format, type, image)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glConvolutionFilter2D(invalid PBO access)"); + 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; } - image = ADD_POINTERS(buf, image); - } - else if (!image) { return; } @@ -276,10 +257,7 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G 0); /* transferOps */ } - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); _mesa_scale_and_bias_rgba(width * height, (GLfloat (*)[4]) ctx->Convolution2D.Filter, @@ -598,26 +576,21 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, return; } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* Pack the filter into a PBO */ - GLubyte *buf; - 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; - } - 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 */ + 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)"); - return; } - image = ADD_POINTERS(image, buf); + return; } for (row = 0; row < filter->Height; row++) { @@ -629,10 +602,7 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, format, type, dst, &ctx->Pack, 0x0); } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - ctx->Pack.BufferObj); - } + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); } |