Skip to content
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
@KySpace

Description

@KySpace

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions