Bug 80018 - [HSW] Ambient occlusion glitch in Planetary Annihilation on Intel HD4600
Summary: [HSW] Ambient occlusion glitch in Planetary Annihilation on Intel HD4600
Status: RESOLVED NOTOURBUG
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i965 (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Ian Romanick
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 77449
  Show dependency treegraph
 
Reported: 2014-06-14 09:16 UTC by sxx.public
Modified: 2018-07-31 13:06 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Ambient occlusion on Intel: enabled (238.88 KB, image/jpeg)
2014-06-14 09:16 UTC, sxx.public
Details
Ambient occlusion on Intel: disabled (239.46 KB, image/jpeg)
2014-06-14 09:17 UTC, sxx.public
Details
Ambient occlusion on R600g: enabled (251.02 KB, image/jpeg)
2014-06-14 09:17 UTC, sxx.public
Details
Ambient occlusion on R600g: disabled (250.20 KB, image/jpeg)
2014-06-14 09:18 UTC, sxx.public
Details

Description sxx.public 2014-06-14 09:16:28 UTC
Created attachment 101033 [details]
Ambient occlusion on Intel: enabled

Here is some screenshots of incorrect rendering in Planetary Annihilation. If AO enabled I get really weird behavior when move or zoom camera: shadow is moving all the time. It's working fine on R600g with same version of Mesa

Here is video on youtube:
http://www.youtube.com/watch?v=gYk8p13sifA
http://www.youtube.com/watch?v=hVpHlZ6LNJE

I also will attach screenshots with correct (R600g, HD6950) and incorrect (i965, HD4600) rendering. I tested it on vanilla Ubuntu 14.04 drivers as well as Oibaf PPA.

GL trace using fairly recent build of APITrace (500MB unpacked):
https://drive.google.com/file/d/0B5LwC3WbdQ3DT2dUVHIxZmVQMmc/edit?usp=sharing
Comment 1 sxx.public 2014-06-14 09:17:08 UTC
Created attachment 101034 [details]
Ambient occlusion on Intel: disabled
Comment 2 sxx.public 2014-06-14 09:17:51 UTC
Created attachment 101035 [details]
Ambient occlusion on R600g: enabled
Comment 3 sxx.public 2014-06-14 09:18:16 UTC
Created attachment 101036 [details]
Ambient occlusion on R600g: disabled
Comment 4 Danylo 2018-07-30 15:32:37 UTC
I think I found the cause:

In sao_apply.fs random angle is calculated in the following way:
> ivec2 ssC = ivec2(gl_FragCoord.xy);
> float randomPatternRotationAngle = (3 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 10;
This means that randomPatternRotationAngle will have huge values thus sin and cos may give quite imprecise values. It is precise enough on Radeon and Nvidia but not enough on Intel GPUs.

The documentation Volume 7: 3D-Media-GPGPU states:
> Precision: 
> DirectX 10 and below Absolute error <= 0.0008 for the range of +/- 32767 * pi 
> Outside of the above range the function will remain periodic, 
> producing values between -1 and 1.
In practice passing values greater than 32767 * pi to cos or sin gives unusable output for most purposes (I'm not exactly sure if it is true for all Intel GPUs).

The easy fix will be calculating randomPatternRotationAngle like this:
> float randomPatternRotationAngle = mod(3 * ssC.x ^ ssC.y + ssC.x * ssC.y, 6.28318530718);

After the change there is no more artifacts.
Comment 5 Danylo 2018-07-31 08:15:22 UTC
To summarize, I think that is not a mesa issue. I notified http://support.uberent.com about it (#771156 ticket id in their internal system).


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.