GLM, the OpenGL Mathematics library
One important limit when working with OpenGL and Vulkan is that all data must be available in GPU memory so the graphics card can access it directly. We must copy the information about every vertex to the memory of the graphics card, including the vertex position, color, texture coordinates, and more. All or part of this data may be copied in every frame to the graphics card, so the fastest way to copy the data to the GPU memory is a simple memory copy command. In C and C++, this command is called memcpy
. The compiler may utilize the best fitting internal method to achieve the data duplication, such as by using the large SIMD registers on a modern CPU.
But a question arises from this transfer: how do we ensure we make a simple copy, without having to touch and adjust every data element?
This may happen if the data is stored in the system memory in a different format compared to the GPU memory. It may differ in element sizes or the alignment...