Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Darksiders 2 Deathinitive Edition does not work with Nine #317

Closed
Kzimir opened this issue Sep 9, 2018 · 52 comments
Closed

Darksiders 2 Deathinitive Edition does not work with Nine #317

Kzimir opened this issue Sep 9, 2018 · 52 comments

Comments

@Kzimir
Copy link

Kzimir commented Sep 9, 2018

Hello,

The game does not work with Gallium Nine but works without problem (except the glitch issue) with Wined3d. When i launch the game with Nine, i have an error message say me that the resolution is not supported for fullscreen display.

Screenshot for the error message :
https://reho.st/thumb/self/85c7d34037ec89e764078870eeaa98fe12cd226b.png

And i have this message in the output console :

odelpasso@gentoo-desktop /mnt/HDData/Jeux/Prefix64/drive_c/Program Files (x86)/GOG Galaxy/Games/Darksiders II Deathinitive Edition $ wine Darksiders2.exe
01f2:fixme:module:load_dll Loader redirect from L"d3d9.dll" to L"d3d9-nine.dll"
01f2:fixme:heap:RtlSetHeapInformation 0x9e0000 0 0x23e740 4 stub
01f2:fixme:system:SystemParametersInfoW Unimplemented action: 59 (SPI_SETSTICKYKEYS)
01f2:fixme:system:SystemParametersInfoW Unimplemented action: 53 (SPI_SETTOGGLEKEYS)
01f2:fixme:system:SystemParametersInfoW Unimplemented action: 51 (SPI_SETFILTERKEYS)
01f2:fixme:d3d9nine:d3dadapter9_new
Native Direct3D 9 is active.
For more information visit https://wiki.ixit.cz/d3d9
01f2:fixme:d3d9nine:DRI3PresentGroup_GetMultiheadCount (0x48e60), stub!
01f2:fixme:d3d9nine:DRI3PresentGroup_GetMultiheadCount (0x48e60), stub!

Maxime

@axeldavy
Copy link

axeldavy commented Sep 9, 2018

Could you describe your configuration ?

@Kzimir
Copy link
Author

Kzimir commented Sep 9, 2018

Gentoo x86_64
AMD Ryzen 1600
AMD Rx580 - 8Gb
Wine-Staging 3.15
Mesa Git + LLVM 8
Kernel 4.18.x

@axeldavy
Copy link

axeldavy commented Sep 9, 2018

To exclude a configuration issue, have you checked your other dx9 games to see if they work right ?

@Kzimir
Copy link
Author

Kzimir commented Sep 9, 2018

I tried with Splinter Cell : Conviction and it works without problem with Nine.

@iiv3
Copy link

iiv3 commented Sep 10, 2018

@berillions,
Since you are on Gentoo, it should be easier for you to recompile Mesa3D with debug support.

After that run the game with NINE_DEBUG=all wine prog.exe &> nine.log. Compress the log and upload it to the nine ftp, or just provide the last few messages that look relevant to you. (The ones before you get the error.).

You can find more details here . BTW, you don't need to bother with the additional CFLAGS, they are for using gdb. In your case just configure --enable-debug is enough to get the logs.

BTW, this reminds me, before you recompile with debug support, you could also try D3D_ALWAYS_SOFTWARE=1. It would force the use of generic software rendering. If the game works with it, then the bug might be radeonsi driver specific. (It might also not work at all.)

@Kzimir
Copy link
Author

Kzimir commented Sep 10, 2018

After to disable Nine in winecfg and export D3D_ALWAYS_SOFTWARE=1 before to launch the game, i can confirm that the game works.

I compiled Mesa with debug flag and when i launch the game with Nine enabled and NINE_DEBUG=all, i have only these lines in the log :
https://pastebin.com/DGH3JfCy

@axeldavy
Copy link

Somehow NINE_DEBUG=all didn't work. Could you try again (try export it maybe before launch)
The crash log is interesting, it seems the app tries to create a depth buffer with an invalid depth buffer format.

@Kzimir
Copy link
Author

Kzimir commented Sep 11, 2018

Even if i export NINE_DEBUG before to launch the bug, i have the same output console log than in my previous message ... :/

@axeldavy
Copy link

axeldavy commented Sep 11, 2018 via email

@Kzimir
Copy link
Author

Kzimir commented Sep 11, 2018

The game is 64-bits :
file Darksiders2.exe
Darksiders2.exe: PE32+ executable (GUI) x86-64, for MS Windows

And if i check in Mesa log compilation, debug mode is enabled :/

@iiv3
Copy link

iiv3 commented Sep 11, 2018

The debugging page gives the hint to try NINE_DEBUG=help to see the options. See if that works. Copy-paste the exact text, sometimes if you type it you won't see your own spelling mistake. Also make sure you do use &> to capture all stdio&stderr output.

If logging still does not produce the desired output, then we'd ask you to disable Nine (aka use wined3d) and use apitrace to record a very short game session. You can upload it on the nine ftp or public sharing site. (We may keep it to use it for regression testing.)

My favorite method for making apitrace is to take the d3d9.dll wrapper library from apitrace (in your case, from x86_64 folder) and put that wrapper into the game directory. Then inwinecfg->libraries->overrides add d3d9 override as "native, built-in".

Run the game as usual, the trace would be in your game directory.
Once you have the trace, remove the d3d9.dll wrapper, turn on Nine and replay the trace to see if you get the same assert().

If you get error related to GDI32 (or 64) it means that the d3d9.dll in the windows system folder has been replaced with native(real windows) one. Find it and restore the fakedll stub.
Don't forget to remove the d3d9.dll wrapper after you are done with the trace or it will keep making traces.

@axeldavy
Copy link

axeldavy commented Sep 11, 2018

I have no clue why you don't have debug info.

In the case of your bug report, a log would be more valuable since the last buggy call wouldn't be captured by the trace, but it's better than nothing.

@iiv3
Copy link

iiv3 commented Sep 12, 2018

I have no clue why you don't have debug info.

In the case of your bug report, a log would be more valuable since the last buggy call wouldn't be captured by the trace, but it's better than nothing.

That is why I asked for a fully working trace made with wined3d.

@axeldavy
Copy link

That is why I asked for a fully working trace made with wined3d.

It shouldn't reproduce the issue. Since D3D_ALWAYS_SOFTWARE works, it means the problem is with the format support the game queries. We likely wrongly advertise support for something as depth buffer, and the game tries to create a depth buffer out of it. Thus it is unlikely a wined3d trace would reproduce the issue.

@Kzimir
Copy link
Author

Kzimir commented Sep 12, 2018

Yeah i confirm that i can't reproduce the issue with apitrace.

I create correctly a .trace file and i can replay it when Nine is enabled.

@axeldavy
Copy link

Since we can't get the log, could you give us a working trace (D3D_ALWAYS_SOFTWARE if possible, or wined3d) and a non working trace (nine, but the trace will be cut just before the buggy call). Then we can compare the previous calls to check format compatibility and figure out which calls return a different value.

@Kzimir
Copy link
Author

Kzimir commented Sep 12, 2018

How i do a trace with Nine ?
Same thing than wined3d but i enable Nine in winecfg ?

@axeldavy
Copy link

Yes, exactly

axeldavy added a commit that referenced this issue Sep 13, 2018
d3d9_get_pipe_depth_format_bindings assumes the input format
is a depth stencil format.
Previously the user could hit this function with an invalid format.
Protect the last non protected call with a depth_stencil_format check.

Another solution is to have d3d9_get_pipe_depth_format_bindings
support non depth stencil format, but we don't want the user
to create depth buffers with d3d formats that can't be one,
it's better to check if the format can be depth buffer with d3d.

Fixes crash of:
#317

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
@axeldavy
Copy link

I pushed a patch that should prevent the crash, but I don't think the game will be working.
Even if the game begins to work, there is another problem here: the game doing that invalid call on nine and not elsewhere, and this means nine does something wrong.

@Kzimir
Copy link
Author

Kzimir commented Sep 14, 2018

Hi Axel,

I compiled Mesa with your patch and unfortunatly, the game still crashes with the same error.

I create a .trace without Nine but impossible to do the same thing with Nine. A .trace is create but there are no frame captured by apitrace when i replay it.

DarkSiders_2_apitrace_wined3d

@axeldavy
Copy link

I checked the trace but (as expected), I couldn't deduce what is the issue.

It would be useful to find a way to force the debug info to be printed.
Maybe in nine_debug.c, replace the calls to debug_printf for printf ? or fprintf(stderr, )

