Default OpenGL settings on Mac - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Default OpenGL settings on Mac (/thread-2475.html)
Default OpenGL settings on Mac - GolfHacker - Aug 8, 2008 06:14 PM
After switching to Mac and purchasing a Mac Pro, I noticed the OpenGL side-scrolling on my Dirk Dashing game had a lot of shearing going on. I had not noticed this on my MacBook Pro originally, so I did not realize that Mac didn't have the vertical sync turned on (I'm actually amazed the game sells so well on Mac with this obvious shearing effect). After some Googling, I found the CGLSetParameter command and a little snippet of code to turn vsync on/off.
Now that vsync is on, the game scrolling is very smooth in lightly populated areas and very jerky in areas where there are more polygons. I've got a NVidia 8800GT in this box, and it should be able to keep up. I've got XP setup via Boot Camp on the same machine, and the scrolling is very smooth on XP. So I know it isn't a hardware issue.
So here comes my question: I started looking at the rendering a little more closely, and it looks like the GL antialiasing setting or other expensive visual settings might be on by default on the Mac. Anyone know what the default NVidia/ATI settings are for OpenGL, and how I might change them (either programmatically or via the OS)? I can't find any sort of control panel for adjusting these settings.
Thanks in advance!
Default OpenGL settings on Mac - OneSadCookie - Aug 8, 2008 09:53 PM
No, nothing "expensive" is on by default.
Remember that jerkiness can be caused by vsync if you're even fractionally off meeting the refresh rate.
You need to profile to find out what actually the problem, rather than just making random guesses. Use Shark's "Time Profile" to find out whether you're using lots of CPU time, and if so, where you're spending it. Use Shark's "System Trace" to find out where you're blocked if you're not using lots of CPU time. You may also find OpenGL Profiler and OpenGL Driver Monitor useful.
Post back if you can't figure out what those tools are telling you, or can't figure out how to fix the problems they inform you of
Default OpenGL settings on Mac - GolfHacker - Aug 9, 2008 02:09 PM
Ok, I've never used Shark before (or even heard of it). But after Googling, I downloaded the latest version of the CHUD tools from the Apple FTP site, installed them, and ran Shark. I then started my game and hit the Start button on Shark. I played my game for a bit. After about 2-3 minutes, nothing was happening so I hit the Stop button on Shark. It completely crashed my Mac Pro... meaning, the screen went dim and a message appeared telling me I needed to press and hold the Power button to reboot. This tried 3 times, and Shark brought down my whole OS each time.
What am I doing wrong here? Is Shark really that unstable??
Default OpenGL settings on Mac - OneSadCookie - Aug 9, 2008 02:14 PM
Well, you downloaded Shark rather than just running the one that came with your dev tools, that may not have been a good plan, I dunno. No, it's not generally that unstable.
Default OpenGL settings on Mac - GolfHacker - Aug 9, 2008 02:16 PM
I couldn't find Shark on my system, which is why I downloaded it. You say it comes with XCode? Where do I find it?
Default OpenGL settings on Mac - AnotherJake - Aug 9, 2008 02:43 PM
GolfHacker Wrote:I couldn't find Shark on my system, which is why I downloaded it. You say it comes with XCode? Where do I find it?
Default OpenGL settings on Mac - GolfHacker - Aug 9, 2008 02:54 PM
Ok, I think I found it - in the original XCode dmg. Looks like the XCode Installer Launcher did not install everything. The OpenGL Profiler wasn't on my system either, but I see the package for it in the dmg. I was able to run that and get the OpenGL Profiler installed.
Now I've got a new problem. I was looking for a way to uninstall the latest CHUD tools (which probably doesn't match the XCode 2.5 version I am using), and all I could find was a CHUD Remover program. So I ran that, and the files disappeared. But when I try to run the CHUD package from my 2.5 dmg, it gives me a red exclamation point on all of my drives. It won't let me install it. When I click on Macintosh HD1, it says"You cannot install CHUD Tools on this volume. Could not find specified message for index 18". So I don't know why it won't let me install CHUD. Any ideas?
I ran /XCode2.5/Library/uninstall-devtools to completely uninstall XCode, rebooted, and reinstalled XCode 2.5. Same problem.
Default OpenGL settings on Mac - OneSadCookie - Aug 9, 2008 03:02 PM
Can I ask why you're using Xcode 2.5 rather than Xcode 3.0 or 3.1? AFAIK the only reason to is to support 10.2.8, which it seems unlikely you're trying to...
I've never seen anything like your installation failure, I'm afraid. It's possible that
pkgutil --forget com.apple.pkg.CHUDLeo
Default OpenGL settings on Mac - GolfHacker - Aug 9, 2008 03:18 PM
Nope, that didn't seem to help.
I have a MacBook Pro that is running 10.4, which I want to keep at 10.4 for testing purposes. I also use this laptop when I travel, so I need to use a version of Xcode that will work on both machines. It was my understanding that Xcode 3.0 was only for Leopard.
Guess I'll see if I can install the CHUD tools on the laptop.
Default OpenGL settings on Mac - OneSadCookie - Aug 9, 2008 11:27 PM
Keeping Tiger for testing is sane, developing on Tiger isn't You may want to consider partitioning the disk and dual-booting.
Default OpenGL settings on Mac - GolfHacker - Aug 10, 2008 07:05 AM
Yeah, but at least I'm only on Tiger for brief periods of time.
Still, I may have to figure out how to setup a dual boot situation. I missing having Boot Camp on there with XP installed. (Sorry - sacrilege, I know, but I do have Office 2007 and several other expensive apps that I bought for Windows that I still need to use, and I refuse to pay that kind of $$ again just to get the native Mac versions or an equivalent replacement).
I also miss the easier networking capability. It's kinda tricky transferring files between Tiger and Leopard machines.
By the way, before this thread goes off on a big tangent - I did get Shark to run on my Tiger laptop, and it found a few things that I can analyze. The big one (at nearly half the CPU) was ml_set_interrupts_enabled, but since it is in red (which I understand is Mac OS X kernel code), I am assuming that it's probably something I can't do anything about. I'm thinking it might even be Shark, since the whole machine was noticeably slower when Shark was running.
Now if I can just figure out how to get CHUD installed on my shiny new Mac Pro...
Default OpenGL settings on Mac - OneSadCookie - Aug 10, 2008 03:06 PM
If you're seeing functions that aren't yours taking lots of CPU time, start doing "charge library to callers" until your own functions appear.
ml_set_interrupts_enabled is probably a good indicator that System Trace will tell you more, though. What's your CPU usage?
Default OpenGL settings on Mac - GolfHacker - Aug 10, 2008 04:06 PM
Had to Google to figure out what "charge library to callers" meant, but that led me to the Shark documentation here. Good stuff! Thanks again for pointing me to these tools. Since the main Xcode installer didn't install these tools, I didn't even know about them. These are some of the best free profiling tools I have ever seen! Way to go, Apple!
Anyway, it showed 74.5% for mach_kernel, and 24.8% for Dirk Dashing. I ran a System Trace, but that didn't tell me much more than the process combo box at the bottom of the Time Profile results - it just put it in a pretty pie chart.
I did a little digging through the callstack information, however, and found some references to glFlush. Turns out I had a rogue glFlush call hidden down in the guts of my rendering code. Once I removed that, my game performance skyrocketed. I'm guessing glFlush works a little differently on Windows and Linux...? Maybe that's why I didn't notice these issues on those platforms.
Thanks again for the help, and especially for letting me know about Shark and these other tools.
Default OpenGL settings on Mac - OneSadCookie - Aug 10, 2008 07:26 PM
glFlush is a performance no-no on all platforms, though I suppose it's conceivable that this is more so the case on the Mac.
System Trace's "timeline" tab is the useful one. It shows system calls, CPU utilization, blocking, and lock contention in an easy-to-understand graphical view.
25% is very little CPU time for a game, so System Trace would be expected to tell you much more (it would likely've pinpointed glFlush straight away).
Default OpenGL settings on Mac - GolfHacker - Aug 10, 2008 09:22 PM
Yeah, I thought I had removed all the glFlush calls when I was optimizing it last year, but apparently I missed one. Guess I should have grepped for it to make sure I had them all. If the performance on Linux had suffered like it did on Mac, I would have noticed immediately and found the glFlush call before I released the game. Oh well... my bad. I'm just glad I found it now.
Thanks for the tips on System Trace. I'm going to have to take a day off and just play with Shark and some of the other profiling tools to see what they can do.