diff options
| author | Chris Forbes <chrisforbes@google.com> | 2017-08-25 11:19:39 -0700 |
|---|---|---|
| committer | Chris Forbes <chrisf@ijw.co.nz> | 2017-08-25 12:15:04 -0700 |
| commit | 357c9a73fdda5af11ac23413429a31b161bbeb25 (patch) | |
| tree | c61891bf3195014c95c7124f820c91c6ad9117ac /layers/core_validation.cpp | |
| parent | 9dc2b64b6ddf16ee1f9da448ce163d5ac09eb323 (diff) | |
| download | usermoji-357c9a73fdda5af11ac23413429a31b161bbeb25.tar.xz | |
Revert "Revert "layers: Introduce some unique_ptr into pipeline creation""
This reverts commit 5d6aaa553b634747fb2761c6e5b665bdae54d206.
Diffstat (limited to 'layers/core_validation.cpp')
| -rw-r--r-- | layers/core_validation.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
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<PIPELINE_STATE *> const &pPipelines, int pipelineIndex) { +static bool ValidatePipelineLocked(layer_data *dev_data, std::vector<std::unique_ptr<PIPELINE_STATE>> 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::vector<PIPELINE_ST "Invalid Pipeline CreateInfo: base pipeline must occur earlier in array than derivative pipeline. %s", validation_error_map[VALIDATION_ERROR_208005a0]); } else { - pBasePipeline = pPipelines[pPipeline->graphicsPipelineCI.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<PIPELINE_ST } // UNLOCKED pipeline validation. DO NOT lookup objects in the layer_data->* maps in this function. -static bool ValidatePipelineUnlocked(layer_data *dev_data, std::vector<PIPELINE_STATE *> const &pPipelines, int pipelineIndex) { +static bool ValidatePipelineUnlocked(layer_data *dev_data, std::vector<std::unique_ptr<PIPELINE_STATE>> 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<PIPELINE_STATE *> pipe_state(count); + vector<std::unique_ptr<PIPELINE_STATE>> 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<PIPELINE_STATE>(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(); } } |
