Skip to content

Commit

Permalink
[D3D11] Add missing synchronization for immediate context in new buff…
Browse files Browse the repository at this point in the history
…er update code.
  • Loading branch information
mellinoe committed Mar 20, 2018
1 parent 8a7ccd3 commit 624f70d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/Veldrid/D3D11/D3D11GraphicsDevice.cs
Expand Up @@ -248,7 +248,10 @@ protected unsafe override void UpdateBufferCore(DeviceBuffer buffer, uint buffer
subregion = null;
}

_immediateContext.UpdateSubresource(d3dBuffer.Buffer, 0, subregion, source, 0, 0);
lock (_immediateContextLock)
{
_immediateContext.UpdateSubresource(d3dBuffer.Buffer, 0, subregion, source, 0, 0);
}
}
else if (useMap)
{
Expand All @@ -272,10 +275,13 @@ protected unsafe override void UpdateBufferCore(DeviceBuffer buffer, uint buffer
D3D11Buffer staging = GetFreeStagingBuffer(sizeInBytes);
UpdateBuffer(staging, 0, source, sizeInBytes);
ResourceRegion sourceRegion = new ResourceRegion(0, 0, 0, (int)sizeInBytes, 1, 1);
_immediateContext.CopySubresourceRegion(
staging.Buffer, 0, sourceRegion,
d3dBuffer.Buffer, 0,
(int)bufferOffsetInBytes, 0, 0);
lock (_immediateContextLock)
{
_immediateContext.CopySubresourceRegion(
staging.Buffer, 0, sourceRegion,
d3dBuffer.Buffer, 0,
(int)bufferOffsetInBytes, 0, 0);
}
_availableStagingBuffers.Add(staging);
}
}
Expand Down

0 comments on commit 624f70d

Please sign in to comment.