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

Open
opened 2026-11-26 06:10:33 +00:00 by github-bot · 1 comment
Owner

@⁠Trwthh on GitHub · 2026-11-22 10:19 UTC · original

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
**@⁠Trwthh** on GitHub · 2026-11-22 10:19 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/112) ## 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
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:10:33 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 14:05 UTC · original

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).

**@⁠omonkeyz** on GitHub · 2026-11-22 14:05 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/112#issuecomment-7080283651) 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).
This discussion has been locked. Commenting is limited to contributors.
No description provided.