swrast: implement GL_ARB_texture_storage
authorBrian Paul <brianp@vmware.com>
Mon, 31 Oct 2011 16:52:57 +0000 (10:52 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 31 Oct 2011 16:52:57 +0000 (10:52 -0600)
src/mesa/drivers/common/driverfuncs.c
src/mesa/main/extensions.c
src/mesa/swrast/s_texture.c
src/mesa/swrast/swrast.h

index 80db4bde8d34292c80959c94dfb28fde3fb5f9c1..920271626a9fd992cb348032b9b42e20cd17907d 100644 (file)
@@ -218,6 +218,9 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
    driver->EndList = NULL;
    driver->BeginCallList = NULL;
    driver->EndCallList = NULL;
+
+   /* GL_ARB_texture_storage */
+   driver->AllocTextureStorage = _swrast_AllocTextureStorage;
 }
 
 
index 14f6f1f3afa22754a1a80aa064eda85a987b9f1a..b0fe4c347024f602585d2152197736e1bbc7d3ee 100644 (file)
@@ -422,6 +422,7 @@ _mesa_enable_sw_extensions(struct gl_context *ctx)
    ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
    ctx->Extensions.ARB_texture_rg = GL_TRUE;
    ctx->Extensions.ARB_texture_compression_rgtc = GL_TRUE;
+   ctx->Extensions.ARB_texture_storage = GL_TRUE;
    ctx->Extensions.ARB_vertex_array_object = GL_TRUE;
 #if FEATURE_ARB_vertex_program
    ctx->Extensions.ARB_vertex_program = GL_TRUE;
index fb1edb318ddac259761604670f6e185871cb2909..ba67c6fa417caa71a6affbce4a32b9d892e5b193 100644 (file)
@@ -359,3 +359,35 @@ _swrast_unmap_renderbuffers(struct gl_context *ctx)
    if (ctx->ReadBuffer != ctx->DrawBuffer)
       map_unmap_renderbuffers(ctx, ctx->ReadBuffer, GL_FALSE);
 }
+
+
+
+/**
+ * Called via ctx->Driver.AllocTextureStorage()
+ * Just have to allocate memory for the texture images.
+ */
+GLboolean
+_swrast_AllocTextureStorage(struct gl_context *ctx,
+                            struct gl_texture_object *texObj,
+                            GLsizei levels, GLsizei width,
+                            GLsizei height, GLsizei depth)
+{
+   const GLint numFaces = (texObj->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+   GLint face, level;
+
+   for (face = 0; face < numFaces; face++) {
+      for (level = 0; level < levels; level++) {
+         struct gl_texture_image *texImage = texObj->Image[face][level];
+         if (!_swrast_alloc_texture_image_buffer(ctx, texImage,
+                                                 texImage->TexFormat,
+                                                 texImage->Width,
+                                                 texImage->Height,
+                                                 texImage->Depth)) {
+            return GL_FALSE;
+         }
+      }
+   }
+
+   return GL_TRUE;
+}
+
index 06cc651580d76dbe0d42a46baf5435999f767d44..08d565ba03f8803121fb3f2548db6a6371bea334 100644 (file)
@@ -249,6 +249,13 @@ _swrast_finish_render_texture(struct gl_context *ctx,
 
 
 
+extern GLboolean
+_swrast_AllocTextureStorage(struct gl_context *ctx,
+                            struct gl_texture_object *texObj,
+                            GLsizei levels, GLsizei width,
+                            GLsizei height, GLsizei depth);
+
+
 /**
  * The driver interface for the software rasterizer.
  * XXX this may go away.