mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
synced 2024-11-21 20:00:11 +00:00
Changed macro in defragmentation test to more readable lambda.
Code by @medranSolus
This commit is contained in:
parent
c317c7b3e8
commit
58face4cff
@ -2716,18 +2716,20 @@ void TestDefragmentationIncrementalComplex()
|
|||||||
std::vector<AllocInfo> additionalAllocations;
|
std::vector<AllocInfo> additionalAllocations;
|
||||||
additionalAllocations.reserve(maxAdditionalAllocations);
|
additionalAllocations.reserve(maxAdditionalAllocations);
|
||||||
|
|
||||||
#define MakeAdditionalAllocation() \
|
const auto makeAdditionalAllocation = [&]()
|
||||||
if (additionalAllocations.size() < maxAdditionalAllocations) \
|
{
|
||||||
{ \
|
if (additionalAllocations.size() < maxAdditionalAllocations)
|
||||||
bufCreateInfo.size = align_up<VkDeviceSize>(bufSizeMin + rand.Generate() % (bufSizeMax - bufSizeMin), 16); \
|
{
|
||||||
bufCreateInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT; \
|
bufCreateInfo.size = align_up<VkDeviceSize>(bufSizeMin + rand.Generate() % (bufSizeMax - bufSizeMin), 16);
|
||||||
\
|
bufCreateInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||||
AllocInfo alloc; \
|
|
||||||
alloc.CreateBuffer(bufCreateInfo, allocCreateInfo); \
|
AllocInfo alloc;
|
||||||
\
|
alloc.CreateBuffer(bufCreateInfo, allocCreateInfo);
|
||||||
additionalAllocations.push_back(alloc); \
|
|
||||||
vmaSetAllocationUserData(g_hAllocator, alloc.m_Allocation, &additionalAllocations.back()); \
|
additionalAllocations.push_back(alloc);
|
||||||
}
|
vmaSetAllocationUserData(g_hAllocator, alloc.m_Allocation, &additionalAllocations.back());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Defragment using GPU only.
|
// Defragment using GPU only.
|
||||||
{
|
{
|
||||||
@ -2738,12 +2740,12 @@ void TestDefragmentationIncrementalComplex()
|
|||||||
VkResult res = vmaBeginDefragmentation(g_hAllocator, &defragInfo, &ctx);
|
VkResult res = vmaBeginDefragmentation(g_hAllocator, &defragInfo, &ctx);
|
||||||
TEST(res == VK_SUCCESS);
|
TEST(res == VK_SUCCESS);
|
||||||
|
|
||||||
MakeAdditionalAllocation();
|
makeAdditionalAllocation();
|
||||||
|
|
||||||
VmaDefragmentationPassMoveInfo pass = {};
|
VmaDefragmentationPassMoveInfo pass = {};
|
||||||
while((res = vmaBeginDefragmentationPass(g_hAllocator, ctx, &pass)) == VK_INCOMPLETE)
|
while((res = vmaBeginDefragmentationPass(g_hAllocator, ctx, &pass)) == VK_INCOMPLETE)
|
||||||
{
|
{
|
||||||
MakeAdditionalAllocation();
|
makeAdditionalAllocation();
|
||||||
|
|
||||||
// Ignore data outside of test
|
// Ignore data outside of test
|
||||||
for (uint32_t i = 0; i < pass.moveCount; ++i)
|
for (uint32_t i = 0; i < pass.moveCount; ++i)
|
||||||
@ -2761,7 +2763,7 @@ void TestDefragmentationIncrementalComplex()
|
|||||||
ProcessDefragmentationPass(pass);
|
ProcessDefragmentationPass(pass);
|
||||||
EndSingleTimeCommands();
|
EndSingleTimeCommands();
|
||||||
|
|
||||||
MakeAdditionalAllocation();
|
makeAdditionalAllocation();
|
||||||
|
|
||||||
// Destroy old buffers/images and replace them with new handles.
|
// Destroy old buffers/images and replace them with new handles.
|
||||||
for (size_t i = 0; i < pass.moveCount; ++i)
|
for (size_t i = 0; i < pass.moveCount; ++i)
|
||||||
@ -2796,7 +2798,7 @@ void TestDefragmentationIncrementalComplex()
|
|||||||
break;
|
break;
|
||||||
TEST(res == VK_INCOMPLETE);
|
TEST(res == VK_INCOMPLETE);
|
||||||
|
|
||||||
MakeAdditionalAllocation();
|
makeAdditionalAllocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(res == VK_SUCCESS);
|
TEST(res == VK_SUCCESS);
|
||||||
|
Loading…
Reference in New Issue
Block a user