On Tue Jul 4 13:08:35 2023 +0000, Henri Verbeet wrote:
The part that doesn't thrill me is the fact that DXGI still directly
accesses the VkQueue object, which I tend to see as an internal implementation detail to vkd3d. On the other hand it's nice that we don't need new API from vkd3d (even if, in the future, we were to need something other than vkQueueSubmit() and vkQueuePresentKHR()). For what it's worth, it was a fairly explicit design decision early on to expose the underlying Vulkan objects for d3d12 devices and command queues, as well as to allow the creation of d3d12 resources on top of existing Vulkan images, for the purpose of interoperation with other Vulkan code. I.e., the idea is that it should be possible to integrate vkd3d into a larger Vulkan application to draw some parts using the d3d12 API, while everything else is drawn using Vulkan. The internal queueing of command queue operations on the vkd3d level is unfortunate in that regard; ideally we just wouldn't do that. This MR could probably do a better job of explaining why we need to do that in some cases, and what kind of command queue operation sequences could result in out-of-order presentation. If we're going to need to introduce a DXGI worker thread anyway, could we just make vkd3d_acquire_vk_queue() block until there are no longer any operations queued?
We already somewhat discussed that internally, but for the benefit of public archival the behavior of `vkd3d_acquire_vk_queue()` and `vkd3d_release_vk_queue()` was documented in https://gitlab.winehq.org/wine/vkd3d/-/commit/b2a1f6b5e4f59fbc7f91ada7e56563.... I'll implement the behavior recommended there in my next MR.
The reason why it was decided to recommend to explicitly synchronize with an `ID3D12Fence` instead of making `vkd3d_acquire_vk_queue()` block until the queue is empty is because it is believed that the application is better than vkd3d at knowing how long it really makes sense to wait before actually acquiring the queue. In other words, `vkd3d_acquire_vk_queue()` doesn't know which queued operations are really required to be serialized with the queue acquisition.