Your graphics driver keeps a cache per game, and it never shrinks
DirectX and the driver both cache compiled shaders. Where they are, why clearing them is harmless, and when it actually helps.
Compiling shaders is expensive, so everything caches them: the game, DirectX, and the graphics driver separately. On a gaming machine these add up to several gigabytes and none of them are cleared automatically.
The three caches
$paths = @(
"$env:LOCALAPPDATA\D3DSCache",
"$env:LOCALAPPDATA\NVIDIA\DXCache",
"$env:LOCALAPPDATA\NVIDIA\GLCache",
"$env:LOCALAPPDATA\AMD\DxCache",
"$env:LOCALAPPDATA\AMD\GLCache"
)
foreach ($p in $paths) {
if (Test-Path $p) {
$s = (Get-ChildItem $p -Recurse -Force -File -EA SilentlyContinue | Measure-Object Length -Sum).Sum
'{0,8:N0} MB {1}' -f ($s/1MB), $p
}
}Why clearing them is safe
Every one of these is derived from the game's own shader source and the driver currently installed. Delete them and the next launch recompiles what it needs, which costs some stutter for the first few minutes of play and nothing else.
When it actually helps
- After a driver update. A stale cache built against the previous driver is a classic cause of stuttering or visual glitches that appear right after an update.
- After uninstalling games. Their cached shaders stay behind indefinitely.
- When a game crashes on launch and nothing else explains it. Clearing the cache is one of the first things support will ask for.
Doing it properly
Disk Cleanup lists DirectX Shader Cache as a category, which covers the D3D cache. The vendor caches are cleared from the graphics control panel, or by deleting their folders with the machine idle. Nvidia's control panel also has a cache size setting, which is the way to bound it rather than clear it repeatedly.
Game specific caches
Many games keep their own, inside their install folder or their AppData directory, under names like shadercache or pipelinecache. Those go with the game when it is properly uninstalled, and stay when the folder is deleted by hand, which is one more reason to use the launcher's own uninstall.
Common questions
Where is the shader cache on Windows?
DirectX keeps one in %LOCALAPPDATA%\D3DSCache, and Nvidia and AMD keep their own DXCache and GLCache folders under AppData. Many games also cache shaders inside their own folders.
Is it safe to delete the shader cache?
Yes. Everything in it is recompiled from the game's shaders on the next launch. The only cost is some stutter for the first few minutes of play.
Does clearing the shader cache fix stuttering?
Sometimes, particularly right after a graphics driver update, when a cache built against the previous driver can cause glitches or stutter. It is one of the first things support asks for.
How do I clear the DirectX shader cache?
Disk Cleanup lists it as DirectX Shader Cache. The vendor caches are cleared from the graphics control panel or by removing their folders with the machine idle.