turnip: Fix failure behavior of vkCreateGraphicsPipelines.
authorEric Anholt <eric@anholt.net>
Thu, 19 Sep 2019 18:09:46 +0000 (11:09 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 27 Sep 2019 20:34:28 +0000 (13:34 -0700)
According to the 1.1.123 spec:

    "The implementation will attempt to create all pipelines, and only
     return VK_NULL_HANDLE values for those that actually failed."

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
src/freedreno/vulkan/tu_pipeline.c

index 49ce5d2710895024999fcaff0396a0013b4d73a4..2acf55564341e6fae18758605615aa4c6f1ef704 100644 (file)
@@ -1876,6 +1876,7 @@ tu_CreateGraphicsPipelines(VkDevice device,
 {
    TU_FROM_HANDLE(tu_device, dev, device);
    TU_FROM_HANDLE(tu_pipeline_cache, cache, pipelineCache);
+   VkResult final_result = VK_SUCCESS;
 
    for (uint32_t i = 0; i < count; i++) {
       struct tu_pipeline_builder builder;
@@ -1886,19 +1887,15 @@ tu_CreateGraphicsPipelines(VkDevice device,
       VkResult result = tu_pipeline_builder_build(&builder, &pipeline);
       tu_pipeline_builder_finish(&builder);
 
-      if (result != VK_SUCCESS) {
-         for (uint32_t j = 0; j < i; j++) {
-            tu_DestroyPipeline(device, pPipelines[j], pAllocator);
-            pPipelines[j] = VK_NULL_HANDLE;
-         }
-
-         return result;
+      if (result == VK_SUCCESS) {
+         pPipelines[i] = tu_pipeline_to_handle(pipeline);
+      } else {
+         pPipelines[i] = NULL;
+         final_result = result;
       }
-
-      pPipelines[i] = tu_pipeline_to_handle(pipeline);
    }
 
-   return VK_SUCCESS;
+   return final_result;
 }
 
 static VkResult