d3d12_xs: synchronous shader compilation causes 1-2.5s GPU hitches #112

Open
opened 2026-11-22 10:19:06 +00:00 by Trwthh · 1 comment
Trwthh commented 2026-11-22 10:19:06 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by Trwthh on 2026-11-22T10:19:06Z.


Bug

Shader translation + DXC compilation + PSO creation all run synchronously on first use. The console uses precompiled PSOs, so this cost doesn't exist on hardware. The emulator blocks the render thread while each new shader is translated and compiled.

Evidence (from run 33/35/42)

  • Run 33 lobby: 45.2 FPS average (console runs 60), with 1-2.5 s hitches
  • Run 42 gpuprof: 47 "Hitch in GPU" events totaling 20.6 s; 12 of them (6.7 s) directly correlate with "caller thread blocked N ms" shader-translation waits + driver CreateGraphicsPipelineState time
  • UE confirms: STAT_PSOGraphicsFindOrCreateTime appears 14 times (7.9 s)
  • Menu navigation freezes (run 35): opening the item shop causes hitches up to 1060 ms at ~329 draws

Impact

High. The game is not playable at the lobby due to constant multi-second freezes every time a new shader is encountered. This is especially severe during first boot and menu navigation where many new materials are loaded.

Suggested approaches

  • Async PSO compilation with a placeholder/fallback shader while the real one compiles
  • Pre-warming the shader cache with xscan --compile 1 before launching a title
  • Background compilation thread pool that doesn't block the render thread
<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6541205485 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/issues/112). Originally posted by [Trwthh](https://github.com/Trwthh) on 2026-11-22T10:19:06Z. --- ## Bug Shader translation + DXC compilation + PSO creation all run synchronously on first use. The console uses precompiled PSOs, so this cost doesn't exist on hardware. The emulator blocks the render thread while each new shader is translated and compiled. ### Evidence (from run 33/35/42) - Run 33 lobby: 45.2 FPS average (console runs 60), with **1-2.5 s hitches** - Run 42 gpuprof: **47 "Hitch in GPU" events totaling 20.6 s**; 12 of them (6.7 s) directly correlate with "caller thread blocked N ms" shader-translation waits + driver CreateGraphicsPipelineState time - UE confirms: STAT_PSOGraphicsFindOrCreateTime appears 14 times (7.9 s) - Menu navigation freezes (run 35): opening the item shop causes hitches up to 1060 ms at ~329 draws ### Impact **High.** The game is not playable at the lobby due to constant multi-second freezes every time a new shader is encountered. This is especially severe during first boot and menu navigation where many new materials are loaded. ### Suggested approaches - Async PSO compilation with a placeholder/fallback shader while the real one compiles - Pre-warming the shader cache with `xscan --compile 1` before launching a title - Background compilation thread pool that doesn't block the render thread
omonkeyz commented 2026-11-22 14:05:26 +00:00 (Migrated from github.com)
Author

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-22T14:05:26Z.


Status: both suggested approaches are now in. (1) The prelaunch shader pack (xshader_prelaunch) converts the title's shaders before launch; Fortnite is fully cached. (2) Graphics PSOs build asynchronously: pso_async returns a placeholder after 12 ms while the real PSO builds in the background. In today's headless Fortnite run, 100/100 shaders were disk hits, with 'caller blocked 0 ms in 0 waits'. Runs 33/35/42 predate both changes. Leaving this open until a lobby run re-measures the hitches (Fortnite comes after Trackmania and Terraria in the current order).

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7080283651 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/issues/112#issuecomment-7080283651). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-22T14:05:26Z. --- Status: both suggested approaches are now in. (1) The prelaunch shader pack (xshader_prelaunch) converts the title's shaders before launch; Fortnite is fully cached. (2) Graphics PSOs build asynchronously: pso_async returns a placeholder after 12 ms while the real PSO builds in the background. In today's headless Fortnite run, 100/100 shaders were disk hits, with 'caller blocked 0 ms in 0 waits'. Runs 33/35/42 predate both changes. Leaving this open until a lobby run re-measures the hitches (Fortnite comes after Trackmania and Terraria in the current order).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
omonkeyz/xbox-emulator#112
No description provided.