[Mesa-dev] [PATCH 01/18] glsl: Add parsing support for multi-stream output in geometry shaders.

Samuel Iglesias Gonsálvez siglesias at igalia.com
Wed Jun 11 23:32:29 PDT 2014


On Wed, 2014-06-11 at 15:29 -0700, Ian Romanick wrote:
> On 06/11/2014 12:49 AM, Iago Toral Quiroga wrote:
> > From: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
> > 
> > This implements parsing requirements for multi-stream support in
> > geometry shaders as defined in ARB_gpu_shader5.
> > 
> > Signed-off-by: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
> > ---
> >  src/glsl/ast.h          |  5 +++++
> >  src/glsl/ast_to_hir.cpp |  6 ++++++
> >  src/glsl/ast_type.cpp   | 19 ++++++++++++++++++-
> >  src/glsl/glsl_parser.yy | 45 +++++++++++++++++++++++++++++++++++++++++++++
> >  src/glsl/ir.h           |  5 +++++
> >  5 files changed, 79 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/glsl/ast.h b/src/glsl/ast.h
> > index 56e7bd8..823b1d2 100644
> > --- a/src/glsl/ast.h
> > +++ b/src/glsl/ast.h
> > @@ -509,6 +509,8 @@ struct ast_type_qualifier {
> >           /** \name Layout qualifiers for GL_ARB_gpu_shader5 */
> >           /** \{ */
> >           unsigned invocations:1;
> > +         unsigned streamId:1; /* Has streamId value assigned  */
> > +         unsigned explicit_streamId:1; /* streamId value assigned explicitely by shader code */
> >           /** \} */
> >        }
> >        /** \brief Set of flags, accessed by name. */
> > @@ -542,6 +544,9 @@ struct ast_type_qualifier {
> >     /** Maximum output vertices in GLSL 1.50 geometry shaders. */
> >     int max_vertices;
> >  
> > +   /** Stream ID in GLSL 1.50 geometry shaders. */
> > +   unsigned streamId;
> > +
> >     /** Input or output primitive type in GLSL 1.50 geometry shaders */
> >     GLenum prim_type;
> >  
> > diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
> > index 140bb74..ab0f50f 100644
> > --- a/src/glsl/ast_to_hir.cpp
> > +++ b/src/glsl/ast_to_hir.cpp
> > @@ -2426,6 +2426,11 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
> >     if (qual->flags.q.sample)
> >        var->data.sample = 1;
> >  
> > +   if (state->stage == MESA_SHADER_GEOMETRY &&
> > +       qual->flags.q.out && qual->flags.q.streamId) {
> > +      var->data.streamId = qual->streamId;
> > +   }
> > +
> >     if (qual->flags.q.attribute && state->stage != MESA_SHADER_VERTEX) {
> >        var->type = glsl_type::error_type;
> >        _mesa_glsl_error(loc, state,
> > @@ -5455,6 +5460,7 @@ ast_interface_block::hir(exec_list *instructions,
> >           var->data.centroid = fields[i].centroid;
> >           var->data.sample = fields[i].sample;
> >           var->init_interface_type(block_type);
> > +         var->data.streamId = this->layout.streamId;
> >  
> >           if (redeclaring_per_vertex) {
> >              ir_variable *earlier =
> > diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp
> > index 0ee2c49..749f161 100644
> > --- a/src/glsl/ast_type.cpp
> > +++ b/src/glsl/ast_type.cpp
> > @@ -125,9 +125,13 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
> >     /* Uniform block layout qualifiers get to overwrite each
> >      * other (rightmost having priority), while all other
> >      * qualifiers currently don't allow duplicates.
> > +    *
> > +    * Geometry shaders can have several layout qualifiers
> > +    * assigning different stream ID values.
> >      */
> >  
> > -   if ((this->flags.i & q.flags.i & ~(ubo_mat_mask.flags.i |
> > +   if ((state->stage != MESA_SHADER_GEOMETRY) &&
> > +       (this->flags.i & q.flags.i & ~(ubo_mat_mask.flags.i |
> >  				      ubo_layout_mask.flags.i |
> >                                        ubo_binding_mask.flags.i)) != 0) {
> 
> I think this will allow multiply layout(location=) qualifiers on
> geometry shader inputs / outputs.  So...
> 
> #version 150
> #extension GL_ARB_separate_shader_objects: require
> 
> layout(location=1) layout(location=2) in vec4 v;
> 
> should generate an error, but I think this change will disable that error.
> 

OK, we will test it and modify the patch accordingly.

Thanks for the review!

Sam
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140612/bd6e99e4/attachment.sig>


More information about the mesa-dev mailing list