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

disable padding for VBO?

Started by Bow_vernon Oct 22, 2011 at 5:24 PM 3 replies 1.2k views
Original Post
Bow_vernon
Bow_vernon
Hi I'm learning to use VBO (again) now, as I never had time to learn on that one. I wonder if I should disable padding in my custom vertex structure for the VBO to work....something like

#include <pshpack1.h>
//blah blah vertex structure
struct MyVert
{
float u1,v1;
float x,y,z;
};
#include <poppack.h>


I know the compiler would pad the structure otherwise, but will the opengl work fine with it? thanks before
Brother Bob
Brother Bob
That structure won't contain any padding, and even if a structure contains padding in general, the padding will be beneficial for the VBO as well. Removing the automatic padding costs you unaligned memory accesses, which may be bad for the VBO as well.
21st Century Moose
21st Century Moose
As always, until you've definitively proven that it's a problem, don't do it. When you're learning something new is not the time to start complicating things by introducing optimizations, even optimizations that are not of dubious benefit. You're introducing too many variable factors, and if something goes wrong you're reducing your chances of being able to fix it (and of understanding what went wrong). Learn VBOs first, learn how to use them properly, then worry about lower level stuff.
Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls. 
Bow_vernon
Bow_vernon
wow ok, I'll just start writing some code. Thanks guys, I'll come back when I got some problems
V-man
V-man
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"

Topic Locked

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

Sign in to reply to this topic.