I'm trying to apply a Kalman filter to the data coming out from the iPhone accelerometer. I need to perform matrix multiplication and inversion as fast as possible, so I was curious about the possibility of using the GPU to perform these two tasks. As of now I found only one reference for the matrix multiplication:
float mBone01[16] = { ... }
float mBone02[16] = { ... }
float mResult[16];
glMatrixMode ( GL_MODELVIEW );
glLoadIdentity( );
glLoadMatrix ( mBone01 );
glMultMatrix ( mBone02 );
glGetMatrix ( GL_MODELVIEW, mResult );
even tough the user is not really sure about the fact that this multiplication is performed inside the GPU. Do you have any hint on how to do (if possible) the same for the inversion?
Thank you all!
As Kornel (and the OpenGL FAQ) already said, OpenGL does not provide an implementation of a matrix inversion.
This thread has some C++ implementations, that should work with the iPhone SDK.
Also, by calling the OpenGL API your code is not running on the GPU.
To use the GPU of the iPhone, you have to use OpenGL ES 2.0, which currently is only available on the following models:
Apple has a sample project, that makes use of OpenGL ES 2.0 and shaders: http://developer.apple.com/iphone/library/samplecode/GLES2Sample/index.html
The only sure way to perform calculations on the GPU is by using shaders.
That said, neither OpenGL nor GLSL has a built-in function for calculating inverse matrices, you have to code it by yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With