diff options
author | Brian Paul <[email protected]> | 2011-08-01 23:04:12 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2011-10-03 13:29:30 -0700 |
commit | e0304180c32227342dbb67b707bfae446543bb48 (patch) | |
tree | 05224697ca0948eded9adb328a215bc2c5a3a24f /src/mesa/drivers | |
parent | 1165b64f561a7bdd3f603d9e30a2340774ba31ee (diff) |
mesa: Convert _mesa_generate_mipmap to MapTexImage()-based access.
Now that we can zero-copy generate the mipmaps into brand new
glTexImage()-generated storage using MapTextureImage(), we no longer
need to allocate image->Data in mipmap generate. This requires
deleting the drivers' old overrides of the miptree tracking after
calling _mesa_generate_mipmap at the same time, or the drivers
promptly lose our newly-generated data.
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex.c | 30 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_texture.c | 10 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_texture.c | 50 |
3 files changed, 2 insertions, 88 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c index 55b3e349b4c..bc7b1f64b3e 100644 --- a/src/mesa/drivers/dri/intel/intel_tex.c +++ b/src/mesa/drivers/dri/intel/intel_tex.c @@ -163,37 +163,9 @@ intelGenerateMipmap(struct gl_context *ctx, GLenum target, struct gl_texture_object *texObj) { if (_mesa_meta_check_generate_mipmap_fallback(ctx, target, texObj)) { - /* sw path: need to map texture images */ - struct intel_context *intel = intel_context(ctx); - struct intel_texture_object *intelObj = intel_texture_object(texObj); - struct gl_texture_image *first_image = texObj->Image[0][texObj->BaseLevel]; - fallback_debug("%s - fallback to swrast\n", __FUNCTION__); - if (_mesa_is_format_compressed(first_image->TexFormat)) { - _mesa_generate_mipmap(ctx, target, texObj); - } else { - intel_tex_map_level_images(intel, intelObj, texObj->BaseLevel); - _mesa_generate_mipmap(ctx, target, texObj); - intel_tex_unmap_level_images(intel, intelObj, texObj->BaseLevel); - } - - if (!_mesa_is_format_compressed(first_image->TexFormat)) { - GLuint nr_faces = (texObj->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; - GLuint face, i; - for (face = 0; face < nr_faces; face++) { - for (i = texObj->BaseLevel + 1; i < texObj->MaxLevel; i++) { - struct intel_texture_image *intelImage = - intel_texture_image(texObj->Image[face][i]); - if (!intelImage) - break; - /* Unreference the miptree to signal that the new Data is a - * bare pointer from mesa. - */ - intel_miptree_release(&intelImage->mt); - } - } - } + _mesa_generate_mipmap(ctx, target, texObj); } else { _mesa_meta_GenerateMipmap(ctx, target, texObj); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c index 9dc21869ca8..508c8a59dbd 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c @@ -739,17 +739,7 @@ nouveau_generate_mipmap(struct gl_context *ctx, GLenum target, { if (_mesa_meta_check_generate_mipmap_fallback(ctx, target, t)) { struct gl_texture_image *base = t->Image[0][t->BaseLevel]; - - nouveau_teximage_map(ctx, base, GL_MAP_READ_BIT, - 0, 0, base->Width, base->Height); _mesa_generate_mipmap(ctx, target, t); - nouveau_teximage_unmap(ctx, base); - - if (!_mesa_is_format_compressed(base->TexFormat)) { - store_mipmap(ctx, target, t->BaseLevel + 1, - get_last_level(t), t); - } - } else { _mesa_meta_GenerateMipmap(ctx, target, t); } diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c index 7f824ce2038..6bd89671083 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c @@ -324,52 +324,6 @@ radeon_unmap_texture_image(struct gl_context *ctx, radeon_bo_unmap(image->mt->bo); } -/** - * Wraps Mesa's implementation to ensure that the base level image is mapped. - * - * This relies on internal details of _mesa_generate_mipmap, in particular - * the fact that the memory for recreated texture images is always freed. - */ -static void radeon_generate_mipmap(struct gl_context *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; - struct gl_texture_image *first_image; - - radeon_print(RADEON_TEXTURE, RADEON_VERBOSE, - "%s(%p, tex %p) Target type %s.\n", - __func__, ctx, texObj, - _mesa_lookup_enum_by_nr(target)); - - _mesa_generate_mipmap(ctx, target, texObj); - - /* For the compressed case, we don't need to do the - * non-TexImage recovery path below. - */ - first_image = texObj->Image[0][texObj->BaseLevel]; - if (_mesa_is_format_compressed(first_image->TexFormat)) - return; - - 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); - } - } - -} - void radeonGenerateMipmap(struct gl_context* ctx, GLenum target, struct gl_texture_object *texObj) { radeonContextPtr rmesa = RADEON_CONTEXT(ctx); @@ -392,9 +346,7 @@ void radeonGenerateMipmap(struct gl_context* ctx, GLenum target, struct gl_textu } if (_mesa_meta_check_generate_mipmap_fallback(ctx, target, texObj)) { - radeon_teximage_map(baseimage, GL_FALSE); - radeon_generate_mipmap(ctx, target, texObj); - radeon_teximage_unmap(baseimage); + _mesa_generate_mipmap(ctx, target, texObj); } else { _mesa_meta_GenerateMipmap(ctx, target, texObj); } |