intel: If a tex image doesn't fit in the object's tree, make a temporary tree.
authorEric Anholt <eric@anholt.net>
Fri, 25 Jul 2008 19:17:58 +0000 (12:17 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 25 Jul 2008 19:19:50 +0000 (12:19 -0700)
Previously, we would just store the data as malloced memory hanging off the
object, which would get memcpyed in at validate time.  This broke an
oglconform render-to-texture test, since validate wasn't called but a miptree
was expected.

src/mesa/drivers/dri/intel/intel_tex_image.c

index 6d57b2b7dd1090f73b2b318d33b4ac39135a4cc4..b8dcd1e06102454fdaf1c2bbe450e7d3f4f1a72c 100644 (file)
@@ -395,10 +395,25 @@ intelTexImage(GLcontext * ctx,
 
       intel_miptree_reference(&intelImage->mt, intelObj->mt);
       assert(intelImage->mt);
-   }
+   } else if (intelImage->base.Border == 0) {
+      int comp_byte = 0;
+
+      if (intelImage->base.IsCompressed) {
+        comp_byte =
+           intel_compressed_num_bytes(intelImage->base.TexFormat->MesaFormat);
+      }
 
-   if (!intelImage->mt)
-      DBG("XXX: Image did not fit into tree - storing in local memory!\n");
+      /* Didn't fit in the object miptree, but it's suitable for inclusion in
+       * a miptree, so create one just for our level and store it in the image.
+       * It'll get moved into the object miptree at validate time.
+       */
+      intelImage->mt = intel_miptree_create(intel, target, internalFormat,
+                                           level, level,
+                                           width, height, depth,
+                                           intelImage->base.TexFormat->TexelBytes,
+                                           comp_byte);
+
+   }
 
    /* PBO fastpaths:
     */