From a40059b83f330e3c1673ef184efdd3abbb260cc6 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 24 Apr 2017 16:59:02 -0700 Subject: layers: Simplify DESCRIPTOR_POOL_STATE Just use safe_* here rather than copying things manually. --- layers/core_validation_types.h | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/layers/core_validation_types.h b/layers/core_validation_types.h index ee070fe8..68017d1c 100644 --- a/layers/core_validation_types.h +++ b/layers/core_validation_types.h @@ -134,7 +134,7 @@ struct DESCRIPTOR_POOL_STATE : BASE_NODE { uint32_t maxSets; // Max descriptor sets allowed in this pool uint32_t availableSets; // Available descriptor sets in this pool - VkDescriptorPoolCreateInfo createInfo; + safe_VkDescriptorPoolCreateInfo createInfo; std::unordered_set sets; // Collection of all sets in this pool std::vector maxDescriptorTypeCount; // Max # of descriptors of each type in this pool std::vector availableDescriptorTypeCount; // Available # of descriptors of each type in this pool @@ -143,30 +143,17 @@ struct DESCRIPTOR_POOL_STATE : BASE_NODE { : pool(pool), maxSets(pCreateInfo->maxSets), availableSets(pCreateInfo->maxSets), - createInfo(*pCreateInfo), + createInfo(pCreateInfo), maxDescriptorTypeCount(VK_DESCRIPTOR_TYPE_RANGE_SIZE, 0), availableDescriptorTypeCount(VK_DESCRIPTOR_TYPE_RANGE_SIZE, 0) { - if (createInfo.poolSizeCount) { // Shadow type struct from ptr into local struct - size_t poolSizeCountSize = createInfo.poolSizeCount * sizeof(VkDescriptorPoolSize); - createInfo.pPoolSizes = new VkDescriptorPoolSize[poolSizeCountSize]; - memcpy((void *)createInfo.pPoolSizes, pCreateInfo->pPoolSizes, poolSizeCountSize); - // Now set max counts for each descriptor type based on count of that type times maxSets - uint32_t i = 0; - for (i = 0; i < createInfo.poolSizeCount; ++i) { - uint32_t typeIndex = static_cast(createInfo.pPoolSizes[i].type); - // Same descriptor types can appear several times - maxDescriptorTypeCount[typeIndex] += createInfo.pPoolSizes[i].descriptorCount; - availableDescriptorTypeCount[typeIndex] = maxDescriptorTypeCount[typeIndex]; - } - } else { - createInfo.pPoolSizes = NULL; // Make sure this is NULL so we don't try to clean it up + // Collect maximums per descriptor type. + for (uint32_t i = 0; i < createInfo.poolSizeCount; ++i) { + uint32_t typeIndex = static_cast(createInfo.pPoolSizes[i].type); + // Same descriptor types can appear several times + maxDescriptorTypeCount[typeIndex] += createInfo.pPoolSizes[i].descriptorCount; + availableDescriptorTypeCount[typeIndex] = maxDescriptorTypeCount[typeIndex]; } } - ~DESCRIPTOR_POOL_STATE() { - delete[] createInfo.pPoolSizes; - // TODO : pSets are currently freed in deletePools function which uses freeShadowUpdateTree function - // need to migrate that struct to smart ptrs for auto-cleanup - } }; // Generic memory binding struct to track objects bound to objects -- cgit v1.2.3