Mesa (master): mesa: add integer texture completeness check

Brian Paul brianp at kemper.freedesktop.org
Tue Mar 20 14:27:43 UTC 2012


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

Author: Brian Paul <brianp at vmware.com>
Date:   Sat Mar 17 16:30:03 2012 -0600

mesa: add integer texture completeness check

Per the spec, only nearest filtering is supported for integer textures.
Otherwise, the texture is incomplete.

Reviewed-by: José Fonseca <jfonseca at vmware.com>
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/mesa/main/mtypes.h |    1 +
 src/mesa/main/texobj.c |    6 ++++++
 src/mesa/main/texobj.h |    8 ++++++++
 3 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index c6e5b94..a3827d4 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1318,6 +1318,7 @@ struct gl_texture_object
    GLboolean GenerateMipmap;    /**< GL_SGIS_generate_mipmap */
    GLboolean _BaseComplete;     /**< Is the base texture level valid? */
    GLboolean _MipmapComplete;   /**< Is the whole mipmap valid? */
+   GLboolean _IsIntegerFormat;  /**< Does the texture store integer values? */
    GLboolean _RenderToTexture;  /**< Any rendering to this texture? */
    GLboolean Purgeable;         /**< Is the buffer purgeable under memory pressure? */
    GLboolean Immutable;         /**< GL_ARB_texture_storage */
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index da27d92..d641e40 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -478,6 +478,12 @@ _mesa_test_texobj_completeness( const struct gl_context *ctx,
       return;
    }
 
+   /* Check if the texture values are integer */
+   {
+      GLenum datatype = _mesa_get_format_datatype(baseImage->TexFormat);
+      t->_IsIntegerFormat = datatype == GL_INT || datatype == GL_UNSIGNED_INT;
+   }
+
    /* Compute _MaxLevel (the maximum mipmap level we'll sample from given the
     * mipmap image sizes and GL_TEXTURE_MAX_LEVEL state).
     */
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index 850091e..c020b90 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -83,6 +83,14 @@ static inline GLboolean
 _mesa_is_texture_complete(const struct gl_texture_object *texObj,
                           const struct gl_sampler_object *sampler)
 {
+   if (texObj->_IsIntegerFormat &&
+       (sampler->MagFilter != GL_NEAREST ||
+        (sampler->MinFilter != GL_NEAREST &&
+         sampler->MinFilter != GL_NEAREST_MIPMAP_NEAREST))) {
+      /* If the format is integer, only nearest filtering is allowed */
+      return GL_FALSE;
+   }
+
    if (_mesa_is_mipmap_filter(sampler))
       return texObj->_MipmapComplete;
    else




More information about the mesa-commit mailing list