Commit 789460c1 authored by Siarhei Siamashka's avatar Siarhei Siamashka
Browse files

DRI2: Added new "SwapbuffersWait" option for xorg.conf



When enabled, it tries to avoid tearing in OpenGL ES applications.
Works on sunxi hardware in the case if the hardware overlay (sunxi
disp layer) is used for a DRI2 window. The name of this option and
the description in the man page has been borrowed from intel and
radeon drivers.
Signed-off-by: default avatarSiarhei Siamashka <siarhei.siamashka@gmail.com>
parent a60b0238
......@@ -104,6 +104,15 @@ some improvements are possible in this area. But if you really care
about the desktop performance, then you likely don't want to enable
any compositing effects in your window manager anyway.
.TP
.BI "Option \*qSwapbuffersWait\*q \*q" boolean \*q
This option controls the behavior of eglSwapBuffers calls by OpenGL ES
applications. If enabled, the calls will try to avoid tearing by making
sure the display scanline is outside of the area to be copied before the
copy occurs. If disabled, no scanline synchronization is performed,
meaning tearing will likely occur. Note that when enabled, this option
can adversely affect the framerate of applications that render frames
at less than refresh rate. Default: enabled.
.TP
.BI "Option \*qAccelMethod\*q \*q" "string" \*q
Chooses between available acceleration architectures. Valid values are
.B G2D
......
......@@ -167,6 +167,7 @@ typedef enum {
OPTION_SW_CURSOR,
OPTION_DRI2,
OPTION_DRI2_OVERLAY,
OPTION_SWAPBUFFERS_WAIT,
OPTION_ACCELMETHOD,
OPTION_USE_BS,
OPTION_FORCE_BS,
......@@ -182,6 +183,7 @@ static const OptionInfoRec FBDevOptions[] = {
{ OPTION_SW_CURSOR, "SWCursor", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_DRI2, "DRI2", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_DRI2_OVERLAY, "DRI2HWOverlay",OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_SWAPBUFFERS_WAIT,"SwapbuffersWait",OPTV_BOOLEAN,{0}, FALSE },
{ OPTION_ACCELMETHOD, "AccelMethod", OPTV_STRING, {0}, FALSE },
{ OPTION_USE_BS, "UseBackingStore",OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_FORCE_BS, "ForceBackingStore",OPTV_BOOLEAN,{0}, FALSE },
......@@ -1047,7 +1049,8 @@ FBDevScreenInit(SCREEN_INIT_ARGS_DECL)
if (xf86ReturnOptValBool(fPtr->Options, OPTION_DRI2, TRUE)) {
fPtr->SunxiMaliDRI2_private = SunxiMaliDRI2_Init(pScreen,
xf86ReturnOptValBool(fPtr->Options, OPTION_DRI2_OVERLAY, TRUE));
xf86ReturnOptValBool(fPtr->Options, OPTION_DRI2_OVERLAY, TRUE),
xf86ReturnOptValBool(fPtr->Options, OPTION_SWAPBUFFERS_WAIT, TRUE));
if (fPtr->SunxiMaliDRI2_private) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
......
......@@ -614,6 +614,11 @@ static void MaliDRI2CopyRegion(DrawablePtr pDraw,
sunxi_layer_set_x8r8g8b8_input_buffer(disp, umpbuf->offs, umpbuf->width,
umpbuf->height, umpbuf->pitch / 4);
sunxi_layer_show(disp);
if (drvpriv->bSwapbuffersWait) {
/* FIXME: blocking here for up to 1/60 second is not nice */
sunxi_wait_for_vsync(disp);
}
}
/************************************************************************/
......@@ -838,7 +843,9 @@ static void DisableHWCursor(ScrnInfoPtr pScrn)
}
}
SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, Bool bUseOverlay)
SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen,
Bool bUseOverlay,
Bool bSwapbuffersWait)
{
int drm_fd;
DRI2InfoRec info;
......@@ -909,6 +916,9 @@ SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, Bool bUseOverlay)
xf86DrvMsg(pScreen->myNum, X_INFO,
"display controller hardware overlays are not used for DRI2\n");
xf86DrvMsg(pScreen->myNum, X_INFO, "Wait on SwapBuffers? %s\n",
bSwapbuffersWait ? "enabled" : "disabled");
info.version = 3;
info.driverName = "sunxi-mali";
......@@ -949,6 +959,7 @@ SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, Bool bUseOverlay)
}
private->drm_fd = drm_fd;
private->bSwapbuffersWait = bSwapbuffersWait;
return private;
}
}
......
......@@ -131,9 +131,14 @@ typedef struct {
DRI2WindowStatePtr HashWindowState;
int drm_fd;
/* Wait for vsync when swapping DRI2 buffers */
Bool bSwapbuffersWait;
} SunxiMaliDRI2;
SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, Bool bUseOverlay);
SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen,
Bool bUseOverlay,
Bool bSwapbuffersWait);
void SunxiMaliDRI2_Close(ScreenPtr pScreen);
#endif
......@@ -12,4 +12,6 @@ Section "Device"
Identifier "Allwinner A10/A13 FBDEV"
Driver "sunxifb"
Option "fbdev" "/dev/fb0"
Option "SwapbuffersWait" "true"
EndSection
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment