diff options
author | Brian Paul <[email protected]> | 2012-09-08 09:33:13 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-09-11 17:38:21 -0600 |
commit | 35c75f6777c177a59df8a87adf0777403113ce74 (patch) | |
tree | c26b84c9a3d91c7c3c2c0adc6aeddc377a6cbb7d /src/mesa/main | |
parent | d17440dcaa42ac4c19dad1be7d4c7199395135a9 (diff) |
mesa: fix proxy texture error handling in glTexStorage()
This is basically a follow-on to 1f5b1f98468d5e80be39e619ed15c422fbede8d3.
Basically, generate GL errors for ordinary invalid parameters for proxy
targets the same as for non-proxy targets. Only texture size and OOM
errors should be handled specially for proxies.
Note: This is a candidate for the stable branches.
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/texstorage.c | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c index 8e03e5eb738..f8a9397949a 100644 --- a/src/mesa/main/texstorage.c +++ b/src/mesa/main/texstorage.c @@ -192,9 +192,10 @@ setup_texstorage(struct gl_context *ctx, return; } - } - texObj->Immutable = GL_TRUE; + /* Only set this field for non-proxy texture objects */ + texObj->Immutable = GL_TRUE; + } } @@ -242,7 +243,6 @@ tex_storage_error_check(struct gl_context *ctx, GLuint dims, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) { - const GLboolean isProxy = _mesa_is_proxy_texture(target); struct gl_texture_object *texObj; GLuint maxDim; GLboolean legalFormat; @@ -296,19 +296,15 @@ tex_storage_error_check(struct gl_context *ctx, GLuint dims, GLenum target, /* size check */ if (width < 1 || height < 1 || depth < 1) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexStorage%uD(width, height or depth < 1)", dims); - } + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexStorage%uD(width, height or depth < 1)", dims); return GL_TRUE; } /* levels check */ if (levels < 1 || height < 1 || depth < 1) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexStorage%uD(levels < 1)", - dims); - } + _mesa_error(ctx, GL_INVALID_VALUE, "glTexStorage%uD(levels < 1)", + dims); return GL_TRUE; } @@ -322,40 +318,32 @@ tex_storage_error_check(struct gl_context *ctx, GLuint dims, GLenum target, /* check levels against maximum */ if (levels > _mesa_max_texture_levels(ctx, target)) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexStorage%uD(levels too large)", dims); - } + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexStorage%uD(levels too large)", dims); return GL_TRUE; } /* check levels against width/height/depth */ maxDim = MAX3(width, height, depth); if (levels > _mesa_logbase2(maxDim) + 1) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexStorage%uD(too many levels for max texture dimension)", - dims); - } + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexStorage%uD(too many levels for max texture dimension)", + dims); return GL_TRUE; } /* non-default texture object check */ texObj = _mesa_get_current_tex_object(ctx, target); - if (!texObj || (texObj->Name == 0 && !isProxy)) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexStorage%uD(texture object 0)", dims); - } + if (!texObj || (texObj->Name == 0)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexStorage%uD(texture object 0)", dims); return GL_TRUE; } /* Check if texObj->Immutable is set */ if (texObj->Immutable) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexStorage%uD(immutable)", - dims); - } + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexStorage%uD(immutable)", + dims); return GL_TRUE; } @@ -371,22 +359,38 @@ texstorage(GLuint dims, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) { struct gl_texture_object *texObj; - GLboolean error; + GLboolean sizeOK; + GLenum proxyTarget = _mesa_get_proxy_target(target); GET_CURRENT_CONTEXT(ctx); texObj = _mesa_get_current_tex_object(ctx, target); - error = tex_storage_error_check(ctx, dims, target, levels, - internalformat, width, height, depth); - if (!error) { + 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, + width, height, depth, 0); + + if (!sizeOK) { + if (_mesa_is_proxy_texture(texObj->Target)) { + /* clear all image fields for [levels] */ + clear_image_fields(ctx, dims, texObj); + } + else { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexStorage%uD(invalid width, height or depth)", + dims); + return; + } + } + else { setup_texstorage(ctx, texObj, dims, levels, internalformat, width, height, depth); } - else if (_mesa_is_proxy_texture(target)) { - /* clear all image fields for [levels] */ - clear_image_fields(ctx, dims, texObj); - } } |