Mesa (master): mesa: extract _mesa_is_legal_tex_storage_format helper

Chris Forbes chrisf at kemper.freedesktop.org
Sun Mar 31 09:21:07 UTC 2013


Module: Mesa
Branch: master
Commit: 7f32b9560b63ffa6967bbc0c8e61d2cc30081ab3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f32b9560b63ffa6967bbc0c8e61d2cc30081ab3

Author: Chris Forbes <chrisf at ijw.co.nz>
Date:   Fri Mar 22 19:58:03 2013 +1300

mesa: extract _mesa_is_legal_tex_storage_format helper

This is about to be used in teximagemultisample() when immutable=true.

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/main/texstorage.c |   37 ++++++++++++++++++++-----------------
 src/mesa/main/texstorage.h |    3 +++
 2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c
index 675fd74..6309b57 100644
--- a/src/mesa/main/texstorage.c
+++ b/src/mesa/main/texstorage.c
@@ -202,20 +202,9 @@ clear_texture_fields(struct gl_context *ctx,
 }
 
 
-/**
- * Do error checking for calls to glTexStorage1/2/3D().
- * If an error is found, record it with _mesa_error(), unless the target
- * is a proxy texture.
- * \return GL_TRUE if any error, GL_FALSE otherwise.
- */
-static GLboolean
-tex_storage_error_check(struct gl_context *ctx, GLuint dims, GLenum target,
-                        GLsizei levels, GLenum internalformat,
-                        GLsizei width, GLsizei height, GLsizei depth)
+GLboolean
+_mesa_is_legal_tex_storage_format(struct gl_context *ctx, GLenum internalformat)
 {
-   struct gl_texture_object *texObj;
-   GLboolean legalFormat;
-
    /* check internal format - note that only sized formats are allowed */
    switch (internalformat) {
    case GL_ALPHA:
@@ -250,13 +239,27 @@ tex_storage_error_check(struct gl_context *ctx, GLuint dims, GLenum target,
    case GL_LUMINANCE_INTEGER_EXT:
    case GL_LUMINANCE_ALPHA_INTEGER_EXT:
       /* these unsized formats are illegal */
-      legalFormat = GL_FALSE;
-      break;
+      return GL_FALSE;
    default:
-      legalFormat = _mesa_base_tex_format(ctx, internalformat) > 0;
+      return _mesa_base_tex_format(ctx, internalformat) > 0;
    }
+}
+
+
+/**
+ * Do error checking for calls to glTexStorage1/2/3D().
+ * If an error is found, record it with _mesa_error(), unless the target
+ * is a proxy texture.
+ * \return GL_TRUE if any error, GL_FALSE otherwise.
+ */
+static GLboolean
+tex_storage_error_check(struct gl_context *ctx, GLuint dims, GLenum target,
+                        GLsizei levels, GLenum internalformat,
+                        GLsizei width, GLsizei height, GLsizei depth)
+{
+   struct gl_texture_object *texObj;
 
-   if (!legalFormat) {
+   if (!_mesa_is_legal_tex_storage_format(ctx, internalformat)) {
       _mesa_error(ctx, GL_INVALID_ENUM,
                   "glTexStorage%uD(internalformat = %s)", dims,
                   _mesa_lookup_enum_by_nr(internalformat));
diff --git a/src/mesa/main/texstorage.h b/src/mesa/main/texstorage.h
index 99382df..9f172e1 100644
--- a/src/mesa/main/texstorage.h
+++ b/src/mesa/main/texstorage.h
@@ -57,5 +57,8 @@ _mesa_TextureStorage3DEXT(GLuint texture, GLenum target, GLsizei levels,
                           GLenum internalformat,
                           GLsizei width, GLsizei height, GLsizei depth);
 
+extern GLboolean
+_mesa_is_legal_tex_storage_format(struct gl_context *ctx, GLenum internalformat);
+
 
 #endif /* TEXSTORAGE_H */




More information about the mesa-commit mailing list