[Mesa-dev] [RFC 38/63] mesa/genmipmap: Added a function to validate the internalformat
Eduardo Lima Mitev
elima at igalia.com
Tue Jan 19 08:42:18 PST 2016
From: Antia Puentes <apuentes at igalia.com>
It will be used by the ARB_internalformat_query2 implementation to
implement mipmap related queries.
---
src/mesa/main/genmipmap.c | 16 ++++++++++++----
src/mesa/main/genmipmap.h | 3 +++
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/mesa/main/genmipmap.c b/src/mesa/main/genmipmap.c
index 13ec766..1d9ed57 100644
--- a/src/mesa/main/genmipmap.c
+++ b/src/mesa/main/genmipmap.c
@@ -75,6 +75,16 @@ _mesa_is_valid_generate_texture_mipmap_target(struct gl_context *ctx,
return (error != GL_TRUE);
}
+bool
+_mesa_is_valid_generate_texture_mipmap_internalformat(struct gl_context *ctx,
+ GLenum internalformat)
+{
+ return (!_mesa_is_enum_format_integer(internalformat) &&
+ !_mesa_is_depthstencil_format(internalformat) &&
+ !_mesa_is_astc_format(internalformat) &&
+ !_mesa_is_stencil_format(internalformat));
+}
+
/**
* Implements glGenerateMipmap and glGenerateTextureMipmap.
* Generates all the mipmap levels below the base level.
@@ -117,10 +127,8 @@ _mesa_generate_texture_mipmap(struct gl_context *ctx,
return;
}
- if (_mesa_is_enum_format_integer(srcImage->InternalFormat) ||
- _mesa_is_depthstencil_format(srcImage->InternalFormat) ||
- _mesa_is_astc_format(srcImage->InternalFormat) ||
- _mesa_is_stencil_format(srcImage->InternalFormat)) {
+ 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)", suffix);
diff --git a/src/mesa/main/genmipmap.h b/src/mesa/main/genmipmap.h
index 843eeac..40b7f36 100644
--- a/src/mesa/main/genmipmap.h
+++ b/src/mesa/main/genmipmap.h
@@ -35,6 +35,9 @@ _mesa_generate_texture_mipmap(struct gl_context *ctx,
bool
_mesa_is_valid_generate_texture_mipmap_target(struct gl_context *ctx,
GLenum target);
+bool
+_mesa_is_valid_generate_texture_mipmap_internalformat(struct gl_context *ctx,
+ GLenum internalformat);
extern void GLAPIENTRY
_mesa_GenerateMipmap(GLenum target);
--
2.5.3
More information about the mesa-dev
mailing list