Module: Mesa
Branch: staging/21.3
Commit: f591ecb5105f04e7967b9c670942eab51d7f1343
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f591ecb5105f04e7967b9c670942eab51d7f1343

Author: Jason Ekstrand <[email protected]>
Date:   Tue Feb  8 16:04:34 2022 -0600

anv: Call vk_command_buffer_finish if create fails

This wasn't much of a problem before because vk_command_buffer_finish()
doesn't do much on an empty command buffer.  However, it's about to be
responsible for managing the pool's list of command buffers so it will
be critical to get this right.

Fixes: c9189f481353 ("anv: Use a common vk_command_buffer structure")
Reviewed-by: Lionel Landwerlin <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14917>
(cherry picked from commit 7b0e30685446d30aaea1c2c7c1fd04a658c74d94)

---

 .pick_status.json                 | 2 +-
 src/intel/vulkan/anv_cmd_buffer.c | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index e8b561e4284..3a8b28c1fc4 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -2380,7 +2380,7 @@
         "description": "anv: Call vk_command_buffer_finish if create fails",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "c9189f4813534b9525babdee09e95f53f025608a"
     },
diff --git a/src/intel/vulkan/anv_cmd_buffer.c 
b/src/intel/vulkan/anv_cmd_buffer.c
index 48571622707..a58a12eba9d 100644
--- a/src/intel/vulkan/anv_cmd_buffer.c
+++ b/src/intel/vulkan/anv_cmd_buffer.c
@@ -275,7 +275,7 @@ static VkResult anv_create_cmd_buffer(
 
    result = vk_command_buffer_init(&cmd_buffer->vk, &device->vk);
    if (result != VK_SUCCESS)
-      goto fail;
+      goto fail_alloc;
 
    cmd_buffer->batch.status = VK_SUCCESS;
 
@@ -285,7 +285,7 @@ static VkResult anv_create_cmd_buffer(
 
    result = anv_cmd_buffer_init_batch_bo_chain(cmd_buffer);
    if (result != VK_SUCCESS)
-      goto fail;
+      goto fail_vk;
 
    anv_state_stream_init(&cmd_buffer->surface_state_stream,
                          &device->surface_state_pool, 4096);
@@ -306,7 +306,9 @@ static VkResult anv_create_cmd_buffer(
 
    return VK_SUCCESS;
 
- fail:
+ fail_vk:
+   vk_command_buffer_finish(&cmd_buffer->vk);
+ fail_alloc:
    vk_free2(&device->vk.alloc, &pool->alloc, cmd_buffer);
 
    return result;

Reply via email to