summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Forbes <chrisforbes@google.com>2017-04-24 16:59:02 -0700
committerChris Forbes <chrisf@ijw.co.nz>2017-04-26 07:55:08 +1200
commit47ce19b3248ab08a928e518f9ae89a9f74631df9 (patch)
treeb8a830f2ac9ebb68fc375d492b68670429bbc6af
parenta0f96857422c17299f72ba61defcd7b7ae113ec7 (diff)
layers: Simplify DESCRIPTOR_POOL_STATE
Just use safe_* here rather than copying things manually.
-rw-r--r--layers/core_validation_types.h29
1 files 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<cvdescriptorset::DescriptorSet *> sets; // Collection of all sets in this pool
std::vector<uint32_t> maxDescriptorTypeCount; // Max # of descriptors of each type in this pool
std::vector<uint32_t> 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<uint32_t>(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<uint32_t>(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