I use this construct in many real applications, in fact my iPhone engine bases heavily on this kind of pointer to pointer to memory access relation.

There is a performance problem, but this has nothing todo with those pointers but with copying the data into the GPU memory and blocking the CPU in the meantime.

I just checked the access time on my very old iPhone 3G running iOS 4.1 and the difference between fixed array and pointer to pointer is not visible in the log (about 0.010 seconds to read and write into the memory).

I know that I can't compare a RISC CPU with an x86 CISC CPU, so I checked it also on my 2 Ghz Intel Dual Core Machine running Mac OS X 10.6.4, the result:
Read and write into the memory was about 0.001 seconds (both, fixed arrays and pointer to pointer).

Both versions had debug symbols and was build with LLVM 1.5 and Clang. No optimizations and no link time optimization.
I have checked the assembler code that was generated to make sure that the loops will be executed.
The test function has written PI into every member of the array and then read the value and saved it into another float.

Output:
OS X:
Code:
2010-07-15 12:19:57.766 Test[1375:903] Writing fixed
2010-07-15 12:19:57.766 Test[1375:903] Reading fixed
2010-07-15 12:19:57.767 Test[1375:903] Writing pointer
2010-07-15 12:19:57.767 Test[1375:903] Reading pointer
2010-07-15 12:19:57.768 Test[1375:903] Writing fixed
2010-07-15 12:19:57.769 Test[1375:903] Reading fixed
2010-07-15 12:19:57.769 Test[1375:903] Writing pointer
2010-07-15 12:19:57.770 Test[1375:903] Reading pointer



iPhone:
Code:
2010-07-15 12:24:23.859 iTest[507:307] Writing fixed
2010-07-15 12:24:23.872 iTest[507:307] Reading fixed
2010-07-15 12:24:23.885 iTest[507:307] Writing pointer
2010-07-15 12:24:23.900 iTest[507:307] Reading pointer
2010-07-15 12:24:23.913 iTest[507:307] Writing fixed
2010-07-15 12:24:23.926 iTest[507:307] Reading fixed
2010-07-15 12:24:23.940 iTest[507:307] Writing pointer
2010-07-15 12:24:23.953 iTest[507:307] Reading pointer



Could you please explain what is so much slower? Because I really can't reproduce this (was too lazy to boot windows, so I haven't tested it with Gamestudio).
I use this construct very often, and if there is really a performance problem with that, I wish to know about that so I can avoid this.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com