Jump to content
  • Advertisement
Sign in to follow this  
slayemin

XNA: When does "stuff" go into VRAM?

This topic is 2140 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm going to be generating a lot of primitives and meshes programmatically. For example, a huge terrain object which is based off of a height map. This terrain object will have thousands and thousands of verticies. Let's assume that I've got the height map and it's able to fill a vertex buffer in RAM with all of the pertinent vertex information. Now, I need to draw it. To do that, I'd call something like this:
 

public void Render()
{
     foreach (EffectPass pass in m_effect.CurrentTechnique.Passes)
     {
          pass.Apply();
          m_gd.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList,
          m_verticies, 0, 4, m_indicies, 0, 2);
     }
}

In this case, all of the verticies are stored inside of a "VertexPositionNormalTexture[] m_verticies" array. By calling the "DrawUserIndexedPrimitives", I'm assuming that in this render frame, it's copying the data from RAM into VRAM and the graphics card takes over the rendering from there. However, if my verticies don't ever change, it seems like it'd be a waste of RAM->VRAM bandwidth to keep copying the same data every frame. It'd be better if I could store the data directly on the graphics card as some sort of object in VRAM and then tell the graphics card when I want to render the stored object. Ideally, if I ever need to update the object in VRAM, I could do it on my own time instead of updating every object every frame. I feel like this is totally possible but none of the XNA documentation gives any hints at how to do it. My initial thought was that I could convert my user created primitive into a mesh object and then store the mesh in VRAM and render it like a mesh object, but I don't know how to do this either (documentation isn't helpful). I'm wondering if its possible or if this is just a limitation of the XNA API?

 

Share this post


Link to post
Share on other sites
Advertisement
You're right: You're burning bandwidth for no reason. You want to explicitly use a VertexBuffer and IndexBuffer (or several of them). Here's a tutorial.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!