From 16eae7addec8e0dbe2d1afa78fa077546642e6c5 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 20 Jul 2022 13:57:52 +0200 Subject: [PATCH] [dxvk] Allow resetting the state cache using the DXVK_STATE_CACHE env var --- README.md | 4 +++- src/dxvk/dxvk_state_cache.cpp | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4db6c29a5..db344e378 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,9 @@ Some applications do not provide a method to select a different GPU. In that cas DXVK caches pipeline state by default, so that shaders can be recompiled ahead of time on subsequent runs of an application, even if the driver's own shader cache got invalidated in the meantime. This cache is enabled by default, and generally reduces stuttering. The following environment variables can be used to control the cache: -- `DXVK_STATE_CACHE=0` Disables the state cache. +- `DXVK_STATE_CACHE`: Controls the state cache. The following values are supported: + - `disable`: Disables the cache entirely. + - `reset`: Clears the cache file. - `DXVK_STATE_CACHE_PATH=/some/directory` Specifies a directory where to put the cache files. Defaults to the current working directory of the application. ### Debugging diff --git a/src/dxvk/dxvk_state_cache.cpp b/src/dxvk/dxvk_state_cache.cpp index 31800cb27..770fedc5a 100644 --- a/src/dxvk/dxvk_state_cache.cpp +++ b/src/dxvk/dxvk_state_cache.cpp @@ -238,12 +238,13 @@ namespace dxvk { m_pipeManager (pipeManager), m_pipeWorkers (pipeWorkers) { std::string useStateCache = env::getEnvVar("DXVK_STATE_CACHE"); - m_enable = useStateCache != "0" && device->config().enableStateCache; + m_enable = useStateCache != "0" && useStateCache != "disable" && + device->config().enableStateCache; if (!m_enable) return; - bool newFile = !readCacheFile(); + bool newFile = (useStateCache == "reset") || (!readCacheFile()); if (newFile) { Logger::warn("DXVK: Creating new state cache file");