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

Compiling latest dxvk with -march=native (znver2) causes games to crash #4447

Closed
IAmDunningKrugerIncarnate opened this issue Nov 12, 2024 · 10 comments
Labels

Comments

@IAmDunningKrugerIncarnate
Copy link

IAmDunningKrugerIncarnate commented Nov 12, 2024

compile commands:

meson setup --cross-file build-win64.txt --buildtype release \
--prefix /mnt/gitdisk/root/dxvk --libdir lib64 --bindir bin64 build64 \
-Dc_args="-march=native -pipe" -Dc_link_args="-march=native -pipe" \
-Dcpp_args="-march=native -pipe" -Dcpp_link_args="-march=native -pipe" \
-Dstrip=true \
&& ninja -C build64/ install

meson setup --cross-file build-win32.txt --buildtype release \
--prefix /mnt/gitdisk/root/dxvk --libdir lib32 --bindir bin32 build32 \
-Dc_args="-march=native -pipe" -Dc_link_args="-march=native -pipe" \
-Dcpp_args="-march=native -pipe" -Dcpp_link_args="-march=native -pipe" \
-Dstrip=true \
&& ninja -C build32/ install

test environment:
I recreated Proton Experimental bleeding edge's folder structure in /Steam/compatibilitytools.d/ and symlinked all files sans dxvk dlls.
Games tested: Arma 3 for 64bit and Company of Heroes 1 for 32bit. Arma 3 makes it to the splash screen then crashes. CoH pops up it's crash report mailer.

-march=x86-64-v3 also fails. -march=x86-64-v2 works with reduced performance. compiling without custom flags works fine. My cpu is AMD zen2 3500x
I skimmed the discussion about how adding newer instruction sets does nothing basicly. So no biggie I suppose.
Hopefully I'm not being an idiot again.

@WinterSnowfall
Copy link
Contributor

Sounds like a compiler bug? That being said, why not simply add -march=native in dxvk's Meson script instead of -msse3 and friends? You'd still want the sse math among other things that are already in there.

Also note -march=native can be rather problematic in this day and age when (as an example) disabling your E cores may expose instructions specific to your P cores. And indeed, I have tested this myself a while back (worked for me at least), but it brings little if any benefit.

@Blisto91
Copy link
Contributor

Blisto91 commented Nov 12, 2024

What error does the games crash with in log?

Edit: Just attach a full Proton log

@IAmDunningKrugerIncarnate
Copy link
Author

steam-107410.log

@IAmDunningKrugerIncarnate
Copy link
Author

IAmDunningKrugerIncarnate commented Nov 12, 2024

Indeed, has to be a compiler bug. I reviewed this document. I went through and added every instruction -m flag that is listed under znver2 to the Meson.build file. Arma 3 works again. Thank you Winter for the suggestion.

@doitsujin
Copy link
Owner

Can repro, got a crash with 0x006ffffd515001 d3d11+0xc5001: vmovdqa %ymm0, 0x40(%rsp)

This pretty much proves that there has to be some sort of stack alignment issue somewhere. I'm not entirely sure what's going on here, stack alignment is 16 and not 32 so this kind of code should never be emitted, and we don't really use alignas(≥32) on anything that's stack-allocated either...

@doitsujin
Copy link
Owner

Still looks like a compiler issue though and it doesn't look like it's possible to work around that, short of not allowing the use of ymm registers (i.e. no avx, not sure if there's a way to only allow 128-bit AVX).

@ViNi-Arco
Copy link

If you want DXVK with AVX, you'll need to build with MSVC or Clang+Mingw, GCC+Mingw needs a special patch, and the compiler aligning to 32 may be due to AVX 256 znver2

@IAmDunningKrugerIncarnate
Copy link
Author

After taking a second look at the GCC doc, there is this flag -mprefer-avx128. Used openSUSE's Build Service to produce a patched Mingw here. Added these flags to the Meson.build file:

  '-march=native',
  '-mtune=native',
  '-mprefer-avx128',
  '-mno-align-vector-insn',

Success!

Using the one game I own that has a benchmark which pumps out frames and is consistent between runs: Company of Heroes 1 on lowest settings. Here are the results:

GCC No custom flags
Avg 425.5 Max 611.0 Min 175.8

GCC Natived
Avg 431.7 Max 620.0 Min 176.8

Proton Experimental Bleeding Edge
Avg 456.6 Max 627.0 Min 186.0

@ViNi-Arco
Copy link

ViNi-Arco commented Nov 13, 2024

Used openSUSE's Build Service to produce a patched Mingw

Very good 😊, I see you've used the patch and are using the new flag, if you're going to try Graphite optimizations I recommend building against isl 0.25, in my tests it's more consistent than 0.26

Edit: Looking at the spec of your Mingw you can improve this result, the performance difference for the DXVK built by Valve is the dwarf exception, your GCC+Mingw is sjlj exception, you can add in the .spec and build again that should decrease this difference:

mingw32-gcc with:
--disable-sjlj-exceptions
--with-dwarf2 \

mingw64-gcc with:
--disable-sjlj-exceptions \

@IAmDunningKrugerIncarnate
Copy link
Author

IAmDunningKrugerIncarnate commented Nov 14, 2024

Edit: Looking at the spec of your Mingw you can improve this result, the performance difference for the DXVK built by Valve is the dwarf exception, your GCC+Mingw is sjlj exception, you can add in the .spec and build again that should decrease this difference:

mingw32-gcc with: --disable-sjlj-exceptions --with-dwarf2 \

mingw64-gcc with: --disable-sjlj-exceptions \

Done. Thank you kindly

Edit: New result:
Avg 464.3 Max 638.0 Min 191.4

Excellent. Thank you @ViNi-Arco !

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

Successfully merging a pull request may close this issue.

5 participants