axeldavy added a commit that referenced this issue Sep 15, 2018
d3d9_get_pipe_depth_format_bindings assumes the input format
is a depth stencil format.
Previously the user could hit this function with an invalid format.
Protect the last non protected call with a depth_stencil_format check.

Another solution is to have d3d9_get_pipe_depth_format_bindings
support non depth stencil format, but we don't want the user
to create depth buffers with d3d formats that can't be one,
it's better to check if the format can be depth buffer with d3d.

Fixes crash of:
#317

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
@Kzimir
Copy link
Author

Kzimir commented May 4, 2019

Hello Axel,
i still try to run this game with D9VK and/or Nine, i still have this issue.

Can you explain how to replace the calls to debug_printf for printf ? or fprintf(stderr, ) in nine_debug.c ?

Thanks

@axeldavy
Copy link

axeldavy commented May 4, 2019

Maybe you should give a try with the new build system (meson) ? The additional flag is -D b_ndebug=false

Also remember if the game is 32 bits, that's mesa 32 bits that should be rebuilt.

@Kzimir
Copy link
Author

Kzimir commented May 4, 2019

I will try with debug option enabled. Just to say that i have the same problem with D9VK than Nine ... Maybe it's a problem in Wine directly ?

@axeldavy
Copy link

axeldavy commented May 4, 2019

Most likely the game behaves bad when a specific weird combination of abilities is advertised. It's quite possible both nine and D9VK do wrong there.

@Kzimir
Copy link
Author

Kzimir commented May 4, 2019

An idea to search where come from the issue ?

@axeldavy
Copy link

axeldavy commented May 4, 2019

Yes, comparing trace taken on wine or nine would have helped, but I can compare the wine trace with nine log and see what is different.

@Kzimir
Copy link
Author

Kzimir commented May 4, 2019

It will be a trace with plain Wine (= wined3d) and with Nine disabled right ?

@axeldavy
Copy link

axeldavy commented May 4, 2019

Yes, but you already provided one. If you do the same things (game save, config) when you do the log (with Nine) than what you did for the trace, it'll be fine.

@axeldavy
Copy link

axeldavy commented May 4, 2019

Also since D3D_ALWAYS_SOFTWARE=1 works, I'd like to have a log with it as well.
Please make the logs with
csmt_force=0 vblank_mode=3 NINE_DEBUG=all

csmt_force=0 will prevent issue in the log due to several threads writing at the same time, and vblank_mode=3 forces vsync, thus fewer frames and shorter log.

The log can be quite big, it's easier to work with if you try to play fast to reproduce the issues, in order to have shortest log.

@Kzimir
Copy link
Author

Kzimir commented May 5, 2019

Hello Alex,

If i launch the game with

env csmt_force=0 vblank_mode=3 NINE_DEBUG=all D3D_ALWAYS_SOFTWARE=1 wine Darksiders2.exe &> Nine_D2.txt

after to rebuild mesa with debug flag enabled, i have this log :
https://pastebin.com/Fv9CsVJc

I have only this log because the game crash at launch, not in-game.

@axeldavy
Copy link

axeldavy commented May 5, 2019 via email

@Kzimir
Copy link
Author

Kzimir commented May 5, 2019

Hum... I don't know how to do a "good" debug log... I correctly built Mesa with "-Db_ndebug=false"

@axeldavy
Copy link

axeldavy commented May 5, 2019 via email

@Kzimir
Copy link
Author

Kzimir commented May 5, 2019

Hum, i rebuilt Mesa git + debug flag enabled and packaged/installed it and now i have a good log with print debug for Nine :
https://pastebin.com/v3WVDq6T

@axeldavy
Copy link

axeldavy commented May 5, 2019

Problem is indeed capabilities advertised.

