Test dEQP-VK.api.invariance.random contains memory leaks.
Change fixes memory leaks.
Components: Vulkan
VK-GL-CTS Issue: 2110
Affects: dEQP-VK.api.invariance.random
Change-Id: I4ccd9d87b69f51da661ca85f10eb347086594aaa
void BufferAllocator::allocate (Context& context)
{
void BufferAllocator::allocate (Context& context)
{
- Allocator& memAlloc = context.getDefaultAllocator();
- IBufferAllocator* allocator = 0;
- MemoryRequirement requirement = legalMemoryTypes[m_memoryType];
+ Allocator& memAlloc = context.getDefaultAllocator();
+ de::MovePtr<IBufferAllocator> allocator;
+ MemoryRequirement requirement = legalMemoryTypes[m_memoryType];
- allocator = new BufferDedicatedAllocation;
+ allocator = de::MovePtr<IBufferAllocator>(new BufferDedicatedAllocation);
- allocator = new BufferSuballocation;
+ allocator = de::MovePtr<IBufferAllocator>(new BufferSuballocation);
allocator->createTestBuffer(
m_size,
allocator->createTestBuffer(
m_size,
m_buffer,
requirement,
m_bufferAlloc);
m_buffer,
requirement,
m_bufferAlloc);
}
void BufferAllocator::deallocate (Context& context)
}
void BufferAllocator::deallocate (Context& context)
const vk::VkDevice& device = context.getDevice();
vk.destroyBuffer(device, m_buffer.disown(), DE_NULL);
const vk::VkDevice& device = context.getDevice();
vk.destroyBuffer(device, m_buffer.disown(), DE_NULL);
- vk.freeMemory(device, m_bufferAlloc.get()->getMemory(), (const VkAllocationCallbacks*)DE_NULL);
- m_bufferAlloc.release();
}
size_t BufferAllocator::getSize (Context &context)
}
size_t BufferAllocator::getSize (Context &context)
void ImageAllocator::allocate (Context& context)
{
void ImageAllocator::allocate (Context& context)
{
- Allocator& memAlloc = context.getDefaultAllocator();
- IImageAllocator* allocator = 0;
- MemoryRequirement requirement = legalMemoryTypes[m_memoryType];
+ Allocator& memAlloc = context.getDefaultAllocator();
+ de::MovePtr<IImageAllocator> allocator;
+ MemoryRequirement requirement = legalMemoryTypes[m_memoryType];
- allocator = new ImageDedicatedAllocation;
+ allocator = de::MovePtr<IImageAllocator>(new ImageDedicatedAllocation);
- allocator = new ImageSuballocation;
+ allocator = de::MovePtr<IImageAllocator>(new ImageSuballocation);
allocator->createTestImage(
m_size,
allocator->createTestImage(
m_size,
requirement,
m_imageAlloc,
m_linear ? VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL);
requirement,
m_imageAlloc,
m_linear ? VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL);
}
void ImageAllocator::deallocate (Context& context)
}
void ImageAllocator::deallocate (Context& context)
const VkDevice& device = context.getDevice();
vk.destroyImage(device, m_image.disown(), DE_NULL);
const VkDevice& device = context.getDevice();
vk.destroyImage(device, m_image.disown(), DE_NULL);
- vk.freeMemory(device, m_imageAlloc.get()->getMemory(), (const VkAllocationCallbacks*)DE_NULL);
- m_imageAlloc.release();
}
size_t ImageAllocator::getSize (Context &context)
}
size_t ImageAllocator::getSize (Context &context)
tcu::TestStatus InvarianceInstance::iterate (void)
{
tcu::TestStatus InvarianceInstance::iterate (void)
{
- IObjectAllocator* objs[testCycles];
+ de::MovePtr<IObjectAllocator> objs[testCycles];
size_t refSizes[testCycles];
unsigned int order[testCycles];
bool success = true;
size_t refSizes[testCycles];
unsigned int order[testCycles];
bool success = true;
for (unsigned int i = 0; i < testCycles; i++)
{
if (deRandom_getBool(&m_random))
for (unsigned int i = 0; i < testCycles; i++)
{
if (deRandom_getBool(&m_random))
- objs[i] = new BufferAllocator(m_random, isDedicatedAllocationSupported, memoryTypes);
+ objs[i] = de::MovePtr<IObjectAllocator>(new BufferAllocator(m_random, isDedicatedAllocationSupported, memoryTypes));
- objs[i] = new ImageAllocator(m_random, isDedicatedAllocationSupported, linearFormats, optimalFormats, memoryTypes);
+ objs[i] = de::MovePtr<IObjectAllocator>(new ImageAllocator(m_random, isDedicatedAllocationSupported, linearFormats, optimalFormats, memoryTypes));