This repository was archived by the owner on Mar 30, 2019. It is now read-only.
This repository was archived by the owner on Mar 30, 2019. It is now read-only.
Data overwritten in MapSubresource() method #825
Open
Description
I am trying to dynamically update the vertex buffer, once every time I call the following method, where context is the device context member.
public void UpdateVertexBuffer(ScatterVertex data)
{
DataBox dataBox =
this.context.MapSubresource(
scatterPointVertexBuffer,
0,
D3D11.MapMode.WriteNoOverwrite,
D3D11.MapFlags.None
);
var pointer = dataBox.DataPointer;
pointer = Utilities.WriteAndPosition(pointer, ref data);
this.context.UnmapSubresource(scatterPointVertexBuffer, 0);
}
I am expecting to keep the old data during the update process. However each time I call this method, the previous data is overwritten. I checked the pointer of dataBox.DataPointer and it remains the same value in every call. But shouldn't the MapSubresource method protect the old data if I choose the WriteNoOverwrite mode?
What should I do to keep the previous data during update?