summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/extensions.c25
-rw-r--r--src/mesa/main/extensions.h4
-rw-r--r--src/mesa/main/get.c12
-rw-r--r--src/mesa/main/get_gen.py3
-rw-r--r--src/mesa/main/mtypes.h2
5 files changed, 46 insertions, 0 deletions
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index a1561b4065b..88c025ee326 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 05ad859a27e..194c2efa40b 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 99478f0ec43..618b5411cc9 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 82eacf03146..7540661187f 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 3a48c8bf009..849d1689c35 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;
};