Bug 80183 - [llvmpipe] triangles with vertices that map to raster positions > viewport width/height are not displayed
Summary: [llvmpipe] triangles with vertices that map to raster positions > viewport wi...
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Other (show other bugs)
Version: 10.2
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-18 11:44 UTC by Florian Link
Modified: 2015-12-17 16:05 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Traces that reproduce the problem (819.33 KB, application/zip)
2014-06-18 11:44 UTC, Florian Link
Details
all clipped triangles are within the viewport (416.88 KB, image/png)
2015-05-06 12:06 UTC, cgerlach42
Details
triangles get completely clipped on viewport - 1 (532.70 KB, image/png)
2015-05-06 12:07 UTC, cgerlach42
Details
triangles get completely clipped on viewport - 2 (458.46 KB, image/png)
2015-05-06 12:08 UTC, cgerlach42
Details

Description Florian Link 2014-06-18 11:44:31 UTC
Created attachment 101296 [details]
Traces that reproduce the problem

When using llvmpipe/64bit, we experience missing triangles when one of the vertices of the triangle has a raster position outside of the viewport top/right. 

It only happens when a GLSL shader is active, not when fixed function rendering is used. It only happens with llvmpipe, using softpipe all is fine (also with GLSL shader).

Attached you find a apitrace that works and a apitrace that shows the problem.

While MeVisLab.ok.trace (Frame 11) shows a textured polygon, MeVisLab.wrong.trace (Frame 13) is rendered black, while it should show the same textured polygon, clipped to the viewport width/height.

The traces contain some MeVisLab network rendering as well, these can be ignored.
Comment 1 Roland Scheidegger 2014-07-03 01:02:43 UTC
Sorry that trace is a bit too much to handle. I looked at it but I can't really make out any difference wrt use of glsl shader or not at all (note that for the gallium driver this cannot make a difference in any case as it has no idea if you used glsl or not, though in theory there could be slight differences depending on how ftransform() is implemented). Just about the only thing I noticed is that the actual geometry is different between the two... Could you tell me at what call number this is?
Also it looks like it has depth test enabled as well, I'm not entirely sure if or how clipping would affect interpolated depth, though nothing bad should happen.
Comment 2 Florian Link 2014-07-10 14:27:42 UTC
I found out that the problem is the line:

gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;

in the fragment shader. If I remove that line, it works as expected.

Since the rendering is ok on ATI/NVidia and on softpipe, I suspect that
gl_ClipVertex support is broken in LLVM pipe.
Comment 3 Brian Paul 2014-07-10 14:52:34 UTC
(In reply to comment #2)
> I found out that the problem is the line:
> 
> gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;
> 
> in the fragment shader. If I remove that line, it works as expected.
> 
> Since the rendering is ok on ATI/NVidia and on softpipe, I suspect that
> gl_ClipVertex support is broken in LLVM pipe.

Are you sure you're seeing that in the fragment shader?  Vertex-related code like that would normally be seen in the vertex shader.
Comment 4 Florian Link 2014-07-10 15:08:48 UTC
Sorry, that was a typo, of course it is in the vertex shader.
Comment 5 Roland Scheidegger 2014-07-16 00:43:18 UTC
Reassigning to mesa core.
Though in my testing this seems to be *both* a core and a draw problem.
With my piglit test the first error (without redrawing) appears with 4097 vertices - despite that the vbo code can handle 5460 (per vertex size is just 12 bytes) without splitting.
Comment 6 Roland Scheidegger 2014-07-16 00:49:31 UTC
Oops wrong bug. Disregard last comment...
Comment 7 Roland Scheidegger 2014-08-08 17:01:04 UTC
(In reply to comment #2)
> I found out that the problem is the line:
> 
> gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;
> 
> in the fragment shader. If I remove that line, it works as expected.
> 
> Since the rendering is ok on ATI/NVidia and on softpipe, I suspect that
> gl_ClipVertex support is broken in LLVM pipe.

Actually I suspect gl_ClipVertex is mostly ok, but you're writing garbage to it and relying on the fact that user plane clipping is disabled so the output isn't actually used. Or something like that. This is where we failed (using the clipvertex output for ordinary clipping even if user plane clipping is disabled). Patch coming...
Comment 8 Roland Scheidegger 2014-08-09 02:33:40 UTC
Fixed by 6d2ecdb4a63350cfeee803c00ac283ee013a5ee5.
Comment 9 cgerlach42 2015-05-06 12:05:29 UTC
I also observe this problem, but I have used a really new mesa version:
OpenGL 3.0 Mesa 10.5.3
Gallium 0.4 on llvmpipe (LLVM 3.6, 256 bits)

To get an impression how the clipping looks, I have attached some snapshots:
* snapshot_1.png: clipping is active (axis aligned clipping cube) and all possibly clipped triangles are in the viewport -> clipping works as expected.
* snapshot_2.png/snapshot_3.png: after zooming in a little bit, most triangles that have a clipped vertex are clipped completely.

Additional information:
* We do the clipping within a GLSL shader with gl_ClipVertex (not fixed function).
* Reproducible on windows and linux llvmpipe version -> I did not expect any difference, but who knows...
* Using nvidia hardware rendering with the same shader code looks correct.
* Because the clipping is working correct when all triangles are within the viewport, I don't expect a shader problem.
Comment 10 cgerlach42 2015-05-06 12:06:19 UTC
Created attachment 115588 [details]
all clipped triangles are within the viewport
Comment 11 cgerlach42 2015-05-06 12:07:54 UTC
Created attachment 115589 [details]
triangles get completely clipped on viewport - 1
Comment 12 cgerlach42 2015-05-06 12:08:13 UTC
Created attachment 115590 [details]
triangles get completely clipped on viewport - 2
Comment 13 Roland Scheidegger 2015-05-06 13:35:51 UTC
Does this happen with other gallium based drivers (softpipe for instance, though it might hit all the same code)?
I'm afraid noone will look into it without an apitrace trace (or some sample code like a piglit test).
Comment 14 cgerlach42 2015-05-07 09:13:03 UTC
The problem is also reproducible with softpipe.

I understand your concern and I will try provide some samplecode to reproduce the clipping error.
Comment 15 Roland Scheidegger 2015-12-15 03:11:43 UTC
cgerlach42, does this still happen?
There were some more clip fixes very recently.
If this still happens you really need to provide either sample code or an apitrace.
Comment 16 cgerlach42 2015-12-16 14:52:54 UTC
I have checked mesa version 10.6.9 and 11.0.7 both with llvm 3.4 and the clipping problem is still reproducible here.

I have also tried to provide an apitrace. The tool works fine, as long as I stick to hardware rendering (where the problem does not occur). For software rendering the context creation fails. I'm hoping that I will find a solution for this...
Comment 17 Roland Scheidegger 2015-12-16 16:25:20 UTC
(In reply to cgerlach42 from comment #16)
> I have checked mesa version 10.6.9 and 11.0.7 both with llvm 3.4 and the
> clipping problem is still reproducible here.
That would be too old for these fixes, only mesa master would do.

> 
> I have also tried to provide an apitrace. The tool works fine, as long as I
> stick to hardware rendering (where the problem does not occur). For software
> rendering the context creation fails. I'm hoping that I will find a solution
> for this...

You don't need the same driver to capture the trace. As long as your app sticks to things which is supported by both this should work. Though of course depending on the reasons why context creation fails it might just fail on replay too.
Comment 18 cgerlach42 2015-12-17 08:21:38 UTC
You were right, the latest mesa version fixes this problem :-)

Latest git hash from my checkout is:
e97b207654a1c0b2c27b6ad6579b5570a83ce8cd

I also tried to replay an apitrace generated with hardware rendering, but I can't get the glretrace to use software rendering. It always uses the systems opengl32.dll and therefore the clipping problem is not reproducible.
Comment 19 Jose Fonseca 2015-12-17 10:09:47 UTC
(In reply to cgerlach42 from comment #18)
> I also tried to replay an apitrace generated with hardware rendering, but I
> can't get the glretrace to use software rendering. It always uses the
> systems opengl32.dll and therefore the clipping problem is not reproducible.

If you put Mesa opengl32.dll into the same dir as glretrace.exe it should work.

Alternatively, you can do


  set TRACE_LIBGL=C:\path\to\desired\opengl32.dll
  glretrace foo.trace
Comment 20 Roland Scheidegger 2015-12-17 16:05:12 UTC
Ok let's close it then.
FWIW I suspect 9e3f2af3c3732bd618308ddeffb017966a4fc93e fixed it (this applies if you were writing gl_ClipVertex and have enabled at least one clip plane).


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.