<div dir="ltr">On 29 July 2013 10:55, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Certain extensions only add functionality to particular shader stages.<br>
(For example, ARB_draw_instanced only adds variables to the vertex<br>
shader stage.)<br>
<br>
Previously, we only allowed such extensions to be enabled in the shader<br>
stages where they're useful.  However, I've never found any text which<br>
mandates that behavior; in my opinion, you should be able to turn on<br>
extensions in any shader stage, even if they have no effect.<br>
<br>
Fixes Piglit tests glslparsertest/glsl2/draw_buffers-05.vert and<br>
ARB_draw_instanced/preprocessor/feature-macro-enabled.frag.<br>
<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=29185" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=29185</a><br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br></blockquote><div><br></div><div>I like this.  It would have saved me some pain when I was working on geometry shaders.<br>
</div><div><br></div><div>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

---<br>
 src/glsl/glsl_parser_extras.cpp | 89 +++++++++++++----------------------------<br>
 1 file changed, 28 insertions(+), 61 deletions(-)<br>
<br>
Let's stop putting band-aids on this disaster and throw it out instead.<br>
<br>
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp<br>
index e36ba58..4f8fcab 100644<br>
--- a/src/glsl/glsl_parser_extras.cpp<br>
+++ b/src/glsl/glsl_parser_extras.cpp<br>
@@ -430,15 +430,6 @@ struct _mesa_glsl_extension {<br>
     */<br>
    const char *name;<br>
<br>
-   /** True if this extension is available to vertex shaders */<br>
-   bool avail_in_VS;<br>
-<br>
-   /** True if this extension is available to geometry shaders */<br>
-   bool avail_in_GS;<br>
-<br>
-   /** True if this extension is available to fragment shaders */<br>
-   bool avail_in_FS;<br>
-<br>
    /** True if this extension is available to desktop GL shaders */<br>
    bool avail_in_GL;<br>
<br>
@@ -485,9 +476,9 @@ struct _mesa_glsl_extension {<br>
    void set_flags(_mesa_glsl_parse_state *state, ext_behavior behavior) const;<br>
 };<br>
<br>
-#define EXT(NAME, VS, GS, FS, GL, ES, SUPPORTED_FLAG)                   \<br>
-   { "GL_" #NAME, VS, GS, FS, GL, ES, &gl_extensions::SUPPORTED_FLAG,   \<br>
-         &_mesa_glsl_parse_state::NAME##_enable,                        \<br>
+#define EXT(NAME, GL, ES, SUPPORTED_FLAG)                   \<br>
+   { "GL_" #NAME, GL, ES, &gl_extensions::SUPPORTED_FLAG,   \<br>
+         &_mesa_glsl_parse_state::NAME##_enable,            \<br>
          &_mesa_glsl_parse_state::NAME##_warn }<br>
<br>
 /**<br>
@@ -495,31 +486,31 @@ struct _mesa_glsl_extension {<br>
  * and the conditions under which they are supported.<br>
  */<br>
 static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {<br>
-   /*                                  target availability  API availability */<br>
-   /* name                             VS     GS     FS     GL     ES         supported flag */<br>
-   EXT(ARB_conservative_depth,         false, false, true,  true,  false,     ARB_conservative_depth),<br>
-   EXT(ARB_draw_buffers,               false, false, true,  true,  false,     dummy_true),<br>
-   EXT(ARB_draw_instanced,             true,  false, false, true,  false,     ARB_draw_instanced),<br>
-   EXT(ARB_explicit_attrib_location,   true,  false, true,  true,  false,     ARB_explicit_attrib_location),<br>
-   EXT(ARB_fragment_coord_conventions, true,  false, true,  true,  false,     ARB_fragment_coord_conventions),<br>
-   EXT(ARB_texture_rectangle,          true,  false, true,  true,  false,     dummy_true),<br>
-   EXT(EXT_texture_array,              true,  false, true,  true,  false,     EXT_texture_array),<br>
-   EXT(ARB_shader_texture_lod,         true,  false, true,  true,  false,     ARB_shader_texture_lod),<br>
-   EXT(ARB_shader_stencil_export,      false, false, true,  true,  false,     ARB_shader_stencil_export),<br>
-   EXT(AMD_conservative_depth,         false, false, true,  true,  false,     ARB_conservative_depth),<br>
-   EXT(AMD_shader_stencil_export,      false, false, true,  true,  false,     ARB_shader_stencil_export),<br>
-   EXT(OES_texture_3D,                 true,  false, true,  false, true,      EXT_texture3D),<br>
-   EXT(OES_EGL_image_external,         true,  false, true,  false, true,      OES_EGL_image_external),<br>
-   EXT(ARB_shader_bit_encoding,        true,  true,  true,  true,  false,     ARB_shader_bit_encoding),<br>
-   EXT(ARB_uniform_buffer_object,      true,  false, true,  true,  false,     ARB_uniform_buffer_object),<br>
-   EXT(OES_standard_derivatives,       false, false, true,  false,  true,     OES_standard_derivatives),<br>
-   EXT(ARB_texture_cube_map_array,     true,  false, true,  true,  false,     ARB_texture_cube_map_array),<br>
-   EXT(ARB_shading_language_packing,   true,  false, true,  true,  false,     ARB_shading_language_packing),<br>
-   EXT(ARB_shading_language_420pack,   true,  true,  true,  true,  false,     ARB_shading_language_420pack),<br>
-   EXT(ARB_texture_multisample,        true,  false, true,  true,  false,     ARB_texture_multisample),<br>
-   EXT(ARB_texture_query_lod,          false, false, true,  true,  false,     ARB_texture_query_lod),<br>
-   EXT(ARB_gpu_shader5,                true,  true,  true,  true,  false,     ARB_gpu_shader5),<br>
-   EXT(AMD_vertex_shader_layer,        true,  false, false, true,  false,     AMD_vertex_shader_layer),<br>
+   /*                                  API availability */<br>
+   /* name                             GL     ES         supported flag */<br>
+   EXT(ARB_conservative_depth,         true,  false,     ARB_conservative_depth),<br>
+   EXT(ARB_draw_buffers,               true,  false,     dummy_true),<br>
+   EXT(ARB_draw_instanced,             true,  false,     ARB_draw_instanced),<br>
+   EXT(ARB_explicit_attrib_location,   true,  false,     ARB_explicit_attrib_location),<br>
+   EXT(ARB_fragment_coord_conventions, true,  false,     ARB_fragment_coord_conventions),<br>
+   EXT(ARB_texture_rectangle,          true,  false,     dummy_true),<br>
+   EXT(EXT_texture_array,              true,  false,     EXT_texture_array),<br>
+   EXT(ARB_shader_texture_lod,         true,  false,     ARB_shader_texture_lod),<br>
+   EXT(ARB_shader_stencil_export,      true,  false,     ARB_shader_stencil_export),<br>
+   EXT(AMD_conservative_depth,         true,  false,     ARB_conservative_depth),<br>
+   EXT(AMD_shader_stencil_export,      true,  false,     ARB_shader_stencil_export),<br>
+   EXT(OES_texture_3D,                 false, true,      EXT_texture3D),<br>
+   EXT(OES_EGL_image_external,         false, true,      OES_EGL_image_external),<br>
+   EXT(ARB_shader_bit_encoding,        true,  false,     ARB_shader_bit_encoding),<br>
+   EXT(ARB_uniform_buffer_object,      true,  false,     ARB_uniform_buffer_object),<br>
+   EXT(OES_standard_derivatives,       false,  true,     OES_standard_derivatives),<br>
+   EXT(ARB_texture_cube_map_array,     true,  false,     ARB_texture_cube_map_array),<br>
+   EXT(ARB_shading_language_packing,   true,  false,     ARB_shading_language_packing),<br>
+   EXT(ARB_shading_language_420pack,   true,  false,     ARB_shading_language_420pack),<br>
+   EXT(ARB_texture_multisample,        true,  false,     ARB_texture_multisample),<br>
+   EXT(ARB_texture_query_lod,          true,  false,     ARB_texture_query_lod),<br>
+   EXT(ARB_gpu_shader5,                true,  false,     ARB_gpu_shader5),<br>
+   EXT(AMD_vertex_shader_layer,        true,  false,     AMD_vertex_shader_layer),<br>
 };<br>
<br>
 #undef EXT<br>
@@ -532,30 +523,6 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {<br>
 bool _mesa_glsl_extension::compatible_with_state(const _mesa_glsl_parse_state *<br>
                                                  state) const<br>
 {<br>
-   /* Check that this extension matches the type of shader we are<br>
-    * compiling to.<br>
-    */<br>
-   switch (state->target) {<br>
-   case vertex_shader:<br>
-      if (!this->avail_in_VS) {<br>
-         return false;<br>
-      }<br>
-      break;<br>
-   case geometry_shader:<br>
-      if (!this->avail_in_GS) {<br>
-         return false;<br>
-      }<br>
-      break;<br>
-   case fragment_shader:<br>
-      if (!this->avail_in_FS) {<br>
-         return false;<br>
-      }<br>
-      break;<br>
-   default:<br>
-      assert (!"Unrecognized shader target");<br>
-      return false;<br>
-   }<br>
-<br>
    /* Check that this extension matches whether we are compiling<br>
     * for desktop GL or GLES.<br>
     */<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>