mirror of https://github.com/doitsujin/dxvk
[dxvk] Add option to limit memory chunk size
This commit is contained in:
parent
0d28be4ab8
commit
2be0d6842e
11
dxvk.conf
11
dxvk.conf
|
@ -294,6 +294,17 @@
|
||||||
# dxvk.useRawSsbo = Auto
|
# dxvk.useRawSsbo = Auto
|
||||||
|
|
||||||
|
|
||||||
|
# Changes memory chunk size.
|
||||||
|
#
|
||||||
|
# Can be used to override the maximum memory chunk size.
|
||||||
|
#
|
||||||
|
# Supported values:
|
||||||
|
# - 0 to use the defaults
|
||||||
|
# - any positive integer to limit the chunk size, in MiB
|
||||||
|
|
||||||
|
# dxvk.maxChunkSize = 0
|
||||||
|
|
||||||
|
|
||||||
# Controls graphics pipeline library behaviour
|
# Controls graphics pipeline library behaviour
|
||||||
#
|
#
|
||||||
# Can be used to change VK_EXT_graphics_pipeline_library usage for
|
# Can be used to change VK_EXT_graphics_pipeline_library usage for
|
||||||
|
|
|
@ -183,7 +183,8 @@ namespace dxvk {
|
||||||
|
|
||||||
DxvkMemoryAllocator::DxvkMemoryAllocator(DxvkDevice* device)
|
DxvkMemoryAllocator::DxvkMemoryAllocator(DxvkDevice* device)
|
||||||
: m_device (device),
|
: m_device (device),
|
||||||
m_memProps (device->adapter()->memoryProperties()) {
|
m_memProps (device->adapter()->memoryProperties()),
|
||||||
|
m_maxChunkSize (determineMaxChunkSize(device)) {
|
||||||
for (uint32_t i = 0; i < m_memProps.memoryHeapCount; i++) {
|
for (uint32_t i = 0; i < m_memProps.memoryHeapCount; i++) {
|
||||||
m_memHeaps[i].properties = m_memProps.memoryHeaps[i];
|
m_memHeaps[i].properties = m_memProps.memoryHeaps[i];
|
||||||
m_memHeaps[i].stats = DxvkMemoryStats { 0, 0 };
|
m_memHeaps[i].stats = DxvkMemoryStats { 0, 0 };
|
||||||
|
@ -493,15 +494,15 @@ namespace dxvk {
|
||||||
VkMemoryHeap heap = m_memProps.memoryHeaps[type.heapIndex];
|
VkMemoryHeap heap = m_memProps.memoryHeaps[type.heapIndex];
|
||||||
|
|
||||||
// Default to a chunk size of 256 MiB
|
// Default to a chunk size of 256 MiB
|
||||||
VkDeviceSize chunkSize = 256 << 20;
|
VkDeviceSize chunkSize = m_maxChunkSize;
|
||||||
|
|
||||||
if (hints.test(DxvkMemoryFlag::Small))
|
if (hints.test(DxvkMemoryFlag::Small))
|
||||||
chunkSize = 16 << 20;
|
chunkSize = std::min<VkDeviceSize>(chunkSize, 16 << 20);
|
||||||
|
|
||||||
// Try to waste a bit less system memory especially in
|
// Try to waste a bit less system memory especially in
|
||||||
// 32-bit applications due to address space constraints
|
// 32-bit applications due to address space constraints
|
||||||
if (type.propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
|
if (type.propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
|
||||||
chunkSize = (env::is32BitHostPlatform() ? 16 : 64) << 20;
|
chunkSize = std::min<VkDeviceSize>((env::is32BitHostPlatform() ? 16 : 64) << 20, chunkSize);
|
||||||
|
|
||||||
// Reduce the chunk size on small heaps so
|
// Reduce the chunk size on small heaps so
|
||||||
// we can at least fit in 15 allocations
|
// we can at least fit in 15 allocations
|
||||||
|
@ -638,6 +639,17 @@ namespace dxvk {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VkDeviceSize DxvkMemoryAllocator::determineMaxChunkSize(
|
||||||
|
DxvkDevice* device) const {
|
||||||
|
int32_t option = device->config().maxChunkSize;
|
||||||
|
|
||||||
|
if (option <= 0)
|
||||||
|
option = 256;
|
||||||
|
|
||||||
|
return VkDeviceSize(option) << 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkMemoryAllocator::logMemoryError(const VkMemoryRequirements& req) const {
|
void DxvkMemoryAllocator::logMemoryError(const VkMemoryRequirements& req) const {
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
sstr << "DxvkMemoryAllocator: Memory allocation failed" << std::endl
|
sstr << "DxvkMemoryAllocator: Memory allocation failed" << std::endl
|
||||||
|
|
|
@ -352,6 +352,8 @@ namespace dxvk {
|
||||||
std::array<DxvkMemoryHeap, VK_MAX_MEMORY_HEAPS> m_memHeaps;
|
std::array<DxvkMemoryHeap, VK_MAX_MEMORY_HEAPS> m_memHeaps;
|
||||||
std::array<DxvkMemoryType, VK_MAX_MEMORY_TYPES> m_memTypes;
|
std::array<DxvkMemoryType, VK_MAX_MEMORY_TYPES> m_memTypes;
|
||||||
|
|
||||||
|
VkDeviceSize m_maxChunkSize;
|
||||||
|
|
||||||
uint32_t m_sparseMemoryTypes = 0u;
|
uint32_t m_sparseMemoryTypes = 0u;
|
||||||
|
|
||||||
DxvkMemory tryAlloc(
|
DxvkMemory tryAlloc(
|
||||||
|
@ -403,6 +405,9 @@ namespace dxvk {
|
||||||
uint32_t determineSparseMemoryTypes(
|
uint32_t determineSparseMemoryTypes(
|
||||||
DxvkDevice* device) const;
|
DxvkDevice* device) const;
|
||||||
|
|
||||||
|
VkDeviceSize determineMaxChunkSize(
|
||||||
|
DxvkDevice* device) const;
|
||||||
|
|
||||||
void logMemoryError(
|
void logMemoryError(
|
||||||
const VkMemoryRequirements& req) const;
|
const VkMemoryRequirements& req) const;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace dxvk {
|
||||||
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);
|
||||||
useRawSsbo = config.getOption<Tristate>("dxvk.useRawSsbo", Tristate::Auto);
|
useRawSsbo = config.getOption<Tristate>("dxvk.useRawSsbo", Tristate::Auto);
|
||||||
|
maxChunkSize = config.getOption<int32_t> ("dxvk.maxChunkSize", 0);
|
||||||
hud = config.getOption<std::string>("dxvk.hud", "");
|
hud = config.getOption<std::string>("dxvk.hud", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@ namespace dxvk {
|
||||||
/// Shader-related options
|
/// Shader-related options
|
||||||
Tristate useRawSsbo;
|
Tristate useRawSsbo;
|
||||||
|
|
||||||
|
/// Maximum memory chunk size in MiB
|
||||||
|
int32_t maxChunkSize;
|
||||||
|
|
||||||
/// HUD elements
|
/// HUD elements
|
||||||
std::string hud;
|
std::string hud;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue