xf86-video-amdgpu integration for DRM variable refresh rate API
cover xf86-video-amdgpu integration for DRM variable refresh rate API
These patches are part of a proposed new interface for supporting variable refresh rate via DRM properties.
https://patchwork.freedesktop.org/series/49486/
When notified of a window that is FreeSync capable via X these patches help track when the window is fullscreen to manage the variable_refresh property on the CRTC.
=== Adaptive sync and variable refresh rate ===
Adaptive sync is part of the DisplayPort spec and allows for graphics adapters to drive displays with varying frame timings.
Variable refresh rate (VRR) is essentially the same, but defined for HDMI.
=== Use cases for variable refresh rate ===
Variable frame (flip) timings don't align well with fixed refresh rate displays. This results in stuttering, tearing and/or input lag. By adjusting the display refresh rate dynamically these issues can be reduced or eliminated.
However, not all content is suitable for dynamic refresh adaptation. Content that is flipped infrequently or at random intervals tends to fair poorly. Multiple clients trying to flip under the same screen can similarly interfere with prediction.
Userland needs a way to let the driver know when the content on the screen is suitable for variable refresh rate and if the user wishes to have the feature enabled.
=== DRM API to support variable refresh rates ===
This patch introduces a new API via atomic properties on the DRM connector and CRTC.
The connector has two new optional properties:
* bool variable_refresh_capable - set by the driver if the hardware is capable of supporting variable refresh tech
* bool variable_refresh_enabled - set by the user to enable variable refresh adjustment over the connector
The CRTC has one additional default property:
* bool variable_refresh - a content hint to the driver specifying that the CRTC contents are suitable for variable refresh adjustment
== Overview for DRM driver developers ===
Driver developers can attach the optional connector properties via drm_connector_attach_variable_refresh_properties on connectors that support variable refresh (typically DP or HDMI).
The variable_refresh_capable property should be managed as the output on the connector changes. The property is read only from userspace.
The variable_refresh_enabled property is intended to be a property controlled by userland as a global on/off switch for variable refresh technology. It should be checked before enabling variable refresh rate.
=== Overview for Userland developers ==
The variable_refresh property on the CRTC should be set to true when the CRTCs are suitable for variable refresh rate. In practice this is probably an application like a game - a single window that covers the whole CRTC surface and is the only client issuing flips.
To demonstrate the suitability of the API for variable refresh and dynamic adaptation there are additional patches using this API that implement adaptive variable refresh across kernel and userland projects:
- DRM (dri-devel)
- amdgpu DRM kernel driver (amd-gfx)
- xf86-video-amdgpu (amd-gfx)
- mesa (mesa-dev)
These patches enable adaptive variable refresh on X for AMD hardware provided that the user sets the variable_refresh_enabled property to true on supported connectors (ie. using xrandr --set-prop).
They have been tested on upstream userland under GNOME/KDE desktop environments under single and multi-monitor setups for a number of GL applications. Most games and benchmarks should work as expected provided that the compositor correctly unredirects the application's surface. KDE seems to have the best support for this with an explicit option to disable tearing support.
Full implementation details for these changes can be reviewed in their respective mailing lists.
=== Previous discussions ===
These patches are based upon feedback from patches and feedback from two previous threads on the subject which are linked below for reference:
https://lists.freedesktop.org/archives/amd-gfx/2018-April/021047.html
https://lists.freedesktop.org/archives/dri-devel/2017-October/155207.html
Nicholas Kazlauskas
Hawking Zhang (5):
Enable/Disable freesync when enter/exit fullscreen game v2 Set freesync capability when client has fullscreen size drawable Do not fail the X request when there is just BadDrawable/BadMatch Handle Alt+Tab case when freesync enabled in steam client v2 Do not issue freesync ioctl from present unflip
Nicholas Kazlauskas (1):
Replace amdgpu ioctl with CRTC properties for enabling FreeSync
src/Makefile.am | 2 + src/amdgpu_dri2.c | 1 + src/amdgpu_drv.h | 10 ++ src/amdgpu_extension.c | 210 +++++++++++++++++++++++++++++++++++++++++ src/amdgpu_extension.h | 53 +++++++++++ src/amdgpu_kms.c | 60 ++++++++++++ src/amdgpu_present.c | 1 + src/drmmode_display.c | 88 +++++++++++++++++ src/drmmode_display.h | 1 + 9 files changed, 426 insertions(+) create mode 100644 src/amdgpu_extension.c create mode 100644 src/amdgpu_extension.h
Signature · 6 lines
2.18.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180911161842.5480-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org
PATCH 1/6 Enable/Disable freesync when enter/exit fullscreen game v2
From: Hawking Zhang <[email protected]>
v2:
resolve undefined symbol in xserver 1.16
--- src/Makefile.am | 2 + src/amdgpu_dri2.c | 24 ++++++ src/amdgpu_drv.h | 5 ++ src/amdgpu_extension.c | 176 +++++++++++++++++++++++++++++++++++++++++ src/amdgpu_extension.h | 52 ++++++++++++ src/amdgpu_kms.c | 4 + src/amdgpu_present.c | 14 ++++ 7 files changed, 277 insertions(+) create mode 100644 src/amdgpu_extension.c create mode 100644 src/amdgpu_extension.h
src/Makefile.am +2 -0
@@ -47,6 +47,7 @@ amdgpu_drv_ladir = @moduledir@/drivers amdgpu_drv_la_SOURCES = \ amdgpu_video.c \ amdgpu_misc.c amdgpu_probe.c \ + amdgpu_extension.c \ $(AMDGPU_KMS_SRCS) AM_CFLAGS += @LIBGLAMOR_CFLAGS@
@@ -64,6 +65,7 @@ EXTRA_DIST = \ amdgpu_drv.h \ amdgpu_pixmap.h \ amdgpu_probe.h \ + amdgpu_extension.h \ amdgpu_version.h \ amdgpu_video.h \ simple_list.h \
src/amdgpu_dri2.c +24 -0
@@ -34,6 +34,7 @@#include "amdgpu_glamor.h" #include "amdgpu_video.h" #include "amdgpu_pixmap.h" +#include "amdgpu_extension.h" #ifdef DRI2
@@ -527,6 +528,13 @@ amdgpu_dri2_schedule_flip(xf86CrtcPtr crtc, ClientPtr client,xf86DrvMsgVerb (scrn->scrnIndex,X_INFO ,AMDGPU_LOGLEVEL_DEBUG ,"%s:%d fevent[%p]\n" , __func__, __LINE__, flip_info); +if (info->freesync_capable_client && + info->freesync_enabled == FALSE) { +AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn); +if (!AMDGPUFreesyncControl (pAMDGPUEnt->fd, TRUE)) + info->freesync_enabled = TRUE; + } +/* Page flip the full screen buffer */ back_priv = back->driverPrivate; if (amdgpu_do_pageflip(scrn, client, back_priv->pixmap,
@@ -680,6 +688,8 @@ static void amdgpu_dri2_frame_event_handler(xf86CrtcPtr crtc, uint32_t seq, {DRI2FrameEventPtr event = event_data;ScrnInfoPtr scrn = crtc->scrn; +AMDGPUInfoPtr info =AMDGPUPTR (scrn); +AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn);DrawablePtr drawable;int status;int swap_type;
@@ -710,6 +720,12 @@ static void amdgpu_dri2_frame_event_handler(xf86CrtcPtr crtc, uint32_t seq, }/* else fall through to exchange/blit */ case DRI2_SWAP : +if (info->freesync_capable_client && + info->freesync_enabled == TRUE) { +if (!AMDGPUFreesyncControl (pAMDGPUEnt->fd, FALSE)) + info->freesync_enabled = FALSE; + } +if (DRI2CanExchange (drawable) &&can_exchange (scrn, drawable, event->front, event->back)) { amdgpu_dri2_exchange_buffers(drawable, event->front,
@@ -1076,6 +1092,8 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, {ScreenPtr screen = draw->pScreen;ScrnInfoPtr scrn =xf86ScreenToScrn (screen); +AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn); +AMDGPUInfoPtr info =AMDGPUPTR (scrn);xf86CrtcPtr crtc =amdgpu_dri2_drawable_crtc (draw, TRUE);uint32_t msc_delta;drmVBlankSeqType type;
@@ -1248,6 +1266,12 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,return TRUE; blit_fallback: +if (info->freesync_capable_client && + info->freesync_enabled == TRUE) { +if (!AMDGPUFreesyncControl (pAMDGPUEnt->fd, FALSE)) + info->freesync_enabled = FALSE; + } +if (swap_info) { swap_info->type =DRI2_SWAP ;amdgpu_dri2_schedule_event (FALLBACK_SWAP_DELAY , swap_info);
src/amdgpu_drv.h +5 -0
@@ -303,6 +303,11 @@ typedef struct {/* kms pageflipping */ Bool allowPageFlip; +/* freesync */ +ClientPtr freesync_capable_client; +uint32_t client_resource_id; +Bool freesync_enabled; +/* cursor size */ int cursor_w;int cursor_h;
src/amdgpu_extension.c new file +176 -0
176 lines not on this page · raw message
src/amdgpu_extension.h new file +52 -0
52 lines not on this page · raw message
src/amdgpu_kms.c +4 -0
@@ -59,6 +59,7 @@#include "amdgpu_bo_helper.h" #include "amdgpu_pixmap.h" +#include "amdgpu_extension.h" #include <gbm.h>
@@ -1885,6 +1886,9 @@ Bool AMDGPUScreenInit_KMS(ScreenPtr pScreen, int argc, char **argv)xf86DrvMsg (pScrn->scrnIndex,X_INFO ,"2D and 3D acceleration disabled\n" ); } +/* AMDGPU extension setup */ +AMDGPUExtensionSetup (); +/* Init DPMS */ xf86DrvMsgVerb (pScrn->scrnIndex,X_INFO ,AMDGPU_LOGLEVEL_DEBUG ,"Initializing DPMS\n" );
src/amdgpu_present.c +14 -0
@@ -45,6 +45,7 @@#include "amdgpu_glamor.h" #include "amdgpu_pixmap.h" #include "amdgpu_video.h" +#include "amdgpu_extension.h" #include "present.h"
@@ -321,6 +322,13 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc,if (!amdgpu_present_check_flip (crtc, screen->root, pixmap, sync_flip))return ret; +if (info->freesync_capable_client && + info->freesync_enabled == FALSE) { +AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn); +if (!AMDGPUFreesyncControl (pAMDGPUEnt->fd, TRUE)) + info->freesync_enabled = TRUE; + } + event =calloc (1 ,sizeof (struct amdgpu_present_vblank_event ));if (!event)return ret;
@@ -362,6 +370,12 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)if (!amdgpu_present_check_unflip (scrn)) goto modeset; +if (info->freesync_capable_client && + info->freesync_enabled == TRUE) { +if (!AMDGPUFreesyncControl (pAMDGPUEnt->fd, FALSE)) + info->freesync_enabled = FALSE; + } + event =calloc (1 ,sizeof (struct amdgpu_present_vblank_event ));if (!event) {ErrorF ("%s: calloc failed, display might freeze\n" , __func__);
Signature · 6 lines
2.18.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/6 Set freesync capability when client has fullscreen size drawable
In reply to a message not in the archiveFrom: Hawking Zhang <[email protected]>
OGL send freesync request to ddx driver when it makes a drawable as current DDX driver only set the client to be freesync capable when it is a fullscreen size one.
--- src/amdgpu_extension.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
src/amdgpu_extension.c +11 -1
@@ -32,6 +32,8 @@#include "extnsionst.h" #include "resource.h" #include "scrnintstr.h" +#include "dixaccess.h" +#include "pixmap.h" #include "amdgpu_drm.h" #include "amdgpu_extension.h"
@@ -53,8 +55,16 @@ static int ProcAMDGPUFreesyncCapability(ClientPtr client)ScrnInfoPtr pScrn =xf86ScreenToScrn (pScreen);AMDGPUInfoPtr info =AMDGPUPTR (pScrn);XID cliResId; +DrawablePtr pDrawable =NULL ; +if (dixLookupDrawable (&pDrawable, (Drawable )stuff->drawable, + client,0 , DixReadAccess)) +return BadValue; -if (info->freesync_capable_client ==NULL ) { +if (info->freesync_capable_client ==NULL && + pDrawable->x == pDrawable->pScreen->x && + pDrawable->y == pDrawable->pScreen->y && + pDrawable->width == pDrawable->pScreen->width && + pDrawable->height == pDrawable->pScreen->height) { info->freesync_capable_client = client; cliResId =FakeClientID (client->index);if (AddResource (cliResId,RT_AMDGPUCLIENT , (void *)pScrn))
Signature · 6 lines
2.18.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/6 Do not fail the X request when there is just BadDrawable/BadMatch
In reply to a message not in the archiveFrom: Hawking Zhang <[email protected]>
There is BadDrawable/BadMatch case for dixLookupDrawable. But DDX driver don't need to fail the request with BadValue. Instead, only make sure the drawable is successfully found and check its size
--- src/amdgpu_extension.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
src/amdgpu_extension.c +6 -4
@@ -56,11 +56,13 @@ static int ProcAMDGPUFreesyncCapability(ClientPtr client)AMDGPUInfoPtr info =AMDGPUPTR (pScrn);XID cliResId;DrawablePtr pDrawable =NULL ; -if (dixLookupDrawable (&pDrawable, (Drawable )stuff->drawable, - client,0 , DixReadAccess)) -return BadValue; +int ret =-1 ; + + ret =dixLookupDrawable (&pDrawable, (Drawable )stuff->drawable, + client,0 , DixReadAccess); - if (info->freesync_capable_client == NULL && + if (!ret && + info->freesync_capable_client == NULL && pDrawable->x == pDrawable->pScreen->x && pDrawable->y == pDrawable->pScreen->y && pDrawable->width == pDrawable->pScreen->width &&
Signature · 6 lines
2.18.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/6 Handle Alt+Tab case when freesync enabled in steam client v2
In reply to a message not in the archiveFrom: Hawking Zhang <[email protected]>
v2:
fix ddx build warning unused var
The change supports the following scenario when freesync enabled for steam game 1). use Alt+Tab to run-time switch between windowed mode and fullscreen mode 2). use option setting to switch between windowed mode and fullscreen mode Also verified on unigine heaven via setting check/un-check fullscreen
--- src/amdgpu_dri2.c | 9 ++++++--- src/amdgpu_drv.h | 8 ++++++-- src/amdgpu_extension.c | 25 +++++++++++++++---------- src/amdgpu_kms.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/amdgpu_present.c | 3 ++- 5 files changed, 70 insertions(+), 16 deletions(-)
src/amdgpu_dri2.c +6 -3
@@ -528,7 +528,8 @@ amdgpu_dri2_schedule_flip(xf86CrtcPtr crtc, ClientPtr client,xf86DrvMsgVerb (scrn->scrnIndex,X_INFO ,AMDGPU_LOGLEVEL_DEBUG ,"%s:%d fevent[%p]\n" , __func__, __LINE__, flip_info); -if (info->freesync_capable_client && +if (info->allow_freesync && + info->freesync_client && info->freesync_enabled == FALSE) {AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn);if (!AMDGPUFreesyncControl (pAMDGPUEnt->fd, TRUE))
@@ -720,7 +721,8 @@ static void amdgpu_dri2_frame_event_handler(xf86CrtcPtr crtc, uint32_t seq, }/* else fall through to exchange/blit */ case DRI2_SWAP : -if (info->freesync_capable_client && +if (info->allow_freesync && + info->freesync_client && info->freesync_enabled == TRUE) {if (!AMDGPUFreesyncControl (pAMDGPUEnt->fd, FALSE)) info->freesync_enabled = FALSE;
@@ -1266,7 +1268,8 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,return TRUE; blit_fallback: -if (info->freesync_capable_client && +if (info->allow_freesync && + info->freesync_client && info->freesync_enabled == TRUE) {if (!AMDGPUFreesyncControl (pAMDGPUEnt->fd, FALSE)) info->freesync_enabled = FALSE;
src/amdgpu_drv.h +6 -2
@@ -248,6 +248,8 @@ typedef struct {uint32_t family;struct gbm_device *gbm; +ClipNotifyProcPtr ClipNotify; +Bool (*CloseScreen) (ScreenPtr pScreen);void (*BlockHandler) (BLOCKHANDLER_ARGS_DECL );
@@ -304,9 +306,11 @@ typedef struct {Bool allowPageFlip;/* freesync */ -ClientPtr freesync_capable_client; -uint32_t client_resource_id; +ClientPtr freesync_client; +DrawablePtr freesync_drawable; +XID freesync_client_id;Bool freesync_enabled; +Bool allow_freesync;/* cursor size */ int cursor_w;
src/amdgpu_extension.c +15 -10
@@ -62,15 +62,17 @@ static int ProcAMDGPUFreesyncCapability(ClientPtr client) client, 0, DixReadAccess);if (!ret && - info->freesync_capable_client ==NULL && pDrawable->x == pDrawable->pScreen->x && pDrawable->y == pDrawable->pScreen->y && pDrawable->width == pDrawable->pScreen->width && pDrawable->height == pDrawable->pScreen->height) { - info->freesync_capable_client = client; - cliResId =FakeClientID (client->index); -if (AddResource (cliResId,RT_AMDGPUCLIENT , (void *)pScrn)) - info->client_resource_id = cliResId; +if (!info->freesync_client) { + info->freesync_client = client; + cliResId =FakeClientID (client->index); +if (AddResource (cliResId,RT_AMDGPUCLIENT , (void *)pScrn)) + info->freesync_client_id = cliResId; + } + info->freesync_drawable = pDrawable; }return client->noClientException;
@@ -162,8 +164,8 @@ void AMDGPUFreeResourceByType(ScreenPtr pScreen)ScrnInfoPtr pScrn =xf86ScreenToScrn (pScreen);AMDGPUInfoPtr info =AMDGPUPTR (pScrn); -if (info->client_resource_id) -FreeResourceByType (info->client_resource_id, +if (info->freesync_client_id) +FreeResourceByType (info->freesync_client_id,RT_AMDGPUCLIENT , FALSE);return ; }
@@ -174,9 +176,10 @@ int AMDGPUClientGone(void *data, XID id)AMDGPUInfoPtr info =AMDGPUPTR (pScrn);AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (pScrn); -if (id == (XID )info->client_resource_id) { - info->client_resource_id = None; - info->freesync_capable_client =NULL ; +if (id == info->freesync_client_id) { + info->freesync_client_id = None; + info->freesync_client =NULL ; + info->freesync_drawable =NULL ; }if (info->freesync_enabled == TRUE) {
@@ -184,5 +187,7 @@ int AMDGPUClientGone(void *data, XID id) info->freesync_enabled = FALSE; } + info->allow_freesync = FALSE; +return 1 ; }
src/amdgpu_kms.c +41 -0
53 lines not on this page · raw message
src/amdgpu_present.c +2 -1
@@ -322,7 +322,8 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc,if (!amdgpu_present_check_flip (crtc, screen->root, pixmap, sync_flip))return ret; -if (info->freesync_capable_client && +if (info->allow_freesync && + info->freesync_client && info->freesync_enabled == FALSE) {AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn);if (!AMDGPUFreesyncControl (pAMDGPUEnt->fd, TRUE))
Signature · 6 lines
2.18.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/6 Do not issue freesync ioctl from present unflip
In reply to a message not in the archiveFrom: Hawking Zhang <[email protected]>
It prefers that freesync is enable/disable per client lifecycle rather than per flip. With the patch, freesync will be disabled when clientgone or switch to windowed mode.
--- src/amdgpu_present.c | 6 ------ 1 file changed, 6 deletions(-)
src/amdgpu_present.c +0 -6
@@ -371,12 +371,6 @@ amdgpu_present_unflip(ScreenPtr screen, uint64_t event_id)if (!amdgpu_present_check_unflip (scrn)) goto modeset; -if (info->freesync_capable_client && - info->freesync_enabled == TRUE) { -if (!AMDGPUFreesyncControl (pAMDGPUEnt->fd, FALSE)) - info->freesync_enabled = FALSE; - } - event =calloc (1 ,sizeof (struct amdgpu_present_vblank_event ));if (!event) {ErrorF ("%s: calloc failed, display might freeze\n" , __func__);
Signature · 6 lines
2.18.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/6 Replace amdgpu ioctl with CRTC properties for enabling FreeSync
In reply to a message not in the archiveThe support for per-CRTC variable refresh control via DRM properties means that the driver specific FreeSync IOCTL can be replaced.
In order to accomodate this new behavior existing changes to how and when FreeSync is enabled/disabled was needed.
There are 3 behavioral differences this patch introduces:
1. FreeSync clients are considered fullscreen when they cover an entire CRTC instead of the X Screen.
This allows FreeSync to be enabled in multi-monitor situations.
2. FreeSync is enabled immediately upon receiving the FreeSync request.
This replaces the deferred enablment on flip. The CRTC can be targeted directly and there's no need to wait until the flip. The DC kernel driver will take care of enabling/disabling on the next flip.
The caveat here is that some windows (like desktop compositor surfaces) will have FreeSync enabled if they are not explicitly blacklisted (ie. in mesa).
Since these typically didn't change position or size they were ignored previously. There was a bug here, however - if you hotplug monitors in certain configurations then you'd be stuck with FreeSync enabled on the Desktop until reboot.
3. Freesync is disabled when the Drawable's Window is destroyed instead of when the client resource is removed.
The need for allocation of a resource to handle this is unecessary when we get callbacks for each Window being destroyed on the screen.
The remaining changes are small cleanups that shouldn't affect functional behavior.
--- src/amdgpu_dri2.c | 26 ------- src/amdgpu_drv.h | 5 +- src/amdgpu_extension.c | 149 +++++++++++++++++++++++------------------ src/amdgpu_extension.h | 7 +- src/amdgpu_kms.c | 45 ++++++++----- src/amdgpu_present.c | 8 --- src/drmmode_display.c | 88 ++++++++++++++++++++++++ src/drmmode_display.h | 1 + 8 files changed, 209 insertions(+), 120 deletions(-)
src/amdgpu_dri2.c +0 -26
@@ -528,14 +528,6 @@ amdgpu_dri2_schedule_flip(xf86CrtcPtr crtc, ClientPtr client,xf86DrvMsgVerb (scrn->scrnIndex,X_INFO ,AMDGPU_LOGLEVEL_DEBUG ,"%s:%d fevent[%p]\n" , __func__, __LINE__, flip_info); -if (info->allow_freesync && - info->freesync_client && - info->freesync_enabled == FALSE) { -AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn); -if (!AMDGPUFreesyncControl (pAMDGPUEnt->fd, TRUE)) - info->freesync_enabled = TRUE; - } -/* Page flip the full screen buffer */ back_priv = back->driverPrivate; if (amdgpu_do_pageflip(scrn, client, back_priv->pixmap,
@@ -689,8 +681,6 @@ static void amdgpu_dri2_frame_event_handler(xf86CrtcPtr crtc, uint32_t seq, {DRI2FrameEventPtr event = event_data;ScrnInfoPtr scrn = crtc->scrn; -AMDGPUInfoPtr info =AMDGPUPTR (scrn); -AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn);DrawablePtr drawable;int status;int swap_type;
@@ -721,13 +711,6 @@ static void amdgpu_dri2_frame_event_handler(xf86CrtcPtr crtc, uint32_t seq, }/* else fall through to exchange/blit */ case DRI2_SWAP : -if (info->allow_freesync && - info->freesync_client && - info->freesync_enabled == TRUE) { -if (!AMDGPUFreesyncControl (pAMDGPUEnt->fd, FALSE)) - info->freesync_enabled = FALSE; - } -if (DRI2CanExchange (drawable) &&can_exchange (scrn, drawable, event->front, event->back)) { amdgpu_dri2_exchange_buffers(drawable, event->front,
@@ -1094,8 +1077,6 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, {ScreenPtr screen = draw->pScreen;ScrnInfoPtr scrn =xf86ScreenToScrn (screen); -AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn); -AMDGPUInfoPtr info =AMDGPUPTR (scrn);xf86CrtcPtr crtc =amdgpu_dri2_drawable_crtc (draw, TRUE);uint32_t msc_delta;drmVBlankSeqType type;
@@ -1268,13 +1249,6 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,return TRUE; blit_fallback: -if (info->allow_freesync && - info->freesync_client && - info->freesync_enabled == TRUE) { -if (!AMDGPUFreesyncControl (pAMDGPUEnt->fd, FALSE)) - info->freesync_enabled = FALSE; - } -if (swap_info) { swap_info->type =DRI2_SWAP ;amdgpu_dri2_schedule_event (FALLBACK_SWAP_DELAY , swap_info);
src/amdgpu_drv.h +3 -2
@@ -249,6 +249,7 @@ typedef struct {struct gbm_device *gbm;ClipNotifyProcPtr ClipNotify; +DestroyWindowProcPtr DestroyWindow;Bool (*CloseScreen) (ScreenPtr pScreen);
@@ -307,8 +308,8 @@ typedef struct {/* freesync */ ClientPtr freesync_client; -DrawablePtr freesync_drawable; -XID freesync_client_id; +xf86CrtcPtr freesync_crtc; +XID freesync_xid;Bool freesync_enabled;Bool allow_freesync;
src/amdgpu_extension.c +83 -66
196 lines not on this page · raw message
src/amdgpu_extension.h +4 -3
@@ -46,7 +46,8 @@ typedef struct _AMDGPUFreesyncCapabilityReq {#define sz_xAMDGPUFreesyncCapabilityReq XREQ_SZ(AMDGPUFreesyncCapability)extern void AMDGPUExtensionSetup (void ); -extern int AMDGPUFreesyncControl (int fd,Bool enable_freesync); -extern void AMDGPUFreeResourceByType (ScreenPtr pScreen); -extern int AMDGPUClientGone (void *data,XID id); +extern void AMDGPUResetFreesync (ScrnInfoPtr pScrn); +extern xf86CrtcPtr AMDGPUGetFreesyncCRTC (WindowPtr win); +extern void AMDGPUSetFreesync (xf86CrtcPtr crtc,Bool enabled); +#endif /* _AMDGPU_EXTENSION_H_ */
src/amdgpu_kms.c +30 -15
69 lines not on this page · raw message
src/amdgpu_present.c +0 -8
@@ -322,14 +322,6 @@ amdgpu_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc,if (!amdgpu_present_check_flip (crtc, screen->root, pixmap, sync_flip))return ret; -if (info->allow_freesync && - info->freesync_client && - info->freesync_enabled == FALSE) { -AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn); -if (!AMDGPUFreesyncControl (pAMDGPUEnt->fd, TRUE)) - info->freesync_enabled = TRUE; - } - event =calloc (1 ,sizeof (struct amdgpu_present_vblank_event ));if (!event)return ret;
src/drmmode_display.c +88 -0
94 lines not on this page · raw message
src/drmmode_display.h +1 -0
@@ -255,6 +255,7 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, uint32_t target_msc);int drmmode_crtc_get_ust_msc (xf86CrtcPtr crtc,CARD64 *ust,CARD64 *msc);int drmmode_get_current_ust (int drm_fd,CARD64 * ust); +extern Bool drmmode_set_variable_refresh (xf86CrtcPtr crtc,Bool enabled); Bool drmmode_wait_vblank(xf86CrtcPtr crtc, drmVBlankSeqType type, uint32_t target_seq, unsigned long signal,
Signature · 6 lines
2.18.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi Nicholas,
thanks for the patches.
Quoted 5 lines · Nicholas Kazlauskas
These patches are part of a proposed new interface for supporting variable refresh rate via DRM properties.
https://patchwork.freedesktop.org/series/49486/
When notified of a window that is FreeSync capable via X these patches help track when the window is fullscreen to manage the
variable_refreshproperty on the CRTC.
I'm afraid the Xorg driver support will have to be more or less redone from scratch for upstreaming:
Whether or not a client wants variable refresh rate enabled can be tracked via the window property mechanism supported by the core X11 protocol, no need for a protocol extension.
That should also allow simpler tracking of when variable refresh rate can actually be enabled: It can be enabled while a window is flipping, and its corresponding property allows it. This should be straightforward with the Present extension, because that also explicitly marks the end of a window flipping (via an "unflip"). DRI2 is trickier; it's probably okay not to support variable refresh rate with that, at least initially.
I can look into this after the upcoming Xorg driver 18.1 releases. Or I can give guidance if one of you wants to look into it.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): fa19516d-92a2-34da-e472-b1f03740a12e-otUistvHUpPR7s880joybQ@public.gmane.org
Quoted 29 lines · Michel Dänzer
Hi Nicholas,
thanks for the patches.
Quoted 5 lines · Nicholas Kazlauskas
These patches are part of a proposed new interface for supporting variable refresh rate via DRM properties.
https://patchwork.freedesktop.org/series/49486/
When notified of a window that is FreeSync capable via X these patches help track when the window is fullscreen to manage the
variable_refreshproperty on the CRTC.I'm afraid the Xorg driver support will have to be more or less redone from scratch for upstreaming:
Whether or not a client wants variable refresh rate enabled can be tracked via the window property mechanism supported by the core X11 protocol, no need for a protocol extension.
That should also allow simpler tracking of when variable refresh rate can actually be enabled: It can be enabled while a window is flipping, and its corresponding property allows it. This should be straightforward with the Present extension, because that also explicitly marks the end of a window flipping (via an "unflip"). DRI2 is trickier; it's probably okay not to support variable refresh rate with that, at least initially.
Quoted 4 lines
I can look into this after the upcoming Xorg driver 18.1 releases. Or I can give guidance if one of you wants to look into it.
I can a look into this. I agree that the extension method is less than ideal - in being vendor specific mostly. It does have the nice property that it remains independent of the application's render backend, though.
I imagine you're suggesting specifying a window property hint like _NET_WM_BYPASS_COMPOSITOR - maybe a define new one like _NET_WM_VARIABLE_REFRESH (even though the two are closely related in terms of fullscreen behavior). Then in each backend the property could probably be checked before the present as appropriate.
This patch series already has the problem you're describing about DRI2 where there's not a nice explicit end notification for flipping - it's only disabled when the window no longer covers the CRTC or the window is destroyed (which is the case for most applications but likely not all).
Thanks for the feedback.
Nicholas Kazlauskas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 542b5954-00f2-938b-b98e-210bd81a833d-5C7GfCeVMHo@public.gmane.org
Quoted 26 lines · Nicholas
Quoted 25 lines · Michel Dänzer
Quoted 8 lines · Nicholas Kazlauskas
These patches are part of a proposed new interface for supporting variable refresh rate via DRM properties.
https://patchwork.freedesktop.org/series/49486/
When notified of a window that is FreeSync capable via X these patches help track when the window is fullscreen to manage the
variable_refreshproperty on the CRTC.I'm afraid the Xorg driver support will have to be more or less redone from scratch for upstreaming:
Whether or not a client wants variable refresh rate enabled can be tracked via the window property mechanism supported by the core X11 protocol, no need for a protocol extension.
That should also allow simpler tracking of when variable refresh rate can actually be enabled: It can be enabled while a window is flipping, and its corresponding property allows it. This should be straightforward with the Present extension, because that also explicitly marks the end of a window flipping (via an "unflip"). DRI2 is trickier; it's probably okay not to support variable refresh rate with that, at least initially.
Quoted 6 lines
Quoted 2 lines
I can look into this after the upcoming Xorg driver 18.1 releases. Or I can give guidance if one of you wants to look into it.
I can a look into this. I agree that the extension method is less than ideal - in being vendor specific mostly. It does have the nice property that it remains independent of the application's render backend, though.
Not sure what you mean by that. Surely a window property is just as independent. :)
Quoted 5 lines
I imagine you're suggesting specifying a window property hint like
_NET_WM_BYPASS_COMPOSITOR- maybe a define new one like_NET_WM_VARIABLE_REFRESH(even though the two are closely related in terms of fullscreen behavior). Then in each backend the property could probably be checked before the present as appropriate.
Right. (Not sure the _NET_WM prefix is appropriate, as it's nothing to do with the window manager, but that's a detail)
Quoted 4 lines
This patch series already has the problem you're describing about DRI2 where there's not a nice explicit end notification for flipping - it's only disabled when the window no longer covers the CRTC or the window is destroyed (which is the case for most applications but likely not all).
Right. I think it's better to just not bother with DRI2, at least until there's a specific scenario where variable refresh is really needed with DRI2.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 4f1abeb4-b948-b4b3-a377-cd00dce18707-otUistvHUpPR7s880joybQ@public.gmane.org
Quoted 30 lines · Michel Dänzer
Quoted 29 lines · Nicholas
Quoted 27 lines · Michel Dänzer
Quoted 8 lines · Nicholas Kazlauskas
These patches are part of a proposed new interface for supporting variable refresh rate via DRM properties.
https://patchwork.freedesktop.org/series/49486/
When notified of a window that is FreeSync capable via X these patches help track when the window is fullscreen to manage the
variable_refreshproperty on the CRTC.I'm afraid the Xorg driver support will have to be more or less redone from scratch for upstreaming:
Whether or not a client wants variable refresh rate enabled can be tracked via the window property mechanism supported by the core X11 protocol, no need for a protocol extension.
That should also allow simpler tracking of when variable refresh rate can actually be enabled: It can be enabled while a window is flipping, and its corresponding property allows it. This should be straightforward with the Present extension, because that also explicitly marks the end of a window flipping (via an "unflip"). DRI2 is trickier; it's probably okay not to support variable refresh rate with that, at least initially.
I can look into this after the upcoming Xorg driver 18.1 releases. Or I can give guidance if one of you wants to look into it.
Quoted 6 lines
Quoted 3 lines
I can a look into this. I agree that the extension method is less than ideal - in being vendor specific mostly. It does have the nice property that it remains independent of the application's render backend, though.
Not sure what you mean by that. Surely a window property is just as independent. :)
I was mostly referring to being independent from the backend specific code in the DDX driver - DRI2/DRI3/present etc. This change turns the notification from being a callback into polling.
Quoted 10 lines
Quoted 7 lines
I imagine you're suggesting specifying a window property hint like
_NET_WM_BYPASS_COMPOSITOR- maybe a define new one like_NET_WM_VARIABLE_REFRESH(even though the two are closely related in terms of fullscreen behavior). Then in each backend the property could probably be checked before the present as appropriate.Right. (Not sure the
_NET_WMprefix is appropriate, as it's nothing to do with the window manager, but that's a detail)
I guess an application could operate independently from the window manager with variable refresh enabled but it's not certainly a common use case. I suppose this would probably need additional documentation patches for the extended window manager standards.
_NET_VARIABLE_REFRESH is probably fine as a name.
Quoted 12 lines
Quoted 6 lines
This patch series already has the problem you're describing about DRI2 where there's not a nice explicit end notification for flipping - it's only disabled when the window no longer covers the CRTC or the window is destroyed (which is the case for most applications but likely not all).
Right. I think it's better to just not bother with DRI2, at least until there's a specific scenario where variable refresh is really needed with DRI2.
Nicholas Kazlauskas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx