iXit / Mesa-3D

Please use official https://gitlab.freedesktop.org/mesa/mesa/ !
https://github.com/iXit/Mesa-3D/wiki
66 stars 13 forks source link

GTA San Andreas no fog on the horizon #315

Closed 18woldemar closed 5 years ago

18woldemar commented 6 years ago

During the game GTA San Andreas, noticed the lack of fog on the horizon. It looks bad because of that. Please fix this. Operation System: Kubuntu 18.04.1 amd64 GPU: AMD Radeon HD 8670M (Hainan) CPU: AMD A4-5000 If you need logs, contact me))

axeldavy commented 6 years ago

could you show a screenshot ?

18woldemar commented 6 years ago

Screen (Gallium Nine) http://priscree.ru/img/ae569896c43e8a.png Screen (WineD3D) http://priscree.ru/img/28db32e000f9a1.png

iiv3 commented 6 years ago

@18woldemar, what is the Mesa3D version that you use?

I'm currently with mesa-18.1.3 on HD5670 (Redwood Evergreen, uses r600 driver) and I do not see difference in the fog between the Nine and WineD3D. Using Steam version of GTA-SA.

I think it might be interesting if you can do an apitrace with the jetpack. Use latest msvc git build for apitrace. The last release is quite old and can't capture GTA-SA.

My favorite method for capturing is putting the d3d9.dll wrapper library in the game directory, setting override for "d3d9" to "native,built-in" in winecfg->libraries. Then just running the game. (Don't forget to remove the d3d9.dll after you are finsihed, or traces will fill your hdd).

You can replay the trace with Nine or WineD3D and be sure the difference is because of different rendering, not because the game uses different code path.

It would be a lot trickier problem if it renders properly on r600, but has issue on radeonsi.

18woldemar commented 6 years ago

I'm using version 1.0 US HOODLUM. The reason for this bug was found out. It was a SkyGFX mod. Without this mod, game plays flawlessly. https://gtaforums.com/topic/750681-skygfx-ps2-and-xbox-graphics-for-pc/ I'm using Mesa 18.3.0-devel.

18woldemar commented 6 years ago

Trace with mod https://yadi.sk/d/AVIHEcHT3ZznTb

iiv3 commented 6 years ago

I can confirm that I do not see the fog when replaying the trace with Gallium Nine, but I do see it with WineD3D.

It means this is not driver specific bug. This should make it easier to fix.

I hope you don't mind if we upload the sample to the Nine ftp and keep it for regression testing.

18woldemar commented 6 years ago

Okay)) Do anything with it.

18woldemar commented 6 years ago

Thank you very much)

18woldemar commented 6 years ago

Another, more detailed trace https://yadi.sk/d/hRP6S8jY3a2qsi Do anything with it))

axeldavy commented 6 years ago

I looked at the trace, but It's pretty hard to debug because the back buffer format is D3DFMT_A2R10G10B10 and apitrace won't allow me to see the content.

Would it be possible to take a new trace with A8R8G8B8 ? if there is any way to set it.

Second, do the pattern also appear when looking at the tree regions ? It looks like there aren't much items there. To isolate the issue, ideally there would be a few frames displaying the issue with very few items on screen.

To make the trace execute faster (debugging requires relaunching the trace a lot of times ), the trace has to show the problem as fast as possible with as few frames as possible. It could make a difference to reduce the speed of your graphic card, which you can do with: sudo chmod ugo+w /sys/class/drm/card0/device/power_dpm_force_performance_level echo low > /sys/class/drm/card0/device/power_dpm_force_performance_level

then to return to normal speed echo auto > /sys/class/drm/card0/device/power_dpm_force_performance_level

You may have to replace card0 with card1

mirh commented 6 years ago

@aap maybe you know something of that (sorry if otherwise)

aap commented 6 years ago

Hm, for reference to the others, i'm the author of said mod (skygfx). For the SAMP multiplayer mod i had to tamper with the fog settings a bit but usually they shouldn't be touched unless SAMP is loaded. Could have something to do with that maybe: https://github.com/aap/skygfx/blob/master/src/main.cpp#L80 Otherwise, try disabling the building pipe hook and see if that changes things. Maybe using a pixel shader somehow breaks fog?

axeldavy commented 6 years ago

Given for the same trace the fog appears right with default wine, but not right with nine, the issue is not in the mod, but in nine where there must be a missing corner case unhandled.

axeldavy commented 6 years ago

There seems to be only one pixel shader used for all objets affected by shadows, thus I was able to investigate the issue. It seems nine incorrectly compute the depth used for fog effects in some scenarios. I need to make some tests to be sure of the correct formula and not trigger regressions.

axeldavy commented 6 years ago

The bug should be corrected by: https://github.com/iXit/Mesa-3D/commit/633047fab15daa5ad387035d4667b4a21c2ea054

At least the trace seems fine to me.

iiv3 commented 6 years ago

I applied the patch and tried few older games that are more likely to use fixed functions. I did not hit any visible regressions.