From 9f83d48d98f8fdc8d8dfb6ca3129d8d4c3425dce Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 25 Aug 2017 11:19:44 -0700 Subject: Revert "Revert "layers: unique_ptr for temp compute pipelines"" This reverts commit 615dc4e3ea0495bc28130377b9e637e9979a560e. --- layers/core_validation.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index d6749ef4..b3e07acb 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -4421,13 +4421,11 @@ bool validate_dual_src_blend_feature(layer_data *device_data, PIPELINE_STATE *pi VKAPI_ATTR VkResult VKAPI_CALL CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t count, const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) { - // TODO What to do with pipelineCache? // The order of operations here is a little convoluted but gets the job done // 1. Pipeline create state is first shadowed into PIPELINE_STATE struct // 2. Create state is then validated (which uses flags setup during shadowing) // 3. If everything looks good, we'll then create the pipeline and add NODE to pipelineMap bool skip = false; - // TODO : Improve this data struct w/ unique_ptrs so cleanup below is automatic vector> pipe_state; pipe_state.reserve(count); layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); @@ -4477,28 +4475,24 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateComputePipelines(VkDevice device, VkPipelin const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) { bool skip = false; - // TODO : Improve this data struct w/ unique_ptrs so cleanup below is automatic - vector pPipeState(count); + vector> pPipeState; + pPipeState.reserve(count); layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); uint32_t i = 0; unique_lock_t lock(global_lock); for (i = 0; i < count; i++) { - // TODO: Verify compute stage bits - // Create and initialize internal tracking data structure - pPipeState[i] = new PIPELINE_STATE; + pPipeState.push_back(unique_ptr(new PIPELINE_STATE)); pPipeState[i]->initComputePipeline(&pCreateInfos[i]); pPipeState[i]->pipeline_layout = *getPipelineLayout(dev_data, pCreateInfos[i].layout); // TODO: Add Compute Pipeline Verification - skip |= validate_compute_pipeline(dev_data, pPipeState[i]); + skip |= validate_compute_pipeline(dev_data, pPipeState[i].get()); } if (skip) { for (i = 0; i < count; i++) { - // Clean up any locally allocated data structures - delete pPipeState[i]; pPipelines[i] = VK_NULL_HANDLE; } return VK_ERROR_VALIDATION_FAILED_EXT; @@ -4509,11 +4503,9 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateComputePipelines(VkDevice device, VkPipelin dev_data->dispatch_table.CreateComputePipelines(device, pipelineCache, count, pCreateInfos, pAllocator, pPipelines); lock.lock(); for (i = 0; i < count; i++) { - if (pPipelines[i] == VK_NULL_HANDLE) { - delete pPipeState[i]; - } else { + if (pPipelines[i] != VK_NULL_HANDLE) { pPipeState[i]->pipeline = pPipelines[i]; - dev_data->pipelineMap[pPipeState[i]->pipeline] = pPipeState[i]; + dev_data->pipelineMap[pPipeState[i]->pipeline] = pPipeState[i].release(); } } -- cgit v1.2.3