OSDN Git Service

glsl: Rewrote _mesa_glsl_process_extension to use table-driven logic.
authorPaul Berry <stereotype441@gmail.com>
Fri, 24 Jun 2011 22:34:04 +0000 (15:34 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 20 Jul 2011 15:15:32 +0000 (08:15 -0700)
commit9aa8c02ae2c7e25a4afa704d9feed4b06eff3b6e
tree727c5265a59523bb48c87074ef68720ecfc23e5c
parentb0ecde7f3972303f44817ae4ba2c3075f5ad48b2
glsl: Rewrote _mesa_glsl_process_extension to use table-driven logic.

Instead of using a chain of manually maintained if/else blocks to
handle "#extension" directives, we now consult a table that specifies,
for each extension, the circumstances under which it is available, and
what flags in _mesa_glsl_parse_state need to be set in order to
activate it.

This makes it easier to add new GLSL extensions in the future, and
fixes the following bugs:

- Previously, _mesa_glsl_process_extension would sometimes set the
  "_enable" and "_warn" flags for an extension before checking whether
  the extension was supported by the driver; as a result, specifying
  "enable" behavior for an unsupported extension would sometimes cause
  front-end support for that extension to be switched on in spite of
  the fact that back-end support was not available, leading to strange
  failures, such as those in
  https://bugs.freedesktop.org/show_bug.cgi?id=38015.

- "#extension all: warn" and "#extension all: disable" had no effect.

Notes:

- All extensions are currently marked as unavailable in geometry
  shaders.  This should not have any adverse effects since geometry
  shaders aren't supported yet.  When we return to working on geometry
  shader support, we'll need to update the table for those extensions
  that are available in geometry shaders.

- Previous to this commit, if a shader mentioned
  ARB_shader_texture_lod, extension ARB_texture_rectangle would be
  automatically turned on in order to ensure that the types
  sampler2DRect and sampler2DRectShadow would be defined.  This was
  unnecessary, because (a) ARB_shader_texture_lod works perfectly well
  without those types provided that the builtin functions that
  reference them are not called, and (b) ARB_texture_rectangle is
  enabled by default in non-ES contexts anyway.  I eliminated this
  unnecessary behavior in order to make the behavior of all extensions
  consistent.

NOTE: This is a candidate for the 7.10 and 7.11 branches.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
(cherry picked from commit 3097715d41da4b725b7ce9f9d5bbc0f684cbf0a6)
src/glsl/glsl_parser_extras.cpp