&gt;&gt; What does Z-ordering mean in this context?<p>You divide the image into quarters and store each quarter as a continuous block of memory. Do this recursively.<p>Normally we&#x27;d index into the pixel data using pixel[x,y]. You can get Z-ordering by using pixel[interleave(x,y)] where the function interleave(x,y) interleaves the bits of the two parameters.<p>This works fantastically well when the image is a square power of two, and gets terrible when it&#x27;s one pixel high and really wide. I think a combination of using square tiles where each one is Z-ordered is probably a useful combination.<p>For my ray tracer I use a single counter to scan all the pixels in an image. I feed the counter into a &quot;deinterleave&quot; function to split it into an X and Y coordinate before shooting a ray. That way the image is rendered in Z-order. That means better cache behavior from ray to ray and resulted in a 7-9 percent speedup from just this one thing.<p>Once you have data coherence, swapping is not a big deal either in applications where you&#x27;re zoomed in.