Fix GPU Buffer Map/Unmap pair to prevent stall if map fails on DX11

#942
This commit is contained in:
Wojtek Figat
2023-02-17 16:28:48 +01:00
parent 5dc63da4bf
commit 679757942f
7 changed files with 19 additions and 16 deletions

View File

@@ -48,18 +48,19 @@ void* GPUBufferDX11::Map(GPUResourceMapMode mode)
const HRESULT result = _device->GetIM()->Map(_resource, 0, mapType, mapFlags, &map);
if (result != DXGI_ERROR_WAS_STILL_DRAWING)
LOG_DIRECTX_RESULT(result);
_mapped = map.pData != nullptr;
if (!_mapped && !isMainThread)
_device->Locker.Unlock();
return map.pData;
}
void GPUBufferDX11::Unmap()
{
if (_mapped)
{
_mapped = false;
_device->GetIM()->Unmap(_resource, 0);
}
ASSERT(_mapped);
_mapped = false;
_device->GetIM()->Unmap(_resource, 0);
if (!IsInMainThread())
_device->Locker.Unlock();
}