Skip to content

Commit

Permalink
[dxvk] Align allocation size to create global buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
doitsujin committed Sep 26, 2024
1 parent 401ca41 commit 06baa48
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/dxvk/dxvk_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
4 changes: 4 additions & 0 deletions src/dxvk/dxvk_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 06baa48

Please sign in to comment.