r300: fix 3D textures
authorMaciej Cencora <m.cencora@gmail.com>
Sun, 14 Jun 2009 23:06:40 +0000 (01:06 +0200)
committerMaciej Cencora <m.cencora@gmail.com>
Sun, 14 Jun 2009 23:07:19 +0000 (01:07 +0200)
src/mesa/drivers/dri/radeon/radeon_texture.c

index 3fc750c005d59d4fec54527d92eb30e10c50f255..429ad50a7d46ec239b17d526af14c56f549c3248 100644 (file)
@@ -614,6 +614,8 @@ static void radeon_teximage(
                        memcpy(texImage->Data, pixels, imageSize);
                } else {
                        GLuint dstRowStride;
+                       GLuint *dstImageOffsets;
+
                        if (image->mt) {
                                radeon_mipmap_level *lvl = &image->mt->levels[image->mtlevel];
                                dstRowStride = lvl->rowstride;
@@ -621,15 +623,32 @@ static void radeon_teximage(
                                dstRowStride = texImage->Width * texImage->TexFormat->TexelBytes;
                        }
 
+                       if (dims == 3) {
+                               int i;
+
+                               dstImageOffsets = _mesa_malloc(depth * sizeof(GLuint)) ;
+                               if (!dstImageOffsets)
+                                       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+
+                               for (i = 0; i < depth; ++i) {
+                                       dstImageOffsets[i] = dstRowStride/texImage->TexFormat->TexelBytes * height * i;
+                               }
+                       } else {
+                               dstImageOffsets = texImage->ImageOffsets;
+                       }
+
                        if (!texImage->TexFormat->StoreImage(ctx, dims,
                                                texImage->_BaseFormat,
                                                texImage->TexFormat,
                                                texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */
                                                dstRowStride,
-                                               texImage->ImageOffsets,
+                                               dstImageOffsets,
                                                width, height, depth,
                                                format, type, pixels, packing))
                                _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+
+                       if (dims == 3)
+                               _mesa_free(dstImageOffsets);
                }
 
                /* SGIS_generate_mipmap */