Reorganise VkResourceRecord to reduce wasted space

* This reduces the total size from 448 bytes -> 232 bytes, but does mean
  some extra pointer chasing. I'm not sure what the best balance is so
  this will do for now and I'll wait and see if profiling turns up any
  issues.
This commit is contained in:
baldurk
2015-11-12 16:33:15 +01:00
parent 773c1e48e5
commit 2decca5f27
9 changed files with 118 additions and 91 deletions
+25 -12
View File
@@ -488,25 +488,38 @@ uint32_t GetByteSize(uint32_t Width, uint32_t Height, uint32_t Depth, VkFormat F
VkResourceRecord::~VkResourceRecord()
{
for(size_t i=0; i < descBindings.size(); i++)
delete[] descBindings[i];
descBindings.clear();
VkResourceType resType = IdentifyTypeByPtr(Resource);
if(resType == eResPhysicalDevice)
SAFE_DELETE(memProps);
SAFE_DELETE(memProps);
// bufferviews and imageviews have non-owning pointers to the sparseinfo struct
if(resType == eResBuffer || resType == eResImage)
SAFE_DELETE(sparseInfo);
SAFE_DELETE(layout);
SAFE_DELETE(swapInfo);
SAFE_DELETE(cmdInfo);
if(memMapState)
if(resType == eResSwapchain)
SAFE_DELETE(swapInfo);
if(resType == eResDeviceMemory && memMapState)
{
Serialiser::FreeAlignedBuffer(memMapState->refData);
SAFE_DELETE(memMapState);
}
if(sparseOwner)
{
SAFE_DELETE(sparseInfo);
}
if(resType == eResCmdBuffer)
SAFE_DELETE(cmdInfo);
if(resType == eResFramebuffer)
SAFE_DELETE(imageAttachments);
// only the descriptor set layout actually owns this pointer, descriptor sets
// have a pointer to it but don't own it
if(resType == eResDescriptorSetLayout)
SAFE_DELETE(descInfo->layout);
if(resType == eResDescriptorSetLayout || resType == eResDescriptorSet)
SAFE_DELETE(descInfo);
}
void SparseMapping::Update(uint32_t numBindings, const VkSparseImageMemoryBindInfo *pBindings)