aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texstore.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2011-09-28 11:17:11 -0700
committerEric Anholt <[email protected]>2011-10-03 13:29:38 -0700
commit229ebf511dcd9b501d9299cfc06d029d1d50079d (patch)
tree035b65909003371f103855ee7216de2677327829 /src/mesa/main/texstore.c
parent5324f9c48d59ef966fbab03664a8d44ea8c19c5f (diff)
mesa: When storing texture data for a 1D array, map each slice separately.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/texstore.c')
-rw-r--r--src/mesa/main/texstore.c68
1 files changed, 52 insertions, 16 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index cbed26cd497..658db2066b5 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -4626,22 +4626,53 @@ _mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
return;
}
- /* Map dest texture buffer (write to whole region) */
- ctx->Driver.MapTextureImage(ctx, texImage, 0,
- 0, 0, width, height,
- rwMode,
- &dstMap, &dstRowStride);
- assert(dstMap);
- success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat,
- dstMap,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &zeroImageOffset,
- width, height, 1,
- format, type, pixels, packing);
-
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ if (target == GL_TEXTURE_1D_ARRAY) {
+ const GLint srcStride =
+ _mesa_image_row_stride(packing, width, format, type);
+ int y;
+
+ success = GL_TRUE;
+
+ for (y = 0; y < height; y++) {
+ /* Map dest texture buffer (write to whole region) */
+ ctx->Driver.MapTextureImage(ctx, texImage, y,
+ 0, 0, width, 1,
+ rwMode,
+ &dstMap, &dstRowStride);
+ assert(dstMap);
+ success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat,
+ dstMap,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ &zeroImageOffset,
+ width, 1, 1,
+ format, type, pixels, packing);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, y);
+
+ if (!success)
+ break;
+
+ pixels += srcStride;
+ }
+ } else {
+ /* Map dest texture buffer (write to whole region) */
+ ctx->Driver.MapTextureImage(ctx, texImage, 0,
+ 0, 0, width, height,
+ rwMode,
+ &dstMap, &dstRowStride);
+ assert(dstMap);
+ success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat,
+ dstMap,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ &zeroImageOffset,
+ width, height, 1,
+ format, type, pixels, packing);
+
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ }
if (!success)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
@@ -4691,6 +4722,11 @@ _mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
return;
}
+ if (target == GL_TEXTURE_1D_ARRAY) {
+ depth = height;
+ height = 1;
+ }
+
sliceMaps = (GLubyte **) malloc(depth * sizeof(GLubyte *));
dstImageOffsets = (GLuint *) malloc(depth * sizeof(GLuint));