[Mesa-dev] [PATCH 2/4] mesa: Switch a bunch of VersionMajor/VersionMinor checks to Version.
Eric Anholt
eric at anholt.net
Thu Jul 26 17:27:44 PDT 2012
---
src/mesa/drivers/dri/intel/intel_screen.c | 4 +---
src/mesa/drivers/dri/nouveau/nouveau_context.c | 4 +---
src/mesa/drivers/dri/r200/r200_context.c | 4 +---
src/mesa/drivers/dri/radeon/radeon_context.c | 4 +---
src/mesa/main/enable.c | 4 ++--
src/mesa/main/get.c | 2 +-
src/mesa/main/teximage.c | 3 +--
src/mesa/main/varray.c | 3 +--
src/mesa/state_tracker/st_manager.c | 3 +--
9 files changed, 10 insertions(+), 21 deletions(-)
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index e8a4ad1..24dab8f 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -693,9 +693,7 @@ intelCreateContext(gl_api api,
(struct gl_context *) driContextPriv->driverPrivate;
_mesa_compute_version(ctx);
- if (ctx->VersionMajor > major_version
- || (ctx->VersionMajor == major_version
- && ctx->VersionMinor >= minor_version)) {
+ if (ctx->Version >= major_version * 10 + minor_version) {
return true;
}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c
index d7d5a04..f794308 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c
@@ -75,9 +75,7 @@ nouveau_context_create(gl_api api,
dri_ctx->driverPrivate = ctx;
_mesa_compute_version(ctx);
- if (ctx->VersionMajor < major_version
- || (ctx->VersionMajor == major_version
- && ctx->VersionMinor < minor_version)) {
+ if (ctx->Version < major_version * 10 + minor_version) {
nouveau_context_destroy(dri_ctx);
*error = __DRI_CTX_ERROR_BAD_VERSION;
return GL_FALSE;
diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c
index 244973e..17e08a1 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -454,9 +454,7 @@ GLboolean r200CreateContext( gl_api api,
}
_mesa_compute_version(ctx);
- if (ctx->VersionMajor < major_version
- || (ctx->VersionMajor == major_version
- && ctx->VersionMinor < minor_version)) {
+ if (ctx->Version < major_version * 10 + minor_version) {
r200DestroyContext(driContextPriv);
*error = __DRI_CTX_ERROR_BAD_VERSION;
return GL_FALSE;
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index 9881d00..34c392e 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -402,9 +402,7 @@ r100CreateContext( gl_api api,
}
_mesa_compute_version(ctx);
- if (ctx->VersionMajor < major_version
- || (ctx->VersionMajor == major_version
- && ctx->VersionMinor < minor_version)) {
+ if (ctx->Version < major_version * 10 + minor_version) {
radeonDestroyContext(driContextPriv);
*error = __DRI_CTX_ERROR_BAD_VERSION;
return GL_FALSE;
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index c811f2a..f811057 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -902,7 +902,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
* GL_PRIMITIVE_RESTART_NV (which is client state).
*/
case GL_PRIMITIVE_RESTART:
- if (ctx->VersionMajor * 10 + ctx->VersionMinor < 31) {
+ if (ctx->Version < 31) {
goto invalid_enum_error;
}
if (ctx->Array.PrimitiveRestart != state) {
@@ -1419,7 +1419,7 @@ _mesa_IsEnabled( GLenum cap )
/* GL 3.1 primitive restart */
case GL_PRIMITIVE_RESTART:
- if (ctx->VersionMajor * 10 + ctx->VersionMinor < 31) {
+ if (ctx->Version < 31) {
goto invalid_enum_error;
}
return ctx->Array.PrimitiveRestart;
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 15de321..ff7ea3a 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1850,7 +1850,7 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
static GLboolean
check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d)
{
- const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor;
+ const GLuint version = ctx->Version;
int total, enabled;
const int *e;
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 91df133..c76bd94 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3860,8 +3860,7 @@ validate_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat)
* any mention of R/RG formats, but they appear in the GL 3.1 core
* specification.
*/
- if (ctx->VersionMajor < 3 ||
- (ctx->VersionMajor == 3 && ctx->VersionMinor == 0)) {
+ if (ctx->Version < 30) {
GLenum base_format = _mesa_get_format_base_format(format);
if (base_format == GL_R || base_format == GL_RG)
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index efa63b0..b39a202 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1092,8 +1092,7 @@ _mesa_PrimitiveRestartIndex(GLuint index)
{
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.NV_primitive_restart &&
- ctx->VersionMajor * 10 + ctx->VersionMinor < 31) {
+ if (!ctx->Extensions.NV_primitive_restart && ctx->Version < 31) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glPrimitiveRestartIndexNV()");
return;
}
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 748624f..4e2f9ec 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -650,8 +650,7 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
* yet enforce the added restrictions of a forward-looking context, so
* fail that too.
*/
- if (st->ctx->VersionMajor * 10 + st->ctx->VersionMinor <
- attribs->major * 10 + attribs->minor
+ if (st->ctx->Version < attribs->major * 10 + attribs->minor
|| (attribs->flags & ~ST_CONTEXT_FLAG_DEBUG) != 0) {
*error = ST_CONTEXT_ERROR_BAD_VERSION;
st_destroy_context(st);
--
1.7.10.4
More information about the mesa-dev
mailing list