mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2025-05-28 23:49:21 +00:00
Add support for buffer device address, together with documentation and tests
Added VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT.
This commit is contained in:
parent
39aeff7a43
commit
e73e988daf
72 changed files with 16279 additions and 15850 deletions
|
@ -34,6 +34,8 @@ static const char* CODE_DESCRIPTION = "Foo";
|
|||
|
||||
extern VkCommandBuffer g_hTemporaryCommandBuffer;
|
||||
extern const VkAllocationCallbacks* g_Allocs;
|
||||
extern bool g_BufferDeviceAddressEnabled;
|
||||
extern PFN_vkGetBufferDeviceAddressEXT g_vkGetBufferDeviceAddressEXT;
|
||||
void BeginSingleTimeCommands();
|
||||
void EndSingleTimeCommands();
|
||||
|
||||
|
@ -3766,6 +3768,44 @@ static void BenchmarkAlgorithmsCase(FILE* file,
|
|||
}
|
||||
}
|
||||
|
||||
static void TestBufferDeviceAddress()
|
||||
{
|
||||
wprintf(L"Test buffer device address\n");
|
||||
|
||||
assert(g_BufferDeviceAddressEnabled);
|
||||
|
||||
VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
||||
bufCreateInfo.size = 0x10000;
|
||||
bufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT |
|
||||
VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT; // !!!
|
||||
|
||||
VmaAllocationCreateInfo allocCreateInfo = {};
|
||||
allocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY;
|
||||
|
||||
for(uint32_t testIndex = 0; testIndex < 2; ++testIndex)
|
||||
{
|
||||
// 1st is placed, 2nd is dedicated.
|
||||
if(testIndex == 1)
|
||||
allocCreateInfo.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
|
||||
|
||||
BufferInfo bufInfo = {};
|
||||
VkResult res = vmaCreateBuffer(g_hAllocator, &bufCreateInfo, &allocCreateInfo,
|
||||
&bufInfo.Buffer, &bufInfo.Allocation, nullptr);
|
||||
TEST(res == VK_SUCCESS);
|
||||
|
||||
VkBufferDeviceAddressInfoEXT bufferDeviceAddressInfo = { VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO_EXT };
|
||||
bufferDeviceAddressInfo.buffer = bufInfo.Buffer;
|
||||
//assert(g_vkGetBufferDeviceAddressEXT != nullptr);
|
||||
if(g_vkGetBufferDeviceAddressEXT != nullptr)
|
||||
{
|
||||
VkDeviceAddress addr = g_vkGetBufferDeviceAddressEXT(g_hDevice, &bufferDeviceAddressInfo);
|
||||
TEST(addr != 0);
|
||||
}
|
||||
|
||||
vmaDestroyBuffer(g_hAllocator, bufInfo.Buffer, bufInfo.Allocation);
|
||||
}
|
||||
}
|
||||
|
||||
static void BenchmarkAlgorithms(FILE* file)
|
||||
{
|
||||
wprintf(L"Benchmark algorithms\n");
|
||||
|
@ -6280,6 +6320,9 @@ void Test()
|
|||
BasicTestBuddyAllocator();
|
||||
BasicTestAllocatePages();
|
||||
|
||||
if(g_BufferDeviceAddressEnabled)
|
||||
TestBufferDeviceAddress();
|
||||
|
||||
{
|
||||
FILE* file;
|
||||
fopen_s(&file, "Algorithms.csv", "w");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue