<< Note: Even though we started this discussion in Phantom's forum under the "Easy CE 2.0" topic, I decided to start a new topic on this issue because it makes it easier for people to find during a search. It's also more of a general programming topic rather than something specific to Jacco's work, or Easy CE 2.0.>>
I've been playing around with blitting code lately in an attempt to determine the penalty for performing a rotated blit per frame. I've got some interesting numbers to share with you guys.
I'm able to do a 240x320 -> 320x240 rotated blit in 5.57 ms. That's close to 180 fps. This is 20 or so lines of C code that I could probably rewrite in ARM assembly to get closer to 200 fps.
Rewriting the routine so that it writes to sequential addresses to avoid tearing results in a severe perf penalty since the cache is getting thrashed. This dropped the throughput to approximately 22 ms per frame (45 fps).
The secret here is that the display memory is not cached. Therefore you don't pay any penalty for writing to non-contiguous addresses to display RAM. The back buffer however IS cached since it's in system memory. You certainly want to read sequentially from your back buffer to take advantage of the cache.
One other interesting thing: I tried these routines writing both to display memory as well as a system memory surface. If you're reading and writing to contiguous addresses, it's really fast. I was seeing 1.77 ms to memcpy from a 320x240 back buffer to another 320x240 offscreen buffer. That same operation when the target was display memory was 4.5 ms. That's the write cache in action I suppose. However, if I try the rotated blit code mentioned above to blit to a system memory surface instead of display memory, the elapsed time jumps to 17.57 ms! This is because the puny cache on the StrongARM is getting thrashed as the routine jumps across cache lines in order to write the data.
Just for the record I also tested GDI's BitBlt from a 240x320 DIB section selected into an off-screen memory DC blitted to the screen DC. It was about 36 ms (27 fps).
I've been playing around with blitting code lately in an attempt to determine the penalty for performing a rotated blit per frame. I've got some interesting numbers to share with you guys.
I'm able to do a 240x320 -> 320x240 rotated blit in 5.57 ms. That's close to 180 fps. This is 20 or so lines of C code that I could probably rewrite in ARM assembly to get closer to 200 fps.
Rewriting the routine so that it writes to sequential addresses to avoid tearing results in a severe perf penalty since the cache is getting thrashed. This dropped the throughput to approximately 22 ms per frame (45 fps).
The secret here is that the display memory is not cached. Therefore you don't pay any penalty for writing to non-contiguous addresses to display RAM. The back buffer however IS cached since it's in system memory. You certainly want to read sequentially from your back buffer to take advantage of the cache.
One other interesting thing: I tried these routines writing both to display memory as well as a system memory surface. If you're reading and writing to contiguous addresses, it's really fast. I was seeing 1.77 ms to memcpy from a 320x240 back buffer to another 320x240 offscreen buffer. That same operation when the target was display memory was 4.5 ms. That's the write cache in action I suppose. However, if I try the rotated blit code mentioned above to blit to a system memory surface instead of display memory, the elapsed time jumps to 17.57 ms! This is because the puny cache on the StrongARM is getting thrashed as the routine jumps across cache lines in order to write the data.
Just for the record I also tested GDI's BitBlt from a 240x320 DIB section selected into an off-screen memory DC blitted to the screen DC. It was about 36 ms (27 fps).