From 10164fdf4d6dc58823c8ca658efacbcf3b4ba5fc Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 23 Sep 2024 01:09:55 +0200 Subject: [PATCH] [dxvk] Store GPU address for allocated chunk memory --- src/dxvk/dxvk_memory.cpp | 9 ++++++++- src/dxvk/dxvk_memory.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/dxvk/dxvk_memory.cpp b/src/dxvk/dxvk_memory.cpp index 0935ef67..b9489495 100644 --- a/src/dxvk/dxvk_memory.cpp +++ b/src/dxvk/dxvk_memory.cpp @@ -713,8 +713,12 @@ namespace dxvk { && (requirements.memoryRequirements.memoryTypeBits & (1u << type.index))) { status = vk->vkBindBufferMemory(vk->device(), buffer, result.memory, 0); - if (status == VK_SUCCESS) + if (status == VK_SUCCESS) { result.buffer = buffer; + + if (type.bufferUsage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) + result.gpuVa = getBufferDeviceAddress(buffer); + } } if (!result.buffer) @@ -796,6 +800,8 @@ namespace dxvk { if (chunk.memory.buffer) { allocation->m_buffer = chunk.memory.buffer; allocation->m_bufferOffset = offset; + allocation->m_bufferAddress = chunk.memory.gpuVa + ? chunk.memory.gpuVa + offset : 0u; } return allocation; @@ -819,6 +825,7 @@ namespace dxvk { allocation->m_mapPtr = memory.mapPtr; allocation->m_buffer = memory.buffer; + allocation->m_bufferAddress = memory.gpuVa; return allocation; } diff --git a/src/dxvk/dxvk_memory.h b/src/dxvk/dxvk_memory.h index 3f41fc3e..9a99f1d8 100644 --- a/src/dxvk/dxvk_memory.h +++ b/src/dxvk/dxvk_memory.h @@ -70,8 +70,9 @@ namespace dxvk { struct DxvkDeviceMemory { VkBuffer buffer = VK_NULL_HANDLE; VkDeviceMemory memory = VK_NULL_HANDLE; - VkDeviceSize size = 0; + VkDeviceSize size = 0u; void* mapPtr = nullptr; + VkDeviceAddress gpuVa = 0u; };