mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-07 10:28:25 +02:00
r300: fixup mipmap + texsubimage issues
This fixes a few regression in piglit, and adds some debug to the mipmap code
This commit is contained in:
parent
dbf72bdd3d
commit
d9cf131925
5 changed files with 58 additions and 16 deletions
|
|
@ -334,7 +334,7 @@ void r300InitTextureFuncs(struct dd_function_table *functions)
|
|||
functions->CompressedTexImage2D = radeonCompressedTexImage2D;
|
||||
functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D;
|
||||
|
||||
functions->GenerateMipmap = radeon_generate_mipmap;
|
||||
functions->GenerateMipmap = radeonGenerateMipmap;
|
||||
|
||||
driInitTextureFormats();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,8 +225,9 @@ static void setup_hardware_state(r300ContextPtr rmesa, radeonTexObj *t)
|
|||
t->pp_txformat |= R300_TX_FORMAT_3D;
|
||||
|
||||
t->pp_txsize = (((firstImage->Width - 1) << R300_TX_WIDTHMASK_SHIFT)
|
||||
| ((firstImage->Height - 1) << R300_TX_HEIGHTMASK_SHIFT))
|
||||
| ((t->mt->lastLevel - t->mt->firstLevel) << R300_TX_MAX_MIP_LEVEL_SHIFT);
|
||||
| ((firstImage->Height - 1) << R300_TX_HEIGHTMASK_SHIFT)
|
||||
| ((firstImage->DepthLog2) << R300_TX_DEPTHMASK_SHIFT)
|
||||
| ((t->mt->lastLevel - t->mt->firstLevel) << R300_TX_MAX_MIP_LEVEL_SHIFT));
|
||||
|
||||
if (t->base.Target == GL_TEXTURE_RECTANGLE_NV) {
|
||||
unsigned int align = (64 / t->mt->bpp) - 1;
|
||||
|
|
|
|||
|
|
@ -1476,13 +1476,42 @@ GLuint radeon_face_for_target(GLenum target)
|
|||
* This relies on internal details of _mesa_generate_mipmap, in particular
|
||||
* the fact that the memory for recreated texture images is always freed.
|
||||
*/
|
||||
void radeon_generate_mipmap(GLcontext* ctx, GLenum target, struct gl_texture_object *texObj)
|
||||
void radeon_generate_mipmap(GLcontext *ctx, GLenum target,
|
||||
struct gl_texture_object *texObj)
|
||||
{
|
||||
radeonTexObj* t = radeon_tex_obj(texObj);
|
||||
GLuint nr_faces = (t->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
|
||||
int i, face;
|
||||
|
||||
|
||||
_mesa_generate_mipmap(ctx, target, texObj);
|
||||
|
||||
for (face = 0; face < nr_faces; face++) {
|
||||
for (i = texObj->BaseLevel + 1; i < texObj->MaxLevel; i++) {
|
||||
radeon_texture_image *image;
|
||||
|
||||
image = get_radeon_texture_image(texObj->Image[face][i]);
|
||||
|
||||
if (image == NULL)
|
||||
break;
|
||||
|
||||
image->mtlevel = i;
|
||||
image->mtface = face;
|
||||
|
||||
radeon_miptree_unreference(image->mt);
|
||||
image->mt = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void radeonGenerateMipmap(GLcontext* ctx, GLenum target, struct gl_texture_object *texObj)
|
||||
{
|
||||
GLuint face = radeon_face_for_target(target);
|
||||
radeon_texture_image *baseimage = get_radeon_texture_image(texObj->Image[face][texObj->BaseLevel]);
|
||||
|
||||
radeon_teximage_map(baseimage, GL_FALSE);
|
||||
_mesa_generate_mipmap(ctx, target, texObj);
|
||||
radeon_generate_mipmap(ctx, target, texObj);
|
||||
radeon_teximage_unmap(baseimage);
|
||||
}
|
||||
|
||||
|
|
@ -1803,15 +1832,17 @@ static void radeon_teximage(
|
|||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
|
||||
}
|
||||
|
||||
radeon_teximage_unmap(image);
|
||||
}
|
||||
|
||||
_mesa_unmap_teximage_pbo(ctx, packing);
|
||||
|
||||
/* SGIS_generate_mipmap */
|
||||
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
|
||||
ctx->Driver.GenerateMipmap(ctx, texObj->Target, texObj);
|
||||
radeon_generate_mipmap(ctx, texObj->Target, texObj);
|
||||
}
|
||||
radeon_teximage_unmap(image);
|
||||
|
||||
_mesa_unmap_teximage_pbo(ctx, packing);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void radeonTexImage1D(GLcontext * ctx, GLenum target, GLint level,
|
||||
|
|
@ -1878,13 +1909,15 @@ static void radeon_texsubimage(GLcontext* ctx, int dims, int level,
|
|||
const struct gl_pixelstore_attrib *packing,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage,
|
||||
int compressed)
|
||||
int compressed)
|
||||
{
|
||||
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
|
||||
radeonTexObj* t = radeon_tex_obj(texObj);
|
||||
radeon_texture_image* image = get_radeon_texture_image(texImage);
|
||||
|
||||
rmesa->vtbl.flush_vertices(rmesa);
|
||||
|
||||
t->validated = GL_FALSE;
|
||||
pixels = _mesa_validate_pbo_teximage(ctx, dims,
|
||||
width, height, depth, format, type, pixels, packing, "glTexSubImage1D");
|
||||
|
||||
|
|
@ -1896,7 +1929,7 @@ static void radeon_texsubimage(GLcontext* ctx, int dims, int level,
|
|||
radeon_mipmap_level *lvl = &image->mt->levels[image->mtlevel];
|
||||
dstRowStride = lvl->rowstride;
|
||||
} else {
|
||||
dstRowStride = texImage->Width * texImage->TexFormat->TexelBytes;
|
||||
dstRowStride = texImage->RowStride * texImage->TexFormat->TexelBytes;
|
||||
}
|
||||
|
||||
if (!texImage->TexFormat->StoreImage(ctx, dims, texImage->_BaseFormat,
|
||||
|
|
@ -1908,15 +1941,18 @@ static void radeon_texsubimage(GLcontext* ctx, int dims, int level,
|
|||
format, type, pixels, packing))
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
|
||||
|
||||
radeon_teximage_unmap(image);
|
||||
}
|
||||
|
||||
_mesa_unmap_teximage_pbo(ctx, packing);
|
||||
}
|
||||
|
||||
/* GL_SGIS_generate_mipmap */
|
||||
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
|
||||
ctx->Driver.GenerateMipmap(ctx, texObj->Target, texObj);
|
||||
radeon_generate_mipmap(ctx, texObj->Target, texObj);
|
||||
}
|
||||
radeon_teximage_unmap(image);
|
||||
|
||||
_mesa_unmap_teximage_pbo(ctx, packing);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void radeonTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ void radeon_teximage_map(radeon_texture_image *image, GLboolean write_enable);
|
|||
void radeon_teximage_unmap(radeon_texture_image *image);
|
||||
void radeonMapTexture(GLcontext *ctx, struct gl_texture_object *texObj);
|
||||
void radeonUnmapTexture(GLcontext *ctx, struct gl_texture_object *texObj);
|
||||
void radeon_generate_mipmap(GLcontext* ctx, GLenum target, struct gl_texture_object *texObj);
|
||||
void radeonGenerateMipmap(GLcontext* ctx, GLenum target, struct gl_texture_object *texObj);
|
||||
int radeon_validate_texture_miptree(GLcontext * ctx, struct gl_texture_object *texObj);
|
||||
GLuint radeon_face_for_target(GLenum target);
|
||||
const struct gl_texture_format *radeonChooseTextureFormat(GLcontext * ctx,
|
||||
|
|
|
|||
|
|
@ -101,6 +101,11 @@ static void compute_tex_image_offset(radeon_mipmap_tree *mt,
|
|||
*curOffset = (*curOffset + 0x1f) & ~0x1f;
|
||||
lvl->faces[face].offset = *curOffset;
|
||||
*curOffset += lvl->size;
|
||||
|
||||
if (RADEON_DEBUG & DEBUG_TEXTURE)
|
||||
fprintf(stderr,
|
||||
"level %d, face %d: rs:%d %dx%d at %d\n",
|
||||
level, face, lvl->rowstride, lvl->width, lvl->height, lvl->faces[face].offset);
|
||||
}
|
||||
|
||||
static GLuint minify(GLuint size, GLuint levels)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue