glsl - Vertex Specification Best Practices using OpenGL (Windows) -


i wonder best practice concerning cache management of vertices.

actually, read numerous of articles on topic i'm not convinced yet best choice should use.

i'm coding small 3d rendering engine , goal optimize rendering limiting number of draw calls , of course number of buffer bindings!

until here, gather within single batch vertices of objects sharing same material properties (same lighting model properties , texture). if vbo reallocation fails (gl_out_of_memory), create new vbo store vertices of object. finally, attach each batch vao.

pseudo-code:

for_each vbo in vbo_list {     vbo->bind();      for_each batch in vbo->getattachedbatchlist()     {         batch->bindvao();         {              gldrawxxx(batch->getoffset(), batch->getlength());         }     } } 

everything works technique use efficient 1 ?

i took following article (opengl es - mac): https://developer.apple.com/library/ios/documentation/3ddrawing/conceptual/opengles_programmingguide/techniquesforworkingwithvertexdata/techniquesforworkingwithvertexdata.html

this article advise store interleaved vertex data below (for 3 given vertices):

vntvntvnt 

in case use following pattern:

vvvnnnttt 

another article on subject: https://www.opengl.org/wiki/vertex_specification_best_practices

according you, best choice in case ?

and have interrogation according vertex data alignement (the topic covered first article). said "avoid misaligned vertex data". apparently, advise relevant case vntvntvnt.

for example, if case best choice following structure declaration should correct:

struct vertex {      float x, y, z;    //12 bytes      float nx, ny, nz; //12 bytes      float s, t;       //8 bytes }; 

in case sizeof(vertex) = 32 bytes multiple of 4 bytes!

if add color components r, g, b:

struct vertex {      float x, y, z;    //12 bytes      float nx, ny, nz; //12 bytes      float r, g, b;    //12 bytes      float s, t;       //8 bytes }; 

we've 44 bytes multiple of 4 bytes!

so according article, if store data way shouldn't have misaligned data problem.

in conclusion: pseudo-code correct ? correct wait gl_out_of_memory exception create new vbo? better respect maximum size of allocation ? , best way store data (interleaved or not) , data alignment proposition correct?

update:

it said on second article: `"1mb 4mb nice size according 1 nvidia document". seems small! wonder if there mistake because know it's possible store larger amount of data (much more 100 mo whithout problem on current hardware). plus, famous models dragon not stored on single vbo (it mean geometry of mesh should shared between 4 5 vbos in best case, 5 draw calls render it. can't imagine, in case, number of vbo allocated in real video game scene!). think of ?

enter image description here


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

c# - MSDN OneNote Api: Navigate to never before opened page without opening a OneNote Application Window -