0

This is an update to the question: iPhone GCC / LLVM GCC or LLVM? ...since it's been over a year since that question was asked.

I'm very new to graphics processing and am just beginning to learn OpenGL ES.

I was reading this: http://www.dpfiles.com/dpfileswiki/index.php?title=Black_Art_of_3D_Game_Programming%2C_Chapter_10:_3D_Fundamentals#Fixed_Point_Mathematics ...and know that some of the information is outdated.

Do the limitations mentioned in this section still apply to iPhones?

i.e. Is using fixed point math still a dramatic improvement over floating point?

What compiler should I use to optimize matrix operations?

Community
  • 1
  • 1
Matisse VerDuyn
  • 1,148
  • 15
  • 40

2 Answers2

2

First, as I stated in answer to the question you've linked above, LLVM in general provides better performance for compiled code when targeting iOS. Apple is even removing GCC as a compiler from Xcode, so you won't really have a choice about that. Use LLVM.

Second, the statements made in that article about fixed point math do not apply to the OpenGL ES implementation on iOS devices. The PowerVR GPUs used in these devices are tuned to use floating point inputs, and can actually have reduced performance when dealing with fixed point data. From Apple's OpenGL ES Programming Guide:

Avoid using the OpenGL ES GL_FIXED data type. It requires the same amount of memory as GL_FLOAT, but provides a smaller range of values. All iOS devices support hardware floating-point units, so floating point values can be processed more quickly.

and

The ARM processor in iOS devices processes floating-point instructions natively. Your application should use floating-point instead of fixed point math whenever possible. If you are porting an application that uses fixed-point operations, rewrite the code to use floating-point types.

I believe that the PowerVR documentation (available as part of their free SDK) also mentions this.

Also, you should probably enable building for Thumb on ARMv7 devices (iPhone 3G S and newer) and disable it for ARMv6 devices, because that slows floating point calculations on the latter, but not the former, and can lead to better performance on the former class of devices.

Finally, when it comes to matrix operations, if you only want to target iOS 5.0, you should use the new matrix math functions that came in with GLKit. Those use NEON-accelerated implementations to do fast vector math. You could also roll your own or find an existing implementation that uses the Accelerate framework or direct NEON calculations.

That all said, none of these areas will likely be a bottleneck for you when doing OpenGL ES rendering. Use Instruments and other tools to find the real areas within your application that are slowing down your rendering. These optimizations I've mentioned will only shave small amounts of time off of this.

Community
  • 1
  • 1
Brad Larson
  • 170,088
  • 45
  • 397
  • 571
  • As per usual, Brad, you're the best! Working on learning the foundation of all this so I can contribute some filters to your GPUImage framework! https://github.com/BradLarson/GPUImage – Matisse VerDuyn Feb 23 '12 at 18:20
  • 1
    @MatisseVerDuyn - Thankfully, a lot of the documentation out there on OpenGL fragment shaders translates across to OpenGL ES. Also, Imagination Technologies has some pretty useful tuning information as part of the PDFs in their SDK: http://www.imgtec.com/powervr/insider/powervr-sdk-docs.asp – Brad Larson Feb 23 '12 at 18:27
1

Easiest would be just write your code and compile with any compiler. Then measure performance, switch to another compiler in project settings (it's as easy as changing one option), then recompile and measure new performance. Thus you'll be able to easily see which compiler gives better performance. For my game clang was giving better performance.

As for floating point math - if you don't target older phones that 3GS then don't worry about fixed point. Use floating point for 3d transformations. It will be fine.

Mārtiņš Možeiko
  • 12,733
  • 2
  • 45
  • 45