1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 19:54:19 +01:00

[dxvk] Align allocation size to create global buffer

This commit is contained in:
Philip Rebohle 2024-09-26 09:13:03 +02:00 committed by Philip Rebohle
parent 401ca41091
commit 06baa48c2b
2 changed files with 10 additions and 0 deletions

View File

@ -279,6 +279,12 @@ namespace dxvk {
const void* next) {
auto vk = m_device->vkd();
// If global buffers are enabled for this allocation, pad the allocation size
// to a multiple of the global buffer alignment. This can happen when we create
// a dedicated allocation for a large resource.
if (type.bufferUsage && !next)
size = align(size, GlobalBufferAlignment);
// Preemptively free some unused allocations to reduce memory waste
freeEmptyChunksInHeap(*type.heap, size, high_resolution_clock::now());

View File

@ -335,6 +335,10 @@ namespace dxvk {
constexpr static VkDeviceSize MinChunkSize = 4ull << 20;
constexpr static VkDeviceSize MaxChunkSize = 256ull << 20;
// Assume an alignment of 256 bytes. This is enough to satisfy all
// buffer use cases, and matches our minimum allocation size.
constexpr static VkDeviceSize GlobalBufferAlignment = 256u;
public:
DxvkMemoryAllocator(DxvkDevice* device);