PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

g_display.Flip() really "eats" ?

Hi,

I don't know how this behaves under CE, but while optimizing my mapdrawing routines under Win32, I wondered, why I have 0 (zero) cpu usage without and around 3% - 5% with Flip() ? I allways do the map drawing and stuff to the backbuffer. But it looks like my stuff is causing no measurable cpu usage.
(All this in 240x320@30fps)

I'm using a Dual AthlonMP 1900 machine, so 3% - 5% in TaskManager here are 6% - 10% on a single CPU machine.

I'm sure this is way too much usage as it should be ?

Using GetTickCount(), I got 0 - 16 ticks usage for processing 100 frames without flip() and around 600 ticks usage with flip(). And as said, I'm doing a whole mapdraw to backbuffer each time, which is causing 0 - 16 ticks.

Is this win32 "thing" only, or is it like this on CE, too, that flip() is a real "eater" ?

I'm really interested in your performce using gapidraw, and what are the best ways to do some elemental things, so I will do a second topic for this.

Greets,

Michael Ritter (5amcoderz)
Flip is what draws your backbuffer to the the display so you should be noticing that when you don't flip you're also not seeing the display updated. That's also the reason for the overhead.

I would wholey expect this overhead to be the same on a single and duel proc machine.
On the desktop machine accessing graphic memory is much slower than accessing system memory therefore flip() will seem slower ( at least that used to be the case with the graphics memory)

On the other hand PocketPC doesn't have such concept meaning that framebuffer memory is basically the same as your main memory so flip() should run exactly as fast as blit from one surface to another.

Anyway, flip() on PPC runs at 5-6 ms which basically corresponds to memcpy() for 320x240x2 bytes.
GapiDraw uses prerotated images ( memory buffers) to match device screen layout.
This saves some time on the final blit but causes performance problems for people who want to access memory buffers directly ( either stuff has to be rotated (lock) or people have to know surface layout when accessing it directly.)

Another option would be to keep internal memory buffers ( surfaces) in the default unrorated state and just do rotated blit in flip() call.
It would not be much slower since rotated flip() takes around 7 ms ( as opposed to 5-6 ms for unrotated)- not much of a difference but saves a lot of trouble ( IMHO of course)
Yep, and the overhead was not the primary reason for using prerotated blits.

Rotating blits to the native format of the display causes severe tearing, since the blit cannot be synchronized to the LCD refresh. I think there has been at least two discussion topics on the subject on these forums, and to many people the tearing effect is so noticable that it is disturbing.
Indeed, it is not hard to come with a Rotated Blit that is as fast as a straight memcpy(). The process is limited by memory bandwidth, not CPU speed.

As Johan says, the reason to do so is to reduce tearing.
warmi · 09 Oct 2002, 23:28 UTC — memcpy and rotated blit
As fast as memcpy ?

Hmm, I would love to see that one ( and I am not being sarcastic here- I would really like to see implementation that is just as fast as straight memcpy.)

Anyway, when rotating you are limited by reading only 2 pixels at a time and have to perform bunch of shifts and logical operations ( admittedly , quite fast on ARM cpu) to be able to write to the destination using STMIA instructions.
In my experience, just the fact that you cannot use ldmia/stmia instructions when writing and reading will result in slowdown of about 30 %.
This all assuming 200 MHZ ARM 1100 CPU.