iphone - Optimizing OpenGL ES application. Should I avoid calling glVertexPointer when possible? -


i'm developing game iphone in opengl es 1.1; have lot of textured quads in data structure each node has list of children nodes. traverse structure root, , render of each quad, childs , on.

the thing is, each quad i'm calling glvertexpointer set vertices.

  • should avoid calling each quad? improve performance calling once example?
  • glvertexpointer copies vertices gpu memory or saves pointer?

trying minimize number of calls not easy since each node may have different quad. have lot of equal sprites same vertex data, i'm not rendering 1 after since may drawing different sprite between them.

thanks.

glvertexpointer keeps pointer, incurs state change in opengl driver , explicit synchronisation, costs quite lot. when 'here's data, please draw', gpu starts drawing , continues in parallel whatever going on on cpu long can. when change rendering state, needs finish whatever doing in old state. changing once per quad, you're forcing concurrent processing consecutive. hence, avoiding glvertexpointer (and, presumably, gldrawarrays or gldrawelements?) per quad should give significant benefit.

an immediate optimisation keep count of number of quads in total in data structure, allocate single target buffer vertices @ least size , have quads copy geometry target buffer rather calling glvertexpointer each time. call glvertexpointer , drawing calls (condensed 1 call also, hopefully) 1 big array @ end. it's bit more costly on cpu side parallelism , lack of repeated gpu/cpu synchronisations should save lot.

while tiptoeing around topics under nda, suggest @ xcode 4 beta. amongst other features apple have stated publicly present opengl es profiler. can compare approaches.

to copy data gpu, need use vertex buffer object. means creating buffer glgenbuffers, pushing data glbufferdata , posting glvertexpointer address of e.g. 0 if first byte in data uploaded first byte of vertices. in es 1.x, can upload data gl_dynamic_draw flag intend update quite , draw quite often. it's worth doing if can position you're drawing more you're uploading.

if ever switch es 2.x there's gl_stream_draw, may worth investigating isn't directly relevant question. mention it'll come if google vertex buffer objects, being available on desktop opengl. options es 1.x gl_static_draw , gl_dynamic_draw.

i've worked on ipad es 1.x application objects change every frame drawn twice per rendering pipeline in use. there 5 such objects on screen, each 40 vertices, switching initial implementation vbo implementation cut 20% off total processing time.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

sql server - python to mssql encoding problem -

windows - Python Service Installation - "Could not find PythonClass entry" -