On 3 January 2012 16:35, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 12/29/2011 09:16 AM, Paul Berry wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This patch series allows transform feedback to work properly on the<br>
built-in vertex shader output variables gl_PointSize, gl_ClipVertex,<br>
and gl_ClipDistance. gl_PointSize and gl_ClipVertex were broken due<br>
to bugs in the i965 driver, and were trivial to fix--those are fixed<br>
in patches 1 and 2.<br>
<br>
gl_ClipDistance was harder to fix, since on i965 its 8 floats are<br>
packed into 2 vec4s, so the linker has to tell the back-end to select<br>
a single component of one of the vec4's for streaming out. This<br>
required changing both core mesa and the back-ends, and adding a new<br>
field to gl_transform_feedback_info. However, the work seems worth it<br>
because it lays some of the groundwork we will need when we get around<br>
to packing varyings. Patch 3 adds the new field, patches 4-5 cause<br>
the back-ends to use it, and patches 6-7 update the linker to populate<br>
it correctly for gl_ClipDistance.<br>
<br>
I'm putting this patch series out as an RFC partly because I want to<br>
find out if the new field in gl_transform_feedback_info makes sense<br>
for other driver back-ends, and partly because it is not 100% clear<br>
from the spec whether transform feedback is intended to work on all<br>
vertex shader outputs, or just the "varyings" (the ones that are<br>
interpolated across the surface of a primitive). Here are the<br>
arguments I can see for and against going through with this patch<br>
series:<br>
<br>
Arguments against: (1) The GL 3.0 spec says that "The varying<br>
variables specified in<varyings> can be either built-in varying<br>
variables (beginning with 'gl_') or user-defined ones". But it also<br>
explicitly states that gl_Position is not a varying variable. And<br>
GLSL 1.20 lists gl_Position, gl_PointSize, and gl_ClipVertex in<br>
section 7.1 ("Vertex Shader Special Variables") rather than section<br>
7.6 ("Varying Variables"). It seems clear that there was an intention<br>
to distinguish between "varyings" and other vertex shader outputs, and<br>
transform feedback is defined to work on varyings. (2) In all<br>
likelihood, most code that uses transform feedback uses it on<br>
user-defined varyings anyhow, so fixing these built-in variables is<br>
unlikely to make much difference. (3) Making transform feedback work<br>
on gl_ClipDistance adds a lot of complication for the benefit of a<br>
tiny corner case.<br>
<br>
Arguments in favor: (1) Because of transform feedback's intended use<br>
and its position in the pipeline, the distinction between varyings and<br>
other vertex shader outputs is irrelevant; in all likelihood the spec<br>
writers intended for it to work on all vertex shader outputs. (2) The<br>
very use of the term "varying" (and hence, this distinction) has<br>
largely disappeared from the standard as of GLSL 1.30. (3) nVidia's<br>
proprietary Linux driver supports transform feedback of all vertex<br>
shader outputs (except gl_ClipVertex, which has many other bugs), so<br>
it's conceivable that some code in the wild relies on this feature.<br>
(4) Fixing transform feedback of gl_ClipVertex provides a nice<br>
opportunity to prepare for the changes we will have to make to<br>
transform feedback in order to support varying packing.<br>
</blockquote>
<br></div></div>
Here are the results on an AMD system:<br>
<br>
[idr@oscar piglit]$ for i in gl_Color gl_SecondaryColor gl_TexCoord gl_FogFragCoord gl_Position gl_PointSize gl_ClipVertex gl_ClipDistance ; do echo $i; bin/ext_transform_feedback-<u></u>builtin-varyings -auto $i; echo; done<br>
gl_Color<br>
PIGLIT: {'result': 'pass' }<br>
<br>
gl_SecondaryColor<br>
PIGLIT: {'result': 'pass' }<br>
<br>
gl_TexCoord<br>
PIGLIT: {'result': 'pass' }<br>
<br>
gl_FogFragCoord<br>
PIGLIT: {'result': 'pass' }<br>
<br>
gl_Position<br>
PIGLIT: {'result': 'pass' }<br>
<br>
gl_PointSize<br>
Failed to link: A variable name specified with the TransformFeedbackVaryings is not declared as an output in the geometry or vertex shader.<br>
<br>
PIGLIT: {'result': 'fail' }<br>
<br>
gl_ClipVertex<br>
PIGLIT: {'result': 'pass' }<br>
<br>
gl_ClipDistance<br>
Failed to link: Vertex shader(s) failed to link.<br>
gl_ClipDistance[2] was not declared as an output in current vertex shader!<br></blockquote><div><br>Heh, sounds like we're not the only ones with a lowering pass that converts gl_ClipDistance from a float[8] to a vec4[2] :)<br>
</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
PIGLIT: {'result': 'fail' }<br>
<br>
It would be interesting to see how this test fares on OS X.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Personally, I'm swayed by the arguments in favor but I would like to<br>
hear what others think.<br>
</blockquote>
<br></div>
I searched a bit through old meeting notes and mailing discussions from the OpenGL 3.0 time frame. It seems to me that your suspicion that "the spec writers intended for it to work on all vertex shader outputs" is almost certainly correct.<br>
<br>
I would consider the failing cases to just be bugs in those other implementations.<br></blockquote><div><br>Ok, sounds good. I'm going to consider this an "acked-by" if that's all right with you. I haven't heard many comments on this patch series, but given that it fixes the tests and there hasn't been any negative feedback, I think I'm going to consider it good. I'll plan on pushing the patches at the end of the day tomorrow unless I hear other comments.<br>
</div></div>