Hi,

in the bufmgr-based rework of the r300 driver we want to override 
gl_texture_image so that texture data is stored in buffer object without 
backing store whenever possible.

Our images have two fields, image->mt and image->base.Data which relate to 
where image data is stored. If image->mt is non-NULL, the image is stored in 
a buffer object and image->base.Data is non-NULL if and only if the image has 
been explicitly mapped for software-based access. In this case, 
image->base.Data simply points into the mapped region (okay, so it's actually 
fake buffer manager backing store right now, but you get the idea).

If image->mt is NULL, then everything behaves like it used to, i.e. 
image->base.Data points to malloc()ed memory.

Now I've run into trouble with _mesa_generate_mipmap because that function 
calls FreeTexImageData only if image->base.Data is NULL. This is incorrect 
when the image in question is stored in a buffer object.

The following patch simply calls FreeTexImageData unconditionally, leaving the 
decision of what to do entirely to the driver. From a visual inspection, all 
of the drivers that override FreeTexImageData check whether Data is NULL, so 
this patch should be fine. Still, is this the right basic notion of what 
should be done?

FYI, you can see the patch in the context of the R300-rework in my tree at 
http://cgit.freedesktop.org/~nh/mesa/

cu,
Nicolai
---
 src/mesa/main/mipmap.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index 8ca912b..fe2fbb8 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1065,8 +1065,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
          _mesa_free(dstImage->ImageOffsets);
 
       /* Free old image data */
-      if (dstImage->Data)
-         ctx->Driver.FreeTexImageData(ctx, dstImage);
+      ctx->Driver.FreeTexImageData(ctx, dstImage);
 
       /* initialize new image */
       _mesa_init_teximage_fields(ctx, target, dstImage, dstWidth, dstHeight,
-- 

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to