[Mesa-dev] [PATCH] radv: only reset command buffers when the allocation fails
Bas Nieuwenhuizen
bas at basnieuwenhuizen.nl
Thu Nov 30 21:52:51 UTC 2017
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
On Thu, Nov 30, 2017 at 10:23 PM, Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
> "vkAllocateCommandBuffers can be used to create multiple command
> buffers. If the creation of any of those command buffers fails, the
> implementation must destroy all successfully created command buffer
> objects from this command, set all entries of the pCommandBuffers
> array to NULL and return the error."
>
> This has been suggested by gabriel at system.is.
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
> src/amd/vulkan/radv_cmd_buffer.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
> index 18a1c55ad1..fe4f989dd1 100644
> --- a/src/amd/vulkan/radv_cmd_buffer.c
> +++ b/src/amd/vulkan/radv_cmd_buffer.c
> @@ -2140,9 +2140,6 @@ VkResult radv_AllocateCommandBuffers(
> VkResult result = VK_SUCCESS;
> uint32_t i;
>
> - memset(pCommandBuffers, 0,
> - sizeof(*pCommandBuffers)*pAllocateInfo->commandBufferCount);
> -
> for (i = 0; i < pAllocateInfo->commandBufferCount; i++) {
>
> if (!list_empty(&pool->free_cmd_buffers)) {
> @@ -2164,10 +2161,23 @@ VkResult radv_AllocateCommandBuffers(
> break;
> }
>
> - if (result != VK_SUCCESS)
> + if (result != VK_SUCCESS) {
> radv_FreeCommandBuffers(_device, pAllocateInfo->commandPool,
> i, pCommandBuffers);
>
> + /* From the Vulkan 1.0.66 spec:
> + *
> + * "vkAllocateCommandBuffers can be used to create multiple
> + * command buffers. If the creation of any of those command
> + * buffers fails, the implementation must destroy all
> + * successfully created command buffer objects from this
> + * command, set all entries of the pCommandBuffers array to
> + * NULL and return the error."
> + */
> + memset(pCommandBuffers, 0,
> + sizeof(*pCommandBuffers) * pAllocateInfo->commandBufferCount);
> + }
> +
> return result;
> }
>
> --
> 2.15.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list