KhronosGroup / Vulkan-LoaderAndValidationLayers

**Deprecated repository** for Vulkan loader and validation layers
Apache License 2.0
414 stars 172 forks source link

vkDestroyFence validation fails after vkDeviceWaitIdle call if no vkWaitForFences is called #2632

Open PVRDevTech opened 6 years ago

PVRDevTech commented 6 years ago

Short description- reproduction

Application appears to have no other errors. There are two sets of fences synchronising command buffers submissions and command buffer presentation. When cleaning up exiting the application:

Result (Actual)

Standard validation fails with: VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT. VULKAN_LAYER_VALIDATION: Object: 0x1c (Type = 7) | Fence 0x1c is in use. The spec valid usage text states 'All queue submission commands that refer to fence must have completed execution' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkDestroyFence-fence-01120)

Additional info (+Workaround)

If I call vkWaitForFences and vkResetFences after (or before) vkDeviceWaitIdle, and before vkDestroyFances, the validation error goes away.Additional info

I also tried just querying the fence status before destroying:

This also fixes the issue (i.e. it does not throw the validation error), which makes me think that it is just that the layer code has the wrong idea about the fence status reasoning (i.e. not updated by vkDeviceWaitIdle that the fence must be signalled).

Expected (Correct) behaviour

Since vkDeviceWaitIdle has been called, it is expected that all commands have finished executing, hence all the fences are signalled, hence the validation error is incorrect as the fences must be signalled.

Rationale

I assume that vkDeviceWaitIdle should not have returned if the fences were not signalled, as then it would be implied that the corresponding commands are not executed.

Debugging Details

For SDK 1.1.73.0 The failure can become apparent seen around core_validation.cpp:3364: if ((*fence_node)->scope == kSyncScopeInternal && (*fence_node)->state == FENCE_INFLIGHT).

Since If I insert a vkWaitForFences the error goes away, it follows that the layer probably misses the fact that the fence must have been signalled as the device has completed all commands. I think that the vkDeviceWaitIdle command should mark the fences as complete itself, or something to that effect.

Thanks, Gerry