MemSet in steps

With OpenGL, there are many times when data steps are required to increase efficiency. for example, the memory structure will be vertex-color-normal-vertex-color-normal, etc.

Is there a viable option for changing, say, only the color section of the memory with some kind of memset option (that is, without using a loop).

The question also arises, is there such a thing as a loop memset? For example, in an array of colors consisting of four floats, set all of them to a specific color.

0
source share
2 answers

Just use a loop. There is nothing magic in memset, inside it just uses a loop, it can be slightly optimized on the same compilers to clear 64 bits at a time, if used with 0, but it does not install a memory block in one command

+2
source

I would just go with the noose. memset () does some neat little optimizations to write a few bytes to iteration, so you can see how memset () works and see if these kinds of optimizations apply to your code. But in the end, it's just a cycle.

Here is the memset () source code - quite readable, although you will have to dig up all typedefs and macros to see how the optimization is going on.

+1
source

All Articles