summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texstorage.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2012-09-15 10:30:20 -0600
committerBrian Paul <brianp@vmware.com>2012-09-17 19:49:26 -0600
commite6eaa85a43616ba6f431276ab94a3b19dd524986 (patch)
tree5a8c908cb96f741092efc60e9a6a0e96665de1e7 /src/mesa/main/texstorage.c
parentce2ae3c3a2e4bef78047a28723f2d06264d6e4b6 (diff)
downloadexternal_mesa3d-e6eaa85a43616ba6f431276ab94a3b19dd524986.zip
external_mesa3d-e6eaa85a43616ba6f431276ab94a3b19dd524986.tar.gz
external_mesa3d-e6eaa85a43616ba6f431276ab94a3b19dd524986.tar.bz2
mesa: rework texture size error checking
There are two aspects to texture image size checking: 1. Are the width, height, depth legal values (not negative, not larger than the max size for the mipmap level, etc)? 2. Is the texture just too large to handle? For example, we might not be able to really allocate memory for a 3D texture of maxSize x maxSize x maxSize. Previously, we did (1) via the ctx->Driver.TestProxyTextureImage() hook but those tests are really device-independent. Now we do (2) via that hook since the max texture memory and texture shape are device-dependent. Also, (1) is now done outside the general texture parameter error checking functions because of the special interaction with proxy textures. The recently introduced PROXY_ERROR token is removed. The teximage() and copyteximage() functions are bit simpler now (less if-then nesting, etc.) Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Diffstat (limited to 'src/mesa/main/texstorage.c')
-rw-r--r--src/mesa/main/texstorage.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c
index f8a9397..10e5f8d 100644
--- a/src/mesa/main/texstorage.c
+++ b/src/mesa/main/texstorage.c
@@ -125,12 +125,12 @@ static void
setup_texstorage(struct gl_context *ctx,
struct gl_texture_object *texObj,
GLuint dims,
+ gl_format texFormat,
GLsizei levels, GLenum internalFormat,
GLsizei width, GLsizei height, GLsizei depth)
{
const GLenum target = texObj->Target;
const GLuint numFaces = _mesa_num_tex_faces(target);
- gl_format texFormat;
GLint level, levelWidth = width, levelHeight = height, levelDepth = depth;
GLuint face;
@@ -139,9 +139,6 @@ setup_texstorage(struct gl_context *ctx,
assert(height > 0);
assert(depth > 0);
- texFormat = _mesa_choose_texture_format(ctx, texObj, target, 0,
- internalFormat, GL_NONE, GL_NONE);
-
/* Set up all the texture object's gl_texture_images */
for (level = 0; level < levels; level++) {
for (face = 0; face < numFaces; face++) {
@@ -360,19 +357,23 @@ texstorage(GLuint dims, GLenum target, GLsizei levels, GLenum internalformat,
{
struct gl_texture_object *texObj;
GLboolean sizeOK;
- GLenum proxyTarget = _mesa_get_proxy_target(target);
+ gl_format texFormat;
GET_CURRENT_CONTEXT(ctx);
- texObj = _mesa_get_current_tex_object(ctx, target);
-
if (tex_storage_error_check(ctx, dims, target, levels,
internalformat, width, height, depth)) {
return; /* error was recorded */
}
- sizeOK = ctx->Driver.TestProxyTexImage(ctx, proxyTarget, 0,
- internalformat, GL_NONE, GL_NONE,
+ texObj = _mesa_get_current_tex_object(ctx, target);
+ assert(texObj);
+
+ texFormat = _mesa_choose_texture_format(ctx, texObj, target, 0,
+ internalformat, GL_NONE, GL_NONE);
+ assert(texFormat != MESA_FORMAT_NONE);
+
+ sizeOK = ctx->Driver.TestProxyTexImage(ctx, target, 0, texFormat,
width, height, depth, 0);
if (!sizeOK) {
@@ -388,7 +389,7 @@ texstorage(GLuint dims, GLenum target, GLsizei levels, GLenum internalformat,
}
}
else {
- setup_texstorage(ctx, texObj, dims, levels, internalformat,
+ setup_texstorage(ctx, texObj, dims, texFormat, levels, internalformat,
width, height, depth);
}
}