mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 20:52:10 +01:00
[dxvk] Introduce transient memory flag for staging buffers
Potentially reduces fragmentation by putting short-lived staging buffers and sysmem resources created by the application into different memory pools.
This commit is contained in:
parent
9d4be00fa7
commit
425fce9200
@ -1,3 +1,4 @@
|
||||
#include "dxvk_barrier.h"
|
||||
#include "dxvk_buffer.h"
|
||||
#include "dxvk_device.h"
|
||||
|
||||
@ -108,6 +109,12 @@ namespace dxvk {
|
||||
if (isGpuWritable)
|
||||
hints.set(DxvkMemoryFlag::GpuWritable);
|
||||
|
||||
// Staging buffers that can't even be used as a transfer destinations
|
||||
// are likely short-lived, so we should put them on a separate memory
|
||||
// pool in order to avoid fragmentation
|
||||
if (DxvkBarrierSet::getAccessTypes(m_info.access) == DxvkAccess::Read)
|
||||
hints.set(DxvkMemoryFlag::Transient);
|
||||
|
||||
// Ask driver whether we should be using a dedicated allocation
|
||||
handle.memory = m_memAlloc->alloc(&memReq.memoryRequirements,
|
||||
dedicatedRequirements, dedMemoryAllocInfo, m_memFlags, hints);
|
||||
|
@ -169,7 +169,8 @@ namespace dxvk {
|
||||
DxvkMemoryFlags mask(
|
||||
DxvkMemoryFlag::Small,
|
||||
DxvkMemoryFlag::GpuReadable,
|
||||
DxvkMemoryFlag::GpuWritable);
|
||||
DxvkMemoryFlag::GpuWritable,
|
||||
DxvkMemoryFlag::Transient);
|
||||
|
||||
if (hints.test(DxvkMemoryFlag::IgnoreConstraints))
|
||||
mask = DxvkMemoryFlags();
|
||||
@ -255,10 +256,10 @@ namespace dxvk {
|
||||
hints.clr(DxvkMemoryFlag::GpuWritable, DxvkMemoryFlag::GpuReadable);
|
||||
}
|
||||
|
||||
// Ignore all hints for host-visible allocations since they
|
||||
// Ignore most hints for host-visible allocations since they
|
||||
// usually don't make much sense for those resources
|
||||
if (flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
|
||||
hints = DxvkMemoryFlags();
|
||||
hints = hints & DxvkMemoryFlag::Transient;
|
||||
|
||||
// Try to allocate from a memory type which supports the given flags exactly
|
||||
auto dedAllocPtr = dedAllocReq.prefersDedicatedAllocation ? &dedAllocInfo : nullptr;
|
||||
|
@ -165,7 +165,8 @@ namespace dxvk {
|
||||
Small = 0, ///< Small allocation
|
||||
GpuReadable = 1, ///< Medium-priority resource
|
||||
GpuWritable = 2, ///< High-priority resource
|
||||
IgnoreConstraints = 3, ///< Ignore most allocation flags
|
||||
Transient = 3, ///< Resource is short-lived
|
||||
IgnoreConstraints = 4, ///< Ignore most allocation flags
|
||||
};
|
||||
|
||||
using DxvkMemoryFlags = Flags<DxvkMemoryFlag>;
|
||||
|
Loading…
x
Reference in New Issue
Block a user