summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2006-07-19 16:13:15 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2006-07-19 16:13:15 +0000
commitad15866ef0e77478508eeb534b28f0136462b644 (patch)
treec3b6beed6f71dcd2a12f4fbd6b778d7689e3fd5e
parent0749e2723b32ba430539791b94acd95dcf939a1d (diff)
For glGetTexImage(), move the _mesa_validate_pbo_access() error check into
_mesa_GetTexImage() so it's not needed in the fallback or driver functions.
-rw-r--r--src/mesa/main/teximage.c12
-rw-r--r--src/mesa/main/texstore.c26
2 files changed, 25 insertions, 13 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index f8528dd96e..2ada4a8942 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2162,6 +2162,18 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
return;
}
+ if (ctx->Pack.BufferObj->Name) {
+ /* packing texture image into a PBO */
+ const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2;
+ if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width,
+ texImage->Height, texImage->Depth,
+ format, type, pixels)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTexImage(invalid PBO access)");
+ return;
+ }
+ }
+
/* typically, this will call _mesa_get_teximage() */
ctx->Driver.GetTexImage(ctx, target, level, format, type, pixels,
texObj, texImage);
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 28f6a191fd..3280051abf 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -4100,26 +4100,26 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2;
+ const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2;
if (ctx->Pack.BufferObj->Name) {
- /* pack texture image into a PBO */
- GLubyte *buf;
- if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width,
- texImage->Height, texImage->Depth,
- format, type, pixels)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTexImage(invalid PBO access)");
- return;
- }
- buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
- GL_WRITE_ONLY_ARB,
- ctx->Pack.BufferObj);
+ /* Packing texture image into a PBO.
+ * Map the (potentially) VRAM-based buffer into our process space so
+ * we can write into it with the code below.
+ * A hardware driver might use a sophisticated blit to move the
+ * texture data to the PBO if the PBO is in VRAM along with the texture.
+ */
+ GLubyte *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,"glGetTexImage(PBO is mapped)");
return;
}
+ /* <pixels> was an offset into the PBO.
+ * Now make it a real, client-side pointer inside the mapped region.
+ */
pixels = ADD_POINTERS(buf, pixels);
}
else if (!pixels) {