Mesa (master): mesa: implement GL3 GL_NUM_EXTENSIONS query

Brian Paul brianp at kemper.freedesktop.org
Wed Dec 30 09:33:17 PST 2009


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

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Dec 30 10:16:01 2009 -0700

mesa: implement GL3 GL_NUM_EXTENSIONS query

---

 src/mesa/main/extensions.c |   25 +++++++++++++++++++++++++
 src/mesa/main/extensions.h |    4 ++++
 src/mesa/main/get.c        |   12 ++++++++++++
 src/mesa/main/get_gen.py   |    3 +++
 src/mesa/main/mtypes.h     |    2 ++
 5 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index a1561b4..88c025e 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -700,3 +700,28 @@ _mesa_make_extension_string( GLcontext *ctx )
 
    return (GLubyte *) s;
 }
+
+
+/**
+ * Return number of enabled extensions.
+ */
+GLuint
+_mesa_get_extension_count(GLcontext *ctx)
+{
+   GLuint i;
+
+   /* only count once */
+   if (!ctx->Extensions.Count) {
+      for (i = 0; i < Elements(default_extensions); i++) {
+         if (extension_enabled(ctx, i)) {
+            ctx->Extensions.Count++;
+         }
+      }
+   }
+
+   if (0)
+      _mesa_debug(ctx, "%u of %d extensions enabled\n", ctx->Extensions.Count,
+                  Elements(default_extensions));
+
+   return ctx->Extensions.Count;
+}
diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h
index 05ad859..194c2ef 100644
--- a/src/mesa/main/extensions.h
+++ b/src/mesa/main/extensions.h
@@ -64,6 +64,10 @@ extern void _mesa_init_extensions(GLcontext *ctx);
 
 extern GLubyte *_mesa_make_extension_string(GLcontext *ctx);
 
+extern GLuint
+_mesa_get_extension_count(GLcontext *ctx);
+
+
 #else
 
 /** No-op */
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 99478f0..618b541 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1899,6 +1899,9 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          CHECK_EXT1(ARB_sync, "GetBooleanv");
          params[0] = INT64_TO_BOOLEAN(ctx->Const.MaxServerWaitTimeout);
          break;
+      case GL_NUM_EXTENSIONS:
+         params[0] = INT_TO_BOOLEAN(_mesa_get_extension_count(ctx));
+         break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv(pname=0x%x)", pname);
    }
@@ -3734,6 +3737,9 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          CHECK_EXT1(ARB_sync, "GetFloatv");
          params[0] = (GLfloat)(ctx->Const.MaxServerWaitTimeout);
          break;
+      case GL_NUM_EXTENSIONS:
+         params[0] = (GLfloat)(_mesa_get_extension_count(ctx));
+         break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv(pname=0x%x)", pname);
    }
@@ -5569,6 +5575,9 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          CHECK_EXT1(ARB_sync, "GetIntegerv");
          params[0] = INT64_TO_INT(ctx->Const.MaxServerWaitTimeout);
          break;
+      case GL_NUM_EXTENSIONS:
+         params[0] = _mesa_get_extension_count(ctx);
+         break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv(pname=0x%x)", pname);
    }
@@ -7405,6 +7414,9 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          CHECK_EXT1(ARB_sync, "GetInteger64v");
          params[0] = ctx->Const.MaxServerWaitTimeout;
          break;
+      case GL_NUM_EXTENSIONS:
+         params[0] = (GLint64)(_mesa_get_extension_count(ctx));
+         break;
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64v(pname=0x%x)", pname);
    }
diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py
index 82eacf0..7540661 100644
--- a/src/mesa/main/get_gen.py
+++ b/src/mesa/main/get_gen.py
@@ -1030,6 +1030,9 @@ StateVars = [
 	# GL_ARB_sync
 	( "GL_MAX_SERVER_WAIT_TIMEOUT", GLint64, ["ctx->Const.MaxServerWaitTimeout"], "",
 	  ["ARB_sync"] ),
+
+	# GL3
+	( "GL_NUM_EXTENSIONS", GLint, ["_mesa_get_extension_count(ctx)"], "", None ),
 ]
 
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 3a48c8b..849d168 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2512,6 +2512,8 @@ struct gl_extensions
    GLboolean S3_s3tc;
    /** The extension string */
    const GLubyte *String;
+   /** Number of supported extensions */
+   GLuint Count;
 };
 
 



More information about the mesa-commit mailing list