diff options
author | marha <marha@users.sourceforge.net> | 2015-02-22 21:39:56 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2015-02-22 21:39:56 +0100 |
commit | 462f18c7b25fe3e467f837647d07ab0a78aa8d2b (patch) | |
tree | fc8013c0a1bac05a1945846c1697e973f4c35013 /mesalib/src/mesa/main/genmipmap.c | |
parent | 36f711ee12b6dd5184198abed3aa551efb585587 (diff) | |
download | vcxsrv-462f18c7b25fe3e467f837647d07ab0a78aa8d2b.tar.gz vcxsrv-462f18c7b25fe3e467f837647d07ab0a78aa8d2b.tar.bz2 vcxsrv-462f18c7b25fe3e467f837647d07ab0a78aa8d2b.zip |
Merged origin/release (checked in because wanted to merge new stuff)
Diffstat (limited to 'mesalib/src/mesa/main/genmipmap.c')
-rw-r--r-- | mesalib/src/mesa/main/genmipmap.c | 73 |
1 files changed, 52 insertions, 21 deletions
diff --git a/mesalib/src/mesa/main/genmipmap.c b/mesalib/src/mesa/main/genmipmap.c index 9d111cab2..9aef09019 100644 --- a/mesalib/src/mesa/main/genmipmap.c +++ b/mesalib/src/mesa/main/genmipmap.c @@ -36,21 +36,20 @@ #include "mtypes.h" #include "teximage.h" #include "texobj.h" - +#include "hash.h" /** - * Generate all the mipmap levels below the base level. - * Note: this GL function would be more useful if one could specify a - * cube face, a set of array slices, etc. + * Implements glGenerateMipmap and glGenerateTextureMipmap. + * Generates all the mipmap levels below the base level. */ -void GLAPIENTRY -_mesa_GenerateMipmap(GLenum target) +void +_mesa_generate_texture_mipmap(struct gl_context *ctx, + struct gl_texture_object *texObj, GLenum target, + bool dsa) { struct gl_texture_image *srcImage; - struct gl_texture_object *texObj; GLboolean error; - - GET_CURRENT_CONTEXT(ctx); + const char *suffix = dsa ? "Texture" : ""; FLUSH_VERTICES(ctx, 0); @@ -83,13 +82,11 @@ _mesa_GenerateMipmap(GLenum target) } if (error) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGenerateMipmapEXT(target=%s)", - _mesa_lookup_enum_by_nr(target)); + _mesa_error(ctx, GL_INVALID_ENUM, "glGenerate%sMipmap(target=%s)", + suffix, _mesa_lookup_enum_by_nr(target)); return; } - texObj = _mesa_get_current_tex_object(ctx, target); - if (texObj->BaseLevel >= texObj->MaxLevel) { /* nothing to do */ return; @@ -98,17 +95,17 @@ _mesa_GenerateMipmap(GLenum target) if (texObj->Target == GL_TEXTURE_CUBE_MAP && !_mesa_cube_complete(texObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glGenerateMipmap(incomplete cube map)"); + "glGenerate%sMipmap(incomplete cube map)", suffix); return; } _mesa_lock_texture(ctx, texObj); - srcImage = _mesa_select_tex_image(ctx, texObj, target, texObj->BaseLevel); + srcImage = _mesa_select_tex_image(texObj, target, texObj->BaseLevel); if (!srcImage) { _mesa_unlock_texture(ctx, texObj); _mesa_error(ctx, GL_INVALID_OPERATION, - "glGenerateMipmap(zero size base image)"); + "glGenerate%sMipmap(zero size base image)", suffix); return; } @@ -117,19 +114,53 @@ _mesa_GenerateMipmap(GLenum target) _mesa_is_stencil_format(srcImage->InternalFormat)) { _mesa_unlock_texture(ctx, texObj); _mesa_error(ctx, GL_INVALID_OPERATION, - "glGenerateMipmap(invalid internal format)"); + "glGenerate%sMipmap(invalid internal format)", suffix); return; } if (target == GL_TEXTURE_CUBE_MAP) { GLuint face; - for (face = 0; face < 6; face++) - ctx->Driver.GenerateMipmap(ctx, - GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + face, - texObj); + for (face = 0; face < 6; face++) { + ctx->Driver.GenerateMipmap(ctx, + GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + face, texObj); + } } else { ctx->Driver.GenerateMipmap(ctx, target, texObj); } _mesa_unlock_texture(ctx, texObj); } + +/** + * Generate all the mipmap levels below the base level. + * Note: this GL function would be more useful if one could specify a + * cube face, a set of array slices, etc. + */ +void GLAPIENTRY +_mesa_GenerateMipmap(GLenum target) +{ + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + + texObj = _mesa_get_current_tex_object(ctx, target); + if (!texObj) + return; + + _mesa_generate_texture_mipmap(ctx, texObj, target, false); +} + +/** + * Generate all the mipmap levels below the base level. + */ +void GLAPIENTRY +_mesa_GenerateTextureMipmap(GLuint texture) +{ + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + + texObj = _mesa_lookup_texture_err(ctx, texture, "glGenerateTextureMipmap"); + if (!texObj) + return; + + _mesa_generate_texture_mipmap(ctx, texObj, texObj->Target, true); +} |