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

@@ -377,12 +377,9 @@ void GPUBuffer::SetData(const void* data, uint32 size)
Log::ArgumentOutOfRangeException(TEXT("Buffer.SetData"));
return;
}
void* mapped = Map(GPUResourceMapMode::Write);
if (!mapped)
{
return;
}
Platform::MemoryCopy(mapped, data, size);
Unmap();
}

View File

@@ -190,6 +190,7 @@ public:
/// <summary>
/// Gets a CPU pointer to the resource by mapping its contents. Denies the GPU access to that resource.
/// </summary>
/// <remarks>Always call Unmap if the returned pointer is valid to release resources.</remarks>
/// <param name="mode">The map operation mode.</param>
/// <returns>The pointer of the mapped CPU buffer with resource data or null if failed.</returns>
API_FUNCTION() virtual void* Map(GPUResourceMapMode mode) = 0;