Its only requirements are the bash shell (and this doesn't have to be the shell you are using, you just need to have bash installed, which it most likely is) the "find" utility and basic core/file utilities like rm and du. I can't imagine a distro not having find.
Nowadays, when you use Proton in Steam, it changes the path to your Mesa shader cache to the game's directory in compatdata. This has nothing to do with Steam's own shader cache management where it uploads and downloads shaders, that's BOLLOCKS (would make good sense on a Steam Deck though). Turn that off to clean that up, it's separate from this.
So not only do you have the shader caches in your home directory (~/.cache/mesa_shader_cache and friends) but scattered throughout the compatdata directories for every Windows game you've ever installed in Steam.
Every time you change your Mesa libraries (upgrade or even install another build of the same version, like if your distributor builds a new package for some reason) these shader cache files are invalidated and new ones get created. Well now they are all over the fucking place.
I want that junk gone, thus:
Code: Select all
#! /bin/bash
### Clean out ~/.cache/mesa_shader_cache(_sf) and radv_builtin shaders
### Clean out the mesa_shader_cache(_sf) directories from Steam's compatdata
### Note that the fossilize cache (MESA_DISK_CACHE_SINGLE_FILE=1) isn't used by default,
### so we cover the mesa_shader_cache_sf case with a wildcard
# System specific path, you may need to edit below if the following doesn't lead
# to the real path correctly
cd "$HOME"/.steam/root/steamapps/compatdata || exit 1
COMPATDATA=$(pwd -P)
find "$COMPATDATA" -name 'mesa_shader_cache*' -exec du -sh '{}' \;
find "$HOME"/.cache -name 'mesa_shader_cache*' -exec du -sh '{}' \;
echo "Look at all the CRUD that is accumulating..."
while true; do
read -p "Do you wish to clean it out? (y/n) " yn
case $yn in
[yY] ) echo Nuking...;
break;;
[nN] ) echo Aborting...;
exit 0;;
* ) echo "Enter y or n, silly!";;
esac
done
find "$COMPATDATA" -name 'mesa_shader_cache*' -exec rm -rvf '{}' \;
rm -vf "$HOME"/.cache/radv_builtin_shaders32
rm -vf "$HOME"/.cache/radv_builtin_shaders64
rm -rvf "$HOME"/.cache/mesa_shader_cache*
You can use this just to see how much crap is there. Say N and the script aborts
Code: Select all
[grogan@nicetry mesabuild]$ ./cleanshadercaches
22M /storage3/shit/steam/steamapps/compatdata/1716740/pfx/mesa_shader_cache_sf
1.3M /storage3/shit/steam/steamapps/compatdata/0/pfx/mesa_shader_cache_sf
3.0M /storage3/shit/steam/steamapps/compatdata/1029690/pfx/mesa_shader_cache_sf
43M /storage3/shit/steam/steamapps/compatdata/2369390/pfx/mesa_shader_cache_sf
17M /home/grogan/.cache/mesa_shader_cache_sf
Look at all the CRUD that is accumulating...
Do you wish to clean it out? (y/n) n
Aborting...
[grogan@nicetry mesabuild]$
I run this script after upgrading mesa, there's no point in leaving hundreds of megabytes of crud behind, scattered throughout the Steam profile. If I were to go a couple of weeks between Mesa upgrades, there is quite a lot of disconnected shit that doesn't need to be taking up valuable NVME real estate.
P.S. Note: Because of the use of the wildcard, this script still works without modifications, with the new mesa_shader_cache_db directory format, which is the default unless overridden by variables, as of Mesa 24.2.0
Code: Select all
[grogan@nicetry mesabuild]$ ./cleanshadercaches
43M /storage3/shit/steam/steamapps/compatdata/1716740/pfx/mesa_shader_cache_db
1.9M /storage3/shit/steam/steamapps/compatdata/0/pfx/mesa_shader_cache_db
2.9M /storage3/shit/steam/steamapps/compatdata/612880/pfx/mesa_shader_cache_db
2.3M /storage3/shit/steam/steamapps/compatdata/312660/pfx/mesa_shader_cache_db
42M /storage3/shit/steam/steamapps/compatdata/2369390/pfx/mesa_shader_cache_db
84M /storage3/shit/steam/steamapps/compatdata/397540/pfx/mesa_shader_cache_db
266M /home/grogan/.cache/mesa_shader_cache_db
4.0K /home/grogan/.cache/mesa_shader_cache
Look at all the CRUD that is accumulating...
Do you wish to clean it out? (y/n) y