Jump to content
  • Advertisement
Sign in to follow this  
OuncleJulien

IndexBuffer locking techinques

This topic is 5054 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

Is it best to lock the index buffer once and fill it with everything you can based on render state and texture? Or is it best to lock the index buffer and fill it with a chunks of indicies based on render state and texture? For example, say I have 3,000 (or any arbitrary number) of triangles all with the same texture and render state: Method 1: lockIndexBuffer() // Use DISCARD fillIndiciesForAll3000TrisAtOnce() unlockIndexBuffer() draw() Method 2: lockIndexBuffer() // Use DISCARD fillIndiciesFor1000Tris() unlockIndexBuffer() lockIndexBuffer() // Use NOOVERWRITE fillIndiciesFor1000Tris() unlockIndexBuffer() lockIndexBuffer() // Use NOOVERWRITE fillIndiciesFor1000Tris() unlockIndexBuffer() draw() Or, Method 3: lockIndexBuffer() // USE DISCARD fillIndiciesFor1000Tris() unlockIndexBuffer() draw() lockIndexBuffer() // Use NOOVERWRITE fillIndiciesFor1000Tris() unlockIndexBuffer() draw() lockIndexBuffer() // Use NOOVERWRITE fillIndiciesFor1000Tris() unlockIndexBuffer() draw() My assumption would be that method 2 is the fastest because it allows you to transfer indicies while processing other triangles on the GPU at the same time. Is this correct? If you have anything else to add please do! =)

Share this post


Link to post
Share on other sites
Advertisement
Well, if each of these 1000 triangles takes up significant GPU time (vertex shaders, pixel shaders, fill rate intensive, etc.) then method 3 would be the best, as it provides maximum parallelism - the time spent in the driver would be much more negligible then method 2.

However, if these 3000 triangles don't take up too much GPU time (entirely dependent on the graphics card) then method 2 would be the best, as the time spent in the driver would be minimized, and you'd still have pretty good parallelism going on.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!