protonscr

Unreal Tournament 2004: Shader compilation stutter

dxvkclosed d3d9fixed function
doitsujin/dxvk#3534 · opened 2023-06-24 by K0bin · updated 2025-09-13 · 13 comments · github
KK0bin 2023-06-24 github

Unreal Tournament 2004 (with D3D8to9 or D8VK) suffers from shader compilation stutters.
DXVK generates a lot of fixed function vertex shaders. Additionally the game has a queue sync every frame, which naturally means that we also synchronize with the CS thread. So each shader compilation stalls both threads making it even worse.

A possible solution would be to move our generated fixed function shaders more towards uber-shaders and handle multiple versions in one shader.

Software information

Unreal Tournament 2004

System information

  • GPU: Nvidia RTX 3090
  • DXVK version: 2.2+ (doesn't really matter, happens on all versions)

Apitrace file(s)

https://drive.google.com/file/d/1dTbqCiJL8AJESJWZZsJNliCZvV0tc4Cl/view?usp=sharing

Log files

I made it print out the 4 uint32_t words of the FF VS key.
shader_compilation_log.txt

WWinterSnowfall 2023-06-25 github

Most likely related: https://github.com/AlpyneDreams/d8vk/issues/165

It's also using UE2, and arguably the stuttering is nowhere near as bad as it is in UT2004, but it's there. It's probably more evident in single player.

KK0bin maintainer 2023-06-25 github

According to Josh it's mostly down to TexcoordFlags, TransformFlags and TexcoordDeclMask.

Nnetborg-afps 2023-06-25 github

This eliminates stutters almost completely, but has rendering artifacts on the HUD:
https://github.com/doitsujin/dxvk/compare/master...netborg-afps:dxvk:2023_06_fixing_ut2004_stutters

Not sure if this is a fix or a hack?
Edit: Seems like I forgot that Vertex Shader and Pixel Shader are part of the Pipeline definition, so this obviously is a hack.

What I also found out is that Pipeline compilation did take at most 0.5 ms in most cases and 30 ms very rarely (OK, that seems to be because of nvidia cache).

Nnetborg-afps 2023-07-07 github

Because my previous hack made me confident the game is actually largely stutter-free when moving some variables to the shader, I made a real fix last week. In case someone wants to play UT2004, or any UE2 game via dxvk, the fix is available here:
https://github.com/netborg-afps/dxvk/tree/2023_06_fixing_ut2004_stutters

The disadvantage of the fix though is that vertex shader compile times roughly doubled, so the only true solution which works for all games would be a single uber-shader which wouldn't need to be compiled at runtime.

Aadolfintel 2024-04-06 github

Still an issue unfortunately :disappointed:

Nnetborg-afps 2024-04-23 github

Still an issue unfortunately 😞

Have you tried my fix?
Unfortunately, this won't get into upstream because it slows down other games, but it allows you to play this game largely stutter-free.

Aadolfintel 2024-04-24 github

@netborg-afps I did and it's better than regular dxvk, but not really a stutter-free experience, especially at the beginning of the game. Other UE2 games like Postal 2 20th anniversary are still a very stuttery experience and basically unplayable :cry:

KK0bin maintainer 2024-09-17 github

https://github.com/netborg-afps/dxvk/tree/2023_06_fixing_ut2004_stutters

Prototype branch that turns parts of the FF vertex shader dynamic.

Aadolfintel 2024-09-17 github

@K0bin I don't see a prototype branch in that repo, is it the display_render_latency branch?

KK0bin maintainer 2024-09-17 github

Whoops, lost the branch from my link.

Aadolfintel 2024-09-17 github

That's the branch I previously tested (and that I use regularly for ut2004). It reduces stuttering a lot in ut but other UE2 games like postal 2 still run quite poorly.

CCommandGenius 2025-05-12 github

Still an issue unfortunately 😞

Have you tried my fix? Unfortunately, this won't get into upstream because it slows down other games, but it allows you to play this game largely stutter-free.

Could you update your fix to 2.6.1? Thank you.

Nnetborg-afps 2025-05-18 github

Could you update your fix to 2.6.1? Thank you.

Done
https://github.com/netborg-afps/dxvk/actions/runs/15097936969

Nothing extracted yet.