Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-13-2009, 05:35 PM   #1 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 15
dewhacker is on a distinguished road
Default Rendering architecture/optimizations with OpenGL ES 1.1

I'm working on a rendering engine that will hopefully be optimal and robust for the iPhone. I had one minor performance question regarding batching a bunch of quad objects with the same texture but different positions and scales.

My approach is somewhat complicated, but I am trying to use the advantage of interleaved vertex arrays.
1)Each object's render function strictly creates the object's world matrix, multiplies the object's verticies by the matrix, and concatenates them onto a vertex list of the renderer.
2)The renderer concatenates each object's verticies together with degenerate triangles.
3)When the renderer draws the scene there is only one glInterleavedArrays() and glDrawArrays() for each texture bind.

My big question is the extra matrix multiply per object done on the CPU better than many draw calls (vs one interleaved array ptr)?

Or maybe this is just way to complex, I'm trying to mimic hardware instancing as best I can in a fixed function pipeline.

(p.s. I'm much more familiar with DirectX if you cant tell)
dewhacker is offline   Reply With Quote
Old 02-18-2009, 12:15 AM   #2 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 234
warmi is on a distinguished road
Default

If you are just doing 2d ( or perhaps some sort of 3d particles) then preprocessing them on CPU is definitely way to go.

If you are doing just quads then the extra matrix multiply per vertex is going to be cheaper than doing bunch of OpenGL state changes.

I am doing something like that for 2d rendering and also for my 3d particles.

As far as other objects ( say with hundred of vertices) , I generally do that only when dealing with static "background" geometry which, once pretransformed, doesn't change.
warmi is offline   Reply With Quote
Old 02-18-2009, 12:30 PM   #3 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 15
dewhacker is on a distinguished road
Default

Quote:
Originally Posted by warmi View Post
If you are just doing 2d ( or perhaps some sort of 3d particles) then preprocessing them on CPU is definitely way to go.

If you are doing just quads then the extra matrix multiply per vertex is going to be cheaper than doing bunch of OpenGL state changes.

I am doing something like that for 2d rendering and also for my 3d particles.

As far as other objects ( say with hundred of vertices) , I generally do that only when dealing with static "background" geometry which, once pretransformed, doesn't change.
thanks alot for the suggestion, i will try it out
dewhacker is offline   Reply With Quote
Old 06-15-2009, 12:43 AM   #4 (permalink)
Registered Member
 
Fireball's Avatar
 
Join Date: May 2008
Posts: 25
Fireball is an unknown quantity at this point
Default

Sorry to dig this one up and co-opt your thread, but it's the only place I've been able to find anything similar to what I'm doing now.

I decided (after reading some docs from Apple, and my own testing) to do exactly the same thing you guys are describing. My current engine is all 2D. Although drawable objects are not simply billboard quads, they ARE simple enough that I think the technique of pre-calculating world coordinates and then issuing a single draw call will really help me. I'm building some tests right now, and ran across something I've never had to do before. . . Concatenate all the objects individual vertex arrays into a single large array to be passed to draw.

I've always used memcpy or the like, but that doesn't take an "offset" parameter so I can't append data. It will of course just overwrite it from the beginning. I know I can loop through individual values, but that seems excessively dumb. . .

There has to be a solution out there, but I've been at google for the better part of two hours and can't seem to find it (I guess I just don't have the right keyword today). Sorry if this seems like a newb thing to ask, I'm pretty much self taught. Thanks in advance for a kick in the right direction.

J "Fireball"
Fireball is offline   Reply With Quote
Old 06-15-2009, 01:45 AM   #5 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 234
warmi is on a distinguished road
Default

Quote:
Originally Posted by Fireball View Post
Sorry to dig this one up and co-opt your thread, but it's the only place I've been able to find anything similar to what I'm doing now.

I decided (after reading some docs from Apple, and my own testing) to do exactly the same thing you guys are describing. My current engine is all 2D. Although drawable objects are not simply billboard quads, they ARE simple enough that I think the technique of pre-calculating world coordinates and then issuing a single draw call will really help me. I'm building some tests right now, and ran across something I've never had to do before. . . Concatenate all the objects individual vertex arrays into a single large array to be passed to draw.

I've always used memcpy or the like, but that doesn't take an "offset" parameter so I can't append data. It will of course just overwrite it from the beginning. I know I can loop through individual values, but that seems excessively dumb. . .

There has to be a solution out there, but I've been at google for the better part of two hours and can't seem to find it (I guess I just don't have the right keyword today). Sorry if this seems like a newb thing to ask, I'm pretty much self taught. Thanks in advance for a kick in the right direction.

J "Fireball"
I am not sure what exactly is your vertex format for these objects but in my case all of them are pretty much the same ( being quads and all) and thus I don't really separate them at all.
In other words, I have what I call a dynamic vertex buffer which is just a fancy name for a sufficiently large array of vertex definitions, and anytime I need to draw a sprite I add it to that buffer.
Essentially anytime I call a method like drawSprite(x,y,width,height,textureX,textureY,rota tion,scale) I calculate neccesary vertex values on the fly and store them in the array.

Perhaps this approach won't work for you but I found this to be the most efficient way.

As far as copying with memcpy then you don't really need an additional offset parameter .. your destination pointer is your offset .. all you need to do is calculate it yourself and do some pointer arithmetic and you are done.

Last edited by warmi; 06-15-2009 at 01:47 AM.
warmi is offline   Reply With Quote
Old 06-15-2009, 08:57 AM   #6 (permalink)
Registered Member
 
Fireball's Avatar
 
Join Date: May 2008
Posts: 25
Fireball is an unknown quantity at this point
Default

haha! that's right. . . wow, I must really have been out of it today. I knew all I needed was a kick (in the head maybe? ).

Thanks much,

J "Fireball"
Fireball is offline   Reply With Quote
Reply

Bookmarks

Tags
glinterleavedarrays, opengl, rendering

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 423
10 members and 413 guests
13dario13, chits12345, ChrisYates, fredidf, gmarro, iOS.Lover, Leslie80, Meoz, Wikiboo, Yosh_K
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,670
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Yosh_K
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:38 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0