Use D3D11_MAP_FLAG_DO_NOT_WAIT only from main thread (worker threads can wait for data)

#942
This commit is contained in:
Wojtek Figat
2023-02-17 11:08:12 +01:00
parent 660ecc185b
commit 8b050cf87e
2 changed files with 4 additions and 3 deletions

View File

@@ -19,7 +19,8 @@ GPUBufferView* GPUBufferDX11::View() const
void* GPUBufferDX11::Map(GPUResourceMapMode mode)
{
if (!IsInMainThread())
const bool isMainThread = IsInMainThread();
if (!isMainThread)
_device->Locker.Lock();
ASSERT(!_mapped);
@@ -31,7 +32,7 @@ void* GPUBufferDX11::Map(GPUResourceMapMode mode)
{
case GPUResourceMapMode::Read:
mapType = D3D11_MAP_READ;
if (_desc.Usage == GPUResourceUsage::StagingReadback)
if (_desc.Usage == GPUResourceUsage::StagingReadback && isMainThread)
mapFlags = D3D11_MAP_FLAG_DO_NOT_WAIT;
break;
case GPUResourceMapMode::Write: