aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaciej Cencora <[email protected]>2009-11-14 15:03:31 +0100
committerMaciej Cencora <[email protected]>2009-11-14 16:55:38 +0100
commit9d0af686b27b82dce8ad1ee4c951098660807be6 (patch)
tree35398c8e9daaac52872c2fb962f25c8adf501a29 /src
parent7628b06ba32e42f57a4fdb322bc32e3b411c1f18 (diff)
radeon: minor refactoring of texture code
Also properly set dstImageOffsets for TexSubImage case.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_texture.c57
1 files changed, 46 insertions, 11 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c
index 607ce7864e8..8fc686581b5 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -508,6 +508,27 @@ gl_format radeonChooseTextureFormat(GLcontext * ctx,
return MESA_FORMAT_NONE; /* never get here */
}
+static GLuint * allocate_image_offsets(GLcontext *ctx,
+ unsigned alignedWidth,
+ unsigned height,
+ unsigned depth)
+{
+ int i;
+ GLuint *offsets;
+
+ offsets = _mesa_malloc(depth * sizeof(GLuint)) ;
+ if (!offsets) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTex[Sub]Image");
+ return NULL;
+ }
+
+ for (i = 0; i < depth; ++i) {
+ offsets[i] = alignedWidth * height * i;
+ }
+
+ return offsets;
+}
+
/**
* All glTexImage calls go through this function.
*/
@@ -605,8 +626,8 @@ static void radeon_teximage(
}
if (pixels) {
- radeon_teximage_map(image, GL_TRUE);
if (compressed) {
+ radeon_teximage_map(image, GL_TRUE);
if (image->mt) {
uint32_t srcRowStride, bytesPerRow, rows;
srcRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
@@ -629,19 +650,17 @@ static void radeon_teximage(
}
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/_mesa_get_format_bytes(texImage->TexFormat) * height * i;
+ unsigned alignedWidth = dstRowStride/_mesa_get_format_bytes(texImage->TexFormat);
+ dstImageOffsets = allocate_image_offsets(ctx, alignedWidth, height, depth);
+ if (!dstImageOffsets) {
+ return;
}
} else {
dstImageOffsets = texImage->ImageOffsets;
}
+ radeon_teximage_map(image, GL_TRUE);
+
if (!_mesa_texstore(ctx, dims,
texImage->_BaseFormat,
texImage->TexFormat,
@@ -752,7 +771,7 @@ static void radeon_texsubimage(GLcontext* ctx, int dims, GLenum target, int leve
if (pixels) {
GLint dstRowStride;
- radeon_teximage_map(image, GL_TRUE);
+ GLuint *dstImageOffsets;
if (image->mt) {
radeon_mipmap_level *lvl = &image->mt->levels[image->mtlevel];
@@ -761,6 +780,18 @@ static void radeon_texsubimage(GLcontext* ctx, int dims, GLenum target, int leve
dstRowStride = texImage->RowStride * _mesa_get_format_bytes(texImage->TexFormat);
}
+ if (dims == 3) {
+ unsigned alignedWidth = dstRowStride/_mesa_get_format_bytes(texImage->TexFormat);
+ dstImageOffsets = allocate_image_offsets(ctx, alignedWidth, height, depth);
+ if (!dstImageOffsets) {
+ return;
+ }
+ } else {
+ dstImageOffsets = texImage->ImageOffsets;
+ }
+
+ radeon_teximage_map(image, GL_TRUE);
+
if (compressed) {
uint32_t srcRowStride, bytesPerRow, rows;
GLubyte *img_start;
@@ -786,12 +817,16 @@ static void radeon_texsubimage(GLcontext* ctx, int dims, GLenum target, int leve
texImage->TexFormat, texImage->Data,
xoffset, yoffset, zoffset,
dstRowStride,
- texImage->ImageOffsets,
+ dstImageOffsets,
width, height, depth,
format, type, pixels, packing)) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
}
}
+
+ if (dims == 3) {
+ _mesa_free(dstImageOffsets);
+ }
}
radeon_teximage_unmap(image);