summaryrefslogtreecommitdiffstats
path: root/src/intel/vulkan/genX_pipeline.c
diff options
context:
space:
mode:
authorLionel Landwerlin <[email protected]>2016-12-23 17:47:40 +0000
committerLionel Landwerlin <[email protected]>2017-01-05 21:09:09 +0000
commita8eeb089c0e2e171ffaf8cba3cd0e5aea97b388f (patch)
tree6185ed5db6d28bb459dad2957faf456117249ac4 /src/intel/vulkan/genX_pipeline.c
parent33fa4c99f7fa68fd8c33c75c4fe66c4cca76779f (diff)
anv: fix multiple creation with internal failure
The specification section 9.4 says : When an application attempts to create many pipelines in a single command, it is possible that some subset may fail creation. In that case, the corresponding entries in the pPipelines output array will be filled with VK_NULL_HANDLE values. If any pipeline fails creation (for example, due to out of memory errors), the vkCreate*Pipelines commands will return an error code. The implementation will attempt to create all pipelines, and only return VK_NULL_HANDLE values for those that actually failed. Fixes : dEQP-VK.api.object_management.alloc_callback_fail_multiple.graphics_pipeline dEQP-VK.api.object_management.alloc_callback_fail_multiple.compute_pipeline v2: C is hard let's go shopping (Lionel) v3: Remove unnecessary condition in for loops (Lionel) v4: Document why we return on first failure (Eduardo) Move i declaration inside for() (Eduardo) v5: Move array cleanup out of loop (Jason) Signed-off-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel/vulkan/genX_pipeline.c')
-rw-r--r--src/intel/vulkan/genX_pipeline.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c
index 845d0204d8c..9ff84cd2921 100644
--- a/src/intel/vulkan/genX_pipeline.c
+++ b/src/intel/vulkan/genX_pipeline.c
@@ -1469,22 +1469,23 @@ VkResult genX(CreateGraphicsPipelines)(
VkResult result = VK_SUCCESS;
- unsigned i = 0;
- for (; i < count; i++) {
+ unsigned i;
+ for (i = 0; i < count; i++) {
result = genX(graphics_pipeline_create)(_device,
pipeline_cache,
&pCreateInfos[i],
pAllocator, &pPipelines[i]);
- if (result != VK_SUCCESS) {
- for (unsigned j = 0; j < i; j++) {
- anv_DestroyPipeline(_device, pPipelines[j], pAllocator);
- }
- return result;
- }
+ /* Bail out on the first error as it is not obvious what error should be
+ * report upon 2 different failures. */
+ if (result != VK_SUCCESS)
+ break;
}
- return VK_SUCCESS;
+ for (; i < count; i++)
+ pPipelines[i] = VK_NULL_HANDLE;
+
+ return result;
}
VkResult genX(CreateComputePipelines)(
@@ -1499,19 +1500,20 @@ VkResult genX(CreateComputePipelines)(
VkResult result = VK_SUCCESS;
- unsigned i = 0;
- for (; i < count; i++) {
+ unsigned i;
+ for (i = 0; i < count; i++) {
result = compute_pipeline_create(_device, pipeline_cache,
&pCreateInfos[i],
pAllocator, &pPipelines[i]);
- if (result != VK_SUCCESS) {
- for (unsigned j = 0; j < i; j++) {
- anv_DestroyPipeline(_device, pPipelines[j], pAllocator);
- }
- return result;
- }
+ /* Bail out on the first error as it is not obvious what error should be
+ * report upon 2 different failures. */
+ if (result != VK_SUCCESS)
+ break;
}
- return VK_SUCCESS;
+ for (; i < count; i++)
+ pPipelines[i] = VK_NULL_HANDLE;
+
+ return result;
}