1
0
Fork 0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-06 20:58:37 +01:00

[dxvk] Add option to disable memory defragmentation

This commit is contained in:
Philip Rebohle 2024-10-24 12:15:44 +02:00 committed by Philip Rebohle
parent 9977313c32
commit ec62551412
4 changed files with 35 additions and 15 deletions

View file

@ -388,6 +388,20 @@
# dxvk.trackPipelineLifetime = Auto # dxvk.trackPipelineLifetime = Auto
# Controls memory defragmentation
#
# By default, DXVK will try to defragment video memory if there is a
# significant amount of memory wasted, or if the allocation budget of
# the application is exceeded. This option is provided solely for
# debug purposes.
#
# Supported values:
# - True: Enable defragmentation
# - False: Disable defragmentation
# dxvk.enableMemoryDefrag = True
# Sets enabled HUD elements # Sets enabled HUD elements
# #
# Behaves like the DXVK_HUD environment variable if the # Behaves like the DXVK_HUD environment variable if the

View file

@ -2283,13 +2283,15 @@ namespace dxvk {
m_memTypes[i].sharedCache->cleanupUnusedFromLockedAllocator(currentTime); m_memTypes[i].sharedCache->cleanupUnusedFromLockedAllocator(currentTime);
} }
// Periodically defragment device-local memory types. We cannot if (m_device->config().enableMemoryDefrag) {
// do anything about mapped allocations since we rely on pointer // Periodically defragment device-local memory types. We cannot
// stability there. // do anything about mapped allocations since we rely on pointer
for (uint32_t i = 0; i < m_memTypeCount; i++) { // stability there.
if (m_memTypes[i].properties.propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) { for (uint32_t i = 0; i < m_memTypeCount; i++) {
moveDefragChunk(m_memTypes[i]); if (m_memTypes[i].properties.propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) {
pickDefragChunk(m_memTypes[i]); moveDefragChunk(m_memTypes[i]);
pickDefragChunk(m_memTypes[i]);
}
} }
} }
} }

View file

@ -5,6 +5,7 @@ namespace dxvk {
DxvkOptions::DxvkOptions(const Config& config) { DxvkOptions::DxvkOptions(const Config& config) {
enableDebugUtils = config.getOption<bool> ("dxvk.enableDebugUtils", false); enableDebugUtils = config.getOption<bool> ("dxvk.enableDebugUtils", false);
enableStateCache = config.getOption<bool> ("dxvk.enableStateCache", true); enableStateCache = config.getOption<bool> ("dxvk.enableStateCache", true);
enableMemoryDefrag = config.getOption<bool> ("dxvk.enableMemoryDefrag", true);
numCompilerThreads = config.getOption<int32_t> ("dxvk.numCompilerThreads", 0); numCompilerThreads = config.getOption<int32_t> ("dxvk.numCompilerThreads", 0);
enableGraphicsPipelineLibrary = config.getOption<Tristate>("dxvk.enableGraphicsPipelineLibrary", Tristate::Auto); enableGraphicsPipelineLibrary = config.getOption<Tristate>("dxvk.enableGraphicsPipelineLibrary", Tristate::Auto);
trackPipelineLifetime = config.getOption<Tristate>("dxvk.trackPipelineLifetime", Tristate::Auto); trackPipelineLifetime = config.getOption<Tristate>("dxvk.trackPipelineLifetime", Tristate::Auto);

View file

@ -9,35 +9,38 @@ namespace dxvk {
DxvkOptions(const Config& config); DxvkOptions(const Config& config);
/// Enable debug utils /// Enable debug utils
bool enableDebugUtils; bool enableDebugUtils = false;
/// Enable state cache /// Enable state cache
bool enableStateCache; bool enableStateCache = true;
/// Enable memory defragmentation
bool enableMemoryDefrag = true;
/// Number of compiler threads /// Number of compiler threads
/// when using the state cache /// when using the state cache
int32_t numCompilerThreads; int32_t numCompilerThreads = 0;
/// Enable graphics pipeline library /// Enable graphics pipeline library
Tristate enableGraphicsPipelineLibrary; Tristate enableGraphicsPipelineLibrary = Tristate::Auto;
/// Enables pipeline lifetime tracking /// Enables pipeline lifetime tracking
Tristate trackPipelineLifetime; Tristate trackPipelineLifetime = Tristate::Auto;
/// Shader-related options /// Shader-related options
Tristate useRawSsbo; Tristate useRawSsbo = Tristate::Auto;
/// HUD elements /// HUD elements
std::string hud; std::string hud;
/// Forces swap chain into MAILBOX (if true) /// Forces swap chain into MAILBOX (if true)
/// or FIFO_RELAXED (if false) present mode /// or FIFO_RELAXED (if false) present mode
Tristate tearFree; Tristate tearFree = Tristate::Auto;
// Hides integrated GPUs if dedicated GPUs are // Hides integrated GPUs if dedicated GPUs are
// present. May be necessary for some games that // present. May be necessary for some games that
// incorrectly assume monitor layouts. // incorrectly assume monitor layouts.
bool hideIntegratedGraphics; bool hideIntegratedGraphics = false;
// Device name // Device name
std::string deviceFilter; std::string deviceFilter;