Flickering in the sample provided (Win version)

Apr 20, 2011 at 8:53 PM

I have 2 graphics cards: inbuilt Intel based and another nVidia based.

I ran the demo in Intel mode and saw CPU used like 60%+. No problem on screen though.

Then I switched to nVidia. CPU usage was like 2-5%, but the whole screen was flickering bad. The clipped windows where the cornblue painting was done was ok, but the rest was not okay. I recorded the video which can see download here (RAR'd, very small size): http://db.tt/3Hk8jGV

FPS text, was not working at all on any card.

Hopefully, I am helping you guys by testing it. :)

Apr 20, 2011 at 9:15 PM
Edited Apr 20, 2011 at 9:16 PM

On isolating the problem, this code caused it:

 

            // Now let's try some scissoring
        spriteBatch.Begin();
            spriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle(50, 40, (int)clippingSize, (int)clippingSize);
            spriteBatch.GraphicsDevice.RenderState.ScissorTestEnable = true;

            spriteBatch.Draw(texture, new Rectangle(50, 40, 320, 40), Color.White);
            spriteBatch.DrawString(font, "Scissor Clipping Test", new Vector2(50, 40), Color.Red);
        spriteBatch.End();

        spriteBatch.GraphicsDevice.RenderState.ScissorTestEnable = false;

 

I am not very clear right now about Scissor Clipping. I will research.

Apr 21, 2011 at 6:25 AM

Bad flickering sounds like it's not page flipping properly, it's drawing on the wrong page, or the view isn't properly set.  Actually, you're saying it was fine inside the clip area?  Then yeah that's what it's supposed to do.

Apr 21, 2011 at 6:57 AM

Yes, inside the clipped windows, the painting was smooth. But it was not clean animation outside the window.

The video might help in understanding.

 

I feel that the Gl.Clear is painting buffer blue, and then clipping it. But both are painted on the window in succession. Hence the black and blue flicker.

Coordinator
Apr 22, 2011 at 8:41 PM

The Windows code is the least robust and least tested. Currently iOS, MacOS X lead and they are followed by Android and Windows is last.

Sounds like the Gl.Scissor state is interfering with normal rendering.

I hope to have a Windows machine set up tomorrow, so I can at least see the problem you mention.

Apr 22, 2011 at 10:10 PM

Please note that it works slowly but perfectly in Intel graphic card, but not in nVidia. I'm beginning to wonder if this could be driver problem.

Coordinator
Apr 22, 2011 at 11:53 PM

It certainly sounds driver related. Are you running the latest drivers in both cases?

When you say slowly, what sort of FrameRate are you getting in the Draw2D sample?

Apr 23, 2011 at 8:24 AM
Edited Apr 23, 2011 at 8:51 AM

You cannot see the FPS printed on screen because it's out of the clipping rectangular area. Hence, its not printed in Intel.

In nVidia, its always 0 (seen during flickering). Please see the video (link above ^)

 

The drivers are the tricky part. Being a dual graphic card system, the latest driver do not work. I had to try lots of them to find a stable one. So, yes, I am using bit old driver version.

Apr 10, 2012 at 4:00 PM

I'm having the same problem. 

My Draw method is only:

spriteBatch.Begin();
spriteBatch.Draw(background, new Vector2(0, 0), Color.White);
spriteBatch.End();

This code works in iOS emulator, but it doesn't in Android emulator.

Does anybody know a kind of workaround to solve this?

Thanks.

Coordinator
Apr 10, 2012 at 8:01 PM

This is an android bug and not related to this topic (which is windows specific). There is a bug it appears with the android emulator. Apparently commenting out Window.SwapBuffers in the AndroidGameWindow or Platform does the trick, it does not happen on actual devices.

Dean