summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/radeon
diff options
context:
space:
mode:
authorMaciej Cencora <[email protected]>2009-11-23 22:14:48 +0100
committerMaciej Cencora <[email protected]>2009-11-23 22:14:48 +0100
commit5173d14cb5821637f22247d16be1b970f3762d6a (patch)
treee93826ec799fdbe513592e253278545e2584a7bf /src/mesa/drivers/dri/radeon
parent18384af7491c408c4182b72807b02c11b55509f8 (diff)
parent960464e42dce138fde11c379ce7744bc4be14aa2 (diff)
Merge commit 'origin/mesa_7_7_branch'
Diffstat (limited to 'src/mesa/drivers/dri/radeon')
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_common_context.c2
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c60
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_texture.c22
3 files changed, 49 insertions, 35 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.c b/src/mesa/drivers/dri/radeon/radeon_common_context.c
index 2a38c4599c6..71f70d724b9 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.c
@@ -262,7 +262,7 @@ GLboolean radeonInitContext(radeonContextPtr radeon,
else
radeon->texture_row_align = 32;
radeon->texture_rect_row_align = 64;
- radeon->texture_compressed_row_align = 64;
+ radeon->texture_compressed_row_align = 32;
}
radeon_init_dma(radeon);
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
index 0497fa7db50..46603de2e76 100644
--- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
+++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
@@ -37,26 +37,35 @@
#include "main/texobj.h"
#include "radeon_texture.h"
-static GLuint radeon_compressed_texture_size(GLcontext *ctx,
- GLsizei width, GLsizei height, GLsizei depth,
- gl_format mesaFormat)
+static unsigned get_aligned_compressed_row_stride(
+ gl_format format,
+ unsigned width,
+ unsigned minStride)
{
- GLuint size = _mesa_format_image_size(mesaFormat, width, height, depth);
-
- if (mesaFormat == MESA_FORMAT_RGB_DXT1 ||
- mesaFormat == MESA_FORMAT_RGBA_DXT1) {
- if (width + 3 < 8) /* width one block */
- size = size * 4;
- else if (width + 3 < 16)
- size = size * 2;
- } else {
- /* DXT3/5, 16 bytes per block */
- // WARN_ONCE("DXT 3/5 suffers from multitexturing problems!\n");
- if (width + 3 < 8)
- size = size * 2;
+ const unsigned blockSize = _mesa_get_format_bytes(format);
+ unsigned blockWidth, blockHeight, numXBlocks;
+
+ _mesa_get_format_block_size(format, &blockWidth, &blockHeight);
+ numXBlocks = (width + blockWidth - 1) / blockWidth;
+
+ while (numXBlocks * blockSize < minStride)
+ {
+ ++numXBlocks;
}
- return size;
+ return numXBlocks * blockSize;
+}
+
+static unsigned get_compressed_image_size(
+ gl_format format,
+ unsigned rowStride,
+ unsigned height)
+{
+ unsigned blockWidth, blockHeight;
+
+ _mesa_get_format_block_size(format, &blockWidth, &blockHeight);
+
+ return rowStride * ((height + blockHeight - 1) / blockHeight);
}
/**
@@ -74,10 +83,8 @@ static void compute_tex_image_offset(radeonContextPtr rmesa, radeon_mipmap_tree
/* Find image size in bytes */
if (_mesa_is_format_compressed(mt->mesaFormat)) {
- /* TODO: Is this correct? Need test cases for compressed textures! */
- row_align = rmesa->texture_compressed_row_align - 1;
- lvl->rowstride = (_mesa_format_row_stride(mt->mesaFormat, lvl->width) + row_align) & ~row_align;
- lvl->size = radeon_compressed_texture_size(rmesa->glCtx, lvl->width, lvl->height, lvl->depth, mt->mesaFormat);
+ lvl->rowstride = get_aligned_compressed_row_stride(mt->mesaFormat, lvl->width, rmesa->texture_compressed_row_align);
+ lvl->size = get_compressed_image_size(mt->mesaFormat, lvl->rowstride, lvl->height);
} else if (mt->target == GL_TEXTURE_RECTANGLE_NV) {
row_align = rmesa->texture_rect_row_align - 1;
lvl->rowstride = (_mesa_format_row_stride(mt->mesaFormat, lvl->width) + row_align) & ~row_align;
@@ -485,11 +492,12 @@ static radeon_mipmap_tree * get_biggest_matching_miptree(radeonTexObj *texObj,
unsigned firstLevel,
unsigned lastLevel)
{
- const unsigned numLevels = lastLevel - firstLevel;
+ const unsigned numLevels = lastLevel - firstLevel + 1;
unsigned *mtSizes = calloc(numLevels, sizeof(unsigned));
radeon_mipmap_tree **mts = calloc(numLevels, sizeof(radeon_mipmap_tree *));
unsigned mtCount = 0;
unsigned maxMtIndex = 0;
+ radeon_mipmap_tree *tmp;
for (unsigned level = firstLevel; level <= lastLevel; ++level) {
radeon_texture_image *img = get_radeon_texture_image(texObj->base.Image[0][level]);
@@ -511,7 +519,7 @@ static radeon_mipmap_tree * get_biggest_matching_miptree(radeonTexObj *texObj,
if (!found) {
mtSizes[mtCount] += img->mt->levels[img->mtlevel].size;
- mts[mtCount++] = img->mt;
+ mts[mtCount] = img->mt;
mtCount++;
}
}
@@ -526,7 +534,11 @@ static radeon_mipmap_tree * get_biggest_matching_miptree(radeonTexObj *texObj,
}
}
- return mts[maxMtIndex];
+ tmp = mts[maxMtIndex];
+ free(mtSizes);
+ free(mts);
+
+ return tmp;
}
/**
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c
index 6f11f1fa4ab..1ee9e2792a5 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -582,12 +582,12 @@ static void radeon_store_teximage(GLcontext* ctx, int dims,
/* TODO */
assert(0);
} else {
- dstRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
+ dstRowStride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width);
}
if (dims == 3) {
unsigned alignedWidth = dstRowStride/_mesa_get_format_bytes(texImage->TexFormat);
- dstImageOffsets = allocate_image_offsets(ctx, alignedWidth, height, depth);
+ dstImageOffsets = allocate_image_offsets(ctx, alignedWidth, texImage->Height, texImage->Depth);
if (!dstImageOffsets) {
return;
}
@@ -598,8 +598,11 @@ static void radeon_store_teximage(GLcontext* ctx, int dims,
radeon_teximage_map(image, GL_TRUE);
if (compressed) {
- uint32_t srcRowStride, bytesPerRow, rows;
+ uint32_t srcRowStride, bytesPerRow, rows, block_width, block_height;
GLubyte *img_start;
+
+ _mesa_get_format_block_size(texImage->TexFormat, &block_width, &block_height);
+
if (!image->mt) {
dstRowStride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width);
img_start = _mesa_compressed_image_address(xoffset, yoffset, 0,
@@ -607,17 +610,16 @@ static void radeon_store_teximage(GLcontext* ctx, int dims,
texImage->Width, texImage->Data);
}
else {
- uint32_t blocks_x, block_width, block_height;
- _mesa_get_format_block_size(image->mt->mesaFormat, &block_width, &block_height);
- blocks_x = dstRowStride / block_width;
- img_start = texImage->Data + _mesa_get_format_bytes(image->mt->mesaFormat) * 4 * (blocks_x * (yoffset / 4) + xoffset / 4);
+ uint32_t offset;
+ offset = dstRowStride / _mesa_get_format_bytes(texImage->TexFormat) * yoffset / block_height + xoffset / block_width;
+ offset *= _mesa_get_format_bytes(texImage->TexFormat);
+ img_start = texImage->Data + offset;
}
srcRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
bytesPerRow = srcRowStride;
- rows = (height + 3) / 4;
-
- copy_rows(img_start, dstRowStride, pixels, srcRowStride, rows, bytesPerRow);
+ rows = (height + block_height - 1) / block_height;
+ copy_rows(img_start, dstRowStride, pixels, srcRowStride, rows, bytesPerRow);
}
else {
if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat,