Jump to content
  • Advertisement
Sign in to follow this  
Aqua Costa

Optimal buffer size

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

Hi, I'm searching for info about optimal buffers size and padding.

Regarding size:
[font="Arial"]During a Lecture with Uncharted 3 Lead Technical Artist[/font] (its a long lecture like 3 hours but its talks about some interesting aspects of game design) it is said that (at least on Naughty Dog engine or the PS3 system) there is a number of vertices that are "optimal", like if you draw less vertices than that number you get exactly the same performance, so if you have a mesh that contains less than that number of vertices you can add more vertices to increase detail because performance wont suffer. And I was wondering if DirectX 11 has something like this?

Regarding padding:
In a post on L.Spiro blog (on the end of his post) he says that
"Direct3D gains a lot of performance (and is more stable) when the vertices within the vertex buffers are padded to 32 bytes."[/quote]
Well I haven't read this anywhere else so I was wondering how this works.

Thanks in advance.

Share this post

Link to post
Share on other sites
PS3 has all kinds of special-case performance considerations, due to the particulars of the hardware. For instance, Nvidia G7x GPU's had dedicated hardware for executing vertex shaders and fragment shaders, and if you didn't saturate both then the hardware would idle. Modern GPU's use the same hardware for all kinds of shaders, and will automatically load balance. So I would be careful not to take what they say out of context.

Share this post

Link to post
Share on other sites
I can't find the original sources I had, but managed to find these:

vertex size ideally multiples of 32 bytes[/quote]

ATI suggests that you align your vertex size for 32 bytes, so I added 4 floats to make it 2 * 32 bytes. For nVidia, I think it doesn't matter[/quote]

If your application needs random access into the vertex buffer in AGP memory, choose a vertex format size that is a multiple of 32 bytes. Otherwise, select the smallest appropriate format.[/quote]

And finally:
Shawn correctly points out that it can depend on a lot of things and you should run your own tests.

I ran my own tests and found that it helps DirectX tremendously with my hardware.
Even my vertex-only buffer (12 bytes) was faster when padded all the way to 32 bytes.
I also tried 16-byte pads instead, but still slower than 32 bytes.

On the other hand, OpenGL showed only slow-down from the padding, and I ultimately left them non-padded.
These results was consistent over various cards I have, which include both ATI and NVidia.

In one article I can't find know, it was stated that 32 bytes is the standard native GPU cache size unit.

L. Spiro

Share this post

Link to post
Share on other sites
I had this discussion with some artists on polycount. Essentially to send a single command from your cpu to your gpu takes some time: X

If I draw 2 models: I sent the draw command. The GPU starts drawing. If it draws and finishes before receiving the next command, then I can give it more work to do with the first model because the GPU is doing nothing while waiting for the second command. So imagine you have 1 triangle, it draws in say .000001 seconds and a GPU command takes .000002 seconds to reach the GPU, then you should draw at least 2 triangles. There is an nvidia presentation you can search like "Batching triangles on the GPU"

The issue I have with that comment is that when your object is drawn really close up, your GPU does more work because it draws more pixels. Or if you render your game at a higher resolution, then everything draws bigger. Since the vertex/pixel shaders are shared, then your performance is ever changing in a dynamic world.

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!