|
game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
|
Service for managing shader caches. More...
#include <shader_cache_manager.h>
Classes | |
| struct | Impl |
Public Types | |
| using | ProgressCallback = std::function<void(int percent, const std::string& status)> |
Public Member Functions | |
| ShaderCacheManager () | |
| ~ShaderCacheManager () | |
| void | addCustomCacheLocation (const std::filesystem::path &path, ShaderCacheType type) |
| Add a custom cache location to scan. | |
| std::filesystem::path | backupCache (const std::filesystem::path &cachePath, const std::filesystem::path &backupDir={}) |
| Backup a shader cache before clearing. | |
| CacheClearResult | clearAllCaches (const ProgressCallback &progressCallback=nullptr) |
| Clear all shader caches (use with caution!). | |
| CacheClearResult | clearCache (const std::filesystem::path &cachePath) |
| Clear a specific cache. | |
| CacheClearResult | clearCachesByType (ShaderCacheType type, const ProgressCallback &progressCallback=nullptr) |
| Clear all caches of a specific type. | |
| CacheClearResult | clearGameCache (const std::string &gameId, ShaderCacheType type=ShaderCacheType::All, const std::filesystem::path &winePrefix={}, uint32_t steamAppId=0) |
| Clear shader cache for a specific game. | |
| CacheClearResult | clearStaleCaches (std::chrono::hours olderThan=std::chrono::hours(720), const ProgressCallback &progressCallback=nullptr) |
| Clear old/stale caches. | |
| std::optional< ShaderCacheInfo > | findDXVKCache (const std::filesystem::path &winePrefix) const |
| Find DXVK cache for a game. | |
| std::optional< ShaderCacheInfo > | findSteamShaderCache (uint32_t steamAppId) const |
| Find Steam shader cache for a game. | |
| std::optional< ShaderCacheInfo > | findVKD3DCache (const std::filesystem::path &winePrefix) const |
| Find VKD3D cache for a game. | |
| std::vector< ShaderCacheInfo > | getAllCaches () const |
| Get all detected shader caches. | |
| std::filesystem::path | getBackupDirectory () const |
| Get the backup directory. | |
| std::vector< std::filesystem::path > | getCacheBackups () const |
| Get list of cache backups. | |
| std::optional< ShaderCacheInfo > | getCacheInfo (const std::filesystem::path &path) const |
| Get cache info for a specific path. | |
| std::vector< ShaderCacheInfo > | getCachesByType (ShaderCacheType type) const |
| Get caches by type. | |
| int64_t | getCacheSizeByType (ShaderCacheType type) const |
| Get cache size by type. | |
| std::vector< std::filesystem::path > | getDefaultCacheLocations (ShaderCacheType type) const |
| Get the default cache location for a type. | |
| GameShaderCache | getGameCache (const std::string &gameId, const std::filesystem::path &winePrefix={}, uint32_t steamAppId=0) const |
| Get shader caches for a specific game. | |
| ShaderCacheStats | getStats () const |
| Get overall shader cache statistics. | |
| int64_t | getTotalCacheSize () const |
| Get total cache size. | |
| std::optional< ShaderCacheType > | identifyCacheType (const std::filesystem::path &path) const |
| Check if a path is a valid shader cache. | |
| int | pruneBackups (int keepCount=3) |
| Delete old cache backups. | |
| bool | restoreCache (const std::filesystem::path &backupPath, const std::filesystem::path &targetPath) |
| Restore a shader cache from backup. | |
| int | scanCaches (const ProgressCallback &progressCallback=nullptr) |
| Scan for all shader caches on the system. | |
| void | setBackupDirectory (const std::filesystem::path &path) |
| Set the backup directory. | |
| void | setSteamLibraryPaths (const std::vector< std::filesystem::path > &paths) |
| Set Steam library paths. | |
Service for managing shader caches.
Provides methods for discovering, analyzing, and clearing shader caches to help troubleshoot graphics issues and free disk space.
Definition at line 150 of file shader_cache_manager.h.
| using ShaderCacheManager::ProgressCallback = std::function<void(int percent, const std::string& status)> |
Definition at line 153 of file shader_cache_manager.h.
| ShaderCacheManager::ShaderCacheManager | ( | ) |
Definition at line 201 of file shader_cache_manager.cpp.
References scanCaches().
|
default |
| void ShaderCacheManager::addCustomCacheLocation | ( | const std::filesystem::path & | path, |
| ShaderCacheType | type ) |
Add a custom cache location to scan.
| path | Path to scan |
| type | Cache type |
Definition at line 837 of file shader_cache_manager.cpp.
| std::filesystem::path ShaderCacheManager::backupCache | ( | const std::filesystem::path & | cachePath, |
| const std::filesystem::path & | backupDir = {} ) |
Backup a shader cache before clearing.
| cachePath | Cache to backup |
| backupDir | Backup destination |
Definition at line 700 of file shader_cache_manager.cpp.
| CacheClearResult ShaderCacheManager::clearAllCaches | ( | const ProgressCallback & | progressCallback = nullptr | ) |
Clear all shader caches (use with caution!).
| progressCallback | Progress updates |
Definition at line 626 of file shader_cache_manager.cpp.
References CacheClearResult::bytesCleared, clearCache(), CacheClearResult::directoriesCleared, CacheClearResult::errors, CacheClearResult::filesCleared, getAllCaches(), and CacheClearResult::success.
| CacheClearResult ShaderCacheManager::clearCache | ( | const std::filesystem::path & | cachePath | ) |
Clear a specific cache.
| cachePath | Path to cache directory |
Definition at line 515 of file shader_cache_manager.cpp.
References CacheClearResult::bytesCleared, CacheClearResult::directoriesCleared, CacheClearResult::errors, CacheClearResult::filesCleared, and CacheClearResult::success.
Referenced by clearAllCaches(), clearCachesByType(), clearGameCache(), clearStaleCaches(), and restoreCache().
| CacheClearResult ShaderCacheManager::clearCachesByType | ( | ShaderCacheType | type, |
| const ProgressCallback & | progressCallback = nullptr ) |
Clear all caches of a specific type.
| type | Cache type to clear |
| progressCallback | Progress updates |
Definition at line 568 of file shader_cache_manager.cpp.
References CacheClearResult::bytesCleared, clearCache(), CacheClearResult::directoriesCleared, CacheClearResult::errors, CacheClearResult::filesCleared, getCachesByType(), and CacheClearResult::success.
| CacheClearResult ShaderCacheManager::clearGameCache | ( | const std::string & | gameId, |
| ShaderCacheType | type = ShaderCacheType::All, | ||
| const std::filesystem::path & | winePrefix = {}, | ||
| uint32_t | steamAppId = 0 ) |
Clear shader cache for a specific game.
| gameId | Game ID |
| type | Cache type (or All) |
| winePrefix | Wine prefix path |
| steamAppId | Steam app ID |
Definition at line 600 of file shader_cache_manager.cpp.
References All, CacheClearResult::bytesCleared, clearCache(), CacheClearResult::directoriesCleared, CacheClearResult::errors, CacheClearResult::filesCleared, getGameCache(), and CacheClearResult::success.
| CacheClearResult ShaderCacheManager::clearStaleCaches | ( | std::chrono::hours | olderThan = std::chrono::hours(720), |
| const ProgressCallback & | progressCallback = nullptr ) |
Clear old/stale caches.
| olderThan | Clear caches older than this duration |
| progressCallback | Progress updates |
Definition at line 657 of file shader_cache_manager.cpp.
References CacheClearResult::bytesCleared, clearCache(), CacheClearResult::directoriesCleared, CacheClearResult::errors, CacheClearResult::filesCleared, getAllCaches(), and CacheClearResult::success.
| std::optional< ShaderCacheInfo > ShaderCacheManager::findDXVKCache | ( | const std::filesystem::path & | winePrefix | ) | const |
Find DXVK cache for a game.
| winePrefix | Wine prefix path |
Definition at line 355 of file shader_cache_manager.cpp.
References DXVK, ShaderCacheInfo::exists, ShaderCacheInfo::fileCount, getCacheInfo(), ShaderCacheInfo::lastModified, ShaderCacheInfo::name, ShaderCacheInfo::path, ShaderCacheInfo::size, ShaderCacheInfo::type, and Logger::warn().
Referenced by getGameCache().
| std::optional< ShaderCacheInfo > ShaderCacheManager::findSteamShaderCache | ( | uint32_t | steamAppId | ) | const |
Find Steam shader cache for a game.
| steamAppId | Steam app ID |
Definition at line 425 of file shader_cache_manager.cpp.
References ShaderCacheInfo::exists, ShaderCacheInfo::fileCount, ShaderCacheInfo::lastModified, ShaderCacheInfo::name, ShaderCacheInfo::path, ShaderCacheInfo::size, SteamShader, and ShaderCacheInfo::type.
Referenced by getGameCache().
| std::optional< ShaderCacheInfo > ShaderCacheManager::findVKD3DCache | ( | const std::filesystem::path & | winePrefix | ) | const |
Find VKD3D cache for a game.
| winePrefix | Wine prefix path |
Definition at line 405 of file shader_cache_manager.cpp.
References getCacheInfo().
Referenced by getGameCache().
| std::vector< ShaderCacheInfo > ShaderCacheManager::getAllCaches | ( | ) | const |
Get all detected shader caches.
Definition at line 212 of file shader_cache_manager.cpp.
Referenced by clearAllCaches(), and clearStaleCaches().
| std::filesystem::path ShaderCacheManager::getBackupDirectory | ( | ) | const |
Get the backup directory.
Definition at line 832 of file shader_cache_manager.cpp.
| std::vector< std::filesystem::path > ShaderCacheManager::getCacheBackups | ( | ) | const |
Get list of cache backups.
Definition at line 765 of file shader_cache_manager.cpp.
References Logger::warn().
Referenced by pruneBackups().
| std::optional< ShaderCacheInfo > ShaderCacheManager::getCacheInfo | ( | const std::filesystem::path & | path | ) | const |
Get cache info for a specific path.
| path | Cache directory path |
Definition at line 235 of file shader_cache_manager.cpp.
References ShaderCacheInfo::exists, ShaderCacheInfo::fileCount, identifyCacheType(), ShaderCacheInfo::lastModified, ShaderCacheInfo::name, ShaderCacheInfo::path, shaderCacheTypeName(), ShaderCacheInfo::size, and ShaderCacheInfo::type.
Referenced by findDXVKCache(), and findVKD3DCache().
| std::vector< ShaderCacheInfo > ShaderCacheManager::getCachesByType | ( | ShaderCacheType | type | ) | const |
Get caches by type.
| type | Cache type to filter |
Definition at line 218 of file shader_cache_manager.cpp.
References All.
Referenced by clearCachesByType(), and getCacheSizeByType().
| int64_t ShaderCacheManager::getCacheSizeByType | ( | ShaderCacheType | type | ) | const |
Get cache size by type.
| type | Cache type |
Definition at line 500 of file shader_cache_manager.cpp.
References getCachesByType().
| std::vector< std::filesystem::path > ShaderCacheManager::getDefaultCacheLocations | ( | ShaderCacheType | type | ) | const |
Get the default cache location for a type.
| type | Cache type |
Definition at line 913 of file shader_cache_manager.cpp.
References DXVK, Fossilize, Mesa, NVIDIA, SteamShader, VKD3D, and WineState.
| GameShaderCache ShaderCacheManager::getGameCache | ( | const std::string & | gameId, |
| const std::filesystem::path & | winePrefix = {}, | ||
| uint32_t | steamAppId = 0 ) const |
Get shader caches for a specific game.
| gameId | Game ID |
| winePrefix | Wine prefix path (for DXVK/VKD3D) |
| steamAppId | Steam app ID (for Steam shader cache) |
Definition at line 312 of file shader_cache_manager.cpp.
References GameShaderCache::caches, findDXVKCache(), findSteamShaderCache(), findVKD3DCache(), GameShaderCache::gameId, GameShaderCache::hasDXVK, GameShaderCache::hasSteamCache, GameShaderCache::hasVKD3D, and GameShaderCache::totalSize.
Referenced by clearGameCache().
| ShaderCacheStats ShaderCacheManager::getStats | ( | ) | const |
Get overall shader cache statistics.
Definition at line 453 of file shader_cache_manager.cpp.
References ShaderCacheStats::cacheDirectories, DXVK, ShaderCacheStats::dxvkSize, Fossilize, ShaderCacheStats::fossilizeSize, Mesa, ShaderCacheStats::mesaSize, NVIDIA, ShaderCacheStats::nvidiaSize, SteamShader, ShaderCacheStats::steamSize, ShaderCacheStats::totalFiles, ShaderCacheStats::totalSize, VKD3D, ShaderCacheStats::vkd3dSize, WineState, and ShaderCacheStats::wineStateSize.
Referenced by getTotalCacheSize().
| int64_t ShaderCacheManager::getTotalCacheSize | ( | ) | const |
Get total cache size.
Definition at line 495 of file shader_cache_manager.cpp.
References getStats(), and ShaderCacheStats::totalSize.
| std::optional< ShaderCacheType > ShaderCacheManager::identifyCacheType | ( | const std::filesystem::path & | path | ) | const |
Check if a path is a valid shader cache.
| path | Path to check |
Definition at line 855 of file shader_cache_manager.cpp.
References DXVK, Fossilize, Mesa, NVIDIA, SteamShader, VKD3D, and WineState.
Referenced by getCacheInfo().
| int ShaderCacheManager::pruneBackups | ( | int | keepCount = 3 | ) |
Delete old cache backups.
| keepCount | Number of recent backups to keep per cache |
Definition at line 795 of file shader_cache_manager.cpp.
References getCacheBackups().
| bool ShaderCacheManager::restoreCache | ( | const std::filesystem::path & | backupPath, |
| const std::filesystem::path & | targetPath ) |
Restore a shader cache from backup.
| backupPath | Backup to restore |
| targetPath | Target cache location |
Definition at line 738 of file shader_cache_manager.cpp.
References clearCache().
| int ShaderCacheManager::scanCaches | ( | const ProgressCallback & | progressCallback = nullptr | ) |
Scan for all shader caches on the system.
| progressCallback | Progress updates |
Definition at line 260 of file shader_cache_manager.cpp.
Referenced by ShaderCacheManager().
| void ShaderCacheManager::setBackupDirectory | ( | const std::filesystem::path & | path | ) |
Set the backup directory.
| path | Directory for cache backups |
Definition at line 823 of file shader_cache_manager.cpp.
| void ShaderCacheManager::setSteamLibraryPaths | ( | const std::vector< std::filesystem::path > & | paths | ) |
Set Steam library paths.
| paths | Steam library root paths |
Definition at line 844 of file shader_cache_manager.cpp.