Bug 34628

Summary: [ilk] skybox errors in quake4
Product: Mesa Reporter: Tobias Jakobi <liquid.acid>
Component: Drivers/DRI/i965Assignee: Kenneth Graunke <kenneth>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: jbarnes
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
URL: http://www.gamershell.com/download_11708.shtml
Whiteboard:
i915 platform: i915 features:
Attachments: skybox 1

Description Tobias Jakobi 2011-02-23 08:40:15 UTC
Created attachment 43718 [details]
skybox 1

System:
Intel Corporation Arrandale Integrated Graphics Controller

vanilla-kernel 2.6.36.2
libdrm, mesa and xf86-video-intel git master
xorg-server-1.9.4

More quake4 problems.

Linux demo can be found here:
http://www.gamershell.com/download_11708.shtml

Ingame settings:
800x600 resolution
medium quality settings

Attached screenshots illustrate the problems with the skybox rendering.
Problem not present on r600g with my Radeon HD4750.

Greets,
Tobias
Comment 1 Chris Wilson 2011-02-24 02:06:43 UTC
Tobias, is this a recent regression (i.e. from my vbuf changes) or should I punt it to mesa? If you can identify it as a regression a bisection would be most valuable.
Comment 2 Tobias Jakobi 2011-02-24 03:58:19 UTC
No, like the random polygon error this one was also present before your patchset.
Comment 3 Tobias Jakobi 2011-04-19 16:03:07 UTC
Reconfirming with latest mesa git master (08d1c91e6c185a186e49189b7ed48629f35a4659)
Comment 4 Md Imam Hossain 2011-04-20 20:55:18 UTC
Unigine Tropics Benchmark also has this bug.
Comment 5 Tobias Jakobi 2011-05-19 09:23:50 UTC
Reconfirming with latest mesa git master
(339544f4bbef9be1b4b3465f28482b9699a99692)
Comment 6 Md Imam Hossain 2011-06-08 07:09:46 UTC
This problem is not present on Intel GMA 4500. Quake 4 is not suffering from this bug on Intel GMA 4500.

Intel GMA 4500 rather has this bug:
https://bugs.freedesktop.org/show_bug.cgi?id=36374

What Intel graphics card are you using.

Ubuntu 10.10
Linux 2.6.38-02063807-generic
libdrm 2.4.24
Xserver 1.9.3
xf86-video-intel 2.14.0
Mesa 7.11-devel mesa-ef59049c5242a1be7fa59a182d342191185dd62b
Comment 7 Tobias Jakobi 2011-06-08 07:21:02 UTC
Read the report before posting. Your bug #36374 is unrelated, since it was (according to your bisect) introduced by Chris Wilson's patchset in February.

As I already pointed out in comment #2 this bug is not related to the patchset and was already present long before.
Comment 8 Md Imam Hossain 2011-06-18 22:03:41 UTC
(In reply to comment #1)
> Tobias, is this a recent regression (i.e. from my vbuf changes) or should I
> punt it to mesa? If you can identify it as a regression a bisection would be
> most valuable.

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

is introduced by the commit

559435d9152acc7162e4e60aae6591c7c6c8274b

http://cgit.freedesktop.org/mesa/mesa/commit/?id=559435d9152acc7162e4e60aae6591c7c6c8274b

still present in git.

Thank you
Comment 9 Tobias Jakobi 2011-07-03 06:07:36 UTC
Issue is still present with uptodate mesa git master (7ed1826e2e2a5b5c4840821c92ef7273efe32e24).
Comment 10 Tobias Jakobi 2011-07-30 08:37:12 UTC
Issue is still present with recent mesa git master (120d71a45cfda1edfa8cd6b1732e209eb98b53d8).
Comment 11 Kenneth Graunke 2011-07-30 19:09:18 UTC
Looks like cubemaps are getting layed out incorrectly when using S3 texture compression.  (In particular, Quake 4's skybox appears to be using DXT1.)  I can now reproduce the issue and shift the cube faces around, I'm just not sure how to adjust the formulas to get the proper result yet.
Comment 12 Tobias Jakobi 2011-07-31 04:26:45 UTC
If that's related to texture compression, then it makes sense why it also happens with FEAR. The Jupiter engine also seems to make full use of texture compression (before s3tc support was introduced in r600g no textures worked).
Comment 13 Kenneth Graunke 2011-08-02 16:19:40 UTC
Yep, it's definitely a S3TC cubemap layout issue.

If you change src/mesa/drivers/dri/i965/brw_tex_layout.c:52 from
          GLuint align_h = 2;
to
          GLuint align_h = mt->compressed ? 4 : 2;

then Quake 4 works.  But, from my reading of the documentation, I don't quite buy that this is the correct/complete solution.  Feel free to use that as a workaround in the meantime while we come up with the final solution.
Comment 14 Tobias Jakobi 2011-08-03 00:46:58 UTC
I can verify that this also fixes the skybox problems in FEAR. It also eliminates some additional issues I had with lighting sources in FEAR (seems like these also used cubemaps to achieve effects).
Comment 15 Tobias Jakobi 2011-08-31 15:21:46 UTC
Issue is still present with latest mesa git master (82fff5f3edfd2f6396a872a12d753b2ab90edd7b).
But I think I've seem a (proper?) patch by Kenneth for this issue on the mailing list. Wonder why it still hasn't surfaced in master?
Comment 16 Kenneth Graunke 2011-09-07 07:50:24 UTC
commit 477b74e85be8e468c63af9f2f3fe788e486764ce
Author: Kenneth Graunke <kenneth@whitecape.org>
Date:   Mon Aug 15 12:04:37 2011 -0700

    i965: Use proper texture alignment units for cubemaps on Gen5+.
    
    In particular, S3TC compressed textures need align_h == 4.
    
    Fixes skybox errors in Quake 4 and FEAR.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=34628
    Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Comment 17 Tobias Jakobi 2011-09-07 07:58:36 UTC
Thanks Kenneth!

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.