From 2f68b290d22d933fda156e0101bb2ebf2f493c04 Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Wed, 1 Jun 2016 11:33:50 -0600 Subject: layers: Pass common data between pre/post AllocDescriptorSets With the break between PreValidate* and PostRecord* calls in the layers we can suffer having to do some repeat work in the Post step. In order to prevent this, this CL slightly modifies the interface to pass common data between the pre/post calls in a custom AllocateDescriptorSetsData struct. I initially attempted to fill this data in a separate function that would preceed the PreValidate* call, but such a function would need to include some validation as it includes map checks which may fail. The simplest solution, then, seems to be passing a ptr to the common data to the PreValidate* function who then fills the data. If the validation and call down the chain succeed, the PostRecord* function then takes a ptr to the common data to prevent having to redo the work that was done at validation time. --- layers/core_validation.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index e7201a7d..21d3b077 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -5869,26 +5869,30 @@ ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescript // Ensure the pool contains enough descriptors and descriptor sets to satisfy // an allocation request. Fills requiredDescriptorsByType with the total number // of descriptors of each type required, for later update. -static bool PreCallValidateAllocateDescriptorSets(layer_data *dev_data, const VkDescriptorSetAllocateInfo *pAllocateInfo) { +static bool PreCallValidateAllocateDescriptorSets(layer_data *dev_data, const VkDescriptorSetAllocateInfo *pAllocateInfo, + cvdescriptorset::AllocateDescriptorSetsData *common_data) { // All state checks for AllocateDescriptorSets is done in single function return cvdescriptorset::ValidateAllocateDescriptorSets(dev_data->report_data, pAllocateInfo, dev_data->descriptorSetLayoutMap, - dev_data->descriptorPoolMap); + dev_data->descriptorPoolMap, common_data); } // Allocation state was good and call down chain was made so update state based on allocating descriptor sets static void PostCallRecordAllocateDescriptorSets(layer_data *dev_data, const VkDescriptorSetAllocateInfo *pAllocateInfo, - VkDescriptorSet *pDescriptorSets) { + VkDescriptorSet *pDescriptorSets, + const cvdescriptorset::AllocateDescriptorSetsData *common_data) { // All the updates are contained in a single cvdescriptorset function cvdescriptorset::PerformAllocateDescriptorSets( - pAllocateInfo, pDescriptorSets, &dev_data->descriptorPoolMap, &dev_data->setMap, dev_data->descriptorSetLayoutMap, - dev_data->bufferMap, dev_data->memObjMap, dev_data->bufferViewMap, dev_data->samplerMap, dev_data->imageViewMap, - dev_data->imageMap, dev_data->device_extensions.imageToSwapchainMap, dev_data->device_extensions.swapchainMap); + pAllocateInfo, pDescriptorSets, common_data, &dev_data->descriptorPoolMap, &dev_data->setMap, + dev_data->descriptorSetLayoutMap, dev_data->bufferMap, dev_data->memObjMap, dev_data->bufferViewMap, dev_data->samplerMap, + dev_data->imageViewMap, dev_data->imageMap, dev_data->device_extensions.imageToSwapchainMap, + dev_data->device_extensions.swapchainMap); } VKAPI_ATTR VkResult VKAPI_CALL AllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, VkDescriptorSet *pDescriptorSets) { layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); std::unique_lock lock(global_lock); - bool skip_call = PreCallValidateAllocateDescriptorSets(dev_data, pAllocateInfo); + cvdescriptorset::AllocateDescriptorSetsData common_data(pAllocateInfo->descriptorSetCount); + bool skip_call = PreCallValidateAllocateDescriptorSets(dev_data, pAllocateInfo, &common_data); lock.unlock(); if (skip_call) @@ -5898,7 +5902,7 @@ AllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllo if (VK_SUCCESS == result) { lock.lock(); - PostCallRecordAllocateDescriptorSets(dev_data, pAllocateInfo, pDescriptorSets); + PostCallRecordAllocateDescriptorSets(dev_data, pAllocateInfo, pDescriptorSets, &common_data); lock.unlock(); } return result; -- cgit v1.2.3