Reputation: 14466
vkUpdateDescriptorSets updates the descriptor instantly, so it seems to me that it's doing a write across PCI-E to write to device-local memory. I think this is what's happening as there's no concept of the descriptor writes being available "by the next command", it's immediate, so I think this must be taking place. My question is that if you have a case where you do:
vkUpdateDescriptorSets();
vkCmdDraw();
And then submit the command buffer to a queue, you're essentially doing the transfer/write to GPU twice. However since you generally don't need the descriptors updated until you submit further commands I'm wondering if we can have greater control of this? I've seen there's an extension vkCmdPushDescriptorSetKHR, which I think does what I want, but according to this answer AMD drivers don't support it.
Is my concept about this right? I mean, for the descriptors writes to be made immediately then what must be happening essentially is an extra HOST-GPU synchronisation, right?
Upvotes: 1
Views: 343
Reputation: 474546
And then submit the command buffer to a queue, you're essentially doing the transfer/write to GPU twice.
The result of that depends on whether you're using descriptor indexing or not. If you're not using VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT
on the binding(s) being modified, then you have undefined behavior. Outside of the protections provided by that flag, you are specifically disallowed from modifying any descriptor set which is bound to any command buffer until all CBs in which the descriptor set is bound have completed execution.
So, does this mean that updating a descriptor set performs some kind of immediate memory transfer to GPU-accessible memory? Or does binding the descriptor set cause the transfer? Or does something else entirely happen?
It doesn't matter. Unless you're using descriptor indexing, you are not allowed to modify a bound descriptor set. And if you are using descriptor indexing, you still cannot modify a descriptor set that's being used. It simply changes the definition of "used" to "is part of a command buffer that was submitted." Exactly how those changes happen is up to the implementation.
Upvotes: 2