Revert "layers: unique_ptr for temp compute pipelines"
authorChris Forbes <chrisforbes@google.com>
Fri, 25 Aug 2017 16:37:28 +0000 (09:37 -0700)
committerChris Forbes <chrisforbes@google.com>
Fri, 25 Aug 2017 16:37:28 +0000 (09:37 -0700)
This reverts commit cfc1ed15584a12ef62e113c8daf673c6a68ce29c.

layers/core_validation.cpp

index b3e07ac..d6749ef 100644 (file)
@@ -4421,11 +4421,13 @@ 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<std::unique_ptr<PIPELINE_STATE>> pipe_state;
     pipe_state.reserve(count);
     layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
@@ -4475,24 +4477,28 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateComputePipelines(VkDevice device, VkPipelin
                                                       const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) {
     bool skip = false;
 
-    vector<std::unique_ptr<PIPELINE_STATE>> pPipeState;
-    pPipeState.reserve(count);
+    // TODO : Improve this data struct w/ unique_ptrs so cleanup below is automatic
+    vector<PIPELINE_STATE *> pPipeState(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.push_back(unique_ptr<PIPELINE_STATE>(new PIPELINE_STATE));
+        pPipeState[i] = 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].get());
+        skip |= validate_compute_pipeline(dev_data, pPipeState[i]);
     }
 
     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;
@@ -4503,9 +4509,11 @@ 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) {
+        if (pPipelines[i] == VK_NULL_HANDLE) {
+            delete pPipeState[i];
+        } else {
             pPipeState[i]->pipeline = pPipelines[i];
-            dev_data->pipelineMap[pPipeState[i]->pipeline] = pPipeState[i].release();
+            dev_data->pipelineMap[pPipeState[i]->pipeline] = pPipeState[i];
         }
     }