1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 14:52:11 +01:00

[d3d11] Synchronize shared texture initialization

This commit is contained in:
Philip Rebohle 2024-09-26 08:16:11 +02:00
parent 97091aad39
commit 15365f2d82
2 changed files with 25 additions and 7 deletions

View File

@ -50,7 +50,7 @@ namespace dxvk {
else
InitDeviceLocalTexture(pTexture, pInitialData);
SyncKeyedMutex(pTexture->GetInterface());
SyncSharedTexture(pTexture);
}
@ -287,13 +287,30 @@ namespace dxvk {
}
void D3D11Initializer::SyncKeyedMutex(ID3D11Resource *pResource) {
Com<IDXGIKeyedMutex> keyedMutex;
if (pResource->QueryInterface(__uuidof(IDXGIKeyedMutex), reinterpret_cast<void**>(&keyedMutex)) != S_OK)
void D3D11Initializer::SyncSharedTexture(D3D11CommonTexture* pResource) {
if (!(pResource->Desc()->MiscFlags & (D3D11_RESOURCE_MISC_SHARED | D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX | D3D11_RESOURCE_MISC_SHARED_NTHANDLE)))
return;
keyedMutex->AcquireSync(0, 0);
keyedMutex->ReleaseSync(0);
// 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->ReleaseSync(0);
}
}
}

View File

@ -71,7 +71,8 @@ namespace dxvk {
void FlushImplicit();
void FlushInternal();
void SyncKeyedMutex(ID3D11Resource *pResource);
void SyncSharedTexture(
D3D11CommonTexture* pResource);
};