[Mesa-dev] RFC [PATCH 0/7] Fix transform feedback of builtin "varyings".

Paul Berry stereotype441 at gmail.com
Thu Dec 29 09:16:21 PST 2011


This patch series allows transform feedback to work properly on the
built-in vertex shader output variables gl_PointSize, gl_ClipVertex,
and gl_ClipDistance.  gl_PointSize and gl_ClipVertex were broken due
to bugs in the i965 driver, and were trivial to fix--those are fixed
in patches 1 and 2.

gl_ClipDistance was harder to fix, since on i965 its 8 floats are
packed into 2 vec4s, so the linker has to tell the back-end to select
a single component of one of the vec4's for streaming out.  This
required changing both core mesa and the back-ends, and adding a new
field to gl_transform_feedback_info.  However, the work seems worth it
because it lays some of the groundwork we will need when we get around
to packing varyings.  Patch 3 adds the new field, patches 4-5 cause
the back-ends to use it, and patches 6-7 update the linker to populate
it correctly for gl_ClipDistance.

I'm putting this patch series out as an RFC partly because I want to
find out if the new field in gl_transform_feedback_info makes sense
for other driver back-ends, and partly because it is not 100% clear
from the spec whether transform feedback is intended to work on all
vertex shader outputs, or just the "varyings" (the ones that are
interpolated across the surface of a primitive).  Here are the
arguments I can see for and against going through with this patch
series:

Arguments against: (1) The GL 3.0 spec says that "The varying
variables specified in <varyings> can be either built-in varying
variables (beginning with 'gl_') or user-defined ones".  But it also
explicitly states that gl_Position is not a varying variable.  And
GLSL 1.20 lists gl_Position, gl_PointSize, and gl_ClipVertex in
section 7.1 ("Vertex Shader Special Variables") rather than section
7.6 ("Varying Variables").  It seems clear that there was an intention
to distinguish between "varyings" and other vertex shader outputs, and
transform feedback is defined to work on varyings.  (2) In all
likelihood, most code that uses transform feedback uses it on
user-defined varyings anyhow, so fixing these built-in variables is
unlikely to make much difference.  (3) Making transform feedback work
on gl_ClipDistance adds a lot of complication for the benefit of a
tiny corner case.

Arguments in favor: (1) Because of transform feedback's intended use
and its position in the pipeline, the distinction between varyings and
other vertex shader outputs is irrelevant; in all likelihood the spec
writers intended for it to work on all vertex shader outputs.  (2) The
very use of the term "varying" (and hence, this distinction) has
largely disappeared from the standard as of GLSL 1.30.  (3) nVidia's
proprietary Linux driver supports transform feedback of all vertex
shader outputs (except gl_ClipVertex, which has many other bugs), so
it's conceivable that some code in the wild relies on this feature.
(4) Fixing transform feedback of gl_ClipVertex provides a nice
opportunity to prepare for the changes we will have to make to
transform feedback in order to support varying packing.

Personally, I'm swayed by the arguments in favor but I would like to
hear what others think.

[PATCH 1/7] i965: Fix transform feedback of gl_PointSize.
[PATCH 2/7] i965: Fix transform feedback of gl_ClipVertex.
[PATCH 3/7] mesa: Add gl_transform_feedback_info::ComponentOffset.
[PATCH 4/7] i965: Make use of gl_transform_feedback_info::ComponentOffset.
[PATCH 5/7] gallium: Make use of gl_transform_feedback_info::ComponentOffset.
[PATCH 6/7] mesa: Make tfeedback_decl::var_name a const char *.
[PATCH 7/7] mesa: Fix transform feedback of gl_ClipDistance.


More information about the mesa-dev mailing list