Reputation: 652
I'm implementing asynchronous VkCommandBuffer recording to improve geometry and texture loading in my rendering engine.
I'm facing validation issue about VkFence being in use in two different threads:
UNASSIGNED-Threading-MultipleThreads(ERROR / SPEC): msgNum: 337425955 - Validation Error: [ UNASSIGNED-Threading-MultipleThreads ] Object 0: handle = 0x90a67000000088d3, type = VK_OBJECT_TYPE_FENCE; | MessageID = 0x141cb623 | THREADING ERROR : vkQueueSubmit(): object of type VkFence is simultaneously used in thread 0x3344 and thread 0x2d3c
I've written a minimal example to reproduce my issue here: https://gist.github.com/siliace/fc2633ee2406d3cbc53a60857bb14776
When on line 18, gSubmitBeforeWaitFence
is false
, the worker thread will not wait until the main thread submitted the fence to wait for it, causing my validations errors.
When gSubmitBeforeWaitFence
is true
, everything is fine.
Is it a bug of the validation layer and I should not have to wait for a VkFence to be submitted before waiting for it? Or is it a mistake from me? I would expect vkWaitForFences to be read-only operation so I don't see the point of forbiding this use.
And if my usage is wrong, is it written somewhere in the spec? I could not find it neighter in the documentation of vkQueueSubmut nor vkWaitForFences.
Thanks for your help !
Upvotes: 0
Views: 567
Reputation: 13276
It is not allowed to use a fence while it is being vkQueueSubmit
ed:
Host Synchronization
- Host access to
queue
must be externally synchronized- Host access to
fence
must be externally synchronized
Upvotes: 2