Skip to content

Commit

Permalink
Try to detect failed syncs and display appropriate error message
Browse files Browse the repository at this point in the history
  • Loading branch information
fholger committed Jan 26, 2025
1 parent a01bc71 commit fdc27a0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Code/VR/VRManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,15 +1337,35 @@ void VRManager::AcquireTextureSync(ID3D10Texture2D* target, int key)
if (target == nullptr) return;
ComPtr<IDXGIKeyedMutex> mutex;
target->QueryInterface(__uuidof(IDXGIKeyedMutex), (void**)mutex.GetAddressOf());
CHECK_D3D10(mutex->AcquireSync(key, 100));
HRESULT hr = mutex->AcquireSync(key, 100);
if (FAILED(hr))
{
CryLogAlways("Failed to sync D3D10 textures: %i", hr);
++m_numFailedSyncs;
if (m_numFailedSyncs > 200 && !m_shownSyncFailureMessage)
{
MessageBoxA(nullptr, "Cannot sync textures between the game and the VR runtime. If you are using MSI Afterburner / Rivatuner or similar overlays, disable them and restart the game.", "Render error", MB_OK);
m_shownSyncFailureMessage = true;
}
}
}

void VRManager::AcquireTextureSync(ID3D11Texture2D* target, int key)
{
if (target == nullptr) return;
ComPtr<IDXGIKeyedMutex> mutex;
target->QueryInterface(__uuidof(IDXGIKeyedMutex), (void**)mutex.GetAddressOf());
CHECK_D3D10(mutex->AcquireSync(key, 100));
HRESULT hr = mutex->AcquireSync(key, 100);
if (FAILED(hr))
{
CryLogAlways("Failed to sync D3D11 textures: %i", hr);
++m_numFailedSyncs;
if (m_numFailedSyncs > 200 && !m_shownSyncFailureMessage)
{
MessageBoxA(nullptr, "Cannot sync textures between the game and the VR runtime. If you are using MSI Afterburner / Rivatuner or similar overlays, disable them and restart the game.", "Render error", MB_OK);
m_shownSyncFailureMessage = true;
}
}
}

void VRManager::ReleaseTextureSync(ID3D10Texture2D* target, int key)
Expand Down
3 changes: 3 additions & 0 deletions Code/VR/VRManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ class VRManager
ray_hit m_offHandRayHit;
bool m_offHandRayHitAny = false;
EntityId m_pointAtEntityId;

int m_numFailedSyncs = 0;
bool m_shownSyncFailureMessage = false;
};

extern VRManager* gVR;

0 comments on commit fdc27a0

Please sign in to comment.