[Mesa-dev] [PATCH] glsl: Assign transform feedback varying slots in linker.

Marek Olšák maraeo at gmail.com
Mon Nov 7 18:18:03 PST 2011


On Tue, Nov 8, 2011 at 1:13 AM, Paul Berry <stereotype441 at gmail.com> wrote:
> @@ -1806,16 +2187,50 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
>         break;
>    }
>
> +   /* From GL_EXT_transform_feedback:
> +    *   A program will fail to link if:
> +    *
> +    *   * the <count> specified by TransformFeedbackVaryingsEXT is
> +    *     non-zero, but the program object has no vertex or geometry
> +    *     shader;
> +    */
> +   if (prog->TransformFeedback.NumVarying > 0 &&
> +       prev >= MESA_SHADER_FRAGMENT) {
> +      linker_error(prog, "Transform feedback varyings specified, but "
> +                   "no vertex or geometry shader is present.");
> +      goto done;
> +   }
> +
>    for (unsigned i = prev + 1; i < MESA_SHADER_TYPES; i++) {
>       if (prog->_LinkedShaders[i] == NULL)
>         continue;
>
> +      tfeedback_decl *tfeedback_decls = NULL;
> +      unsigned num_tfeedback_decls = 0;
> +      if (i == MESA_SHADER_FRAGMENT &&
> +          prog->TransformFeedback.NumVarying != 0) {
> +         num_tfeedback_decls = prog->TransformFeedback.NumVarying;
> +         tfeedback_decls = ralloc_array(mem_ctx, tfeedback_decl,
> +                                        prog->TransformFeedback.NumVarying);
> +         if (!parse_tfeedback_decls(prog, mem_ctx, num_tfeedback_decls,
> +                                    prog->TransformFeedback.VaryingNames,
> +                                    tfeedback_decls))
> +            goto done;
> +      }
> +
>       if (!assign_varying_locations(ctx, prog,
>                                    prog->_LinkedShaders[prev],
> -                                   prog->_LinkedShaders[i])) {
> +                                   prog->_LinkedShaders[i],
> +                                    num_tfeedback_decls, tfeedback_decls)) {
>         goto done;
>       }
>
> +      if (i == MESA_SHADER_FRAGMENT) {
> +         if (!store_tfeedback_info(ctx, prog, num_tfeedback_decls,
> +                                   tfeedback_decls))
> +            goto done;
> +      }
> +
>       prev = i;
>    }

Also I realized that this part won't work if there is no fragment
shader. Transform feedback varyings should be assigned *regardless* of
the presence of a fragment shader.

Marek


More information about the mesa-dev mailing list