[android] Adjusted the shader cache wiping tied to driver for a better consistence in per-game change and not globally

This commit is contained in:
CamilleLaVey 2026-04-06 21:34:06 -04:00
parent 67ba161540
commit a431b64fef

View file

@ -58,6 +58,7 @@ class DriverViewModel : ViewModel() {
private val driversToDelete = mutableListOf<String>() private val driversToDelete = mutableListOf<String>()
private var previousDriverPath: String = "" private var previousDriverPath: String = ""
private var activeGame: Game? = null
private val _shouldShowDriverShaderDialog = MutableStateFlow(false) private val _shouldShowDriverShaderDialog = MutableStateFlow(false)
val shouldShowDriverShaderDialog: StateFlow<Boolean> get() = _shouldShowDriverShaderDialog val shouldShowDriverShaderDialog: StateFlow<Boolean> get() = _shouldShowDriverShaderDialog
@ -98,6 +99,7 @@ class DriverViewModel : ViewModel() {
} }
fun onOpenDriverManager(game: Game?) { fun onOpenDriverManager(game: Game?) {
activeGame = game
if (game != null) { if (game != null) {
SettingsFile.loadCustomConfig(game) SettingsFile.loadCustomConfig(game)
} }
@ -116,10 +118,12 @@ class DriverViewModel : ViewModel() {
} }
if (!skipShaderWipe && newDriverPath != previousDriverPath) { if (!skipShaderWipe && newDriverPath != previousDriverPath) {
wipeAllShaders() activeGame?.let {
wipeGameShaders(it)
if (!BooleanSetting.DONT_SHOW_DRIVER_SHADER_WARNING.getBoolean(needsGlobal = true)) { if (!BooleanSetting.DONT_SHOW_DRIVER_SHADER_WARNING.getBoolean(needsGlobal = true)) {
_shouldShowDriverShaderDialog.value = true _shouldShowDriverShaderDialog.value = true
}
} }
} }
@ -139,12 +143,14 @@ class DriverViewModel : ViewModel() {
_shouldShowDriverShaderDialog.value = false _shouldShowDriverShaderDialog.value = false
} }
private fun wipeAllShaders() { private fun wipeGameShaders(game: Game) {
viewModelScope.launch { viewModelScope.launch {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
val externalFilesDir = YuzuApplication.appContext.getExternalFilesDir(null)
?: return@withContext
val shaderDir = File( val shaderDir = File(
YuzuApplication.appContext.getExternalFilesDir(null)?.canonicalPath + externalFilesDir.absolutePath +
"/shader/" "/shader/" + game.settingsName.lowercase()
) )
if (shaderDir.exists()) { if (shaderDir.exists()) {
shaderDir.deleteRecursively() shaderDir.deleteRecursively()
@ -202,6 +208,7 @@ class DriverViewModel : ViewModel() {
} }
driversToDelete.clear() driversToDelete.clear()
} finally { } finally {
activeGame = null
_isDeletingDrivers.value = false _isDeletingDrivers.value = false
} }
} }