diff options
author | Brian Paul <[email protected]> | 2010-04-20 21:17:35 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2010-04-20 21:17:35 -0600 |
commit | 736a2f2f956c14d52c1ca9291a6dfa5df5e7b062 (patch) | |
tree | 67bf5288b585329f30ef841228c92acfc3af1b3c /src/mesa | |
parent | a40e6f220ac7e41126b9815db27d362bda719bf6 (diff) |
mesa: do version checking for GL 3.x queries
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/get.c | 50 | ||||
-rw-r--r-- | src/mesa/main/get_gen.py | 32 |
2 files changed, 74 insertions, 8 deletions
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index f89a798f1b6..e3015cd6033 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -63,12 +63,22 @@ goto invalid_enum_error; \ } +/* + * Check GL version. + */ +#define CHECK_VERSION(VERSION) \ + if (version < VERSION) { \ + goto invalid_enum_error; \ + } + void GLAPIENTRY _mesa_GetBooleanv( GLenum pname, GLboolean *params ) { GET_CURRENT_CONTEXT(ctx); + const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; ASSERT_OUTSIDE_BEGIN_END(ctx); + (void) version; if (!params) return; @@ -1943,24 +1953,31 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTransformFeedbackSeparateComponents); break; case GL_NUM_EXTENSIONS: + CHECK_VERSION(30); params[0] = INT_TO_BOOLEAN(_mesa_get_extension_count(ctx)); break; case GL_MAJOR_VERSION: + CHECK_VERSION(30); params[0] = INT_TO_BOOLEAN(ctx->VersionMajor); break; case GL_MINOR_VERSION: + CHECK_VERSION(30); params[0] = INT_TO_BOOLEAN(ctx->VersionMinor); break; case GL_CONTEXT_FLAGS: + CHECK_VERSION(30); params[0] = INT_TO_BOOLEAN(ctx->Const.ContextFlags); break; case GL_PRIMITIVE_RESTART: + CHECK_VERSION(31); params[0] = ctx->Array.PrimitiveRestart; break; case GL_PRIMITIVE_RESTART_INDEX: + CHECK_VERSION(31); params[0] = INT_TO_BOOLEAN(ctx->Array.RestartIndex); break; case GL_CONTEXT_PROFILE_MASK: + CHECK_VERSION(32); params[0] = INT_TO_BOOLEAN(ctx->Const.ProfileMask); break; default: @@ -1976,7 +1993,9 @@ void GLAPIENTRY _mesa_GetFloatv( GLenum pname, GLfloat *params ) { GET_CURRENT_CONTEXT(ctx); + const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; ASSERT_OUTSIDE_BEGIN_END(ctx); + (void) version; if (!params) return; @@ -3851,24 +3870,31 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) params[0] = (GLfloat)(ctx->Const.MaxTransformFeedbackSeparateComponents); break; case GL_NUM_EXTENSIONS: + CHECK_VERSION(30); params[0] = (GLfloat)(_mesa_get_extension_count(ctx)); break; case GL_MAJOR_VERSION: + CHECK_VERSION(30); params[0] = (GLfloat)(ctx->VersionMajor); break; case GL_MINOR_VERSION: + CHECK_VERSION(30); params[0] = (GLfloat)(ctx->VersionMinor); break; case GL_CONTEXT_FLAGS: + CHECK_VERSION(30); params[0] = (GLfloat)(ctx->Const.ContextFlags); break; case GL_PRIMITIVE_RESTART: + CHECK_VERSION(31); params[0] = BOOLEAN_TO_FLOAT(ctx->Array.PrimitiveRestart); break; case GL_PRIMITIVE_RESTART_INDEX: + CHECK_VERSION(31); params[0] = (GLfloat)(ctx->Array.RestartIndex); break; case GL_CONTEXT_PROFILE_MASK: + CHECK_VERSION(32); params[0] = (GLfloat)(ctx->Const.ProfileMask); break; default: @@ -3884,7 +3910,9 @@ void GLAPIENTRY _mesa_GetIntegerv( GLenum pname, GLint *params ) { GET_CURRENT_CONTEXT(ctx); + const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; ASSERT_OUTSIDE_BEGIN_END(ctx); + (void) version; if (!params) return; @@ -5759,24 +5787,31 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) params[0] = ctx->Const.MaxTransformFeedbackSeparateComponents; break; case GL_NUM_EXTENSIONS: + CHECK_VERSION(30); params[0] = _mesa_get_extension_count(ctx); break; case GL_MAJOR_VERSION: + CHECK_VERSION(30); params[0] = ctx->VersionMajor; break; case GL_MINOR_VERSION: + CHECK_VERSION(30); params[0] = ctx->VersionMinor; break; case GL_CONTEXT_FLAGS: + CHECK_VERSION(30); params[0] = ctx->Const.ContextFlags; break; case GL_PRIMITIVE_RESTART: + CHECK_VERSION(31); params[0] = BOOLEAN_TO_INT(ctx->Array.PrimitiveRestart); break; case GL_PRIMITIVE_RESTART_INDEX: + CHECK_VERSION(31); params[0] = ctx->Array.RestartIndex; break; case GL_CONTEXT_PROFILE_MASK: + CHECK_VERSION(32); params[0] = ctx->Const.ProfileMask; break; default: @@ -5793,7 +5828,9 @@ void GLAPIENTRY _mesa_GetInteger64v( GLenum pname, GLint64 *params ) { GET_CURRENT_CONTEXT(ctx); + const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; ASSERT_OUTSIDE_BEGIN_END(ctx); + (void) version; if (!params) return; @@ -7668,24 +7705,31 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = (GLint64)(ctx->Const.MaxTransformFeedbackSeparateComponents); break; case GL_NUM_EXTENSIONS: + CHECK_VERSION(30); params[0] = (GLint64)(_mesa_get_extension_count(ctx)); break; case GL_MAJOR_VERSION: + CHECK_VERSION(30); params[0] = (GLint64)(ctx->VersionMajor); break; case GL_MINOR_VERSION: + CHECK_VERSION(30); params[0] = (GLint64)(ctx->VersionMinor); break; case GL_CONTEXT_FLAGS: + CHECK_VERSION(30); params[0] = (GLint64)(ctx->Const.ContextFlags); break; case GL_PRIMITIVE_RESTART: + CHECK_VERSION(31); params[0] = BOOLEAN_TO_INT64(ctx->Array.PrimitiveRestart); break; case GL_PRIMITIVE_RESTART_INDEX: + CHECK_VERSION(31); params[0] = (GLint64)(ctx->Array.RestartIndex); break; case GL_CONTEXT_PROFILE_MASK: + CHECK_VERSION(32); params[0] = (GLint64)(ctx->Const.ProfileMask); break; default: @@ -7725,7 +7769,9 @@ void GLAPIENTRY _mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ) { GET_CURRENT_CONTEXT(ctx); + const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; ASSERT_OUTSIDE_BEGIN_END(ctx); + (void) version; if (!params) return; @@ -7787,7 +7833,9 @@ void GLAPIENTRY _mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) { GET_CURRENT_CONTEXT(ctx); + const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; ASSERT_OUTSIDE_BEGIN_END(ctx); + (void) version; if (!params) return; @@ -7850,7 +7898,9 @@ void GLAPIENTRY _mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ) { GET_CURRENT_CONTEXT(ctx); + const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; ASSERT_OUTSIDE_BEGIN_END(ctx); + (void) version; if (!params) return; diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 0279ec9d1d3..21f7750dbd7 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -1140,20 +1140,24 @@ StateVars = [ NoState, ["EXT_transform_feedback"] ), # GL 3.0 - ( "GL_NUM_EXTENSIONS", GLint, ["_mesa_get_extension_count(ctx)"], "", NoState, NoExt ), - ( "GL_MAJOR_VERSION", GLint, ["ctx->VersionMajor"], "", NoState, NoExt ), - ( "GL_MINOR_VERSION", GLint, ["ctx->VersionMinor"], "", NoState, NoExt ), - ( "GL_CONTEXT_FLAGS", GLint, ["ctx->Const.ContextFlags"], "", NoState, NoExt ), + ( "GL_NUM_EXTENSIONS", GLint, + ["_mesa_get_extension_count(ctx)"], "", NoState, "30" ), + ( "GL_MAJOR_VERSION", GLint, + ["ctx->VersionMajor"], "", NoState, "30" ), + ( "GL_MINOR_VERSION", GLint, + ["ctx->VersionMinor"], "", NoState, "30" ), + ( "GL_CONTEXT_FLAGS", GLint, + ["ctx->Const.ContextFlags"], "", NoState, "30" ), # GL 3.1 ( "GL_PRIMITIVE_RESTART", GLboolean, - ["ctx->Array.PrimitiveRestart"], "", NoState, NoExt ), + ["ctx->Array.PrimitiveRestart"], "", NoState, "31" ), ( "GL_PRIMITIVE_RESTART_INDEX", GLint, - ["ctx->Array.RestartIndex"], "", NoState, NoExt ), + ["ctx->Array.RestartIndex"], "", NoState, "31" ), # GL 3.2 ( "GL_CONTEXT_PROFILE_MASK", GLint, ["ctx->Const.ProfileMask"], "", - NoState, NoExt ) + NoState, "32" ) ] @@ -1257,7 +1261,9 @@ def EmitGetFunction(stateVars, returnType, indexed): print "_mesa_%s( GLenum pname, %s *params )" % (function, strType) print "{" print " GET_CURRENT_CONTEXT(ctx);" + print " const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor;" print " ASSERT_OUTSIDE_BEGIN_END(ctx);" + print " (void) version;" print "" print " if (!params)" print " return;" @@ -1280,7 +1286,9 @@ def EmitGetFunction(stateVars, returnType, indexed): # Do extension check if extensions: - if len(extensions) == 1: + if extensions == "30" or extensions == "31" or extensions == "32": + print (' CHECK_VERSION(%s);' % extensions) + elif len(extensions) == 1: print (' CHECK_EXT1(%s);' % extensions[0]) elif len(extensions) == 2: print (' CHECK_EXT2(%s, %s);' % (extensions[0], extensions[1])) @@ -1404,6 +1412,14 @@ def EmitHeader(): goto invalid_enum_error; \\ } +/* + * Check GL version. + */ +#define CHECK_VERSION(VERSION) \\ + if (version < VERSION) { \\ + goto invalid_enum_error; \\ + } + """ return |