summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-11-18 11:40:09 -0700
committerBrian Paul <brianp@vmware.com>2009-11-18 16:52:14 -0700
commit92ca1f4e65aac8ac974ede9d581daf5e53f2013c (patch)
tree8066f2005b3793b72ca2a414cacaa53b8650dd66
parent2dec9219a830624781449886e68e9dc0e3e3b460 (diff)
mesa: simplify teximage PBO mapping/unmapping
Now that error checking is done higher/sooner we don't have to worry about it here. This lets us merge the compressed/uncompressed cases. More simplification and consolidation with the PBO map/unmap functions in bufferobj.c is possible...
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_image.c10
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_subimage.c9
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_texture.c18
-rw-r--r--src/mesa/drivers/dri/unichrome/via_tex.c4
-rw-r--r--src/mesa/main/texstore.c77
-rw-r--r--src/mesa/main/texstore.h13
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c15
7 files changed, 27 insertions, 119 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 44270eea0b..f098b6898a 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -451,15 +451,7 @@ intelTexImage(GLcontext * ctx,
* the expectation that the mipmap tree will be set up but nothing
* more will be done. This is where those calls return:
*/
- if (compressed) {
- pixels = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, pixels,
- unpack,
- "glCompressedTexImage");
- } else {
- pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1,
- format, type,
- pixels, unpack, "glTexImage");
- }
+ pixels = _mesa_map_teximage_pbo(ctx, unpack, pixels);
LOCK_HARDWARE(intel);
diff --git a/src/mesa/drivers/dri/intel/intel_tex_subimage.c b/src/mesa/drivers/dri/intel/intel_tex_subimage.c
index bc3739bdae..e4ab588a0f 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_subimage.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_subimage.c
@@ -61,14 +61,7 @@ intelTexSubimage(GLcontext * ctx,
intelFlush(ctx);
- if (compressed)
- pixels = _mesa_validate_pbo_compressed_teximage(ctx, imageSize,
- pixels, packing,
- "glCompressedTexImage");
- else
- pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, depth,
- format, type, pixels, packing,
- "glTexSubImage");
+ pixels = _mesa_map_teximage_pbo(ctx, packing, pixels);
if (!pixels)
return;
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c
index 7de8fa0d3a..32660952b8 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -584,15 +584,7 @@ static void radeon_teximage(
}
/* Upload texture image; note that the spec allows pixels to be NULL */
- if (compressed) {
- pixels = _mesa_validate_pbo_compressed_teximage(
- ctx, imageSize, pixels, packing, "glCompressedTexImage");
- } else {
- pixels = _mesa_validate_pbo_teximage(
- ctx, dims, width, height, depth,
- format, type, pixels, packing, "glTexImage");
- }
-
+ pixels = _mesa_map_teximage_pbo(ctx, packing, pixels);
if (pixels) {
radeon_teximage_map(image, GL_TRUE);
if (compressed) {
@@ -725,14 +717,8 @@ static void radeon_texsubimage(GLcontext* ctx, int dims, GLenum target, int leve
radeon_firevertices(rmesa);
t->validated = GL_FALSE;
- if (compressed) {
- pixels = _mesa_validate_pbo_compressed_teximage(
- ctx, imageSize, pixels, packing, "glCompressedTexImage");
- } else {
- pixels = _mesa_validate_pbo_teximage(ctx, dims,
- width, height, depth, format, type, pixels, packing, "glTexSubImage1D");
- }
+ pixels = _mesa_map_teximage_pbo(ctx, packing, pixels);
if (pixels) {
GLint dstRowStride;
radeon_teximage_map(image, GL_TRUE);
diff --git a/src/mesa/drivers/dri/unichrome/via_tex.c b/src/mesa/drivers/dri/unichrome/via_tex.c
index c009276958..8a4e44fbc8 100644
--- a/src/mesa/drivers/dri/unichrome/via_tex.c
+++ b/src/mesa/drivers/dri/unichrome/via_tex.c
@@ -771,9 +771,7 @@ static void viaTexImage(GLcontext *ctx,
vmesa->clearTexCache = 1;
- pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1,
- format, type,
- pixels, packing, "glTexImage");
+ pixels = _mesa_map_teximage_pbo(ctx, packing, pixels);
if (!pixels) {
/* Note: we check for a NULL image pointer here, _after_ we allocated
* memory for the texture. That's what the GL spec calls for.
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index cd4a13e3cd..08bebfb154 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -3178,17 +3178,16 @@ _mesa_texstore(TEXSTORE_PARAMS)
/**
- * Check if an unpack PBO is active prior to fetching a texture image.
- * If so, do bounds checking and map the buffer into main memory.
- * Any errors detected will be recorded.
+ * If texture image data is coming from a PBO, map the PBO and
+ * return a pointer into the mapping.
+ * Else return the 'pixels' pointer unchanged.
+ * PBO error checking was already done in the teximage.c code.
* The caller _must_ call _mesa_unmap_teximage_pbo() too!
*/
const GLvoid *
-_mesa_validate_pbo_teximage(GLcontext *ctx, GLuint dimensions,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *unpack,
- const char *funcName)
+_mesa_map_teximage_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels)
{
GLubyte *buf;
@@ -3197,38 +3196,8 @@ _mesa_validate_pbo_teximage(GLcontext *ctx, GLuint dimensions,
return pixels;
}
- buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
- GL_READ_ONLY_ARB, unpack->BufferObj);
- if (!buf) {
- return NULL;
- }
-
- return ADD_POINTERS(buf, pixels);
-}
-
-
-/**
- * Check if an unpack PBO is active prior to fetching a compressed texture
- * image.
- * If so, do bounds checking and map the buffer into main memory.
- * Any errors detected will be recorded.
- * The caller _must_ call _mesa_unmap_teximage_pbo() too!
- */
-const GLvoid *
-_mesa_validate_pbo_compressed_teximage(GLcontext *ctx,
- GLsizei imageSize, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- const char *funcName)
-{
- GLubyte *buf;
-
- if (!_mesa_is_bufferobj(packing->BufferObj)) {
- /* not using a PBO - return pointer unchanged */
- return pixels;
- }
-
buf = (GLubyte*) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
- GL_READ_ONLY_ARB, packing->BufferObj);
+ GL_READ_ONLY_ARB, unpack->BufferObj);
if (!buf) {
return NULL;
}
@@ -3238,8 +3207,7 @@ _mesa_validate_pbo_compressed_teximage(GLcontext *ctx,
/**
- * This function must be called after either of the validate_pbo_*_teximage()
- * functions. It unmaps the PBO buffer if it was mapped earlier.
+ * This is the counterpart to the _mesa_map_teximage_pbo().
*/
void
_mesa_unmap_teximage_pbo(GLcontext *ctx,
@@ -3285,8 +3253,7 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
return;
}
- pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type,
- pixels, packing, "glTexImage1D");
+ pixels = _mesa_map_teximage_pbo(ctx, pixels, packing);
if (!pixels) {
/* Note: we check for a NULL image pointer here, _after_ we allocated
* memory for the texture. That's what the GL spec calls for.
@@ -3339,8 +3306,7 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
return;
}
- pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
- pixels, packing, "glTexImage2D");
+ pixels = _mesa_map_teximage_pbo(ctx, packing, pixels);
if (!pixels) {
/* Note: we check for a NULL image pointer here, _after_ we allocated
* memory for the texture. That's what the GL spec calls for.
@@ -3389,8 +3355,7 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
return;
}
- pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format,
- type, pixels, packing, "glTexImage3D");
+ pixels = _mesa_map_teximage_pbo(ctx, packing, pixels);
if (!pixels) {
/* Note: we check for a NULL image pointer here, _after_ we allocated
* memory for the texture. That's what the GL spec calls for.
@@ -3431,8 +3396,7 @@ _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_image *texImage)
{
/* get pointer to src pixels (may be in a pbo which we'll map here) */
- pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type,
- pixels, packing, "glTexSubImage1D");
+ pixels = _mesa_map_teximage_pbo(ctx, packing, pixels);
if (!pixels)
return;
@@ -3470,8 +3434,7 @@ _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_image *texImage)
{
/* get pointer to src pixels (may be in a pbo which we'll map here) */
- pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
- pixels, packing, "glTexSubImage2D");
+ pixels = _mesa_map_teximage_pbo(ctx, packing, pixels);
if (!pixels)
return;
@@ -3508,9 +3471,7 @@ _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_image *texImage)
{
/* get pointer to src pixels (may be in a pbo which we'll map here) */
- pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format,
- type, pixels, packing,
- "glTexSubImage3D");
+ pixels = _mesa_map_teximage_pbo(ctx, packing, pixels);
if (!pixels)
return;
@@ -3584,9 +3545,7 @@ _mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level,
return;
}
- data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data,
- &ctx->Unpack,
- "glCompressedTexImage2D");
+ data = _mesa_map_teximage_pbo(ctx, &ctx->Unpack, data);
if (!data)
return;
@@ -3679,9 +3638,7 @@ _mesa_store_compressed_texsubimage2d(GLcontext *ctx, GLenum target,
ASSERT((yoffset % bh) == 0);
/* get pointer to src pixels (may be in a pbo which we'll map here) */
- data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data,
- &ctx->Unpack,
- "glCompressedTexSubImage2D");
+ data = _mesa_map_teximage_pbo(ctx, &ctx->Unpack, data);
if (!data)
return;
diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h
index 3211086dd6..c5598f5286 100644
--- a/src/mesa/main/texstore.h
+++ b/src/mesa/main/texstore.h
@@ -198,17 +198,10 @@ _mesa_store_compressed_texsubimage3d(GLcontext *ctx, GLenum target,
extern const GLvoid *
-_mesa_validate_pbo_teximage(GLcontext *ctx, GLuint dimensions,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *unpack,
- const char *funcName);
+_mesa_map_teximage_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels);
-extern const GLvoid *
-_mesa_validate_pbo_compressed_teximage(GLcontext *ctx,
- GLsizei imageSize, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- const char *funcName);
extern void
_mesa_unmap_teximage_pbo(GLcontext *ctx,
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index b122d24c16..398f96b904 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -640,16 +640,7 @@ st_TexImage(GLcontext * ctx,
* the expectation that the texture will be set up but nothing
* more will be done. This is where those calls return:
*/
- if (compressed_src) {
- pixels = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, pixels,
- unpack,
- "glCompressedTexImage");
- }
- else {
- pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1,
- format, type,
- pixels, unpack, "glTexImage");
- }
+ pixels = _mesa_map_teximage_pbo(ctx, unpack, pixels);
/* Note: we can't check for pixels==NULL until after we've allocated
* memory for the texture.
@@ -1026,9 +1017,7 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
_mesa_lookup_enum_by_nr(target),
level, xoffset, yoffset, width, height);
- pixels =
- _mesa_validate_pbo_teximage(ctx, dims, width, height, depth, format,
- type, pixels, packing, "glTexSubImage2D");
+ pixels = _mesa_map_teximage_pbo(ctx, packing, pixels);
if (!pixels)
return;