intel: Don't validate in a texture image used as a render target.
authorEric Anholt <eric@anholt.net>
Wed, 4 Nov 2009 22:54:09 +0000 (14:54 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 6 Nov 2009 19:37:32 +0000 (11:37 -0800)
Otherwise, we could lose track of rendering to that image, which could
easily happen during mipmap generation.

src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_tex_obj.h
src/mesa/drivers/dri/intel/intel_tex_validate.c

index d8ac4d36637e0ba06379f82bc7c5df0492bb313f..5615040946fc4fb9b331a13d38279285e4eb1abe 100644 (file)
@@ -577,6 +577,7 @@ intel_render_texture(GLcontext * ctx,
                                           dst_x) * intel_image->mt->cpp;
    intel_image->mt->region->draw_x = dst_x;
    intel_image->mt->region->draw_y = dst_y;
+   intel_image->used_as_render_target = GL_TRUE;
 
    /* update drawing region, etc */
    intel_draw_buffer(ctx, fb);
@@ -590,16 +591,13 @@ static void
 intel_finish_render_texture(GLcontext * ctx,
                             struct gl_renderbuffer_attachment *att)
 {
-   /* no-op
-    * Previously we released the renderbuffer's intel_region but
-    * that's not necessary and actually caused problems when trying
-    * to do a glRead/CopyPixels from the renderbuffer later.
-    * The region will be released later if the texture is replaced
-    * or the renderbuffer deleted.
-    *
-    * The intention of this driver hook is more of a "done rendering
-    * to texture, please re-twiddle/etc if necessary".
-    */
+   struct gl_texture_object *tex_obj = att->Texture;
+   struct gl_texture_image *image =
+      tex_obj->Image[att->CubeMapFace][att->TextureLevel];
+   struct intel_texture_image *intel_image = intel_texture_image(image);
+
+   /* Flag that this image may now be validated into the object's miptree. */
+   intel_image->used_as_render_target = GL_FALSE;
 }
 
 
index 5a934615259787fe030f6e53eac47a97e8dcd287..3ad10d3d23890fab81eac1c7e39f91a7600c10f5 100644 (file)
@@ -66,6 +66,7 @@ struct intel_texture_image
     * Else there is no image data.
     */
    struct intel_mipmap_tree *mt;
+   GLboolean used_as_render_target;
 };
 
 static INLINE struct intel_texture_object *
index dbef2886159313c1fefe3356c0d6fb0816c95ef4..c9a24ac3983381e38b9abf680e482fdd2d945603 100644 (file)
@@ -222,8 +222,13 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
             intel_texture_image(intelObj->base.Image[face][i]);
 
          /* Need to import images in main memory or held in other trees.
+         * If it's a render target, then its data isn't needed to be in
+         * the object tree (otherwise we'd be FBO incomplete), and we need
+         * to keep track of the image's MT as needing to be pulled in still,
+         * or we'll lose the rendering that's done to it.
           */
-         if (intelObj->mt != intelImage->mt) {
+         if (intelObj->mt != intelImage->mt &&
+            !intelImage->used_as_render_target) {
             copy_image_data_to_tree(intel, intelObj, intelImage);
          }
       }