[Mesa-dev] [PATCH 040/101] mesa: add generate_texture_mipmap_error() helper
Samuel Pitoiset
samuel.pitoiset at gmail.com
Fri Jul 21 17:39:49 UTC 2017
And make generate_texture_mipmap() always inline.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/mesa/main/genmipmap.c | 46 ++++++++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 18 deletions(-)
diff --git a/src/mesa/main/genmipmap.c b/src/mesa/main/genmipmap.c
index be49136aa8..9eb83cf85f 100644
--- a/src/mesa/main/genmipmap.c
+++ b/src/mesa/main/genmipmap.c
@@ -107,10 +107,10 @@ _mesa_is_valid_generate_texture_mipmap_internalformat(struct gl_context *ctx,
* Implements glGenerateMipmap and glGenerateTextureMipmap.
* Generates all the mipmap levels below the base level.
*/
-static void
+static ALWAYS_INLINE void
generate_texture_mipmap(struct gl_context *ctx,
struct gl_texture_object *texObj, GLenum target,
- bool dsa)
+ bool dsa, bool no_error)
{
struct gl_texture_image *srcImage;
const char *suffix = dsa ? "Texture" : "";
@@ -122,7 +122,7 @@ generate_texture_mipmap(struct gl_context *ctx,
return;
}
- if (texObj->Target == GL_TEXTURE_CUBE_MAP &&
+ if (!no_error && texObj->Target == GL_TEXTURE_CUBE_MAP &&
!_mesa_cube_complete(texObj)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGenerate%sMipmap(incomplete cube map)", suffix);
@@ -132,20 +132,22 @@ generate_texture_mipmap(struct gl_context *ctx,
_mesa_lock_texture(ctx, texObj);
srcImage = _mesa_select_tex_image(texObj, target, texObj->BaseLevel);
- if (!srcImage) {
- _mesa_unlock_texture(ctx, texObj);
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGenerate%sMipmap(zero size base image)", suffix);
- return;
- }
+ if (!no_error) {
+ if (!srcImage) {
+ _mesa_unlock_texture(ctx, texObj);
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGenerate%sMipmap(zero size base image)", suffix);
+ return;
+ }
- if (!_mesa_is_valid_generate_texture_mipmap_internalformat(ctx,
- srcImage->InternalFormat)) {
- _mesa_unlock_texture(ctx, texObj);
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGenerate%sMipmap(invalid internal format %s)", suffix,
- _mesa_enum_to_string(srcImage->InternalFormat));
- return;
+ if (!_mesa_is_valid_generate_texture_mipmap_internalformat(ctx,
+ srcImage->InternalFormat)) {
+ _mesa_unlock_texture(ctx, texObj);
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGenerate%sMipmap(invalid internal format %s)", suffix,
+ _mesa_enum_to_string(srcImage->InternalFormat));
+ return;
+ }
}
if (srcImage->Width == 0 || srcImage->Height == 0) {
@@ -166,6 +168,14 @@ 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);
+}
+
/**
* Generate all the mipmap levels below the base level.
* Note: this GL function would be more useful if one could specify a
@@ -187,7 +197,7 @@ _mesa_GenerateMipmap(GLenum target)
if (!texObj)
return;
- generate_texture_mipmap(ctx, texObj, target, false);
+ generate_texture_mipmap_error(ctx, texObj, target, false);
}
/**
@@ -209,5 +219,5 @@ _mesa_GenerateTextureMipmap(GLuint texture)
return;
}
- generate_texture_mipmap(ctx, texObj, texObj->Target, true);
+ generate_texture_mipmap_error(ctx, texObj, texObj->Target, true);
}
--
2.13.3
More information about the mesa-dev
mailing list