[Mesa-dev] [PATCH] glsl: Assign transform feedback varying slots in linker.
Paul Berry
stereotype441 at gmail.com
Mon Nov 7 22:18:09 PST 2011
On 7 November 2011 18:18, Marek Olšák <maraeo at gmail.com> wrote:
> 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.
>
Good catch, I forgot to think about that case. That will require modifying
assign_varying_locations to accept NULL for the consumer, and modifying the
control flow in link_shaders slightly. I'll post a revised patch shortly.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20111107/fa8742ce/attachment.html>
More information about the mesa-dev
mailing list