PDA

View Full Version : Weird screen tearing issue (I guess screen tearing)



jason47
06-05-2013, 04:51 AM
Hi all,

I have been asking the same question in different platforms to get some help and finally I found here. Since I render in OpenGL, I believe that I can find some useful answers here.
Here is my problem,
I have a dedicated pc which is running on OpenEmbedded operating system and I am developing an application on this system. The pc has a AMD Radeon 7000 series graphics card on and it hooked up to a full HD DELL monitor. When I show a video (about 25 fps.) I see the screen tearing effect on the screen. The effect is more visible if the fps. increases. I captured a video where you can clearly see the effect. The tearing occurs mostly on the right side of the monitor with a vertical Z shape. ( Video link: https://www.dropbox.com/s/1mozdalh7tq7et7/screen_tearing_issue.mp4 )
If you can't somehow play this video, please try to download it from: https://www.dropbox.com/s/g3by9s89vcq13u1/tearing.zip
I haven't got any clue why this is happening. Could you please tell me possible reasons that I can try out?

Here is the xorg.conf file:


Section "ServerLayout"
Identifier "amdcccle Layout"
Screen 0 "amdcccle-Screen[0]-0" 0 0
Screen 1 "amdcccle-Screen[0]-1" 0 0
EndSection

Section "ServerFlags"
Option "BlankTime" "0"
Option "StandbyTime" "0"
Option "SuspendTime" "0"
Option "OffTime" "0"
Option "NoPM" "true"
EndSection

Section "Monitor"
Identifier "0-DFP1"
Option "VendorName" "ATI Proprietary Driver"
Option "ModelName" "Generic Autodetecting Monitor"
Option "DPMS" "true"
#Option "PreferredMode" "1600x900"
Option "TargetRefresh" "60"
Option "Position" "0 0"
Option "Rotate" "normal"
Option "Disable" "false"
EndSection

Section "Monitor"
Identifier "0-DFP2"
Option "VendorName" "ATI Proprietary Driver"
Option "ModelName" "Generic Autodetecting Monitor"
Option "DPMS" "true"
#Option "PreferredMode" "1920x1080"
Option "TargetRefresh" "60"
Option "Position" "1600 0"
Option "Rotate" "normal"
Option "Disable" "false"
EndSection

Section "Monitor"
Identifier "0-CRT1"
Option "VendorName" "ATI Proprietary Driver"
Option "ModelName" "Generic Autodetecting Monitor"
Option "DPMS" "true"
#Option "PreferredMode" "1920x1080"
Option "TargetRefresh" "60"
Option "Position" "1600 0"
Option "Rotate" "normal"
Option "Disable" "false"
EndSection

Section "Device"
Identifier "amdcccle-Device[0]-0"
Driver "fglrx"
Option "Monitor-DFP1" "0-DFP1"
Option "Monitor-DFP2" "0-DFP2"
BusID "PCI:0:1:0"
EndSection

Section "Screen"
Identifier "amdcccle-Screen[0]-0"
Device "amdcccle-Device[0]-0"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Virtual 4480 1920
Depth 24
EndSubSection
EndSection

Section "Screen"
Identifier "amdcccle-Screen[0]-1"
Device "amdcccle-Device[0]-0"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
#Virtual 3520 1920
Depth 24
EndSubSection
EndSection


I have already tried running



aticonfig --sync-vsync


Eventually it adds the following line to xorg.conf



Option "Capabilities" "0x00000800"


I killed the X Server after this change but the problem still persists.

According to me, the screen tearing effect shows up as a line but in my case it is like a Z shape. Can it be related to something else? Do you think that this is still called as screen tearing?

I'd appreciate your helps.

jason47
06-06-2013, 03:58 AM
Since no one has any idea in such a forum, I will consider this issue impossible to solve. Well, at least for now.

Nowhere-01
06-06-2013, 05:59 AM
maybe that's because you didn't post actual opengl context initialization and drawing code?

it may be lack of double-buffering or you setting 'Target Refresh' to '60' conflicts with V-Sync.

jason47
06-07-2013, 03:49 AM
maybe that's because you didn't post actual opengl context initialization and drawing code?

it may be lack of double-buffering or you setting 'Target Refresh' to '60' conflicts with V-Sync.

Hi. Thanks for your reply.
I forgot to mention that our application is written in Qt 4.8.1. So we just add "QGLContext" and it does everything about context initialization stuff.
For the drawing code,



// Bind to texture that contains the frame buffer.
glBindTexture(GL_TEXTURE_2D, mvID);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

// Enable texturing.
glEnable(GL_TEXTURE_2D);

// Take into account opacity.
glColor4f(1.0f, 1.0f, 1.0f, aOpacity);

// Draw textured rectangle with the image.
glBegin(GL_QUADS);

glTexCoord2f(aTexCoordLeft, aTexCoordTop);
glVertex3f(aVertexLeft, aVertexTop, 0.0f);

glTexCoord2f(aTexCoordRight, aTexCoordTop);
glVertex3f(aVertexRight, aVertexTop, 0.0f);

glTexCoord2f(aTexCoordRight, aTexCoordBottom);
glVertex3f(aVertexRight, aVertexBottom, 0.0f);

glTexCoord2f(aTexCoordLeft, aTexCoordBottom);
glVertex3f(aVertexLeft, aVertexBottom, 0.0f);

glEnd();


Above code is normally written in different functions. I just tried to combine them, so please bear in mind that it may not compile in this form. It is just to show how I draw the texture.

BTW, I already tried disabling 'Target Refresh' to '60' or even changing it to different numbers but it didn't really help.

If above code doesn't help, could you please tell me where or what to look specifically? Because I can browse through the Qt OpenGL related codes and perhaps I can find something useful there?

Many thanks.

Nowhere-01
06-07-2013, 03:53 AM
you should call QGLContext::swapBuffers() at the end of each frame.

jason47
06-07-2013, 04:18 AM
you should call QGLContext::swapBuffers() at the end of each frame.

I called it right after I call apPainter->endNativePainting();
I couldn't directly call it as you provide me but used as below:
mpGLWidget->context()->swapBuffers();

However, it got worse. I see the image on the screen if I move the mouse and whole image goes on and off. I think it is already called somewhere in the endNativePainting().

Nowhere-01
06-07-2013, 05:49 AM
ok, yes, QT does double-buffering by default.

another problem i see is:

glTexCoord2f(aTexCoordLeft, aTexCoordTop);
glVertex3f(aVertexLeft, aVertexTop, 0.0f);

glTexCoord2f(aTexCoordRight, aTexCoordTop);
glVertex3f(aVertexRight, aVertexTop, 0.0f);

glTexCoord2f(aTexCoordRight, aTexCoordBottom);
glVertex3f(aVertexRight, aVertexBottom, 0.0f);

glTexCoord2f(aTexCoordLeft, aTexCoordBottom);
glVertex3f(aVertexLeft, aVertexBottom, 0.0f);

and i don't see any matrix transformations. you are using legacy functions for drawing primitives. but i don't see any gluPerspective\glOrtho2D calls. and your quad's Z-position is 0.0f. if there's no transformations omitted from code, it shouldn't draw at all, cause near plane is always > 0.0;

http://www.thasler.org/blog/?p=10 look at this tutorial. he specifies projection matrix with gluPerspective and although he also has 0.0 as Z-component, he translates a quad with glTranslatef(0.0f, 0.0f, -5.0f); before drawing, because OpenGL is right-handed, so negative-Z points away from default camera origin with legacy matrix math.