summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-12-24 08:54:27 -0700
committerBrian Paul <[email protected]>2011-12-24 09:25:41 -0700
commitafebe13986e1ab69c8f80e957653b35aaee2269b (patch)
treefa489e182dfcad3159f0284cee92c1778d37a632 /src/mesa
parent9b26aa4c7af189b480b620926eed9560c8e63656 (diff)
mesa: fix _mesa_store_texsubimage2d() for GL_TEXTURE_1D_ARRAY
For 1D arrays, map each slice separately. Note that this was handled correctly in _mesa_store_teximage2d() but not here. Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/texstore.c67
1 files changed, 44 insertions, 23 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index a57a38e1266..fb1ad04e014 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -4888,35 +4888,56 @@ _mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level,
struct gl_texture_image *texImage)
{
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
- GLubyte *dstMap;
- GLint dstRowStride;
- GLboolean success;
+ GLboolean success = GL_FALSE;
+ GLuint slice, numSlices, sliceOffset, srcImageStride;
+ const GLubyte *src;
/* 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");
- if (!pixels)
+ src = (const GLubyte *)
+ _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
+ pixels, packing, "glTexSubImage2D");
+ if (!src)
return;
- /* Map dest texture buffer */
- ctx->Driver.MapTextureImage(ctx, texImage, 0,
- xoffset, yoffset, width, height,
- rwMode,
- &dstMap, &dstRowStride);
-
- if (dstMap) {
- success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &dstMap,
- width, height, 1,
- format, type, pixels, packing);
-
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ if (target == GL_TEXTURE_1D_ARRAY) {
+ /* map each slice of the 1D array separately */
+ numSlices = height;
+ sliceOffset = yoffset;
+ height = 1;
+ yoffset = 0;
+ srcImageStride = _mesa_image_row_stride(packing, width, format, type);
}
else {
- success = GL_FALSE;
+ /* regular 2D image */
+ numSlices = 1;
+ sliceOffset = 0;
+ srcImageStride = 0;
+ }
+
+ for (slice = 0; slice < numSlices; slice++) {
+ GLubyte *dstMap;
+ GLint dstRowStride;
+
+ ctx->Driver.MapTextureImage(ctx, texImage,
+ slice + sliceOffset,
+ xoffset, yoffset, width, height,
+ rwMode, &dstMap, &dstRowStride);
+ if (dstMap) {
+ success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ &dstMap,
+ width, height, 1, /* w, h, d */
+ format, type, src, packing);
+
+ ctx->Driver.UnmapTextureImage(ctx, texImage, slice + sliceOffset);
+ }
+
+ src += srcImageStride;
+
+ if (!success)
+ break;
}
if (!success)