Flickering on Toshiba e750
Hi Thierry,
I have had a report of my game which uses PocketHAL flickering on an e750 by fast_rx:
http://www.pocketmatrix.com/forums/viewtopic.php?t=15469
From what is described it sounds like instead of writing to the back buffer it's drawing directly to the screen. Could it by the vsync flag on Swap()? I don't currently use it, but is it good practice to always use it?
VSYNC functionality is only available on devices that use the CPU built-in LCD controller (StrongARM or XScale). The E750 isn't one of them. The E750 has an Imageon 100 and all the screen will be updated all the time. Said another way, both swap flags won't do anything on the E750. Because of this, some (minor) flickering is inevitable. The situation is basically the same as using GAPI (altough PHAL will be running a little bit faster).
PHAL will operate in SWAP_COPY mode on the E750, so I really don't know what could be wrong.
Could you try the following: forcing a call to Display::GetBackBuffer() before rendering each frame and see what happens?
That was a fast response!
I am currently calling Display->GetBackBuffer()->GetPixels() at the beginning of every frame. Did you also want me to call it after each frame is rendered, but just before the swap?
Then you are doing it fine. I have no idea...
This is my main loop just in case it helps:
- Code:
while (Running)
{
//start frame - this is especially important for pocketHAL whose buffer
//could move around in memory
Global->Display->BeginFrame();
//call the OnFrame event
OnRenderFrame();
//blit to screen
Global->Display->BlitToScreen();
ProcessMessages();
fps.WaitForNextFrame();
}
Thierry, could the erase bg or paint events be related? This is how I handle them:
- Code:
case WM_ERASEBKGND:
msg->Result = 1;
msg->Handled = TRUE;
break;
case WM_PAINT:
PAINTSTRUCT p;
BeginPaint(hwnd, &p;);
EndPaint(hwnd, &p;);
msg->Result = 0;
msg->Handled = TRUE;
break;
It could be the problem. Simply do not handle these two messages. Let me know (and everyone else) if this works.
It didn't fix it. fast_rx said the following:
I was noticing that the start button flickers differently than the register and exit buttons. I assume that's because of the order you're drawing them.
The score in the game is also a lot worse than the rest. Is that the first thing you draw or the last?
The more I look at it, the more it looks like what would happen if you had a double buffer, but were displaying the back buffer instead of the front. I don't know if that helps you any or not, but maybe it will.
Assuming that you are using the SWAP_DISCARD mode, can you try with the SWAP_COPY mode?
Did you get any feedback from someone using the E740? If so, does the problem exists on it?
Thierry - it is on an e750. I will get fast_rx to give the SWAP_COPY mode a go and let you know.
Ok, I tried the "ducklets-fast_rx-test.exe" version and it is still messed up.
I also have access to an e740 here... I tried both the last version and the ducklets-fast_rx-test.exe one on the 740. Same results - flickering.
So the problem isn't specific to the 750.
Thierry, is there anything I can test besides the benchmark program?
This brings up another question I had. Should PHal clear out the screen when it starts? I've noticed before that when I first start a PHal app, I see the last screen of the last PHal program I ran for a split second. For instance, if I run the burning sheep demo in the benchmark and then start ducklets - I see the burning sheep image briefly.
This may be expected, but I thought it may be relevant since it seems to be some sort of problem with the buffers.
PocketHAL won't clear the backbuffer when it initializes.
If you see the last image of the last game when starting Ducklets, this would mean that Ducklets is calling Swap() before rendering anything to the backbuffer. This is to be expected on the E740/E750.
Sounds like Duckelet is calling Swap() twice per frame or something like that... J.Edwards, can you look for this? Having the last image appear at the start seems to point to this problem.
I just tried your latest version (on your web site) and sure enough the graphics are messed up on my iPAQ2215. This was working properly with an earlier version I still have (PHAL 0.6.0).
It does look like you are calling Swap() too often.
Could you also try to call BeginScene() at the start of each frame, before calling GetBackBuffer()->GetPixels()?
Thanks for the tips. I have uploaded a new version:
http://www.ducklets.com/downloads/1.00/PocketPC/ducklets-fast_rx-test2.exe
I was not calling BeginScene(). With this version I have gone back to SWAP_DISCARD, no vsync, but calling BeginScene().
I have been going over my code and can't find anywhere where it gets called twice in one frame. Might the carry over image problem just be because BeginScene wasn't called?
It doesn't solve the problem on my 2215, let's see what it does for fast_rx.
If you want, you can send me your source code (or part of it) so that I can take a look at it. It would be the fastest way to fix the issue, but then again I can understand if you don't want to do so.
Still the same...
:cry:
I was able to fix the problem on the MediaQ chips. The problem was that the window class was registered with the "hbrBackground" member set to "GetStockObject(WHITE_BRUSH)". This caused interference as GDI was clearing the screen white while PocketHAL was attempting to display Ducklets.
I am unsure if this will fix your problem fast_rx, I am sure J.Edwards will provide you with an updated copy soon enough.
Meanwhile, I will try to find a way to work around this brush thing (if it is at all possible).
fast_rx, could you please try the following version that has been fixed by Thierry:
http://www.ducklets.com/downloads/1.00/PocketPC/ducklets-fast_rx-test3.exe
PS. Thanks heaps Thierry!
Sill the same...
I also wanted to test something out - so I grabbed the latest version of PHal.
I can easily replicate the problem with ducklets.
I created a simple app that blits random pixels for the entire background. Then it draws a few squares on the screen before calling the swap().
I can see the random pixels flashing through the squares.... UNLESS I set the orientation to something other than NORMAL.
So, it does appear to be displaying the changes as they are made to the buffer, instead of waiting for the swap(). The swap specifier didn't seem to make any difference.
Jason.
fast_rx: interesting. Can you send your code? "thierry-at-droneship-dot-com". I will take a closer look at it.
I sent J.Edwards a new build (0.6.5) that will fix the problem. Waiting on him to release a new Ducklets.
The problem only occured in portrait mode on the E740 and E750.
fast_rx: here is an updated version to try with the recent updates from Thierry:
http://www.ducklets.com/downloads/1.00/PocketPC/ducklets-trial-ppc-setup.exe
Thanks.
No flickering!
But now the game hangs about 2 seconds into a level. The "Level 1" banner is still displayed and I hear the sound of a critical popup (the windows sound, that is) and the graphics stop updating.
I can still click on the screen and hear a gun shot, but not in the center of the screen. It seems like it could be that the popup I hear is keeping me from clicking on that part of the screen.
I have to reset to recover.
Thanks fast_rx. That bug you mention is something else, and it's fixed now, but there's no need to retest - the flickering at least is gone which was the important thing. Thanks for your help.