diff options
author | Pierre-Eric Pelloux-Prayer <[email protected]> | 2019-09-11 09:58:47 +0200 |
---|---|---|
committer | Pierre-Eric Pelloux-Prayer <[email protected]> | 2019-10-18 10:26:26 +0200 |
commit | fb804266a38dbd4204f86fc706494b285c03fc52 (patch) | |
tree | 2ac7e5c4e12abc76c1f32d3f8548d9d87b50be58 | |
parent | cfc0ebe7f1fd02972f86d526d1a4683a52670cf5 (diff) |
mesa: refactor GenerateTextureMipmap handling
Rework _mesa_GenerateTextureMipmap to allow code sharing with EXT_dsa functions.
Reviewed-by: Marek Olšák <[email protected]>
-rw-r--r-- | src/mesa/main/genmipmap.c | 57 |
1 files changed, 25 insertions, 32 deletions
diff --git a/src/mesa/main/genmipmap.c b/src/mesa/main/genmipmap.c index fd20ea28065..6729631b16b 100644 --- a/src/mesa/main/genmipmap.c +++ b/src/mesa/main/genmipmap.c @@ -106,14 +106,14 @@ _mesa_is_valid_generate_texture_mipmap_internalformat(struct gl_context *ctx, /** * Implements glGenerateMipmap and glGenerateTextureMipmap. * Generates all the mipmap levels below the base level. + * Error-checking is done only if caller is not NULL. */ static ALWAYS_INLINE void generate_texture_mipmap(struct gl_context *ctx, struct gl_texture_object *texObj, GLenum target, - bool dsa, bool no_error) + const char* caller) { struct gl_texture_image *srcImage; - const char *suffix = dsa ? "Texture" : ""; FLUSH_VERTICES(ctx, 0); @@ -122,21 +122,21 @@ generate_texture_mipmap(struct gl_context *ctx, return; } - if (!no_error && texObj->Target == GL_TEXTURE_CUBE_MAP && + if (caller && texObj->Target == GL_TEXTURE_CUBE_MAP && !_mesa_cube_complete(texObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glGenerate%sMipmap(incomplete cube map)", suffix); + "%s(incomplete cube map)", caller); return; } _mesa_lock_texture(ctx, texObj); srcImage = _mesa_select_tex_image(texObj, target, texObj->BaseLevel); - if (!no_error) { + if (caller) { if (!srcImage) { _mesa_unlock_texture(ctx, texObj); _mesa_error(ctx, GL_INVALID_OPERATION, - "glGenerate%sMipmap(zero size base image)", suffix); + "%s(zero size base image)", caller); return; } @@ -144,7 +144,7 @@ generate_texture_mipmap(struct gl_context *ctx, srcImage->InternalFormat)) { _mesa_unlock_texture(ctx, texObj); _mesa_error(ctx, GL_INVALID_OPERATION, - "glGenerate%sMipmap(invalid internal format %s)", suffix, + "%s(invalid internal format %s)", caller, _mesa_enum_to_string(srcImage->InternalFormat)); return; } @@ -168,22 +168,6 @@ generate_texture_mipmap(struct gl_context *ctx, _mesa_unlock_texture(ctx, texObj); } -static void -generate_texture_mipmap_error(struct gl_context *ctx, - struct gl_texture_object *texObj, GLenum target, - bool dsa) -{ - generate_texture_mipmap(ctx, texObj, target, dsa, false); -} - -static void -generate_texture_mipmap_no_error(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLenum target, bool dsa) -{ - generate_texture_mipmap(ctx, texObj, target, dsa, true); -} - /** * Generate all the mipmap levels below the base level. * Note: this GL function would be more useful if one could specify a @@ -195,7 +179,7 @@ _mesa_GenerateMipmap_no_error(GLenum target) GET_CURRENT_CONTEXT(ctx); struct gl_texture_object *texObj = _mesa_get_current_tex_object(ctx, target); - generate_texture_mipmap_no_error(ctx, texObj, target, false); + generate_texture_mipmap(ctx, texObj, target, NULL); } void GLAPIENTRY @@ -214,7 +198,7 @@ _mesa_GenerateMipmap(GLenum target) if (!texObj) return; - generate_texture_mipmap_error(ctx, texObj, target, false); + generate_texture_mipmap(ctx, texObj, target, "glGenerateMipmap"); } /** @@ -226,24 +210,33 @@ _mesa_GenerateTextureMipmap_no_error(GLuint texture) GET_CURRENT_CONTEXT(ctx); struct gl_texture_object *texObj = _mesa_lookup_texture(ctx, texture); - generate_texture_mipmap_no_error(ctx, texObj, texObj->Target, true); + generate_texture_mipmap(ctx, texObj, texObj->Target, NULL); } -void GLAPIENTRY -_mesa_GenerateTextureMipmap(GLuint texture) +static void +validate_params_and_generate_mipmap(struct gl_texture_object *texObj, const char* caller) { - struct gl_texture_object *texObj; GET_CURRENT_CONTEXT(ctx); - texObj = _mesa_lookup_texture_err(ctx, texture, "glGenerateTextureMipmap"); if (!texObj) return; if (!_mesa_is_valid_generate_texture_mipmap_target(ctx, texObj->Target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGenerateTextureMipmap(target=%s)", + _mesa_error(ctx, GL_INVALID_ENUM, "%s(target=%s)", + caller, _mesa_enum_to_string(texObj->Target)); return; } - generate_texture_mipmap_error(ctx, texObj, texObj->Target, true); + generate_texture_mipmap(ctx, texObj, texObj->Target, caller); +} + +void GLAPIENTRY +_mesa_GenerateTextureMipmap(GLuint texture) +{ + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + + texObj = _mesa_lookup_texture_err(ctx, texture, "glGenerateTextureMipmap"); + validate_params_and_generate_mipmap(texObj, "glGenerateTextureMipmap"); } |