[Mesa-dev] [PATCH 29/34] glsl: Export the compiler's GS layout qualifiers to the gl_shader.

Paul Berry stereotype441 at gmail.com
Thu Aug 1 14:49:16 PDT 2013


On 1 August 2013 09:34, Ian Romanick <idr at freedesktop.org> wrote:

> On 08/01/2013 07:17 AM, Paul Berry wrote:
>
>> On 31 July 2013 17:42, Ian Romanick <idr at freedesktop.org
>> <mailto:idr at freedesktop.org>> wrote:
>>
>>     On 07/28/2013 11:03 PM, Paul Berry wrote:
>>
>>         From: Eric Anholt <eric at anholt.net <mailto:eric at anholt.net>>
>>
>>
>>         Next step is to validate them at link time.
>>
>>         v2 (Paul Berry <stereotype441 at gmail.com
>>         <mailto:stereotype441 at gmail.**com <stereotype441 at gmail.com>>>):
>> Don't attempt to export the
>>
>>         layout qualifiers in the event of a compile error, since some of
>>         them
>>         are set up by ast_to_hir(), and ast_to_hir() isn't guaranteed to
>>         have
>>         run in the event of a compile error.
>>         ---
>>            src/glsl/glsl_parser_extras.__**cpp | 31
>>         ++++++++++++++++++++++++++++++**__+
>>
>>            src/mesa/main/mtypes.h          | 18 ++++++++++++++++++
>>            2 files changed, 49 insertions(+)
>>
>>         diff --git a/src/glsl/glsl_parser_extras.**__cpp
>>         b/src/glsl/glsl_parser_extras.**__cpp
>>         index 6b8fb45..2311447 100644
>>         --- a/src/glsl/glsl_parser_extras.**__cpp
>>         +++ b/src/glsl/glsl_parser_extras.**__cpp
>>         @@ -1446,6 +1446,34 @@
>>         ast_struct_specifier::ast___**struct_specifier(const char
>> *identifier,
>>
>>               is_declaration = true;
>>            }
>>
>>         +static void
>>         +set_shader_inout_layout(__**struct gl_shader *shader,
>>
>>         +                    struct _mesa_glsl_parse_state *state)
>>         +{
>>         +   if (shader->Type != GL_GEOMETRY_SHADER) {
>>         +      /* Should have been prevented by the parser. */
>>         +      assert(!state->gs_input_prim__**_type_specified);
>>         +      assert(!state->out_qualifier->**__flags.i);
>>
>>         +      return;
>>         +   }
>>         +
>>         +   shader->Geom.VerticesOut = 0;
>>         +   if (state->out_qualifier->flags._**_q.max_vertices)
>>         +      shader->Geom.VerticesOut =
>>         state->out_qualifier->max___**vertices;
>>         +
>>         +   if (state->gs_input_prim_type___**specified) {
>>
>>         +      shader->Geom.InputType = state->gs_input_prim_type;
>>         +   } else {
>>         +      shader->Geom.InputType = ~0;
>>         +   }
>>         +
>>         +   if (state->out_qualifier->flags._**_q.prim_type) {
>>         +      shader->Geom.OutputType = state->out_qualifier->prim___**
>> type;
>>
>>         +   } else {
>>         +      shader->Geom.OutputType = ~0;
>>         +   }
>>         +}
>>         +
>>            extern "C" {
>>
>>            void
>>         @@ -1521,6 +1549,9 @@ _mesa_glsl_compile_shader(__**struct
>>
>>         gl_context *ctx, struct gl_shader *shader,
>>               shader->UniformBlocks = state->uniform_blocks;
>>               ralloc_steal(shader, shader->UniformBlocks);
>>
>>         +   if (!state->error)
>>         +      set_shader_inout_layout(__**shader, state);
>>
>>         +
>>               /* Retain any live IR, but trash the rest. */
>>               reparent_ir(shader->ir, shader->ir);
>>
>>         diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
>>         index 33075bd..bc90d09 100644
>>         --- a/src/mesa/main/mtypes.h
>>         +++ b/src/mesa/main/mtypes.h
>>         @@ -2170,6 +2170,24 @@ struct gl_shader
>>               /** Shaders containing built-in functions that are used
>>         for linking. */
>>               struct gl_shader *builtins_to_link[16];
>>               unsigned num_builtins_to_link;
>>         +
>>         +   /**
>>         +    * Geometry shader state from GLSL 1.50 layout qualifiers.
>>         +    */
>>         +   struct {
>>         +      GLint VerticesOut;
>>         +      /**
>>         +       * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB,
>>         GL_TRIANGLES, or
>>         +       * GL_TRIANGLES_ADJACENCY_ARB, or ~0 if it's not set in
>>         this shader
>>         +       * (since GL_POINTS is 0).
>>         +       */
>>
>>
>>     After looking at the next patch, I wonder if we should make a
>>     descriptive #define for ~0u for this.  Thoughts?
>>
>> Hmm, maybe we should use mtypes.h's PRIM_UNKNOWN.
>>
>
> Good call!  I had forgotten that PRIM_UNKNOWN existed and was defined in
> terms of the other GL_<prim> enums.


Ok, done.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130801/e3a775b8/attachment.html>


More information about the mesa-dev mailing list