diff options
author | Brian Paul <[email protected]> | 2012-08-21 20:22:27 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-08-24 06:18:41 -0600 |
commit | e93cb4b34fed27eccf291963b5fe2c26cea46251 (patch) | |
tree | 200062efd81b1d9b8253439047f3e60dd8f1cd9b /src/mesa/main/teximage.c | |
parent | c1a9e6010baceeff78f72ac0692aefc4312d815f (diff) |
mesa: make glTexImage, glCompressedTexImage proxy code more alike
Next up, we can combine the teximage() and compressed_teximage() functions.
Diffstat (limited to 'src/mesa/main/teximage.c')
-rw-r--r-- | src/mesa/main/teximage.c | 77 |
1 files changed, 42 insertions, 35 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index be01fb9c4e1..1977a25eb1b 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2683,6 +2683,22 @@ teximage(struct gl_context *ctx, GLuint dims, /* Proxy texture: just clear or set state depending on error checking */ struct gl_texture_image *texImage = get_proxy_tex_image(ctx, target, level); + gl_format texFormat = MESA_FORMAT_NONE; + + if (!error) { + /* No parameter errors. Choose a texture format and see if we + * can really allocate the texture. + */ + struct gl_texture_object *texObj = + _mesa_get_current_tex_object(ctx, target); + texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, format, type); + if (!legal_texture_size(ctx, texFormat, width, height, depth)) { + error = PROXY_ERROR; + } + } + + texImage = get_proxy_tex_image(ctx, target, level); if (error == PROXY_ERROR) { /* image too large, etc. Clear all proxy texture image parameters. */ @@ -2690,22 +2706,13 @@ teximage(struct gl_context *ctx, GLuint dims, clear_teximage_fields(texImage); } else if (error == GL_FALSE) { - /* no error, set the tex image parameters */ - struct gl_texture_object *texObj = - _mesa_get_current_tex_object(ctx, target); - gl_format texFormat = _mesa_choose_texture_format(ctx, texObj, - target, level, - internalFormat, - format, type); - - if (legal_texture_size(ctx, texFormat, width, height, depth)) { - _mesa_init_teximage_fields(ctx, texImage, width, height, - depth, border, internalFormat, - texFormat); - } - else if (texImage) { - clear_teximage_fields(texImage); - } + /* no error: store the teximage parameters */ + if (texImage) + _mesa_init_teximage_fields(ctx, texImage, width, height, depth, + border, internalFormat, texFormat); + } + else { + /* other, regular error (was already recorded) */ } } else { @@ -3643,7 +3650,9 @@ compressedteximage(struct gl_context *ctx, GLuint dims, if (_mesa_is_proxy_texture(target)) { /* Proxy texture: just check for errors and update proxy state */ - struct gl_texture_image *texImage; + struct gl_texture_image *texImage = + get_proxy_tex_image(ctx, target, level); + gl_format texFormat = MESA_FORMAT_NONE; if (!error) { /* No parameter errors. Choose a texture format and see if we @@ -3651,30 +3660,28 @@ compressedteximage(struct gl_context *ctx, GLuint dims, */ struct gl_texture_object *texObj = _mesa_get_current_tex_object(ctx, target); - gl_format texFormat = - _mesa_choose_texture_format(ctx, texObj, target, level, - internalFormat, GL_NONE, GL_NONE); + texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, + GL_NONE, GL_NONE); if (!legal_texture_size(ctx, texFormat, width, height, depth)) { error = PROXY_ERROR; } } - texImage = get_proxy_tex_image(ctx, target, level); - if (texImage) { - if (error == PROXY_ERROR) { - /* if error, clear all proxy texture image parameters */ + if (error == PROXY_ERROR) { + /* image too large, etc. Clear all proxy texture image parameters. */ + if (texImage) clear_teximage_fields(texImage); - } - else if (error == GL_NO_ERROR) { - /* no error: store the teximage parameters */ - _mesa_init_teximage_fields(ctx, texImage, width, height, - depth, border, internalFormat, - MESA_FORMAT_NONE); - } - else { - /* other, regular error */ - _mesa_error(ctx, error, "glCompressedTexImage%uD(%s)", dims, reason); - } + } + else if (error == GL_NO_ERROR) { + /* no error: store the teximage parameters */ + if (texImage) + _mesa_init_teximage_fields(ctx, texImage, width, height, depth, + border, internalFormat, texFormat); + } + else { + /* other, regular error */ + _mesa_error(ctx, error, "glCompressedTexImage%uD(%s)", dims, reason); } } else { |