[Mesa-dev] [PATCH 09/18] glsl: Store info about geometry shaders that emit vertices to non-zero streams.
Chris Forbes
chrisf at ijw.co.nz
Wed Jun 11 02:03:41 PDT 2014
I think you need to set this if *any* geometry shader in the program
tries to use a nonzero stream. Currently it looks like the last shader
wins.
On Wed, Jun 11, 2014 at 7:49 PM, Iago Toral Quiroga <itoral at igalia.com> wrote:
> On Intel hardware when a geometry shader outputs GL_POINTS primitives we
> only need to emit vertex control bits if it emits vertices to non-zero
> streams, so use a flag to track this.
>
> This flag will be set to TRUE when a geometry shader calls EmitStreamVertex()
> or EndStreamPrimitive() with a non-zero stream parameter in a later patch.
> ---
> src/glsl/glsl_parser_extras.cpp | 4 ++++
> src/glsl/glsl_parser_extras.h | 5 +++++
> src/glsl/linker.cpp | 4 ++++
> src/mesa/main/mtypes.h | 6 ++++++
> src/mesa/main/shaderapi.c | 1 +
> src/mesa/main/shaderobj.c | 1 +
> src/mesa/program/program.c | 1 +
> 7 files changed, 22 insertions(+)
>
> diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
> index f3c5bd0..b2515e8 100644
> --- a/src/glsl/glsl_parser_extras.cpp
> +++ b/src/glsl/glsl_parser_extras.cpp
> @@ -1407,6 +1407,10 @@ set_shader_inout_layout(struct gl_shader *shader,
> shader->Geom.Invocations = 0;
> if (state->in_qualifier->flags.q.invocations)
> shader->Geom.Invocations = state->in_qualifier->invocations;
> +
> + shader->Geom.UsesStreams = GL_FALSE;
> + if (state->gs_uses_streams)
> + shader->Geom.UsesStreams = GL_TRUE;
> break;
>
> case MESA_SHADER_COMPUTE:
> diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
> index 0416a9c..6610bd7 100644
> --- a/src/glsl/glsl_parser_extras.h
> +++ b/src/glsl/glsl_parser_extras.h
> @@ -447,6 +447,11 @@ struct _mesa_glsl_parse_state {
> */
> unsigned gs_input_size;
>
> + /**
> + * For geometry shaders, whether non-zero streams are used.
> + */
> + bool gs_uses_streams;
> +
> bool early_fragment_tests;
>
> /** Atomic counter offsets by binding */
> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
> index a43d230..7ff7694 100644
> --- a/src/glsl/linker.cpp
> +++ b/src/glsl/linker.cpp
> @@ -1349,6 +1349,8 @@ link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,
> }
> linked_shader->Geom.Invocations = shader->Geom.Invocations;
> }
> +
> + linked_shader->Geom.UsesStreams = shader->Geom.UsesStreams;
> }
>
> /* Just do the intrastage -> interstage propagation right now,
> @@ -1380,6 +1382,8 @@ link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,
> linked_shader->Geom.Invocations = 1;
>
> prog->Geom.Invocations = linked_shader->Geom.Invocations;
> +
> + prog->Geom.UsesStreams = linked_shader->Geom.UsesStreams;
> }
>
>
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 69eb4fa..2519968 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2178,6 +2178,7 @@ struct gl_geometry_program
> GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */
> GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */
> GLboolean UsesEndPrimitive;
> + GLboolean UsesStreams;
> };
>
>
> @@ -2473,6 +2474,10 @@ struct gl_shader
> * it's not set in this shader.
> */
> GLenum OutputType;
> + /**
> + * Whether this geometry shader uses non-zero vertex streams
> + */
> + GLboolean UsesStreams;
> } Geom;
>
> /**
> @@ -2681,6 +2686,7 @@ struct gl_shader_program
> GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or
> 0 if not present. */
> GLboolean UsesEndPrimitive;
> + GLboolean UsesStreams;
> } Geom;
>
> /** Vertex shader state */
> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
> index 2ec2444..2bbef35 100644
> --- a/src/mesa/main/shaderapi.c
> +++ b/src/mesa/main/shaderapi.c
> @@ -1888,6 +1888,7 @@ _mesa_copy_linked_program_data(gl_shader_stage type,
> dst_gp->OutputType = src->Geom.OutputType;
> dst->UsesClipDistanceOut = src->Geom.UsesClipDistance;
> dst_gp->UsesEndPrimitive = src->Geom.UsesEndPrimitive;
> + dst_gp->UsesStreams = src->Geom.UsesStreams;
> }
> break;
> case MESA_SHADER_FRAGMENT: {
> diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
> index b0f0bfa..03db862 100644
> --- a/src/mesa/main/shaderobj.c
> +++ b/src/mesa/main/shaderobj.c
> @@ -248,6 +248,7 @@ _mesa_init_shader_program(struct gl_context *ctx, struct gl_shader_program *prog
> prog->Geom.VerticesOut = 0;
> prog->Geom.InputType = GL_TRIANGLES;
> prog->Geom.OutputType = GL_TRIANGLE_STRIP;
> + prog->Geom.UsesStreams = GL_FALSE;
>
> prog->TransformFeedback.BufferMode = GL_INTERLEAVED_ATTRIBS;
>
> diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
> index b7332fc..1263cea 100644
> --- a/src/mesa/program/program.c
> +++ b/src/mesa/program/program.c
> @@ -552,6 +552,7 @@ _mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog)
> gpc->InputType = gp->InputType;
> gpc->Invocations = gp->Invocations;
> gpc->OutputType = gp->OutputType;
> + gpc->UsesStreams = gp->UsesStreams;
> }
> break;
> default:
> --
> 1.9.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list