From 1842dd08b83269816fe8eb8f2dcc1252f606fe48 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 13 Apr 2013 01:37:35 -0700 Subject: mesa: Generalize TexStorage allocator between swrast and intel. This should be reusable for other non-gallium drivers, so we can make the extension always be available. v2: Add a more detailed comment than the old function had (recommended by Brian). Reviewed-by: Brian Paul (v1) --- src/mesa/main/texstorage.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/mesa/main/texstorage.c') diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c index 330d676..c1f2c16 100644 --- a/src/mesa/main/texstorage.c +++ b/src/mesa/main/texstorage.c @@ -244,6 +244,36 @@ _mesa_is_legal_tex_storage_format(struct gl_context *ctx, GLenum internalformat) } } +/** + * Default ctx->Driver.AllocTextureStorage() handler. + * + * The driver can override this with a more specific implementation if it + * desires, but this can be used to get the texture images allocated using the + * usual texture image handling code. The immutability of + * GL_ARB_texture_storage texture layouts is handled by texObj->Immutable + * checks at glTexImage* time. + */ +GLboolean +_mesa_alloc_texture_storage(struct gl_context *ctx, + struct gl_texture_object *texObj, + GLsizei levels, GLsizei width, + GLsizei height, GLsizei depth) +{ + const int numFaces = _mesa_num_tex_faces(texObj->Target); + int face; + int level; + + for (face = 0; face < numFaces; face++) { + for (level = 0; level < levels; level++) { + struct gl_texture_image *const texImage = texObj->Image[face][level]; + if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage)) + return GL_FALSE; + } + } + + return GL_TRUE; +} + /** * Do error checking for calls to glTexStorage1/2/3D(). -- cgit v1.1