anv/meta: Improve meta clear cleanup a bit
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 18 Jan 2016 22:07:46 +0000 (14:07 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 18 Jan 2016 22:07:46 +0000 (14:07 -0800)
src/vulkan/anv_meta.c
src/vulkan/anv_meta_clear.c

index a02bfed5af36ac20eb58cef4b9193405f2aaacf4..87728943190b320aa04e000d3afcbd5910030f5a 100644 (file)
@@ -1448,8 +1448,10 @@ anv_device_init_meta(struct anv_device *device)
       return result;
 
    result = anv_device_init_meta_blit_state(device);
-   if (result != VK_SUCCESS)
+   if (result != VK_SUCCESS) {
+      anv_device_finish_meta_clear_state(device);
       return result;
+   }
 
    return VK_SUCCESS;
 }
index 8d93ced9ccf811d38dba656a4770eb5f018aee08..0c4b740da24d29217db0690abf0d6351aea0fb38 100644 (file)
@@ -303,6 +303,21 @@ create_color_pipeline(struct anv_device *device, uint32_t frag_output,
                       /*use_repclear*/ false, pipeline);
 }
 
+static void
+free_color_pipelines(struct anv_device *device)
+{
+   for (uint32_t i = 0;
+        i < ARRAY_SIZE(device->meta_state.clear.color_pipelines); ++i) {
+      if (device->meta_state.clear.color_pipelines[i] == NULL)
+         continue;
+
+      ANV_CALL(DestroyPipeline)(
+         anv_device_to_handle(device),
+         anv_pipeline_to_handle(device->meta_state.clear.color_pipelines[i]),
+         &device->meta_state.alloc);
+   }
+}
+
 static VkResult
 init_color_pipelines(struct anv_device *device)
 {
@@ -321,14 +336,7 @@ init_color_pipelines(struct anv_device *device)
    return VK_SUCCESS;
 
 fail:
-   for (uint32_t i = 0; i < n; ++i) {
-      if (pipelines[i] == NULL)
-         break;
-
-      anv_DestroyPipeline(anv_device_to_handle(device),
-                          anv_pipeline_to_handle(pipelines[i]),
-                          &device->meta_state.alloc);
-   }
+   free_color_pipelines(device);
 
    return result;
 }
@@ -677,8 +685,10 @@ anv_device_init_meta_clear_state(struct anv_device *device)
       return result;
 
    result = init_depthstencil_pipelines(device);
-   if (result != VK_SUCCESS)
+   if (result != VK_SUCCESS) {
+      free_color_pipelines(device);
       return result;
+   }
 
    return VK_SUCCESS;
 }
@@ -688,12 +698,7 @@ anv_device_finish_meta_clear_state(struct anv_device *device)
 {
    VkDevice device_h = anv_device_to_handle(device);
 
-   for (uint32_t i = 0;
-        i < ARRAY_SIZE(device->meta_state.clear.color_pipelines); ++i) {
-      ANV_CALL(DestroyPipeline)(device_h,
-         anv_pipeline_to_handle(device->meta_state.clear.color_pipelines[i]),
-         NULL);
-   }
+   free_color_pipelines(device);
 
    ANV_CALL(DestroyPipeline)(device_h,
       anv_pipeline_to_handle(device->meta_state.clear.depth_only_pipeline),