mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-21 13:29:26 +01:00
[d3d11] Synchronize shared texture initialization
This commit is contained in:
parent
97091aad39
commit
15365f2d82
@ -50,7 +50,7 @@ namespace dxvk {
|
|||||||
else
|
else
|
||||||
InitDeviceLocalTexture(pTexture, pInitialData);
|
InitDeviceLocalTexture(pTexture, pInitialData);
|
||||||
|
|
||||||
SyncKeyedMutex(pTexture->GetInterface());
|
SyncSharedTexture(pTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -287,13 +287,30 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void D3D11Initializer::SyncKeyedMutex(ID3D11Resource *pResource) {
|
void D3D11Initializer::SyncSharedTexture(D3D11CommonTexture* pResource) {
|
||||||
Com<IDXGIKeyedMutex> keyedMutex;
|
if (!(pResource->Desc()->MiscFlags & (D3D11_RESOURCE_MISC_SHARED | D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX | D3D11_RESOURCE_MISC_SHARED_NTHANDLE)))
|
||||||
if (pResource->QueryInterface(__uuidof(IDXGIKeyedMutex), reinterpret_cast<void**>(&keyedMutex)) != S_OK)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Ensure that initialization commands are submitted and waited on before
|
||||||
|
// returning control to the application in order to avoid race conditions
|
||||||
|
// in case the texture is used immediately on a secondary device.
|
||||||
|
auto mapMode = pResource->GetMapMode();
|
||||||
|
|
||||||
|
if (mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_NONE
|
||||||
|
|| mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_BUFFER) {
|
||||||
|
FlushInternal();
|
||||||
|
|
||||||
|
m_device->waitForResource(pResource->GetImage(), DxvkAccess::Write);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If a keyed mutex is used, initialize that to the correct state as well.
|
||||||
|
Com<IDXGIKeyedMutex> keyedMutex;
|
||||||
|
|
||||||
|
if (SUCCEEDED(pResource->GetInterface()->QueryInterface(
|
||||||
|
__uuidof(IDXGIKeyedMutex), reinterpret_cast<void**>(&keyedMutex)))) {
|
||||||
keyedMutex->AcquireSync(0, 0);
|
keyedMutex->AcquireSync(0, 0);
|
||||||
keyedMutex->ReleaseSync(0);
|
keyedMutex->ReleaseSync(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -71,7 +71,8 @@ namespace dxvk {
|
|||||||
void FlushImplicit();
|
void FlushImplicit();
|
||||||
void FlushInternal();
|
void FlushInternal();
|
||||||
|
|
||||||
void SyncKeyedMutex(ID3D11Resource *pResource);
|
void SyncSharedTexture(
|
||||||
|
D3D11CommonTexture* pResource);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user