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

2015-10-23 Thread Nanley Chery
On Wed, Oct 21, 2015 at 11:43 PM, Erik Faye-Lund 
wrote:

> On Tue, Oct 20, 2015 at 12:44 AM, Nanley Chery 
> wrote:
> > From: Nanley Chery 
> >
> > 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.
>
> Is this really an improvement? Changing '>=' to '>' and then making
> all versions off-by-one seems like trading less readable and debugable
> code for no real upside...
>

After looking at the assembly generated, I've determined that this is
actually not an improvement. I'll drop this patch. I was using .text size
as my metric earlier. I now realize that it isn't completely reliable.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


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

2015-10-22 Thread Chad Versace
On Thu 22 Oct 2015, Emil Velikov wrote:
> On 22 October 2015 at 07:43, Erik Faye-Lund  wrote:
> > On Tue, Oct 20, 2015 at 12:44 AM, Nanley Chery  
> > wrote:
> >> From: Nanley Chery 
> >>
> >> 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.
> >
> > Is this really an improvement? Changing '>=' to '>' and then making
> > all versions off-by-one seems like trading less readable and debugable
> > code for no real upside...
> 
> Pretty much my line of thinking. Perhaps it was applicable for earlier
> iterations of the series ?

That's my opinion too.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


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

2015-10-22 Thread Emil Velikov
On 22 October 2015 at 07:43, Erik Faye-Lund  wrote:
> On Tue, Oct 20, 2015 at 12:44 AM, Nanley Chery  wrote:
>> From: Nanley Chery 
>>
>> 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.
>
> Is this really an improvement? Changing '>=' to '>' and then making
> all versions off-by-one seems like trading less readable and debugable
> code for no real upside...

Pretty much my line of thinking. Perhaps it was applicable for earlier
iterations of the series ?

-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


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

2015-10-21 Thread Erik Faye-Lund
On Tue, Oct 20, 2015 at 12:44 AM, Nanley Chery  wrote:
> From: Nanley Chery 
>
> 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.

Is this really an improvement? Changing '>=' to '>' and then making
all versions off-by-one seems like trading less readable and debugable
code for no real upside...
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


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

2015-10-19 Thread Nanley Chery
From: Nanley Chery 

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 
---
 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, ) 
\
 { .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 = },
 #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

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev