Bug 64253

Summary: Portal (Beta) rendering issues
Product: Mesa Reporter: Jordan Justen <jljusten>
Component: Drivers/DRI/i965Assignee: Ian Romanick <idr>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: anarsoul, auke-jan.h.kok, chrisf, imamdxl8805, jljusten, kenneth, pgriffais, screwtape, vrodic, xclaesse
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: misrendering
portal-bug.206184.trim.trace_call_206184-1_0-nvidia.png

Description Jordan Justen 2013-05-05 18:46:26 UTC
As reported in:
https://github.com/ValveSoftware/Source-1-Games/issues/390
the recently released native build of Portal on steam has
rendering issues with portals.

Depending on the angle at which the portal is viewed, it
may be draw or not.

I captured an apitrace of this. The trace was captured on
an IVB system, and renders properly when replayed on nVidia
closed source drivers.

When replayed on nVidia, you can also see that Chell's head
turns about the same time that the rendering starts working
properly on IVB.
Comment 1 Jordan Justen 2013-05-05 18:57:51 UTC
apitrace mentioned in the summary:
http://people.freedesktop.org/~jljusten/portal-bug-apitrace.tar.xz
Comment 2 Carl Worth 2013-05-06 21:06:33 UTC
Thanks, Jordan.

I've grabbed the trace and plan to add a new mode to apitrace to be able
to trim to drawing operations that affect a particular region of pixels.

My hope is that the result of that trim will be small enough to make analysis
of the problem much easier.

-Carl
Comment 3 Kenneth Graunke 2013-05-07 05:44:53 UTC
Carl saw this on Sandybridge, and according to comment 24 on bug #59187 it happens on GM45 as well.
Comment 4 Christoph Haag 2013-05-08 10:40:55 UTC
So if it's not only the portal rendering erros but also the depth issues:

Here is a trace for that (unfortunately 400 Megabyte):

http://w3studi.informatik.uni-stuttgart.de/~haagch/files/hl2_linux.trace.gz

And here is a video of how it looks on my Ivy Bridge, mesa git master:

http://w3studi.informatik.uni-stuttgart.de/~haagch/files/hl2_linux.mp4

Note that the depth issues only appear when there is a portal in the field of view and vanish when not looking at a portal.
Comment 5 Md Imam Hossain 2013-05-10 06:25:53 UTC
it is the same problem on my GMA 4500MHD
Comment 6 Chris Forbes 2013-05-11 01:18:05 UTC
Here's a trace trimmed to the first clearly misbehaving draw call.

http://openra.res0l.net/portal-bug-206184.tar.xz
Comment 7 Chris Forbes 2013-05-11 01:55:56 UTC
Created attachment 79126 [details]
misrendering

Error is the block around the timer on the RHS.
Comment 8 Jordan Justen 2013-05-11 06:49:44 UTC
Created attachment 79129 [details]
portal-bug.206184.trim.trace_call_206184-1_0-nvidia.png
Comment 9 Jordan Justen 2013-05-11 06:52:58 UTC
portal-bug.206184.trim.trace_call_206184-1_0-nvidia.png
shows how nvidia renders portal-bug.206184.trim.trace.
Comment 10 Chris Forbes 2013-05-13 07:19:48 UTC
This patch on the mesa list corrects the issue on at least IVB.

http://lists.freedesktop.org/archives/mesa-dev/2013-May/039313.html

Or if you'd prefer a git tree, the portal-fixes branch at http://github.com/chrisforbes/mesa.

I expect the view through portals to still be misclipped on Gen4/5, and will address that separately (relies on gl_ClipVertex).
Comment 11 Chris Forbes 2013-05-13 11:17:29 UTC
After discussing this with Ken, I've sent out a new series which replaces the previous patch.

Git tree is available at http://github.com/chrisforbes/mesa portal-fixes-v2
Comment 12 Vasily Khoruzhick 2013-05-13 11:26:58 UTC
What about backport for 9.1?
Comment 13 Xavier Claessens 2013-05-13 11:29:30 UTC
I would like to give it a try, can it be backported into ubuntu raring packages?
Comment 14 Chris Forbes 2013-05-13 11:37:48 UTC
I'd like to collect some review comments and get it landed into master before thinking too much about backporting to 9.1 ;)

But at a trivial `will the patches apply?` level it should be straightforward to backport.
Comment 15 Xavier Claessens 2013-05-13 12:05:24 UTC
Hm, I cloned the ubuntu package repository, checkout the ubuntu branch, added your git repository in remotes and picked picked your commits:

git cherry-pick 3bcc1e74de332ee13693836901b77870de7f3e8d..ea0a7e7

But building the package says:
../../../../src/mesa/main/get.c: In function 'find_custom_value':
../../../../src/mesa/main/get.c:645:7: error: implicit declaration of function '_mesa_get_stencil_ref' [-Werror=implicit-function-declaration]

Maybe I'm missing some commits?
Comment 16 Xavier Claessens 2013-05-13 12:21:59 UTC
Stupid me, that did not pick commit 3bcc1e74de332ee13693836901b77870de7f3e8d. Builds find now.
Comment 17 Md Imam Hossain 2013-05-13 15:02:17 UTC
great!

applied commit

http://lists.freedesktop.org/archives/mesa-dev/2013-May/039313.html

to Mesa 9.1.2

now depth rendering is fixed on my GMA 4500 MHD.
Comment 18 Vasily Khoruzhick 2013-05-13 16:37:02 UTC
(In reply to comment #11)
> After discussing this with Ken, I've sent out a new series which replaces
> the previous patch.
> 
> Git tree is available at http://github.com/chrisforbes/mesa portal-fixes-v2

Applied v2 against mesa-9.1, now portal works fine for me, thank you very much!
Comment 19 Xavier Claessens 2013-05-13 20:43:16 UTC
Great that seems to have fixed all the problems I've seen in portal. Thanks!

If someone is interested in ubuntu packages, I've pushed them to a ppa: https://launchpad.net/~zdra/+archive/mesa-portal
Comment 20 Md Imam Hossain 2013-05-17 11:42:40 UTC
(In reply to comment #10)
> This patch on the mesa list corrects the issue on at least IVB.
> 
> http://lists.freedesktop.org/archives/mesa-dev/2013-May/039313.html
> 
> Or if you'd prefer a git tree, the portal-fixes branch at
> http://github.com/chrisforbes/mesa.
> 
> I expect the view through portals to still be misclipped on Gen4/5, and will
> address that separately (relies on gl_ClipVertex).

yeah view through portal is misclipped and maybe this is also related to water rendering bug in Half Life 2
Comment 21 Chris Forbes 2013-05-20 03:18:58 UTC
Yes, sounds like the same thing.

I was hoping to finish my new GLSL-1.3-capable clip shader by now, but maybe I'll just send out a patch to do gl_ClipVertex to fix the immediate issues...
Comment 22 Chris Forbes 2013-06-07 20:39:15 UTC
Fix for userclipping is on master now.
Comment 23 Md Imam Hossain 2013-06-07 21:52:20 UTC
Great fixes water rendering bug on Half Life 2 as well unbelievable but true!

tested on my Intel GMA 4500 MHD
Comment 24 Xavier Claessens 2013-06-24 12:20:06 UTC
Ubuntu 13.04 upgraded to mesa 9.1.3 and this bug is not fixed. The patch was not backported in 9.1 branch upstream? or it regressed again?
Comment 25 Xavier Claessens 2013-06-24 12:41:51 UTC
Ah, they were applied in 9.1 branch after the 9.1.3 release. So it will have to wait for 9.1.4.
Comment 26 Md Imam Hossain 2013-06-24 14:17:31 UTC
(In reply to comment #25)
> Ah, they were applied in 9.1 branch after the 9.1.3 release. So it will have
> to wait for 9.1.4.

Or you can try out drivers I have compiled

http://www.youtube.com/watch?v=vB_gX6z53vM
Comment 27 Xavier Claessens 2013-06-24 14:47:47 UTC
(In reply to comment #26)
> (In reply to comment #25)
> > Ah, they were applied in 9.1 branch after the 9.1.3 release. So it will have
> > to wait for 9.1.4.
> 
> Or you can try out drivers I have compiled
> 
> http://www.youtube.com/watch?v=vB_gX6z53vM

I don't know where are your drivers, but I updated my ppa with patches applied on top of latest ubuntu package: https://launchpad.net/~zdra/+archive/mesa-portal (still building on the ppa atm)
Comment 28 Chris Forbes 2013-06-25 04:49:39 UTC
The additional fixes for user clipping on Gen4/5 aren't in the 9.1 branch yet at all.

Ian, and others: any objections to picking those fixes to the 9.1 branch before 9.1.4 gets tagged?
Comment 29 Kenneth Graunke 2013-06-25 12:44:47 UTC
They've been in master a while, and I haven't heard any grumbling about regressions, so it seems like a good idea to me.

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.