[Mesa-dev] [RFC 10/21] mesa: Remove equality check in helper functions

Nanley Chery nanleychery at gmail.com
Mon Oct 19 15:44:48 PDT 2015


From: Nanley Chery <nanley.g.chery at intel.com>

Since the version numbers being compared are integral and we don't ever
expect gl_context::Version to be equal to 0, subtract 1 from the rhs of
the equation and perform the optimization of removing the equality check.

Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
---
 src/mesa/main/extensions.c       | 10 +++++-----
 src/mesa/main/extensions.h       |  2 +-
 src/mesa/main/extensions_table.h | 10 +++++-----
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 136313f..365e7ed 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -57,10 +57,10 @@ const struct extension extension_table[] = {
 #define EXT(name_str, driver_cap, gll_ver, glc_ver, gles_ver, gles2_ver, yyyy) \
         { .name = "GL_" #name_str, .offset = o(driver_cap), \
           .version = { \
-            [API_OPENGL_COMPAT] = gll_ver, \
-            [API_OPENGL_CORE]   = glc_ver, \
-            [API_OPENGLES]      = gles_ver, \
-            [API_OPENGLES2]     = gles2_ver, \
+            [API_OPENGL_COMPAT] = gll_ver - 1, \
+            [API_OPENGL_CORE]   = glc_ver - 1, \
+            [API_OPENGLES]      = gles_ver - 1, \
+            [API_OPENGLES2]     = gles2_ver - 1, \
            }, .year = yyyy},
 #include "extensions_table.h"
 #undef EXT
@@ -399,7 +399,7 @@ _mesa_extension_supported(const struct gl_context *ctx, extension_index ei)
 {
    const bool *base = (bool *) &ctx->Extensions;
    const struct extension *i = extension_table + ei;
-   return (ctx->Version >= i->version[ctx->API]) && base[i->offset];
+   return (ctx->Version > i->version[ctx->API]) && base[i->offset];
 }
 
 /**
diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h
index 24cc04d..50456e98 100644
--- a/src/mesa/main/extensions.h
+++ b/src/mesa/main/extensions.h
@@ -88,7 +88,7 @@ enum {
 /** Checks if the context suports a user-facing extension */
 #define EXT(name_str, driver_cap, ...) \
 static inline bool _mesa_has_##name_str(const struct gl_context *ctx) { \
-      return ctx->Extensions.driver_cap && (ctx->Version >= \
+      return ctx->Extensions.driver_cap && (ctx->Version > \
              extension_table[MESA_EXTENSION_##name_str].version[ctx->API]); \
 }
 #include "extensions_table.h"
diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index ce48b51..b18f4e6 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -1,8 +1,8 @@
-#define GLL 0
-#define GLC 0
-#define ES1 0
-#define ES2 0
-#define  x ~0
+#define GLL 1u
+#define GLC 1u
+#define ES1 1u
+#define ES2 1u
+#define  x ~0u
 EXT(ARB_ES2_compatibility                   , ARB_ES2_compatibility                  , GLL, GLC,  x ,  x , 2009)
 EXT(ARB_ES3_compatibility                   , ARB_ES3_compatibility                  , GLL, GLC,  x ,  x , 2012)
 EXT(ARB_arrays_of_arrays                    , ARB_arrays_of_arrays                   , GLL, GLC,  x ,  x , 2012)
-- 
2.6.1



More information about the mesa-dev mailing list