Distinct Arrays

From http://www.azillionmonkeys.com/windoze/OpenGLvsDirect3D.html :

To maximize the cache bandwidth and some pre-fetching capabilities of the Pentium and Pentium Pro processors, it is significantly better if each type of vertex information (positions, normals, colors, and texture coordinates) were kept in a distinct array.

This is in a quote of a summary of an article written by Intel.

What they are saying is instead of doing:

    typedef struct {
      float x, y, z;
      long reserved;
      long color, specular;  /* Byte packed! */
      float tu, tv;
    } D3DLVERTEX;

It would be better to have an array for x,y,z, an array for the u-v coordinates, an array for the byte packed color and specular info. Doing so can yield quite a lot of performance bonuses on CPUs that do speculative fetching.

So, ugh, the topic for discussion is how does this effect proper data arranging. In the case above, we are talking about something that brings very tangible performance benefits to almost every graphics related task, but also makes the code much more complicated to maintain.


IMHO for a HighLevelLanguage this would be an optimisation that should be performed by the compiler (or JustInTime-compiler/interpreter). The programmer should just have to declare an array of structures or objects and the compiler should store it for optimum efficiency. -- ChrisBrooking?


BTW, this probably relates to UseStorageSpacesWisely


EditText of this page (last edited January 31, 2010) or FindPage with title or text search