In the log:
nine:0x7eff8e378b80:adapter9:CheckDepthStencilMatch: This=0x7e22a260 DeviceType=HAL AdapterFormat=D3DFMT_A8R8G8B8 RenderTargetFormat=D3DFMT_A8R8G8B8 DepthStencilFormat=D3DFMT_D24S8
nine:0x7eff8e378b80:adapter9:CheckDepthStencilMatch: User assertion failed: `display_format(AdapterFormat, 0)'

That is we return D3DERR_NOTAVAILABLE
While in the wine trace, it returns it is valid.

It results in the game passing invalid format later one.

@axeldavy
Copy link

axeldavy commented May 5, 2019

Checking that part of the code and the documentation, it seems we are too strict there. But what we advertise here has to work with other functions, thus it needs a proper fix. Until I write the proper fix, adding D3DFMT_A8R8G8B8 in the list of the function display_format (adapter9.c) should work for your game.

@Kzimir
Copy link
Author

Kzimir commented May 5, 2019

I confirm that with this workaround, the game works with Nine :-)

@Kzimir
Copy link
Author

Kzimir commented May 7, 2019

Hello Axel,

Just a question about this screenshot, i have a lot a tearing. What do you think about CPU/GPU-load/FPS graph ?

Do you know where come from the issue ?
Because i have the same problem between wined3d and Nine, like if Nine does not increase performance.

https://reho.st/view/self/a767537405379bb43d8355508b1d6d97aa4db69d.jpg

@axeldavy
Copy link

axeldavy commented May 7, 2019

It looks like the game caps fps to 30, maybe you can set it in the options.

For the tearing, I guess the app doesn't ask vsync (maybe you can configure it). You can force it with vblank_mode=3

@Kzimir
Copy link
Author

Kzimir commented May 7, 2019

Hum ... I disabled VSync in game and added vblank_mode=3 before to launch the game without success. I still have a lot of stuttering. You can see on the graph on the both screenshot that i have drop FPS while i have a CPU increase ...

I have an AMD Rx580 8Gb + Mesa Git + LLVM 8.0 ...
I hesitate to move to Nvidia ...

Screenshot :
https://reho.st/view/self/f5a83d083e2ec9651dbd41094c2f8028c91560c9.jpg
https://reho.st/view/self/908a3536764606c69ae59436e86cc25759387ec4.jpg

@axeldavy
Copy link

axeldavy commented May 7, 2019

The cpu load seems to spike when you have stutter.

That could indicate a shader recompilation. maybe's GALLIUM_HUD's num-compilations could confirm that ? Gallium nine isn't supposed to have much of them, taking an apitrace with
https://github.com/iXit/wine-nine-standalone/wiki/apitrace

could help make sense of this.
If it's not that, it may not be the graphic drivers, but some problem with other dlls.

@Kzimir
Copy link
Author

Kzimir commented May 8, 2019

This the .trace i done with apitrace :
https://drive.google.com/open?id=1p2ejkoCiAAWIDXhdpGR78XhYJ-vDPuKY

And this is a screenshot with num-compilations.
https://reho.st/view/self/872072b817adc4cf44d72c192694c2622a05fe84.jpg

@axeldavy
Copy link

axeldavy commented May 8, 2019

Replaying the trace, I see indeed a few isolated recompilations, but It's hard to tell whether it's your issue or not.

Do you use repo llvm or did you compile it yourself ? With the debug flags, llvm can be really slow.

radeonsi has a shader cache. If you play a scene, quit, and restart and play the scene again, the stutters should be gone because of the shader cache (the cache is reset whenever mesa or llvm is changed).

@Kzimir
Copy link
Author

Kzimir commented May 8, 2019

I used LLVM and Mesa packaged by Debian (Unstable version).

For the radeonsi shader cache, i already played more time a same scene. And each time i played, i had stuttering :-/

@axeldavy
Copy link

axeldavy commented May 8, 2019

Then it would indicate the issue is not in shader recompilation, and in some other dlls... I would recommand trying out native dlls and integrated dlls, sometimes ones perform better than others.

@Kzimir
Copy link
Author

Kzimir commented May 9, 2019

I reinstall Gentoo and with LLVM 9 + Mesa Git + Nine Standalone Git, stuttering are gone :-)

@axeldavy
Copy link

Ok then

@axeldavy
Copy link

Oups, While the performance issue is fixed, the long term fix for the crash is not yet done, so reopening

@axeldavy axeldavy reopened this May 10, 2019
@Kzimir
Copy link
Author

Kzimir commented Jun 1, 2019

Axel,

Do you fix the issue in Mesa ?

@axeldavy
Copy link

axeldavy commented Jun 3, 2019

Thanks for reminding me, I forgot.

@axeldavy
Copy link

axeldavy commented Jun 3, 2019

It's not exactly the same fix, but hopefully it should work the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants