r600: fix texture pitch alignment
fixes texwrap
This commit is contained in:
@@ -556,7 +556,7 @@ static void setup_hardware_state(context_t *rmesa, struct gl_texture_object *tex
|
||||
radeonTexObj *t = radeon_tex_obj(texObj);
|
||||
const struct gl_texture_image *firstImage;
|
||||
int firstlevel = t->mt ? t->mt->firstLevel : 0;
|
||||
GLuint uTexelPitch;
|
||||
GLuint uTexelPitch, row_align;;
|
||||
|
||||
firstImage = t->base.Image[0][firstlevel];
|
||||
|
||||
@@ -595,7 +595,9 @@ static void setup_hardware_state(context_t *rmesa, struct gl_texture_object *tex
|
||||
return;
|
||||
}
|
||||
|
||||
uTexelPitch = (firstImage->Width + R700_TEXEL_PITCH_ALIGNMENT_MASK)
|
||||
row_align = rmesa->radeon.texture_row_align - 1;
|
||||
uTexelPitch = ((firstImage->Width * t->mt->bpp + row_align) & ~row_align) / t->mt->bpp;
|
||||
uTexelPitch = (uTexelPitch + R700_TEXEL_PITCH_ALIGNMENT_MASK)
|
||||
& ~R700_TEXEL_PITCH_ALIGNMENT_MASK;
|
||||
|
||||
/* min pitch is 8 */
|
||||
|
||||
@@ -241,7 +241,15 @@ GLboolean radeonInitContext(radeonContextPtr radeon,
|
||||
radeon->texture_depth = ( glVisual->rgbBits > 16 ) ?
|
||||
DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
|
||||
|
||||
radeon->texture_row_align = 32;
|
||||
if (IS_R600_CLASS(radeon->radeonScreen)) {
|
||||
radeon->texture_row_align = 256;
|
||||
radeon->texture_rect_row_align = 256;
|
||||
radeon->texture_compressed_row_align = 256;
|
||||
} else {
|
||||
radeon->texture_row_align = 32;
|
||||
radeon->texture_rect_row_align = 64;
|
||||
radeon->texture_compressed_row_align = 64;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
@@ -429,6 +429,8 @@ struct radeon_context {
|
||||
int texture_depth;
|
||||
float initialMaxAnisotropy;
|
||||
uint32_t texture_row_align;
|
||||
uint32_t texture_rect_row_align;
|
||||
uint32_t texture_compressed_row_align;
|
||||
|
||||
struct radeon_dma dma;
|
||||
struct radeon_hw_state hw;
|
||||
|
||||
@@ -90,16 +90,18 @@ static void compute_tex_image_offset(radeonContextPtr rmesa, radeon_mipmap_tree
|
||||
GLuint face, GLuint level, GLuint* curOffset)
|
||||
{
|
||||
radeon_mipmap_level *lvl = &mt->levels[level];
|
||||
uint32_t row_align = rmesa->texture_row_align - 1;
|
||||
uint32_t row_align;
|
||||
|
||||
/* Find image size in bytes */
|
||||
if (mt->compressed) {
|
||||
/* TODO: Is this correct? Need test cases for compressed textures! */
|
||||
lvl->rowstride = (lvl->width * mt->bpp + 63) & ~63;
|
||||
row_align = rmesa->texture_compressed_row_align - 1;
|
||||
lvl->rowstride = (lvl->width * mt->bpp + row_align) & ~row_align;
|
||||
lvl->size = radeon_compressed_texture_size(mt->radeon->glCtx,
|
||||
lvl->width, lvl->height, lvl->depth, mt->compressed);
|
||||
} else if (mt->target == GL_TEXTURE_RECTANGLE_NV) {
|
||||
lvl->rowstride = (lvl->width * mt->bpp + 63) & ~63;
|
||||
row_align = rmesa->texture_rect_row_align - 1;
|
||||
lvl->rowstride = (lvl->width * mt->bpp + row_align) & ~row_align;
|
||||
lvl->size = lvl->rowstride * lvl->height;
|
||||
} else if (mt->tilebits & RADEON_TXO_MICRO_TILE) {
|
||||
/* tile pattern is 16 bytes x2. mipmaps stay 32 byte aligned,
|
||||
@@ -108,6 +110,7 @@ static void compute_tex_image_offset(radeonContextPtr rmesa, radeon_mipmap_tree
|
||||
lvl->rowstride = (lvl->width * mt->bpp * 2 + 31) & ~31;
|
||||
lvl->size = lvl->rowstride * ((lvl->height + 1) / 2) * lvl->depth;
|
||||
} else {
|
||||
row_align = rmesa->texture_row_align - 1;
|
||||
lvl->rowstride = (lvl->width * mt->bpp + row_align) & ~row_align;
|
||||
lvl->size = lvl->rowstride * lvl->height * lvl->depth;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user