From 357c9a73fdda5af11ac23413429a31b161bbeb25 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 25 Aug 2017 11:19:39 -0700 Subject: Revert "Revert "layers: Introduce some unique_ptr into pipeline creation"" This reverts commit 5d6aaa553b634747fb2761c6e5b665bdae54d206. --- layers/core_validation.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 9a6dd942..d6749ef4 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -1182,10 +1182,10 @@ static bool verifyLineWidth(layer_data *dev_data, DRAW_STATE_ERROR dsError, Vulk return skip; } -static bool ValidatePipelineLocked(layer_data *dev_data, std::vector const &pPipelines, int pipelineIndex) { +static bool ValidatePipelineLocked(layer_data *dev_data, std::vector> const &pPipelines, int pipelineIndex) { bool skip = false; - PIPELINE_STATE *pPipeline = pPipelines[pipelineIndex]; + PIPELINE_STATE *pPipeline = pPipelines[pipelineIndex].get(); // If create derivative bit is set, check that we've specified a base // pipeline correctly, and that the base pipeline was created to allow @@ -1206,7 +1206,7 @@ static bool ValidatePipelineLocked(layer_data *dev_data, std::vectorgraphicsPipelineCI.basePipelineIndex]; + pBasePipeline = pPipelines[pPipeline->graphicsPipelineCI.basePipelineIndex].get(); } } else if (pPipeline->graphicsPipelineCI.basePipelineHandle != VK_NULL_HANDLE) { pBasePipeline = getPipelineState(dev_data, pPipeline->graphicsPipelineCI.basePipelineHandle); @@ -1223,10 +1223,10 @@ static bool ValidatePipelineLocked(layer_data *dev_data, std::vector* maps in this function. -static bool ValidatePipelineUnlocked(layer_data *dev_data, std::vector const &pPipelines, int pipelineIndex) { +static bool ValidatePipelineUnlocked(layer_data *dev_data, std::vector> const &pPipelines, int pipelineIndex) { bool skip = false; - PIPELINE_STATE *pPipeline = pPipelines[pipelineIndex]; + PIPELINE_STATE *pPipeline = pPipelines[pipelineIndex].get(); // Ensure the subpass index is valid. If not, then validate_and_capture_pipeline_shader_state // produces nonsense errors that confuse users. Other layers should already @@ -4428,14 +4428,15 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateGraphicsPipelines(VkDevice device, VkPipeli // 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(count); + vector> pipe_state; + pipe_state.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++) { - pipe_state[i] = new PIPELINE_STATE; + pipe_state.push_back(std::unique_ptr(new PIPELINE_STATE)); pipe_state[i]->initGraphicsPipeline(&pCreateInfos[i]); pipe_state[i]->render_pass_ci.initialize(GetRenderPassState(dev_data, pCreateInfos[i].renderPass)->createInfo.ptr()); pipe_state[i]->pipeline_layout = *getPipelineLayout(dev_data, pCreateInfos[i].layout); @@ -4453,7 +4454,6 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateGraphicsPipelines(VkDevice device, VkPipeli if (skip) { for (i = 0; i < count; i++) { - delete pipe_state[i]; pPipelines[i] = VK_NULL_HANDLE; } return VK_ERROR_VALIDATION_FAILED_EXT; @@ -4463,11 +4463,9 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateGraphicsPipelines(VkDevice device, VkPipeli dev_data->dispatch_table.CreateGraphicsPipelines(device, pipelineCache, count, pCreateInfos, pAllocator, pPipelines); lock.lock(); for (i = 0; i < count; i++) { - if (pPipelines[i] == VK_NULL_HANDLE) { - delete pipe_state[i]; - } else { + if (pPipelines[i] != VK_NULL_HANDLE) { pipe_state[i]->pipeline = pPipelines[i]; - dev_data->pipelineMap[pipe_state[i]->pipeline] = pipe_state[i]; + dev_data->pipelineMap[pipe_state[i]->pipeline] = pipe_state[i].release(); } } -- cgit v1.2.3