Re: [Mesa-dev] [PATCH v3] glsl: reuse main extension table to appropriately restrict extensions

2016-07-20 Thread Ilia Mirkin
Thanks to the kind folks at Intel, this has been run through their CI
system, which runs against piglit, as well as CTS. This turned up just
a handful of regressions:

(a) GL_OES_texture_storage_multisample_2d_array define test used
#version 300 es in piglit instead of 310, fixed by
https://patchwork.freedesktop.org/patch/100107/
(b) piglit.es3-cts.shaders.shader_integer_mix.define -- This uses
#version 100, according to Timothy Arceri, while the ext requires ES
3.0. I believe it's correct not to have it defined in that case.
(c) piglit.es31-cts.shader_integer_mix.define -- I strongly suspect
this is the same issue as the ES3 version.

It also fixes some failures due to missing
GL_AMD_shader_stencil_export define string, as well as exts being
exposed in compat when they shouldn't be, like all the layer/viewport
stuff.

  -ilia


On Mon, Jul 18, 2016 at 5:03 PM, Ilia Mirkin  wrote:
> Well, I have a basic review on this from Eric Engestrom, who is not a
> mesa expert (yet?) but has been giving out a lot of good review
> comments lately, and nobody else has piped up saying they hate this,
> so I'm going to push this in the next few days unless I hear any
> objections. IMHO this is a nice simplification of the glsl parser
> boilerplate, and removes the oft-forgotten glcpp annoyance.
>
> On Tue, Jul 12, 2016 at 11:07 AM, Ilia Mirkin  wrote:
>> ping^2
>>
>> On Tue, Jul 5, 2016 at 6:41 PM, Ilia Mirkin  wrote:
>>> ping
>>>
>>> On Fri, Jun 24, 2016 at 1:42 AM, Ilia Mirkin  wrote:
 Previously we were only restricting based on ES/non-ES-ness and whether
 the overall enable bit had been flipped on. However we have been adding
 more fine-grained restrictions, such as based on compat profiles, as
 well as specific ES versions. Most of the time this doesn't matter, but
 it can create awkward situations and duplication of logic.

 Here we separate the main extension table into a separate object file,
 linked to the glsl compiler, which makes use of it with a custom
 function which takes the ES-ness of the shader into account (thus
 allowing desktop shaders to properly use ES extensions that would
 otherwise have been disallowed.)

 The effect of this change should be nil in most cases. However in some
 situations, extensions like GL_ARB_gpu_shader5 which were formerly
 available in compat contexts on the GLSL side of things will now become
 inaccessible.

 Signed-off-by: Ilia Mirkin 
 Reviewed-by: Eric Engestrom  (v2)
 v2 -> v3: integrate glcpp defines into the same mechanism
 ---

 FWIW I hate the method I had to invent to get this information to
 glcpp. A callback that takes a callback. Ugh. Sorry. If someone can
 come up with something cleaner, I'm all ears.

 This does appear to pass some basic testing.

  src/Makefile.am  |   1 +
  src/compiler/SConscript.glsl |   2 +
  src/compiler/glsl/glcpp/glcpp-parse.y| 204 +-
  src/compiler/glsl/glcpp/glcpp.c  |   2 +-
  src/compiler/glsl/glcpp/glcpp.h  |  19 ++-
  src/compiler/glsl/glcpp/pp.c |   6 +-
  src/compiler/glsl/glsl_parser_extras.cpp | 283 
 +--
  src/compiler/glsl/glsl_parser_extras.h   |  17 +-
  src/compiler/glsl/test_optpass.cpp   |   2 +-
  src/mesa/Android.libmesa_glsl_utils.mk   |   2 +
  src/mesa/Makefile.sources|   1 +
  src/mesa/main/extensions.c   |  33 +---
  src/mesa/main/extensions.h   |   1 +
  src/mesa/main/extensions_table.c |  51 ++
  14 files changed, 269 insertions(+), 355 deletions(-)
  create mode 100644 src/mesa/main/extensions_table.c

 diff --git a/src/Makefile.am b/src/Makefile.am
 index 32372da..d38f7c4 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -114,6 +114,7 @@ AM_CPPFLAGS = \
  noinst_LTLIBRARIES = libglsl_util.la

  libglsl_util_la_SOURCES = \
 +   mesa/main/extensions_table.c \
 mesa/main/imports.c \
 mesa/program/prog_hash_table.c \
 mesa/program/symbol_table.c \
 diff --git a/src/compiler/SConscript.glsl b/src/compiler/SConscript.glsl
 index 4252ce1..31d8f6d 100644
 --- a/src/compiler/SConscript.glsl
 +++ b/src/compiler/SConscript.glsl
 @@ -70,6 +70,7 @@ if env['msvc']:
  # Copy these files to avoid generation object files into src/mesa/program
  env.Prepend(CPPPATH = ['#src/mesa/main'])
  env.Command('glsl/imports.c', '#src/mesa/main/imports.c', Copy('$TARGET', 
 '$SOURCE'))
 +env.Command('glsl/extensions_table.c', 
 '#src/mesa/main/extensions_table.c', Copy('$TARGET', '$SOURCE'))
  # Copy these files to avoid 

