Maes
I like big butts!

Posts: 7955
Registered: 07-06 |
Actually, rewriting everything to be completely horizontal would only help speed things up a bit in cached architectures if there was a vertical/horizontal disparity at some point. E.g. textures and sprites are stored as columns-first arrays, FORTRAN style, which is not a problem if all computations are done in that style (I always wondered if a FORTRAN Doom would be faster, back in the day): the cache will read ahead the correct bytes each time.
The only potential slowdown would be if there was a horizontal/vertical hybrid at some point: in that case, the cache would register a lot of misses. Since sprites + textures are read-only inside the engine, the only place where writing array-style occurs is the main screen buffer.
If that one is stored rows-first, then drawing to it columns-first will not help much with cache locality. In layman terms, it could have been faster, even back in the day. Of course, to avoid this, you would have to rearrange sprites + textures to be horizontal, but I recall they settled on the unusual (for C programming at least) columns-first arrangement for rendering optimization reasons, which privileged column-based rendering.
In any case, doing it either way won't allow any particular "renderer tricks": the choice is brought upon by convention, programming convenience and cache locality issues. E.g. for some reason the engine designers felt that drawing stuff columns-first was better for their renderer (which makes sense, since there are no slopes or freelook in the original engine and "see through" spots were limited), and objects would be more likely to be hidden from view width-wise, rather than height-wise, it made sense to draw columns first (and store objects in this way, to avoid unnecessary pointer arithmetic or cache misses).
Now, if the above conditions cease applying (e.g. freelook, a lot of see-through) then yeah, switching to another "array gender" may be preferable.
Last edited by Maes on 03-06-10 at 16:59
|