vkd3d: Delay adding a command queue to the blocked list until after the op is written.

Otherwise the following sequence can occur:
1. A command queue is added to the blocked list during a Wait() call.
2. An unblocking Signal() occurs on the CPU in another thread, flushing the
   blocked ops, but as no op has been written, the queue is removed from the
   blocked list.
3. The blocked op is written.
3. Another op is queued and the queue is not re-added to the blocked
   list because this only happens for the first op.

World of Warcraft triggers this issue.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Conor McCarthy 2022-07-18 13:08:00 +10:00 committed by Alexandre Julliard
parent a7a4eb95e5
commit c1071fda52

View File

@ -6812,12 +6812,6 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_queue_Wait(ID3D12CommandQueue *if
* where multiple queues alias over the same physical queue, so effectively,
* we need to manage out-of-order submits ourselves. */
if (!command_queue->ops_count)
hr = d3d12_device_add_blocked_command_queues(command_queue->device, &command_queue, 1);
if (FAILED(hr))
goto done;
if (!(op = d3d12_command_queue_require_space_locked(command_queue)))
{
hr = E_OUTOFMEMORY;
@ -6829,6 +6823,11 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_queue_Wait(ID3D12CommandQueue *if
d3d12_fence_incref(fence);
/* Add the queue to the blocked list after writing the op to ensure the queue isn't
* removed again in another thread because it has no ops. */
if (command_queue->ops_count == 1)
hr = d3d12_device_add_blocked_command_queues(command_queue->device, &command_queue, 1);
done:
vkd3d_mutex_unlock(&command_queue->op_mutex);
return hr;