Re: [Mesa-dev] [PATCH v3] glsl: reuse main extension table to appropriately restrict extensions

2016-07-18 Thread Ilia Mirkin
Well, I have a basic review on this from Eric Engestrom, who is not a
mesa expert (yet?) but has been giving out a lot of good review
comments lately, and nobody else has piped up saying they hate this,
so I'm going to push this in the next few days unless I hear any
objections. IMHO this is a nice simplification of the glsl parser
boilerplate, and removes the oft-forgotten glcpp annoyance.

On Tue, Jul 12, 2016 at 11:07 AM, Ilia Mirkin  wrote:
> ping^2
>
> On Tue, Jul 5, 2016 at 6:41 PM, Ilia Mirkin  wrote:
>> ping
>>
>> On Fri, Jun 24, 2016 at 1:42 AM, Ilia Mirkin  wrote:
>>> Previously we were only restricting based on ES/non-ES-ness and whether
>>> the overall enable bit had been flipped on. However we have been adding
>>> more fine-grained restrictions, such as based on compat profiles, as
>>> well as specific ES versions. Most of the time this doesn't matter, but
>>> it can create awkward situations and duplication of logic.
>>>
>>> Here we separate the main extension table into a separate object file,
>>> linked to the glsl compiler, which makes use of it with a custom
>>> function which takes the ES-ness of the shader into account (thus
>>> allowing desktop shaders to properly use ES extensions that would
>>> otherwise have been disallowed.)
>>>
>>> The effect of this change should be nil in most cases. However in some
>>> situations, extensions like GL_ARB_gpu_shader5 which were formerly
>>> available in compat contexts on the GLSL side of things will now become
>>> inaccessible.
>>>
>>> Signed-off-by: Ilia Mirkin 
>>> Reviewed-by: Eric Engestrom  (v2)
>>> v2 -> v3: integrate glcpp defines into the same mechanism
>>> ---
>>>
>>> FWIW I hate the method I had to invent to get this information to
>>> glcpp. A callback that takes a callback. Ugh. Sorry. If someone can
>>> come up with something cleaner, I'm all ears.
>>>
>>> This does appear to pass some basic testing.
>>>
>>>  src/Makefile.am  |   1 +
>>>  src/compiler/SConscript.glsl |   2 +
>>>  src/compiler/glsl/glcpp/glcpp-parse.y| 204 +-
>>>  src/compiler/glsl/glcpp/glcpp.c  |   2 +-
>>>  src/compiler/glsl/glcpp/glcpp.h  |  19 ++-
>>>  src/compiler/glsl/glcpp/pp.c |   6 +-
>>>  src/compiler/glsl/glsl_parser_extras.cpp | 283 
>>> +--
>>>  src/compiler/glsl/glsl_parser_extras.h   |  17 +-
>>>  src/compiler/glsl/test_optpass.cpp   |   2 +-
>>>  src/mesa/Android.libmesa_glsl_utils.mk   |   2 +
>>>  src/mesa/Makefile.sources|   1 +
>>>  src/mesa/main/extensions.c   |  33 +---
>>>  src/mesa/main/extensions.h   |   1 +
>>>  src/mesa/main/extensions_table.c |  51 ++
>>>  14 files changed, 269 insertions(+), 355 deletions(-)
>>>  create mode 100644 src/mesa/main/extensions_table.c
>>>
>>> diff --git a/src/Makefile.am b/src/Makefile.am
>>> index 32372da..d38f7c4 100644
>>> --- a/src/Makefile.am
>>> +++ b/src/Makefile.am
>>> @@ -114,6 +114,7 @@ AM_CPPFLAGS = \
>>>  noinst_LTLIBRARIES = libglsl_util.la
>>>
>>>  libglsl_util_la_SOURCES = \
>>> +   mesa/main/extensions_table.c \
>>> mesa/main/imports.c \
>>> mesa/program/prog_hash_table.c \
>>> mesa/program/symbol_table.c \
>>> diff --git a/src/compiler/SConscript.glsl b/src/compiler/SConscript.glsl
>>> index 4252ce1..31d8f6d 100644
>>> --- a/src/compiler/SConscript.glsl
>>> +++ b/src/compiler/SConscript.glsl
>>> @@ -70,6 +70,7 @@ if env['msvc']:
>>>  # Copy these files to avoid generation object files into src/mesa/program
>>>  env.Prepend(CPPPATH = ['#src/mesa/main'])
>>>  env.Command('glsl/imports.c', '#src/mesa/main/imports.c', Copy('$TARGET', 
>>> '$SOURCE'))
>>> +env.Command('glsl/extensions_table.c', 
>>> '#src/mesa/main/extensions_table.c', Copy('$TARGET', '$SOURCE'))
>>>  # Copy these files to avoid generation object files into src/mesa/program
>>>  env.Prepend(CPPPATH = ['#src/mesa/program'])
>>>  env.Command('glsl/prog_hash_table.c', 
>>> '#src/mesa/program/prog_hash_table.c', Copy('$TARGET', '$SOURCE'))
>>> @@ -79,6 +80,7 @@ env.Command('glsl/dummy_errors.c', 
>>> '#src/mesa/program/dummy_errors.c', Copy('$TA
>>>  compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
>>>
>>>  mesa_objs = env.StaticObject([
>>> +'glsl/extensions_table.c',
>>>  'glsl/imports.c',
>>>  'glsl/prog_hash_table.c',
>>>  'glsl/symbol_table.c',
>>> diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y 
>>> b/src/compiler/glsl/glcpp/glcpp-parse.y
>>> index b9d690d..ca376d9 100644
>>> --- a/src/compiler/glsl/glcpp/glcpp-parse.y
>>> +++ b/src/compiler/glsl/glcpp/glcpp-parse.y
>>> @@ -1311,7 +1311,7 @@ add_builtin_define(glcpp_parser_t *parser, const char 
>>> *name, int value)
>>>  }
>>>
>>>  glcpp_parser_t *
>>> -glcpp_parser_create(const struct gl_extensions *extensions, gl_api api)

Re: [Mesa-dev] [PATCH v3] glsl: reuse main extension table to appropriately restrict extensions

2016-07-12 Thread Ilia Mirkin
ping^2

On Tue, Jul 5, 2016 at 6:41 PM, Ilia Mirkin  wrote:
> ping
>
> On Fri, Jun 24, 2016 at 1:42 AM, Ilia Mirkin  wrote:
>> Previously we were only restricting based on ES/non-ES-ness and whether
>> the overall enable bit had been flipped on. However we have been adding
>> more fine-grained restrictions, such as based on compat profiles, as
>> well as specific ES versions. Most of the time this doesn't matter, but
>> it can create awkward situations and duplication of logic.
>>
>> Here we separate the main extension table into a separate object file,
>> linked to the glsl compiler, which makes use of it with a custom
>> function which takes the ES-ness of the shader into account (thus
>> allowing desktop shaders to properly use ES extensions that would
>> otherwise have been disallowed.)
>>
>> The effect of this change should be nil in most cases. However in some
>> situations, extensions like GL_ARB_gpu_shader5 which were formerly
>> available in compat contexts on the GLSL side of things will now become
>> inaccessible.
>>
>> Signed-off-by: Ilia Mirkin 
>> Reviewed-by: Eric Engestrom  (v2)
>> v2 -> v3: integrate glcpp defines into the same mechanism
>> ---
>>
>> FWIW I hate the method I had to invent to get this information to
>> glcpp. A callback that takes a callback. Ugh. Sorry. If someone can
>> come up with something cleaner, I'm all ears.
>>
>> This does appear to pass some basic testing.
>>
>>  src/Makefile.am  |   1 +
>>  src/compiler/SConscript.glsl |   2 +
>>  src/compiler/glsl/glcpp/glcpp-parse.y| 204 +-
>>  src/compiler/glsl/glcpp/glcpp.c  |   2 +-
>>  src/compiler/glsl/glcpp/glcpp.h  |  19 ++-
>>  src/compiler/glsl/glcpp/pp.c |   6 +-
>>  src/compiler/glsl/glsl_parser_extras.cpp | 283 
>> +--
>>  src/compiler/glsl/glsl_parser_extras.h   |  17 +-
>>  src/compiler/glsl/test_optpass.cpp   |   2 +-
>>  src/mesa/Android.libmesa_glsl_utils.mk   |   2 +
>>  src/mesa/Makefile.sources|   1 +
>>  src/mesa/main/extensions.c   |  33 +---
>>  src/mesa/main/extensions.h   |   1 +
>>  src/mesa/main/extensions_table.c |  51 ++
>>  14 files changed, 269 insertions(+), 355 deletions(-)
>>  create mode 100644 src/mesa/main/extensions_table.c
>>
>> diff --git a/src/Makefile.am b/src/Makefile.am
>> index 32372da..d38f7c4 100644
>> --- a/src/Makefile.am
>> +++ b/src/Makefile.am
>> @@ -114,6 +114,7 @@ AM_CPPFLAGS = \
>>  noinst_LTLIBRARIES = libglsl_util.la
>>
>>  libglsl_util_la_SOURCES = \
>> +   mesa/main/extensions_table.c \
>> mesa/main/imports.c \
>> mesa/program/prog_hash_table.c \
>> mesa/program/symbol_table.c \
>> diff --git a/src/compiler/SConscript.glsl b/src/compiler/SConscript.glsl
>> index 4252ce1..31d8f6d 100644
>> --- a/src/compiler/SConscript.glsl
>> +++ b/src/compiler/SConscript.glsl
>> @@ -70,6 +70,7 @@ if env['msvc']:
>>  # Copy these files to avoid generation object files into src/mesa/program
>>  env.Prepend(CPPPATH = ['#src/mesa/main'])
>>  env.Command('glsl/imports.c', '#src/mesa/main/imports.c', Copy('$TARGET', 
>> '$SOURCE'))
>> +env.Command('glsl/extensions_table.c', '#src/mesa/main/extensions_table.c', 
>> Copy('$TARGET', '$SOURCE'))
>>  # Copy these files to avoid generation object files into src/mesa/program
>>  env.Prepend(CPPPATH = ['#src/mesa/program'])
>>  env.Command('glsl/prog_hash_table.c', 
>> '#src/mesa/program/prog_hash_table.c', Copy('$TARGET', '$SOURCE'))
>> @@ -79,6 +80,7 @@ env.Command('glsl/dummy_errors.c', 
>> '#src/mesa/program/dummy_errors.c', Copy('$TA
>>  compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
>>
>>  mesa_objs = env.StaticObject([
>> +'glsl/extensions_table.c',
>>  'glsl/imports.c',
>>  'glsl/prog_hash_table.c',
>>  'glsl/symbol_table.c',
>> diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y 
>> b/src/compiler/glsl/glcpp/glcpp-parse.y
>> index b9d690d..ca376d9 100644
>> --- a/src/compiler/glsl/glcpp/glcpp-parse.y
>> +++ b/src/compiler/glsl/glcpp/glcpp-parse.y
>> @@ -1311,7 +1311,7 @@ add_builtin_define(glcpp_parser_t *parser, const char 
>> *name, int value)
>>  }
>>
>>  glcpp_parser_t *
>> -glcpp_parser_create(const struct gl_extensions *extensions, gl_api api)
>> +glcpp_parser_create(glcpp_extension_iterator extensions, void *state, 
>> gl_api api)
>>  {
>> glcpp_parser_t *parser;
>>
>> @@ -1344,6 +1344,7 @@ glcpp_parser_create(const struct gl_extensions 
>> *extensions, gl_api api)
>> parser->error = 0;
>>
>> parser->extensions = extensions;
>> +   parser->state = state;
>> parser->api = api;
>> parser->version_resolved = false;
>>
>> @@ -2279,8 +2280,6 @@ 
>> _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t 
>> versio
>>   const char 

Re: [Mesa-dev] [PATCH v3] glsl: reuse main extension table to appropriately restrict extensions

2016-07-05 Thread Ilia Mirkin
ping

On Fri, Jun 24, 2016 at 1:42 AM, Ilia Mirkin  wrote:
> Previously we were only restricting based on ES/non-ES-ness and whether
> the overall enable bit had been flipped on. However we have been adding
> more fine-grained restrictions, such as based on compat profiles, as
> well as specific ES versions. Most of the time this doesn't matter, but
> it can create awkward situations and duplication of logic.
>
> Here we separate the main extension table into a separate object file,
> linked to the glsl compiler, which makes use of it with a custom
> function which takes the ES-ness of the shader into account (thus
> allowing desktop shaders to properly use ES extensions that would
> otherwise have been disallowed.)
>
> The effect of this change should be nil in most cases. However in some
> situations, extensions like GL_ARB_gpu_shader5 which were formerly
> available in compat contexts on the GLSL side of things will now become
> inaccessible.
>
> Signed-off-by: Ilia Mirkin 
> Reviewed-by: Eric Engestrom  (v2)
> v2 -> v3: integrate glcpp defines into the same mechanism
> ---
>
> FWIW I hate the method I had to invent to get this information to
> glcpp. A callback that takes a callback. Ugh. Sorry. If someone can
> come up with something cleaner, I'm all ears.
>
> This does appear to pass some basic testing.
>
>  src/Makefile.am  |   1 +
>  src/compiler/SConscript.glsl |   2 +
>  src/compiler/glsl/glcpp/glcpp-parse.y| 204 +-
>  src/compiler/glsl/glcpp/glcpp.c  |   2 +-
>  src/compiler/glsl/glcpp/glcpp.h  |  19 ++-
>  src/compiler/glsl/glcpp/pp.c |   6 +-
>  src/compiler/glsl/glsl_parser_extras.cpp | 283 
> +--
>  src/compiler/glsl/glsl_parser_extras.h   |  17 +-
>  src/compiler/glsl/test_optpass.cpp   |   2 +-
>  src/mesa/Android.libmesa_glsl_utils.mk   |   2 +
>  src/mesa/Makefile.sources|   1 +
>  src/mesa/main/extensions.c   |  33 +---
>  src/mesa/main/extensions.h   |   1 +
>  src/mesa/main/extensions_table.c |  51 ++
>  14 files changed, 269 insertions(+), 355 deletions(-)
>  create mode 100644 src/mesa/main/extensions_table.c
>
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 32372da..d38f7c4 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -114,6 +114,7 @@ AM_CPPFLAGS = \
>  noinst_LTLIBRARIES = libglsl_util.la
>
>  libglsl_util_la_SOURCES = \
> +   mesa/main/extensions_table.c \
> mesa/main/imports.c \
> mesa/program/prog_hash_table.c \
> mesa/program/symbol_table.c \
> diff --git a/src/compiler/SConscript.glsl b/src/compiler/SConscript.glsl
> index 4252ce1..31d8f6d 100644
> --- a/src/compiler/SConscript.glsl
> +++ b/src/compiler/SConscript.glsl
> @@ -70,6 +70,7 @@ if env['msvc']:
>  # Copy these files to avoid generation object files into src/mesa/program
>  env.Prepend(CPPPATH = ['#src/mesa/main'])
>  env.Command('glsl/imports.c', '#src/mesa/main/imports.c', Copy('$TARGET', 
> '$SOURCE'))
> +env.Command('glsl/extensions_table.c', '#src/mesa/main/extensions_table.c', 
> Copy('$TARGET', '$SOURCE'))
>  # Copy these files to avoid generation object files into src/mesa/program
>  env.Prepend(CPPPATH = ['#src/mesa/program'])
>  env.Command('glsl/prog_hash_table.c', '#src/mesa/program/prog_hash_table.c', 
> Copy('$TARGET', '$SOURCE'))
> @@ -79,6 +80,7 @@ env.Command('glsl/dummy_errors.c', 
> '#src/mesa/program/dummy_errors.c', Copy('$TA
>  compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
>
>  mesa_objs = env.StaticObject([
> +'glsl/extensions_table.c',
>  'glsl/imports.c',
>  'glsl/prog_hash_table.c',
>  'glsl/symbol_table.c',
> diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y 
> b/src/compiler/glsl/glcpp/glcpp-parse.y
> index b9d690d..ca376d9 100644
> --- a/src/compiler/glsl/glcpp/glcpp-parse.y
> +++ b/src/compiler/glsl/glcpp/glcpp-parse.y
> @@ -1311,7 +1311,7 @@ add_builtin_define(glcpp_parser_t *parser, const char 
> *name, int value)
>  }
>
>  glcpp_parser_t *
> -glcpp_parser_create(const struct gl_extensions *extensions, gl_api api)
> +glcpp_parser_create(glcpp_extension_iterator extensions, void *state, gl_api 
> api)
>  {
> glcpp_parser_t *parser;
>
> @@ -1344,6 +1344,7 @@ glcpp_parser_create(const struct gl_extensions 
> *extensions, gl_api api)
> parser->error = 0;
>
> parser->extensions = extensions;
> +   parser->state = state;
> parser->api = api;
> parser->version_resolved = false;
>
> @@ -2279,8 +2280,6 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t 
> *parser, intmax_t versio
>   const char *es_identifier,
>   bool explicitly_set)
>  {
> -   const struct gl_extensions *extensions = parser->extensions;
> -
> if (parser->version_resolved)
>

[Mesa-dev] [PATCH v3] glsl: reuse main extension table to appropriately restrict extensions

2016-06-23 Thread Ilia Mirkin
Previously we were only restricting based on ES/non-ES-ness and whether
the overall enable bit had been flipped on. However we have been adding
more fine-grained restrictions, such as based on compat profiles, as
well as specific ES versions. Most of the time this doesn't matter, but
it can create awkward situations and duplication of logic.

Here we separate the main extension table into a separate object file,
linked to the glsl compiler, which makes use of it with a custom
function which takes the ES-ness of the shader into account (thus
allowing desktop shaders to properly use ES extensions that would
otherwise have been disallowed.)

The effect of this change should be nil in most cases. However in some
situations, extensions like GL_ARB_gpu_shader5 which were formerly
available in compat contexts on the GLSL side of things will now become
inaccessible.

Signed-off-by: Ilia Mirkin 
Reviewed-by: Eric Engestrom  (v2)
v2 -> v3: integrate glcpp defines into the same mechanism
---

FWIW I hate the method I had to invent to get this information to
glcpp. A callback that takes a callback. Ugh. Sorry. If someone can
come up with something cleaner, I'm all ears.

This does appear to pass some basic testing.

 src/Makefile.am  |   1 +
 src/compiler/SConscript.glsl |   2 +
 src/compiler/glsl/glcpp/glcpp-parse.y| 204 +-
 src/compiler/glsl/glcpp/glcpp.c  |   2 +-
 src/compiler/glsl/glcpp/glcpp.h  |  19 ++-
 src/compiler/glsl/glcpp/pp.c |   6 +-
 src/compiler/glsl/glsl_parser_extras.cpp | 283 +--
 src/compiler/glsl/glsl_parser_extras.h   |  17 +-
 src/compiler/glsl/test_optpass.cpp   |   2 +-
 src/mesa/Android.libmesa_glsl_utils.mk   |   2 +
 src/mesa/Makefile.sources|   1 +
 src/mesa/main/extensions.c   |  33 +---
 src/mesa/main/extensions.h   |   1 +
 src/mesa/main/extensions_table.c |  51 ++
 14 files changed, 269 insertions(+), 355 deletions(-)
 create mode 100644 src/mesa/main/extensions_table.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 32372da..d38f7c4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -114,6 +114,7 @@ AM_CPPFLAGS = \
 noinst_LTLIBRARIES = libglsl_util.la
 
 libglsl_util_la_SOURCES = \
+   mesa/main/extensions_table.c \
mesa/main/imports.c \
mesa/program/prog_hash_table.c \
mesa/program/symbol_table.c \
diff --git a/src/compiler/SConscript.glsl b/src/compiler/SConscript.glsl
index 4252ce1..31d8f6d 100644
--- a/src/compiler/SConscript.glsl
+++ b/src/compiler/SConscript.glsl
@@ -70,6 +70,7 @@ if env['msvc']:
 # Copy these files to avoid generation object files into src/mesa/program
 env.Prepend(CPPPATH = ['#src/mesa/main'])
 env.Command('glsl/imports.c', '#src/mesa/main/imports.c', Copy('$TARGET', 
'$SOURCE'))
+env.Command('glsl/extensions_table.c', '#src/mesa/main/extensions_table.c', 
Copy('$TARGET', '$SOURCE'))
 # Copy these files to avoid generation object files into src/mesa/program
 env.Prepend(CPPPATH = ['#src/mesa/program'])
 env.Command('glsl/prog_hash_table.c', '#src/mesa/program/prog_hash_table.c', 
Copy('$TARGET', '$SOURCE'))
@@ -79,6 +80,7 @@ env.Command('glsl/dummy_errors.c', 
'#src/mesa/program/dummy_errors.c', Copy('$TA
 compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
 
 mesa_objs = env.StaticObject([
+'glsl/extensions_table.c',
 'glsl/imports.c',
 'glsl/prog_hash_table.c',
 'glsl/symbol_table.c',
diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y 
b/src/compiler/glsl/glcpp/glcpp-parse.y
index b9d690d..ca376d9 100644
--- a/src/compiler/glsl/glcpp/glcpp-parse.y
+++ b/src/compiler/glsl/glcpp/glcpp-parse.y
@@ -1311,7 +1311,7 @@ add_builtin_define(glcpp_parser_t *parser, const char 
*name, int value)
 }
 
 glcpp_parser_t *
-glcpp_parser_create(const struct gl_extensions *extensions, gl_api api)
+glcpp_parser_create(glcpp_extension_iterator extensions, void *state, gl_api 
api)
 {
glcpp_parser_t *parser;
 
@@ -1344,6 +1344,7 @@ glcpp_parser_create(const struct gl_extensions 
*extensions, gl_api api)
parser->error = 0;
 
parser->extensions = extensions;
+   parser->state = state;
parser->api = api;
parser->version_resolved = false;
 
@@ -2279,8 +2280,6 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t 
*parser, intmax_t versio
  const char *es_identifier,
  bool explicitly_set)
 {
-   const struct gl_extensions *extensions = parser->extensions;
-
if (parser->version_resolved)
   return;
 
@@ -2292,199 +2291,9 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t 
*parser, intmax_t versio
  (es_identifier && (strcmp(es_identifier, "es") == 0));
 
/* Add pre-defined macros. */
-   if (parser->is_gles) {
+   if (parser->is_gles)