Ok, so lately I have been writing a simple rendering engine for iOS using OpenGL es 2.0 spec. To do anything moderately exciting requires adding back in the model, view and projection matricies.
One of the most common operations a graphics engine performs is 4x4 matrix multiplication, which in itself performed many times in a given frame is quite computationally expensive:
Code :matrix = m1*m2 + m1*m2 + m1*m2 + m1*m2; matrix = m1*m2 + m1*m2 + m1*m2 + m1*m2; matrix = m1*m2 + m1*m2 + m1*m2 + m1*m2; … matrix = m1*m2 + m1*m2 + m1*m2 + m1*m2;
Now for the sake of optimisation on the CPU side, I could setup a matrix multiplication daemon with threading to split the load.
However, the shader language gives the inbuilt matrix primitive and operations.
Code :uniform mat4 m_model; uniform mat4 m_view; uniform mat4 m_projection; gl_Position = m_projection * m_view * m_model * v_position;
Now my question is, is the matrix multiplication as expressed in the shader language (and presumable executed on the GPU) optimised? Does the matrix multiplication happen serially or in parallel? Is it better to send a precomputed on the CPU model view projection matrix to the vertex shader or is what I am doing here ok?