[Nouveau] [PATCH] Add Option "DRI3" to allow to disable DRI3 under EXA.

Martin Peres martin.peres at free.fr
Tue Jun 30 00:00:42 PDT 2015


On 30/06/2015 06:30, Mario Kleiner wrote:
> X-Server versions older than 1.16.3 have bugs in their
> DRI3/Present implementation which impair nouveau, so
> it is better to stick to good old DRI2 by default on
> such servers. E.g., page flipping doesn't work at all
> under DRI3/Present with older servers, and use of
> extensions like OML_sync_control, SGI_video_sync or
> INTEL_swap_events also causes failure of Present.
>
> nouveau's glamor accel backend currently doesn't work under
> DRI2, so continue to use DRI3 whenever it is supported.
>
> Under the exa accel backend, DRI2 works just fine, so
> disable DRI3 and choose DRI2 by default when nouveau
> is built for X-Server < 1.16.3, and enable DRI3 if
> building on later X-Servers which work reasonably well
> under DRI3/Present.
>
> A new boolean xorg.conf Option "DRI3" allows to enforce or
> prevent use of DRI3/Present under EXA acceleration for
> testing.
>
> Also add a bit more output about status of Present and
> DRI3 to aid debugging.
>
> Signed-off-by: Mario Kleiner <mario.kleiner.de at gmail.com>
> ---
>   man/nouveau.man    |  6 ++++++
>   src/nouveau_dri2.c | 11 ++++++++++-
>   src/nv_const.h     |  2 ++
>   src/nv_driver.c    | 17 +++++++++++++++--
>   4 files changed, 33 insertions(+), 3 deletions(-)
>
> diff --git a/man/nouveau.man b/man/nouveau.man
> index 129bb7f..12cfbc0 100644
> --- a/man/nouveau.man
> +++ b/man/nouveau.man
> @@ -125,6 +125,12 @@ that relies on correct presentation timing behaviour as defined in that
>   specification.
>   .br
>   Default: 1.
> +.TP
> +.BI "Option \*qDRI3\*q \*q" boolean \*q
> +Enable the DRI3 extension under exa acceleration if supported by server.
> +A setting of "off" will only use DRI2 instead. Under glamor acceleration,
> +DRI3 is always enabled if supported. Default: on for XOrg >= 1.16.3, off for
> +earlier versions.
>   .SH "SEE ALSO"
>   __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
>   .SH AUTHORS
> diff --git a/src/nouveau_dri2.c b/src/nouveau_dri2.c
> index f22e319..d818976 100644
> --- a/src/nouveau_dri2.c
> +++ b/src/nouveau_dri2.c
> @@ -1130,7 +1130,16 @@ nouveau_dri3_screen_init(ScreenPtr screen)
>   	if (buf && stat(buf, &render) == 0 &&
>   	    master.st_mode == render.st_mode) {
>   		pNv->render_node = buf;
> -		return dri3_screen_init(screen, &nouveau_dri3_screen_info);
> +		if (dri3_screen_init(screen, &nouveau_dri3_screen_info)) {
> +			xf86DrvMsg(pScrn->scrnIndex, X_INFO,
> +				   "DRI3 on EXA enabled\n");
> +			return TRUE;
> +		}
> +		else {
> +			xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
> +				   "DRI3 on EXA initialization failed\n");
> +			return FALSE;
> +		}
>   	} else
>   		free(buf);
>   #endif
> diff --git a/src/nv_const.h b/src/nv_const.h
> index f1b4e9b..df1e398 100644
> --- a/src/nv_const.h
> +++ b/src/nv_const.h
> @@ -18,6 +18,7 @@ typedef enum {
>       OPTION_SWAP_LIMIT,
>       OPTION_ASYNC_COPY,
>       OPTION_ACCELMETHOD,
> +    OPTION_DRI3,
>   } NVOpts;
>   
>   
> @@ -34,6 +35,7 @@ static const OptionInfoRec NVOptions[] = {
>       { OPTION_SWAP_LIMIT,	"SwapLimit",	OPTV_INTEGER,	{0}, FALSE },
>       { OPTION_ASYNC_COPY,	"AsyncUTSDFS",	OPTV_BOOLEAN,	{0}, FALSE },
>       { OPTION_ACCELMETHOD,	"AccelMethod",	OPTV_STRING,	{0}, FALSE },
> +    { OPTION_DRI3,		"DRI3",		OPTV_BOOLEAN,	{0}, FALSE },
>       { -1,                       NULL,           OPTV_NONE,      {0}, FALSE }
>   };
>   
> diff --git a/src/nv_driver.c b/src/nv_driver.c
> index 8e2ae03..32f04d8 100644
> --- a/src/nv_driver.c
> +++ b/src/nv_driver.c
> @@ -1470,7 +1470,13 @@ NVScreenInit(SCREEN_INIT_ARGS_DECL)
>   
>   	xf86SetBlackWhitePixels(pScreen);
>   
> -	nouveau_present_init(pScreen);
> +	if (nouveau_present_init(pScreen) <= 0)
> +		xf86DrvMsg(pScrn->scrnIndex, X_INFO,
> +			   "Hardware support for Present disabled\n");
> +	else
> +		xf86DrvMsg(pScrn->scrnIndex, X_INFO,
> +			   "Hardware support for Present enabled\n");
> +
>   	nouveau_sync_init(pScreen);
>   	nouveau_dri2_init(pScreen);
>   	if (pNv->AccelMethod == GLAMOR) {
> @@ -1478,7 +1484,14 @@ NVScreenInit(SCREEN_INIT_ARGS_DECL)
>   			return FALSE;
>   	} else
>   	if (pNv->AccelMethod == EXA) {
> -		if (!nouveau_dri3_screen_init(pScreen))
> +		/* Default to DRI3/Present on XOrg >= 1.16.3, DRI2 on older
> +		 * servers, as older servers have DRI3/Present bugs affecting
> +		 * nouveau.
> +		 */
> +		ret = xf86ReturnOptValBool(pNv->Options, OPTION_DRI3,
> +					   XORG_VERSION_CURRENT >=
> +					   XORG_VERSION_NUMERIC(1,16,3,0,0));
> +		if (ret && !nouveau_dri3_screen_init(pScreen))
>   			return FALSE;
>   
>   		if (!nouveau_exa_init(pScreen))

I like the added verbosity and indeed, dri3 is not ready yet (I started 
working on it). I trust you for which version of the xserver is started 
working better and that you actually tested your code:

Reviewed-by: Martin Peres <martin.peres at free.fr>


More information about the Nouveau mailing list