[d3d11] Lock immediate context when submitting presentation commands

Otherwise, a race condition occurs if a game submits rendering commands
at the same time as presenting the swap chain image. Only works if
multithreaded protection is enabled, but according to MSDN, it is
illegal to use DXGI commands and the immediate context in parallel.

Fixes stability issues in Tales of Vesperia.
parent a7b4c299
Pipeline #1000 passed with stage
in 4 minutes and 11 seconds
......@@ -700,6 +700,10 @@ namespace dxvk {
VkImageLayout OldLayout,
VkImageLayout NewLayout);
D3D10DeviceLock LockContext() {
return m_multithread.AcquireLock();
}
protected:
D3D11Device* const m_parent;
......@@ -917,10 +921,6 @@ namespace dxvk {
return pShader != nullptr ? pShader->GetCommonShader() : nullptr;
}
D3D10DeviceLock LockContext() {
return m_multithread.AcquireLock();
}
template<typename Cmd>
void EmitCs(Cmd&& command) {
m_cmdData = nullptr;
......
......@@ -368,6 +368,8 @@ namespace dxvk {
D3D11ImmediateContext* pContext,
const vk::PresenterSync& Sync,
uint32_t FrameId) {
auto lock = pContext->LockContext();
// Present from CS thread so that we don't
// have to synchronize with it first.
m_presentStatus.result = VK_NOT_READY;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment