[Mesa-dev] [RFC PATCH 10/56] mesa: Generalize sso stage interleaving check for tess

Ian Romanick idr at freedesktop.org
Tue Sep 30 09:04:02 PDT 2014


On 09/20/2014 06:40 PM, Chris Forbes wrote:
> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
> ---
>  src/mesa/main/pipelineobj.c | 53 +++++++++++++++++++++++++++++++--------------
>  1 file changed, 37 insertions(+), 16 deletions(-)
> 
> diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
> index c902107..b91289e 100644
> --- a/src/mesa/main/pipelineobj.c
> +++ b/src/mesa/main/pipelineobj.c
> @@ -662,6 +662,38 @@ program_stages_all_active(struct gl_pipeline_object *pipe,
>     return status;
>  }
>  
> +static bool
> +program_stages_interleaved_illegally(struct gl_pipeline_object *pipe)

                                        const

> +{
> +   struct gl_shader_program *prev = NULL;
> +   unsigned i, j;
> +
> +   /* Look for programs bound to stages: A -> B -> A, with
> +    * any intervening sequence of unrelated programs or
> +    * empty stages
> +    */

I think this (and perhaps the next comment) are wrapped too narrow. :)

> +
> +   for (i = 0; i < MESA_SHADER_STAGES; i++) {
> +      /* Empty stages anywhere in the pipe are OK */
> +      if (!pipe->CurrentProgram[i])
> +         continue;
> +
> +      if (prev && pipe->CurrentProgram[i] != prev) {
> +         /* We've seen an A -> B transition; look at the rest of
> +          * the pipe to see if we ever see A again.
> +          */
> +         for (j = i + 1; j < MESA_SHADER_STAGES; j++) {
> +            if (pipe->CurrentProgram[j] == prev)
> +               return true;
> +         }
> +      }

It took me a bit to convince myself that this code is correct.  I think
this would be a good place for a unit test.

Since this is a good clean-up for this code, I think it could also land
before the reset of the series.

> +
> +      prev = pipe->CurrentProgram[i];
> +   }
> +
> +   return false;
> +}
> +
>  extern GLboolean
>  _mesa_validate_program_pipeline(struct gl_context* ctx,
>                                  struct gl_pipeline_object *pipe,
> @@ -714,22 +746,11 @@ _mesa_validate_program_pipeline(struct gl_context* ctx,
>      * Without Tesselation, the only case where this can occur is the geometry
>      * shader between the fragment shader and vertex shader.
>      */
> -   if (pipe->CurrentProgram[MESA_SHADER_GEOMETRY]
> -       && pipe->CurrentProgram[MESA_SHADER_FRAGMENT]
> -       && pipe->CurrentProgram[MESA_SHADER_VERTEX]) {
> -      if (pipe->CurrentProgram[MESA_SHADER_VERTEX]->Name == pipe->CurrentProgram[MESA_SHADER_FRAGMENT]->Name &&
> -          pipe->CurrentProgram[MESA_SHADER_GEOMETRY]->Name != pipe->CurrentProgram[MESA_SHADER_VERTEX]->Name) {
> -         pipe->InfoLog =
> -            ralloc_asprintf(pipe,
> -                            "Program %d is active for geometry stage between "
> -                            "two stages for which another program %d is "
> -                            "active",
> -                            pipe->CurrentProgram[MESA_SHADER_GEOMETRY]->Name,
> -                            pipe->CurrentProgram[MESA_SHADER_VERTEX]->Name);
> -         goto err;
> -      }
> -
> -      /* XXX tess */
> +   if (program_stages_interleaved_illegally(pipe)) {
> +      pipe->InfoLog = ralloc_strdup(pipe, "Program is active for multiple shader"
> +                                          "stages with an intervening stage provided"
> +                                          "by another program");
> +      goto err;
>     }
>  
>     /* Section 2.11.11 (Shader Execution), subheading "Validation," of the
> 



More information about the mesa-dev mailing list