summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texstore.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-09-17 14:50:49 -0600
committerBrian Paul <[email protected]>2011-09-17 14:57:41 -0600
commit78026b8acef9d6eea4f37d9c5435447944d1befd (patch)
tree30aba1350b0a5f1fa93899aba95fcc764029ffe9 /src/mesa/main/texstore.c
parente6cf338d015e994012535fce5e06c7dc59482b02 (diff)
mesa: use ctx->Driver.AllocTextureImageBuffer() to alloc texture memory
Diffstat (limited to 'src/mesa/main/texstore.c')
-rw-r--r--src/mesa/main/texstore.c46
1 files changed, 14 insertions, 32 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 2cdc8ed6740..b958615b582 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -4508,16 +4508,6 @@ _mesa_texstore(TEXSTORE_PARAMS)
}
-/** Return texture size in bytes */
-static GLuint
-texture_size(const struct gl_texture_image *texImage)
-{
- GLuint sz = _mesa_format_image_size(texImage->TexFormat, texImage->Width,
- texImage->Height, texImage->Depth);
- return sz;
-}
-
-
/**
* Normally, we'll only _write_ texel data to a texture when we map it.
* But if the user is providing depth or stencil values and the texture
@@ -4549,7 +4539,6 @@ _mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- GLuint sizeInBytes;
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
const GLuint zeroImageOffset = 0;
GLubyte *dstMap;
@@ -4558,10 +4547,9 @@ _mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
(void) border;
- /* allocate memory */
- sizeInBytes = texture_size(texImage);
- texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
- if (!texImage->Data) {
+ /* allocate storage for texture data */
+ if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
+ width, 1, 1)) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
return;
}
@@ -4614,7 +4602,6 @@ _mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- GLuint sizeInBytes;
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
const GLuint zeroImageOffset = 0;
GLubyte *dstMap;
@@ -4623,10 +4610,9 @@ _mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
(void) border;
- /* allocate memory */
- sizeInBytes = texture_size(texImage);
- texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
- if (!texImage->Data) {
+ /* allocate storage for texture data */
+ if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
+ width, height, 1)) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
return;
}
@@ -4678,7 +4664,6 @@ _mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- GLuint sizeInBytes;
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
GLboolean success;
GLint slice;
@@ -4689,13 +4674,10 @@ _mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
(void) border;
- /* allocate memory */
- sizeInBytes = texture_size(texImage);
- texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
- if (!texImage->Data) {
- /* Note: we check for a NULL image pointer here, _after_ we allocated
- * memory for the texture. That's what the GL spec calls for.
- */
+ /* allocate storage for texture data */
+ if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
+ width, height, depth)) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
return;
}
@@ -4966,10 +4948,10 @@ _mesa_store_compressed_teximage2d(struct gl_context *ctx,
ASSERT(texImage->Depth == 1);
ASSERT(texImage->Data == NULL); /* was freed in glCompressedTexImage2DARB */
- /* allocate storage */
- texImage->Data = _mesa_alloc_texmemory(imageSize);
- if (!texImage->Data) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
+ /* allocate storage for texture data */
+ if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
+ width, height, 1)) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
return;
}