[Mesa-dev] [Bug 64668] Clipping is performed incorrectly when using shaders with intel/nouveau/radeon drivers.

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu May 16 08:22:54 PDT 2013


https://bugs.freedesktop.org/show_bug.cgi?id=64668

--- Comment #12 from Paul Berry <stereotype441 at gmail.com> ---
I've verified that your test passes with the nVidia proprietary driver. 
However I'm not yet convinced this is a bug in Mesa, and here's why:

This test is exercising a corner case which the spec are somewhat contradictory
about: what happens when user clip planes are in use but a shader does not
write to gl_ClipVertex?

- All versions of OpenGL from 2.0 onward clearly state that the behaviour is
undefined.
- GLSL 1.10 and 1.20 specs say that the behaviour is undefined.
- GLSL 1.30 through 4.10 specs say that clipping is performed using
gl_Position*.
- GLSL 4.20 onward say that the behaviour is undefined.  Additionally, the
"Changes from revision 8 of Version 4.20" section of the spec says "Make GLSL
consistent with the API regarding user clipping, by no longer referring to
gl_Position when gl_ClipVertex is not written. Rather, user clipping becomes
undefined."

*Even in the GLSL 1.30 through 4.10 case, the behaviour is poorly defined:
OpenGL says that clip planes are specified in "object coordinates" and are then
converted to "eye coordinates" by OpenGL at the time they are specified.  When
gl_ClipVertex is in use, it is assumed to be in eye coordinates too.  However,
gl_Position uses "clip coordinates".  So, in the case where clipping is
performed using gl_Position, should the coordinates be transformed to match, or
should the clipping be performed directly using gl_Position, in spite of the
coordinate system mismatch?  A literal reading of the spec seems to indicate
that clipping should be performed directly using gl_Position--this is the
interpretation Mesa uses.

As a result of the coordinate system mismatch, clipping using gl_Position is
usually counterintuitive, and doesn't match the behaviour of the fixed function
pipeline.  In the case of your test, that manifests as the left half of the
window getting clipped, since the left half of the window has a negative value
of gl_Position.x.

As far as I've been able to tell from experimenting with the nVidia proprietary
driver, its behaviour in this corner case is to not clip at all.  That causes
your test to pass, but not because clipping is being performed in the way you
expect.  So I'm a little bit loathe to "fix" the bug by changing Mesa to match
nVidia behaviour.

Instead, my recommendation would be to change the test to avoid exercising the
undefined/poorly-defined behaviour.  If you add this line to the vertex shader:

    gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;

you will get the expected clipping behaviour from both Mesa and proprietary
drivers.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130516/20ed97cd/attachment.html>


More information about the mesa-dev mailing list