Sign in to follow this  

IndexBuffer locking techinques

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

This topic is 4835 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this