Skip to content

Don't end command buffers before resetting them#969

Merged
paulthomson merged 1 commit intogoogle:mainfrom
gfxstrand:fix-cmd-buffer-reset
Nov 12, 2021
Merged

Don't end command buffers before resetting them#969
paulthomson merged 1 commit intogoogle:mainfrom
gfxstrand:fix-cmd-buffer-reset

Conversation

@gfxstrand
Copy link
Contributor

This isn't necessary. The Vulkan spec has only one restriction on the
state of a command buffer when vkResetCommandBuffer is called:

"commandBuffer must not be in the pending state"

So as long as it's not currently waiting to be executed on the GPU, we
can reset it. By contrast, vkEndCommandBuffer is tightly restricted and
can only be called when a command buffer is in the recording state which
it's not guaranteed to be when the guard is destroyed. This fixes a
crash that happens in certain Amber-based Vulkan CTS tests after a
VK_ERROR_DEVICE_LOST because Amber is calling vkEndCommandBuffer on
command buffers that were never begun.

This isn't necessary.  The Vulkan spec has only one restriction on the
state of a command buffer when vkResetCommandBuffer is called:

    "commandBuffer must not be in the pending state"

So as long as it's not currently waiting to be executed on the GPU, we
can reset it.  By contrast, vkEndCommandBuffer is tightly restricted and
can only be called when a command buffer is in the recording state which
it's not guaranteed to be when the guard is destroyed.  This fixes a
crash that happens in certain Amber-based Vulkan CTS tests after a
VK_ERROR_DEVICE_LOST because Amber is calling vkEndCommandBuffer on
command buffers that were never begun.
@paulthomson paulthomson merged commit 02dc821 into google:main Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants