OpenGL code optimization

Sage
Posts: 1,403
Joined: 2005.07
Post: #16
if CPU is the problem then the number of sprites im drawing would have to be large because Im not doing anything else than loadidentity() translate rotate scale draw again and again.
What should I profile and how?

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #17
We clearly need a Shark tutorial soon. Smile

Assuming you have the CHUD tools installed (/Developer/Applications/Performance Tools), fire up Shark. There'll be a small window with a big button saying Start. Start your game, hit Option+Esc to start Shark in the background. Run the game for 30 seconds, then Shark will say boing, and start chewing the results for an eternity. Then, you'll see a breakdown of what's taking time in your application. Tell us what is the top entry, and let's see what's happening. If it turns out to be an OpenGL call we'll break out the OpenGL profiler, and see where we can take this baby. Smile
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Sage
Posts: 1,403
Joined: 2005.07
Post: #19
Sounds fun!
Ill do that

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #20
Here is the shark file, i dont really know what it to make of it but the top line is
Code:
97% machine_idle_ret
   97% machine_idle_ret
      97% idle_thread_continue

If its any use http://www.geocities.com/ed72678954/session01.shark.zip is the shark file.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #21
Hm, odd. Did you make sure to set the Process popup to All, and the Thread popup to all? They're both at the bottom.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #22
Well, I am loading the application from the terminal but with Process All the top few lines are

Code:
61.4% machine_idle_reset   mach_kernel
   97% machine_idle
      97% idle_thread_continue
9.9% ml_set_interrupts_enabled   mach_kernel
1.1% gldFreeVertexBuffer   GeForceMX2GLDriver
   gldUpdate..   GLEngine
     dylid_stub..   GLEngine
        dylid_stub..   GLEngine
           drawCircle   MyGame
1.1% luaV_execute   MyGame
0.7% UNREADABLE_PAGE 0x00277000   NO_LIBRARY

Hope you can make more sense of that than me!

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #23
so your game is using virtually no CPU time. It's probably worth using a system trace profile in shark to see which system calls are taking up your time (look on the timeline view) (system trace is new in shark 4.2.0a15)
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #24
Shark 3.5.1, Dammit!
Where can I find an update?
Will it run om my measly os 10.3.9?

Quote:In my experience, when drawing with alpha testing (rather than blending), you only pay for the pixels which actually got drawn. With that in mind, drawing a 128x128 sprite which only has a 40x40 area containing opaque pixels would seem to be a bit silly, but shouldn't slow you down massively. It still makes sense to use a more optimal texture size if you can.
No, im the textures are that big but get scaled to 40x40, the opaque pixels take up 3.141*64*64 pixels

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #25
No, I don't think Shark 4.2 will work on 10.3.9... can anyone confirm?

Time to upgrade to 10.4 Rasp

http://developer.apple.com/tools/download/
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #26
Haha, I think ill have to make some money designing websites or somthing for a while before I can pay for it.
hmm, might get a new graphics card and some more ram too.

The DMG wont even mount, thats so cruel.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Member
Posts: 111
Joined: 2002.06
Post: #27
If you can't upgrade to 10.4, there are two ways to come close to the system trace profile. The function trace can trace system calls, but only for your program. The time profile can be set to profile everything so you can find a problem outside of your program.

For those of you interested in a Shark tutorial, I placed an old version of my new book's Shark chapter on my website. Go to http://www.meandmark.com/xcodebook.html to read the chapter. The chapter was written for Shark 4.1. I know Shark 4.0 will run on Mac OS X 10.3.9, and there weren't many changes between 4.0 and 4.1.

Mark Szymczyk
http://www.meandmark.com
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #28
Cool, thanks a lot.
Ive downloaded your tutorial and ill get 4.0.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Member
Posts: 208
Joined: 2005.04
Post: #29
just wondering... have you read Apple's tech note on OpenGL performance optimization?
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #30
Blush So heres a good way to optimize a game for speed, reduce the texture size from 512x512....

At least its running over 100 fps now!

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Simple ray-face intersect optimization NYGhost 8 6,576 Aug 17, 2007 12:01 PM
Last Post: NYGhost
  NEED HELP! OpenGL code for my exam doesn't work mr02077 2 2,875 Feb 9, 2007 05:44 PM
Last Post: stevejohnson
  SDL/OpenGL Initialization Code Nick 15 7,305 Sep 7, 2005 07:28 AM
Last Post: Nick
  OpenGL Source Code Generator Leisure Suit Lurie 2 4,151 Jul 5, 2005 11:55 AM
Last Post: Cochrane
  bus error with opengl code mnorton 2 3,992 Jan 21, 2005 02:53 PM
Last Post: ThemsAllTook