Slow Drawsprite - IPHONE - Questions

Previous topic - Next topic

StuC_Ovine


Ignore my ignorance

Few little questions about the IPHONE.

Im  profiling my sprite routines whilst optimizing and it seems that DRAWSPRITE is a large CPU hog  (also the other drawsprite counterparts too)

Firstly does Glbasic use the openGL interface ? if so I was expecting DRAWSPRITE just to send the quad and texture reference to the pipeline - or does the iPhone do something else ?


/Stu


doimus

As I understand, drawing OpenGL "sprites" is resource hog on iPhone in general, regardless of dev environment.

Kitty Hello

I have to see. It's OpenGL|ES, so I remember writing a small wrapper for glBegin and such commands. But Sprites should be glDrawArray, already. Is the overhead that big?

Stu_C


Im drawing 200 sprites with drawsprite - same image of 32x32 and the routine takes between 12 and 15 milliseconds - I dont understand why it should fluctuate either - I'm literally just doing a DRAWSPRITE.

Same on a PC takes 0.5 millisecs :)

/Stu
www.ovine.net

codegit

#4
Hi

I am using DRAWANIM (32 x 32 pixel sprites) with a scrolling world map of 300 sprites (20 across and 15 down) on the iTouch and it is running very smoothly. I had to restrict frame rate to 20FPS to acheive a slow scroll. My calculation is that I am displaying about 150 sprites per frame.


PLease note: I have not tried DRAWSPRITE.
------------------------------------------
1 X Acer TravelMate 4270, laptop, XP PRO
1 X Dell Studio 17 laptop, Windows 7
1 X MacBook Pro 2,2 GHz Core 2 Duo, 2 GB RAM, 160 GB HDD, 9400M
2 X iTouch
1 X HTC Desire (Android 2.1)
iPad soon to be added

Kitty Hello

oh dear. I found out that the draw calls (glDrawArrays) is a bottleneck on the iPhone. 200 calls is quite a lot. You can easily get a higher framerate with larger sprites if you only draw 100.

You should try to use POLYVECTOR for larger sprite-fans, when possible. But for simple sprites, that seems the limit.

It's a bad situation. What are you exactly trying to do, maybe there's another solution.

StuC_Ovine


Im just stress testing to see which is the best way for the framework to work.    Also thinking of particle effects and the best way to draw them too (hence more than 200 sprites)


doimus

What exactly is a draw-call when drawing sprites? Ie. if I have single 32x32px sprite tile and fill the screen with it - is that one draw-call, or is it 150 (480/32 x 320/32) draw calls?

Stu_C

Each DRAWSPRITE is sending it once, so if your drawing it 150 times - its bing sent 150 times.  The texture would only be uploaded once but each drawsprite is sending  6 sets of verts - I would imagine.


/Stu
www.ovine.net

MikeHart

Why 6? A quad has 4 corners. Or is it drawing 2 triangles?

Sokurah

Quote from: Stu_C on 2009-Aug-13

Im drawing 200 sprites with drawsprite - same image of 32x32 and the routine takes between 12 and 15 milliseconds - I dont understand why it should fluctuate either - I'm literally just doing a DRAWSPRITE.

Same on a PC takes 0.5 millisecs :)

Does the iPhone distinguish between sprites and tiles?

I mean, let's say you're making a tile based game, then at 480x320 you'd be using 140 pieces of 32x32 tiles to draw the entire screen and then you'd be close to what seems to a problem.

Would there be a more practical way of doing the above scenario than using tiles/sprites?

Performancewise, how time costly is blitting an entire 480x320 image to the screen compared to using separate tiles?

Also, if "200 calls is quite a lot" what hardware is that based on - the "normal" iPhone/iPod or the 3GS?


Website: Tardis remakes / Mostly remakes of Arcade and ZX Spectrum games. All freeware. :-)
Twitter: Sokurah

MikeHart

Quote from: MikeHart on 2009-Aug-16
Why 6? A quad has 4 corners. Or is it drawing 2 triangles?

Ok, I answered this to myself. OpenGL ES doesn't support QUADS. So that is why 6 vertices if you use TRIANGLES. But it supports TRIANGLE_STRIP and so you can have again just 4 vertices.

Hemlos

#12
Quote from: StuC_Ovine on 2009-Aug-14

Im just stress testing to see which is the best way for the framework to work.    Also thinking of particle effects and the best way to draw them too (hence more than 200 sprites)




I would say the best "fastest" not "prettiest", is pixels as a particle.
Next in line is lines, then a little slower would be polyvector(3 vertice).
4 vertice is possible, but you will experience the largest slowdown with these, in comparison.


I dont know if SpriteZ api will work on an iphone or not, it seems like iphone compiler has some issues which would prevent me from compiling a demo for you.

But i can give you the source for a 4 point polyvector, skinable, rotatable, and scalable, if want to try a test for it.
It is faster than zotozoomsprite i think.
That is what i used for this screenshot below, using 8000 particles using 4 point polyvectors, on a pc ( note: its very slow with this many particles , but looks good ) :


[attachment deleted by admin]
Bing ChatGpt is pretty smart :O

Billamu

The iPhone / iPod Touch has a very particular way of drawing stuff. The following file is directed at 3d graphics but I think is relavent to this discussion as far as understanding what the iPhone is doing, and why it has a low drawcall count.

Gernot's suggestion of using Polyvector instead might be the way to go.

http://www.imgtec.com/factsheets/SDK/PowerVR%20MBX.3D%20Application%20Development%20Recommendations.1.0.67a.External.pdf
I'm an Aries. I have lots of Ram.

Kitty Hello

The new update (7.085) offers a way to draw triangle in POLYVECTOR. Thus, you can put all triangles (make 2 triangles for a quad) of the same texture in one batch. Should be a bit faster then.