# How do I draw a high-performanced scatter plot

I am new to DirectX and currently I'm trying to use it for data visualization, to be specific, a 3D scatter plot. There are very limited resources on the internet, and I have read part of Frank D Luna's book as suggested by many. I studied some samples provided by Microsoft and finally have a grasp on how the loops work inside programs.

However, since I need to manipulate a huge amount of data and require performance as much as possible, I run into something that I hardly find reference with current material.

1. Buffer Usage I expect the points I plot to be constant after they are created, but the creation of points happens all the time, should I set the D3D11_USAGE to Default or Dynamic, and which method to call when I need to update the buffer? I have noticed How to use UpdateSubresource and Map/Unmap?, and the presentation https://developer.nvidia.com/sites/default/files/akamai/gamedev/files/gdc12/Efficient_Buffer_Management_McDonald.pdf by NVIDIA. But what should I do if I do need frequent updates of buffer, while no update for each data in the buffer needed?
2. I noticed in the example "Simple Direct3D game" by Microsoft, it seem to rewrite the entire buffer each time it is updated.

        auto objects = m_game->RenderObjects();
for (auto object = objects.begin(); object != objects.end(); object++)
{
(*object)->Render(d3dContext, m_constantBufferChangesEveryPrim.Get());
}


Is it really so? And How should I only add new vertices into the buffer every time updating it?

3. Since the program is expected to run very fast, the buffer is expected to be updated much faster than once per frame. Can I write a method to update the buffer and add a new point into the buffer every time I call it? If I could, can I put it in another thread or is there any better method to realize it?

4. In the example the main loop of the game seems to be in GameMain::StartRenderLoop(), is this loop running once per frame? And what determines the frequency of the loop?

I might have many misconception on frame and rendering, so thank you very much for the patience and answers.

This is called 'dynamic' submission in which you generate vertices on-the-fly and draw them. The more efficient approach is to use 'static' submission where you upload the vertex data to the video card and draw it many times, but most real-world graphics programs are a mix of both.

If you are doing 2D rendering, you should look at Direct2D if that's an option for you.

How to: Use dynamic resources

You could also use the PrimitiveBatch class in the DirectX Tool Kit

• Thanks for your answer. The static submission you mentioned, should it be submitted every frame or for every primitive, and when I draw it, can I only add elements to the current buffer rather than redraw the whole thing? – 王凯越 Kaiyue Wang Oct 19 '16 at 5:23
• Static submission means that data doesn't change at all. For example in a game, the characters and buildings. What you are describing is better suited to dynamic submission. – Chuck Walbourn Oct 19 '16 at 16:16
• Yeah, that's what I thought it would be. But still, is there a way to avoid discarding the previous data in the buffer during dynamic update? And how do I control the update rate? – 王凯越 Kaiyue Wang Oct 20 '16 at 15:25