Skip to main content
GameDev.net gamedev.net
🔒 Locked

Optimal buffer size

Started by Aqua Costa Nov 15, 2011 at 8:02 PM 2 replies 2.4k views
Original Post
Aqua Costa
Aqua Costa
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.
MJP
MJP
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.
L. Spiro
L. Spiro
I can't find the original sources I had, but managed to find these:

http://developer.amd.com/media/gpu_assets/PerformanceTuning.pdf
vertex size ideally multiples of 32 bytes[/quote]

http://www.opengl.org/wiki/Vertex_Buffer_Object
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]

http://msdn.microsoft.com/en-us/library/windows/desktop/bb147263(v=vs.85).aspx#General_Performance_Tips
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:
http://forums.create.msdn.com/forums/t/94118.aspx
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
I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid
dpadam450
dpadam450
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.
NBA2K, Madden, Maneater, Killing Floor, Sims 

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.