i965: Allocate texture buffer in intelTexImage
authorAnuj Phogat <anuj.phogat@gmail.com>
Thu, 5 Feb 2015 20:24:57 +0000 (12:24 -0800)
committerAnuj Phogat <anuj.phogat@gmail.com>
Wed, 25 Feb 2015 22:11:46 +0000 (14:11 -0800)
before calling _mesa_meta_pbo_TexSubImage(). This will be used in
later patches and will be required in Skylake to get the tile
resource mode of miptree before calling _mesa_meta_pbo_TexSubImage().

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
src/mesa/drivers/dri/i965/intel_tex_image.c

index 6eebfc4bd4bb38c017b658198da8f586f176ff88..da42fdd8a081fbe9dbf79d372fddbf10f7d7682f 100644 (file)
@@ -103,11 +103,20 @@ intelTexImage(struct gl_context * ctx,
        _mesa_lookup_enum_by_nr(format), _mesa_lookup_enum_by_nr(type),
        texImage->Level, texImage->Width, texImage->Height, texImage->Depth);
 
+   /* Allocate storage for texture data. */
+   if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage)) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims);
+      return;
+   }
+
+   assert(intelImage->mt);
+
    ok = _mesa_meta_pbo_TexSubImage(ctx, dims, texImage, 0, 0, 0,
                                    texImage->Width, texImage->Height,
                                    texImage->Depth,
                                    format, type, pixels,
-                                   true, tex_busy, unpack);
+                                   false /*allocate_storage*/,
+                                   tex_busy, unpack);
    if (ok)
       return;
 
@@ -117,7 +126,7 @@ intelTexImage(struct gl_context * ctx,
                                        texImage->Height,
                                        texImage->Depth,
                                        format, type, pixels, unpack,
-                                       true /*for_glTexImage*/);
+                                       false /*allocate_storage*/);
    if (ok)
       return;