Add explicit AMDGPU_DRM_QUEUE_ERROR define
PATCH 1/12 Add explicit AMDGPU_DRM_QUEUE_ERROR define
From: Michel Dänzer <[email protected]>
Should make the amdgpu_drm_queue_alloc error handling clearer, and gets rid of a compile warning about it returning NULL.
(Ported from radeon commit a37af701768b12d86868a831a79f1e02ee4968cf)
--- src/amdgpu_dri2.c | 4 ++-- src/amdgpu_drm_queue.c | 7 ++++--- src/amdgpu_drm_queue.h | 2 ++ src/amdgpu_kms.c | 4 ++-- src/amdgpu_present.c | 2 +- src/drmmode_display.c | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-)
src/amdgpu_dri2.c +2 -2
@@ -1035,7 +1035,7 @@ static int amdgpu_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, drm_queue_seq =amdgpu_drm_queue_alloc (crtc, client,AMDGPU_DRM_QUEUE_ID_DEFAULT , wait_info, amdgpu_dri2_frame_event_handler, amdgpu_dri2_frame_event_abort); -if (!drm_queue_seq) { +if (drm_queue_seq ==AMDGPU_DRM_QUEUE_ERROR ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"Allocating DRM queue event entry failed.\n" ); goto out_complete;
@@ -1183,7 +1183,7 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, drm_queue_seq =amdgpu_drm_queue_alloc (crtc, client,AMDGPU_DRM_QUEUE_ID_DEFAULT , swap_info, amdgpu_dri2_frame_event_handler, amdgpu_dri2_frame_event_abort); -if (!drm_queue_seq) { +if (drm_queue_seq ==AMDGPU_DRM_QUEUE_ERROR ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"Allocating DRM queue entry failed.\n" ); goto blit_fallback;
src/amdgpu_drm_queue.c +4 -3
@@ -92,10 +92,11 @@ amdgpu_drm_queue_alloc(xf86CrtcPtr crtc, ClientPtr client, e =calloc (1 ,sizeof (struct amdgpu_drm_queue_entry ));if (!e) -return NULL ; +return AMDGPU_DRM_QUEUE_ERROR ; + +if (_X_UNLIKELY (amdgpu_drm_queue_seq ==AMDGPU_DRM_QUEUE_ERROR )) + amdgpu_drm_queue_seq++; -if (!amdgpu_drm_queue_seq) - amdgpu_drm_queue_seq =1 ; e->seq = amdgpu_drm_queue_seq++; e->client = client; e->crtc = crtc;
src/amdgpu_drm_queue.h +2 -0
@@ -31,6 +31,8 @@#include <xf86Crtc.h> +#define AMDGPU_DRM_QUEUE_ERROR 0 +#define AMDGPU_DRM_QUEUE_CLIENT_DEFAULT serverClient#define AMDGPU_DRM_QUEUE_ID_DEFAULT ~0ULL
src/amdgpu_kms.c +2 -2
@@ -426,7 +426,7 @@ amdgpu_scanout_update(xf86CrtcPtr xf86_crtc) drmmode_crtc, amdgpu_scanout_update_handler, amdgpu_scanout_update_abort); -if (!drm_queue_seq) { +if (drm_queue_seq ==AMDGPU_DRM_QUEUE_ERROR ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"amdgpu_drm_queue_alloc failed for scanout update\n" );return ;
@@ -480,7 +480,7 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,AMDGPU_DRM_QUEUE_ID_DEFAULT , drmmode_crtc,NULL , amdgpu_scanout_flip_abort); -if (!drm_queue_seq) { +if (drm_queue_seq ==AMDGPU_DRM_QUEUE_ERROR ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"Allocating DRM event queue entry failed.\n" );return ;
src/amdgpu_present.c +1 -1
@@ -170,7 +170,7 @@ amdgpu_present_queue_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc) event_id, event, amdgpu_present_vblank_handler, amdgpu_present_vblank_abort); -if (!drm_queue_seq) { +if (drm_queue_seq ==AMDGPU_DRM_QUEUE_ERROR ) {free (event);return BadAlloc; }
src/drmmode_display.c +1 -1
@@ -2537,7 +2537,7 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, flipdata, drmmode_flip_handler, drmmode_flip_abort); -if (!drm_queue_seq) { +if (drm_queue_seq ==AMDGPU_DRM_QUEUE_ERROR ) {xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"Allocating DRM queue event entry failed.\n" ); goto error;
Signature · 6 lines
2.9.3 _______________________________________________ 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): 20160908100242.19964-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org
PATCH 2/12 Use EventCallback to avoid flushing every time in the FlushCallback
From: Michel Dänzer <[email protected]>
We only need to flush for XDamageNotify events.
Significantly reduces compositing slowdown due to flushing overhead, in particular with glamor.
(Ported from radeon commit 9a1afbf61fbb2827c86bd86d295fa0848980d60b)
--- src/amdgpu_drv.h | 2 ++ src/amdgpu_glamor.c | 3 ++- src/amdgpu_kms.c | 77 ++++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 66 insertions(+), 16 deletions(-)
src/amdgpu_drv.h +2 -0
@@ -209,6 +209,8 @@ typedef struct {/* accel */ PixmapPtr fbcon_pixmap; +int callback_event_type; +uint_fast32_t callback_needs_flush;uint_fast32_t gpu_flushed;uint_fast32_t gpu_synced;Bool use_glamor;
src/amdgpu_glamor.c +2 -1
@@ -460,8 +460,9 @@ void amdgpu_glamor_flush(ScrnInfoPtr pScrn)if (info->use_glamor) {glamor_block_handler (pScrn->pScreen); - info->gpu_flushed++; } + + info->gpu_flushed++; }void amdgpu_glamor_finish (ScrnInfoPtr pScrn)
src/amdgpu_kms.c +62 -15
115 lines not on this page · raw message
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/12 Keep track of damage event related flushes per-client
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
This further reduces the compositing slowdown due to flushing overhead, by only flushing when the X server actually sends XDamageNotify events to a client, and there hasn't been a flush yet in the meantime.
(Ported from radeon commit 121a6de72da5fcf9a32408eff36b2235f3dfbcfe)
--- src/amdgpu_drv.h | 5 ++++- src/amdgpu_kms.c | 41 +++++++++++++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 9 deletions(-)
src/amdgpu_drv.h +4 -1
@@ -185,6 +185,10 @@ struct amdgpu_buffer {uint32_t flags; }; +struct amdgpu_client_priv { +uint_fast32_t needs_flush; +}; + typedef struct { EntityInfoPtr pEnt; pciVideoPtr PciInfo;
@@ -210,7 +214,6 @@ typedef struct {/* accel */ PixmapPtr fbcon_pixmap;int callback_event_type; -uint_fast32_t callback_needs_flush;uint_fast32_t gpu_flushed;uint_fast32_t gpu_synced;Bool use_glamor;
src/amdgpu_kms.c +33 -8
89 lines not on this page · raw message
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/12 Wait for pending flips to complete before turning off an output or CRTC
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
At least with older kernels, the flip may never complete otherwise, which can result in us hanging in drmmode_set_mode_major.
(Ported from radeon commits 9090309e057dc703d1a5bffd88e6cae14108cfc3,
e520ce0ec0adf91ddce5c932d4b3f9477fd49304, a36fdaff40d5b4795a1400c348a80eee94892212 and 4bd2d01552f18153afa03a8947b22eebf3d67c6b)
--- src/amdgpu_kms.c | 6 ++--- src/amdgpu_present.c | 4 +-- src/amdgpu_video.c | 2 +- src/drmmode_display.c | 73 +++++++++++++++++++++++++++++++++++++++++---------- src/drmmode_display.h | 3 +++ 5 files changed, 68 insertions(+), 20 deletions(-)
src/amdgpu_kms.c +3 -3
@@ -366,7 +366,7 @@ amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id)BoxRec extents;if (!xf86_crtc->enabled || - drmmode_crtc->dpms_mode != DPMSModeOn || + drmmode_crtc->pending_dpms_mode != DPMSModeOn || !drmmode_crtc->scanout[scanout_id].pixmap)return FALSE;
@@ -485,7 +485,7 @@ amdgpu_scanout_update(xf86CrtcPtr xf86_crtc)if (!xf86_crtc->enabled || drmmode_crtc->scanout_update_pending || !drmmode_crtc->scanout[0 ].pixmap || - drmmode_crtc->dpms_mode != DPMSModeOn) + drmmode_crtc->pending_dpms_mode != DPMSModeOn)return ; pDamage = drmmode_crtc->scanout[0 ].damage;
@@ -537,7 +537,7 @@ amdgpu_scanout_flip_abort(xf86CrtcPtr crtc, void *event_data)drmmode_crtc_private_ptr drmmode_crtc = event_data; drmmode_crtc->scanout_update_pending = FALSE; - drmmode_crtc->flip_pending = FALSE; +drmmode_clear_pending_flip (crtc); } static void
src/amdgpu_present.c +2 -2
@@ -235,7 +235,7 @@ amdgpu_present_check_unflip(ScrnInfoPtr scrn) drmmode_crtc->scanout[0].bo)return FALSE; -if (drmmode_crtc->dpms_mode == DPMSModeOn) +if (drmmode_crtc->pending_dpms_mode == DPMSModeOn) num_crtcs_on++; }
@@ -376,7 +376,7 @@ modeset:if (!crtc->enabled)continue ; -if (drmmode_crtc->dpms_mode == DPMSModeOn) +if (drmmode_crtc->pending_dpms_mode == DPMSModeOn) crtc->funcs->set_mode_major (crtc, &crtc->mode, crtc->rotation, crtc->x, crtc->y);else
src/amdgpu_video.c +1 -1
@@ -67,7 +67,7 @@ static int amdgpu_box_area(BoxPtr box)Bool amdgpu_crtc_is_enabled (xf86CrtcPtr crtc) {drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; -return drmmode_crtc->dpms_mode == DPMSModeOn; +return drmmode_crtc->pending_dpms_mode == DPMSModeOn; } xf86CrtcPtr
src/drmmode_display.c +59 -14
137 lines not on this page · raw message
src/drmmode_display.h +3 -0
@@ -88,6 +88,8 @@ typedef struct {unsigned scanout_id;Bool scanout_update_pending;int dpms_mode; +/* For when a flip is pending when DPMS off requested */ +int pending_dpms_mode;CARD64 dpms_last_ust;uint32_t dpms_last_seq;int dpms_last_fps;
@@ -147,6 +149,7 @@ extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);extern int drmmode_get_crtc_id (xf86CrtcPtr crtc);extern int drmmode_get_pitch_align (ScrnInfoPtr scrn,int bpe); +extern void drmmode_clear_pending_flip (xf86CrtcPtr crtc); Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, PixmapPtr new_front, uint64_t id, void *data, int ref_crtc_hw_id, amdgpu_drm_handler_proc handler,
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/12 Use drmmode_crtc_scanout_* helpers for RandR 1.4 scanout pixmaps
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
This should allow using multiple CRTCs via RandR 1.4 even with xserver < 1.17. It also simplifies the code a little, and paves the way for following changes.
(Ported from radeon commits 4cfa4615f79f64062e5e771cd45dd7048f48b4f6
and a92c27484703abc7c410b6ae0e4b8d1efbbb8e6f)
--- src/amdgpu_kms.c | 19 ++++++++----- src/drmmode_display.c | 76 +++++++++++++++------------------------------------ src/drmmode_display.h | 1 - 3 files changed, 34 insertions(+), 62 deletions(-)
src/amdgpu_kms.c +12 -7
@@ -595,15 +595,20 @@ static void AMDGPUBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL) (*pScreen->BlockHandler) (BLOCKHANDLER_ARGS ); pScreen->BlockHandler = AMDGPUBlockHandler_KMS; -for (c =0 ; c < xf86_config->num_crtc; c++) { -if (info->tear_free) -amdgpu_scanout_flip (pScreen, info, xf86_config->crtc[c]); -else if (info->shadow_primary +#ifdef AMDGPU_PIXMAP_SHARING +if (!pScreen->isGPU) +#endif + { +for (c =0 ; c < xf86_config->num_crtc; c++) { +if (info->tear_free) +amdgpu_scanout_flip (pScreen, info, xf86_config->crtc[c]); +else if (info->shadow_primary #if XF86_CRTC_VERSION >= 4 - || xf86_config->crtc[c]->driverIsPerformingTransform + || xf86_config->crtc[c]->driverIsPerformingTransform #endif - ) -amdgpu_scanout_update (xf86_config->crtc[c]); + ) +amdgpu_scanout_update (xf86_config->crtc[c]); + } }if (info->use_glamor)
src/drmmode_display.c +22 -54
106 lines not on this page · raw message
src/drmmode_display.h +0 -1
@@ -94,7 +94,6 @@ typedef struct {uint32_t dpms_last_seq;int dpms_last_fps;uint32_t interpolated_vblanks; -int prime_pixmap_x;/* Modeset needed for DPMS on */ Bool need_modeset;
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/12 Handle RandR 1.4 slave dirty updates via amdgpu_drm_queue
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
This reduces PCIe bandwidth usage and tearing.
(Ported from radeon commit ad0a0656dd0e74683e6d7789decba827aa29c221)
--- src/amdgpu_kms.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 3 deletions(-)
src/amdgpu_kms.c +93 -3
@@ -304,8 +304,10 @@ static Bool AMDGPUCreateScreenResources_KMS(ScreenPtr pScreen) }#ifdef AMDGPU_PIXMAP_SHARING -static void redisplay_dirty (ScreenPtr screen,PixmapDirtyUpdatePtr dirty) +static void +redisplay_dirty (PixmapDirtyUpdatePtr dirty) { +ScrnInfoPtr scrn =xf86ScreenToScrn (dirty->src->drawable.pScreen);RegionRec pixregion;PixmapRegionInit (&pixregion, dirty->slave_dst);
@@ -316,8 +318,94 @@ static void redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty)PixmapSyncDirtyHelper (dirty, &pixregion);#endif +amdgpu_glamor_flush (scrn);DamageRegionProcessPending (&dirty->slave_dst->drawable);RegionUninit (&pixregion); + +DamageEmpty (dirty->damage); +} + +static void +amdgpu_prime_scanout_update_abort (xf86CrtcPtr crtc,void *event_data) +{ +drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + + drmmode_crtc->scanout_update_pending = FALSE; +} + +void +amdgpu_prime_scanout_update_handler (xf86CrtcPtr crtc,uint32_t frame,uint64_t usec, +void *event_data) +{ +ScrnInfoPtr scrn = crtc->scrn; +ScreenPtr screen = scrn->pScreen; +drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; +PixmapPtr scanoutpix = crtc->randr_crtc->scanout_pixmap; +PixmapDirtyUpdatePtr dirty; + +xorg_list_for_each_entry (dirty, &screen->pixmap_dirty_list, ent) { +if (dirty->src == scanoutpix && + dirty->slave_dst == drmmode_crtc->scanout[0 ].pixmap) { +redisplay_dirty (dirty); +break ; + } + } + + drmmode_crtc->scanout_update_pending = FALSE; +} + +static void +amdgpu_prime_scanout_update (PixmapDirtyUpdatePtr dirty) +{ +ScreenPtr screen = dirty->slave_dst->drawable.pScreen; +ScrnInfoPtr scrn =xf86ScreenToScrn (screen); +AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn); +xf86CrtcConfigPtr xf86_config =XF86_CRTC_CONFIG_PTR (scrn); +xf86CrtcPtr xf86_crtc =NULL ; +drmmode_crtc_private_ptr drmmode_crtc =NULL ; +uintptr_t drm_queue_seq; +drmVBlank vbl; +int c; + +/* Find the CRTC which is scanning out from this slave pixmap */ +for (c =0 ; c < xf86_config->num_crtc; c++) { + xf86_crtc = xf86_config->crtc[c]; + drmmode_crtc = xf86_crtc->driver_private; +if (drmmode_crtc->scanout[0 ].pixmap == dirty->slave_dst) +break ; + } + +if (c == xf86_config->num_crtc || + !xf86_crtc->enabled || + drmmode_crtc->scanout_update_pending || + !drmmode_crtc->scanout[0 ].pixmap || + drmmode_crtc->pending_dpms_mode != DPMSModeOn) +return ; + + drm_queue_seq =amdgpu_drm_queue_alloc (xf86_crtc, +AMDGPU_DRM_QUEUE_CLIENT_DEFAULT , +AMDGPU_DRM_QUEUE_ID_DEFAULT ,NULL , + amdgpu_prime_scanout_update_handler, + amdgpu_prime_scanout_update_abort); +if (drm_queue_seq ==AMDGPU_DRM_QUEUE_ERROR ) { +xf86DrvMsg (scrn->scrnIndex,X_WARNING , +"amdgpu_drm_queue_alloc failed for PRIME update\n" ); +return ; + } + + vbl.request.type =DRM_VBLANK_RELATIVE |DRM_VBLANK_EVENT ; + vbl.request.type |=amdgpu_populate_vbl_request_type (xf86_crtc); + vbl.request.sequence =1 ; + vbl.request.signal = drm_queue_seq; +if (drmWaitVBlank (pAMDGPUEnt->fd, &vbl)) { +xf86DrvMsg (scrn->scrnIndex,X_WARNING , +"drmWaitVBlank failed for PRIME update: %s\n" , +strerror (errno)); +amdgpu_drm_abort_entry (drm_queue_seq); +return ; + } + + drmmode_crtc->scanout_update_pending = TRUE; }static void amdgpu_dirty_update (ScreenPtr screen)
@@ -331,8 +419,10 @@ static void amdgpu_dirty_update(ScreenPtr screen)xorg_list_for_each_entry (ent, &screen->pixmap_dirty_list, ent) { region =DamageRegion (ent->damage);if (RegionNotEmpty (region)) { -redisplay_dirty (screen, ent); -DamageEmpty (ent->damage); +if (screen->isGPU) +amdgpu_prime_scanout_update (ent); +else +redisplay_dirty (ent); } } }
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/12 Track damage accurately for RandR 1.4 slave scanout
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
This further reduces the PCIe bandwidth usage.
(Ported from radeon commit b0867063abb197b9134166706d99fcbe5f204bb5,
plus leak fix from 5a57005178fc13b6f7e513458ca6dae72a3e5783)
--- src/amdgpu_kms.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 11 deletions(-)
src/amdgpu_kms.c +72 -11
@@ -304,23 +304,77 @@ static Bool AMDGPUCreateScreenResources_KMS(ScreenPtr pScreen) }#ifdef AMDGPU_PIXMAP_SHARING +static RegionPtr +dirty_region (PixmapDirtyUpdatePtr dirty) +{ +RegionPtr damageregion =DamageRegion (dirty->damage); +RegionPtr dstregion; + +#ifdef HAS_DIRTYTRACKING_ROTATION +if (dirty->rotation != RR_Rotate_0) { +BoxPtr boxes =RegionRects (damageregion); +int nboxes =RegionNumRects (damageregion); +xRectanglePtr rects =malloc (nboxes *sizeof (*rects)); +int dst_w = dirty->slave_dst->drawable.width; +int dst_h = dirty->slave_dst->drawable.height; +int nrects =0 ; +BoxRec box; +int i; + +for (i =0 ; i < nboxes; i++) { + box.x1 = boxes[i].x1; + box.x2 = boxes[i].x2; + box.y1 = boxes[i].y1; + box.y2 = boxes[i].y2; +pixman_f_transform_bounds (&dirty->f_inverse, &box); + + box.x1 =max (box.x1,0 ); + box.y1 =max (box.y1,0 ); + box.x2 =min (box.x2, dst_w); + box.y2 =min (box.y2, dst_h); +if (box.x1 >= box.x2 || box.y1 >= box.y2) +continue ; + + rects[nrects].x = box.x1; + rects[nrects].y = box.y1; + rects[nrects].width = box.x2 - box.x1; + rects[nrects].height = box.y2 - box.y1; + nrects++; + } + dstregion =RegionFromRects (nrects, rects,CT_UNSORTED ); +free (rects); + } else +#endif + { +RegionRec pixregion; + + dstregion =RegionDuplicate (damageregion); +RegionTranslate (dstregion, -dirty->x, -dirty->y); +PixmapRegionInit (&pixregion, dirty->slave_dst); +RegionIntersect (dstregion, dstregion, &pixregion); +RegionUninit (&pixregion); + } + +return dstregion; +} +static void -redisplay_dirty (PixmapDirtyUpdatePtr dirty) +redisplay_dirty (PixmapDirtyUpdatePtr dirty,RegionPtr region) {ScrnInfoPtr scrn =xf86ScreenToScrn (dirty->src->drawable.pScreen); -RegionRec pixregion; -PixmapRegionInit (&pixregion, dirty->slave_dst); -DamageRegionAppend (&dirty->slave_dst->drawable, &pixregion); +if (dirty->slave_dst->master_pixmap) +DamageRegionAppend (&dirty->slave_dst->drawable, region); +#ifdef HAS_DIRTYTRACKING_ROTATION PixmapSyncDirtyHelper (dirty);#else -PixmapSyncDirtyHelper (dirty, &pixregion); +PixmapSyncDirtyHelper (dirty, region);#endif amdgpu_glamor_flush (scrn); -DamageRegionProcessPending (&dirty->slave_dst->drawable); -RegionUninit (&pixregion); +if (dirty->slave_dst->master_pixmap) +DamageRegionProcessPending (&dirty->slave_dst->drawable);DamageEmpty (dirty->damage); }
@@ -346,7 +400,10 @@ amdgpu_prime_scanout_update_handler(xf86CrtcPtr crtc, uint32_t frame, uint64_t uxorg_list_for_each_entry (dirty, &screen->pixmap_dirty_list, ent) {if (dirty->src == scanoutpix && dirty->slave_dst == drmmode_crtc->scanout[0 ].pixmap) { -redisplay_dirty (dirty); +RegionPtr region =dirty_region (dirty); + +redisplay_dirty (dirty, region); +RegionDestroy (region);break ; } }
@@ -410,20 +467,24 @@ amdgpu_prime_scanout_update(PixmapDirtyUpdatePtr dirty)static void amdgpu_dirty_update (ScreenPtr screen) { -RegionPtr region;PixmapDirtyUpdatePtr ent;if (xorg_list_is_empty (&screen->pixmap_dirty_list))return ;xorg_list_for_each_entry (ent, &screen->pixmap_dirty_list, ent) { - region =DamageRegion (ent->damage); +RegionPtr region =dirty_region (ent); +if (RegionNotEmpty (region)) {if (screen->isGPU)amdgpu_prime_scanout_update (ent);else -redisplay_dirty (ent); +redisplay_dirty (ent, region); + }else { +DamageEmpty (ent->damage); } + +RegionDestroy (region); } }#endif
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/12 Only copy from screen pixmap to shared pixmap on demand for slave scanout
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
Only copy once for each time we update the corresponding scanout pixmap. This can significantly reduce the bandwidth usage when there are frequent updates to the screen pixmap.
This initial implementation only works when both the master and slave screens use this driver.
(Ported from radeon commit 99232f64db52812a843cd616d263d3a6b90eef3d)
--- src/amdgpu_kms.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 13 deletions(-)
src/amdgpu_kms.c +70 -13
@@ -363,6 +363,9 @@ redisplay_dirty(PixmapDirtyUpdatePtr dirty, RegionPtr region) {ScrnInfoPtr scrn =xf86ScreenToScrn (dirty->src->drawable.pScreen); +if (RegionNil (region)) + goto out; +if (dirty->slave_dst->master_pixmap)DamageRegionAppend (&dirty->slave_dst->drawable, region);
@@ -376,6 +379,7 @@ redisplay_dirty(PixmapDirtyUpdatePtr dirty, RegionPtr region)if (dirty->slave_dst->master_pixmap)DamageRegionProcessPending (&dirty->slave_dst->drawable); +out:DamageEmpty (dirty->damage); }
@@ -388,6 +392,39 @@ amdgpu_prime_scanout_update_abort(xf86CrtcPtr crtc, void *event_data) }void +amdgpu_sync_shared_pixmap (PixmapDirtyUpdatePtr dirty) +{ +ScreenPtr master_screen = dirty->src->master_pixmap->drawable.pScreen; +PixmapDirtyUpdatePtr ent; +RegionPtr region; + +xorg_list_for_each_entry (ent, &master_screen->pixmap_dirty_list, ent) { +if (ent->slave_dst != dirty->src) +continue ; + + region =dirty_region (ent); +redisplay_dirty (ent, region); +RegionDestroy (region); + } +} + +static Bool +master_has_sync_shared_pixmap (ScrnInfoPtr scrn,PixmapDirtyUpdatePtr dirty) +{ +ScrnInfoPtr master_scrn =xf86ScreenToScrn (dirty->src->master_pixmap->drawable.pScreen); + +return master_scrn->driverName == scrn->driverName; +} + +static Bool +slave_has_sync_shared_pixmap (ScrnInfoPtr scrn,PixmapDirtyUpdatePtr dirty) +{ +ScrnInfoPtr slave_scrn =xf86ScreenToScrn (dirty->slave_dst->drawable.pScreen); + +return slave_scrn->driverName == scrn->driverName; +} + +void amdgpu_prime_scanout_update_handler (xf86CrtcPtr crtc,uint32_t frame,uint64_t usec,void *event_data) {
@@ -400,8 +437,12 @@ amdgpu_prime_scanout_update_handler(xf86CrtcPtr crtc, uint32_t frame, uint64_t uxorg_list_for_each_entry (dirty, &screen->pixmap_dirty_list, ent) {if (dirty->src == scanoutpix && dirty->slave_dst == drmmode_crtc->scanout[0 ].pixmap) { -RegionPtr region =dirty_region (dirty); +RegionPtr region; + +if (master_has_sync_shared_pixmap (scrn, dirty)) +amdgpu_sync_shared_pixmap (dirty); + region =dirty_region (dirty);redisplay_dirty (dirty, region);RegionDestroy (region);break ;
@@ -465,26 +506,42 @@ amdgpu_prime_scanout_update(PixmapDirtyUpdatePtr dirty) drmmode_crtc->scanout_update_pending = TRUE; } -static void amdgpu_dirty_update (ScreenPtr screen) +static void +amdgpu_dirty_update (ScrnInfoPtr scrn) { +ScreenPtr screen = scrn->pScreen;PixmapDirtyUpdatePtr ent; - -if (xorg_list_is_empty (&screen->pixmap_dirty_list)) -return ; +RegionPtr region;xorg_list_for_each_entry (ent, &screen->pixmap_dirty_list, ent) { -RegionPtr region =dirty_region (ent); +if (screen->isGPU) { +PixmapDirtyUpdatePtr region_ent = ent; + +if (master_has_sync_shared_pixmap (scrn, ent)) { +ScreenPtr master_screen = ent->src->master_pixmap->drawable.pScreen; -if (RegionNotEmpty (region)) { -if (screen->isGPU) +xorg_list_for_each_entry (region_ent, &master_screen->pixmap_dirty_list, ent) { +if (region_ent->slave_dst == ent->src) +break ; + } + } + + region =dirty_region (region_ent); + +if (RegionNotEmpty (region))amdgpu_prime_scanout_update (ent);else -redisplay_dirty (ent, region); +DamageEmpty (region_ent->damage); + +RegionDestroy (region); }else { -DamageEmpty (ent->damage); - } +if (slave_has_sync_shared_pixmap (scrn, ent)) +continue ; -RegionDestroy (region); + region =dirty_region (ent); +redisplay_dirty (ent, region); +RegionDestroy (region); + } } }#endif
@@ -766,7 +823,7 @@ static void AMDGPUBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)amdgpu_glamor_flush (pScrn);#ifdef AMDGPU_PIXMAP_SHARING -amdgpu_dirty_update (pScreen); +amdgpu_dirty_update (pScrn);#endif }
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/12 Factor out transform_region helper
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
(Ported from radeon commit 5a57005178fc13b6f7e513458ca6dae72a3e5783)
--- src/amdgpu_kms.c | 74 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 31 deletions(-)
src/amdgpu_kms.c +43 -31
@@ -304,6 +304,45 @@ static Bool AMDGPUCreateScreenResources_KMS(ScreenPtr pScreen) }#ifdef AMDGPU_PIXMAP_SHARING + +static RegionPtr +transform_region (RegionPtr region,struct pict_f_transform *transform, +int w,int h) +{ +BoxPtr boxes =RegionRects (region); +int nboxes =RegionNumRects (region); +xRectanglePtr rects =malloc (nboxes *sizeof (*rects)); +RegionPtr transformed; +int nrects =0 ; +BoxRec box; +int i; + +for (i =0 ; i < nboxes; i++) { + box.x1 = boxes[i].x1; + box.x2 = boxes[i].x2; + box.y1 = boxes[i].y1; + box.y2 = boxes[i].y2; +pixman_f_transform_bounds (transform, &box); + + box.x1 =max (box.x1,0 ); + box.y1 =max (box.y1,0 ); + box.x2 =min (box.x2, w); + box.y2 =min (box.y2, h); +if (box.x1 >= box.x2 || box.y1 >= box.y2) +continue ; + + rects[nrects].x = box.x1; + rects[nrects].y = box.y1; + rects[nrects].width = box.x2 - box.x1; + rects[nrects].height = box.y2 - box.y1; + nrects++; + } + + transformed =RegionFromRects (nrects, rects,CT_UNSORTED ); +free (rects); +return transformed; +} +static RegionPtr dirty_region (PixmapDirtyUpdatePtr dirty) {
@@ -312,37 +351,10 @@ dirty_region(PixmapDirtyUpdatePtr dirty)#ifdef HAS_DIRTYTRACKING_ROTATION if (dirty->rotation != RR_Rotate_0) { -BoxPtr boxes =RegionRects (damageregion); -int nboxes =RegionNumRects (damageregion); -xRectanglePtr rects =malloc (nboxes *sizeof (*rects)); -int dst_w = dirty->slave_dst->drawable.width; -int dst_h = dirty->slave_dst->drawable.height; -int nrects =0 ; -BoxRec box; -int i; - -for (i =0 ; i < nboxes; i++) { - box.x1 = boxes[i].x1; - box.x2 = boxes[i].x2; - box.y1 = boxes[i].y1; - box.y2 = boxes[i].y2; -pixman_f_transform_bounds (&dirty->f_inverse, &box); - - box.x1 =max (box.x1,0 ); - box.y1 =max (box.y1,0 ); - box.x2 =min (box.x2, dst_w); - box.y2 =min (box.y2, dst_h); -if (box.x1 >= box.x2 || box.y1 >= box.y2) -continue ; - - rects[nrects].x = box.x1; - rects[nrects].y = box.y1; - rects[nrects].width = box.x2 - box.x1; - rects[nrects].height = box.y2 - box.y1; - nrects++; - } - dstregion =RegionFromRects (nrects, rects,CT_UNSORTED ); -free (rects); + dstregion =transform_region (damageregion, + &dirty->f_inverse, + dirty->slave_dst->drawable.width, + dirty->slave_dst->drawable.height); } else#endif {
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 10/12 Move up amdgpu_scanout_extents_intersect
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
Will be needed higher up by the following changes. No functional change.
(Ported from radeon commit 2f6e5fb15f1a9ce523c85550e493f8bda9d0c00f)
--- src/amdgpu_kms.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
src/amdgpu_kms.c +17 -17
@@ -303,6 +303,23 @@ static Bool AMDGPUCreateScreenResources_KMS(ScreenPtr pScreen)return TRUE; } +static Bool +amdgpu_scanout_extents_intersect (xf86CrtcPtr xf86_crtc,BoxPtr extents) +{ + extents->x1 -= xf86_crtc->filter_width >>1 ; + extents->x2 += xf86_crtc->filter_width >>1 ; + extents->y1 -= xf86_crtc->filter_height >>1 ; + extents->y2 += xf86_crtc->filter_height >>1 ; +pixman_f_transform_bounds (&xf86_crtc->f_framebuffer_to_crtc, extents); + + extents->x1 =max (extents->x1,0 ); + extents->y1 =max (extents->y1,0 ); + extents->x2 =min (extents->x2, xf86_crtc->mode.HDisplay); + extents->y2 =min (extents->y2, xf86_crtc->mode.VDisplay); + +return (extents->x1 < extents->x2 && extents->y1 < extents->y2); +} +#ifdef AMDGPU_PIXMAP_SHARING static RegionPtr
@@ -559,23 +576,6 @@ amdgpu_dirty_update(ScrnInfoPtr scrn)#endif static Bool -amdgpu_scanout_extents_intersect (xf86CrtcPtr xf86_crtc,BoxPtr extents) -{ - extents->x1 -= xf86_crtc->filter_width >>1 ; - extents->x2 += xf86_crtc->filter_width >>1 ; - extents->y1 -= xf86_crtc->filter_height >>1 ; - extents->y2 += xf86_crtc->filter_height >>1 ; -pixman_f_transform_bounds (&xf86_crtc->f_framebuffer_to_crtc, extents); - - extents->x1 =max (extents->x1,0 ); - extents->y1 =max (extents->y1,0 ); - extents->x2 =min (extents->x2, xf86_crtc->mode.HDisplay); - extents->y2 =min (extents->y2, xf86_crtc->mode.VDisplay); - -return (extents->x1 < extents->x2 && extents->y1 < extents->y2); -} - -static Bool amdgpu_scanout_do_update (xf86CrtcPtr xf86_crtc,int scanout_id) {drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
Signature · 6 lines
2.9.3 _______________________________________________ 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): 20160908100310.20051-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org
PATCH 11/12 Synchronize scanout pixmaps for TearFree
From: Michel Dänzer <[email protected]>
Copy the damaged areas which are still valid in the other scanout pixmap from there, then only copy the remaining damaged area from the screen pixmap.
This is slightly more efficient (only needs one Damage record instead of two, and only needs to copy each screen update across PCIe once with ShadowPrimary and a discrete GPU), and will be significantly more efficient for PRIME with the following change.
(Ported from radeon commit eda1f3df6aaed683036369fe8820da4dac3c2ae2)
--- src/amdgpu_kms.c | 80 ++++++++++++++++++++++++++++++++++++++++++--------- src/drmmode_display.c | 80 +++++++++++++++++++++++++-------------------------- src/drmmode_display.h | 3 +- 3 files changed, 108 insertions(+), 55 deletions(-)
src/amdgpu_kms.c +67 -13
@@ -320,8 +320,6 @@ amdgpu_scanout_extents_intersect(xf86CrtcPtr xf86_crtc, BoxPtr extents)return (extents->x1 < extents->x2 && extents->y1 < extents->y2); } -#ifdef AMDGPU_PIXMAP_SHARING -static RegionPtr transform_region (RegionPtr region,struct pict_f_transform *transform,int w,int h)
@@ -360,6 +358,62 @@ transform_region(RegionPtr region, struct pict_f_transform *transform,return transformed; } +static void +amdgpu_sync_scanout_pixmaps (xf86CrtcPtr xf86_crtc,RegionPtr new_region, +int scanout_id) +{ +drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private; +DrawablePtr dst = &drmmode_crtc->scanout[scanout_id].pixmap->drawable; +DrawablePtr src = &drmmode_crtc->scanout[scanout_id ^1 ].pixmap->drawable; +RegionPtr last_region = &drmmode_crtc->scanout_last_region; +ScrnInfoPtr scrn = xf86_crtc->scrn; +ScreenPtr pScreen = scrn->pScreen; +RegionRec remaining; +RegionPtr sync_region =NULL ; +BoxRec extents; +GCPtr gc; + +if (RegionNil (last_region)) +return ; + +RegionNull (&remaining); +RegionSubtract (&remaining, last_region, new_region); +if (RegionNil (&remaining)) + goto uninit; + + extents = *RegionExtents (&remaining); +if (!amdgpu_scanout_extents_intersect (xf86_crtc, &extents)) + goto uninit; + +#if XF86_CRTC_VERSION >=4 +if (xf86_crtc->driverIsPerformingTransform) { + sync_region =transform_region (&remaining, + &xf86_crtc->f_framebuffer_to_crtc, + dst->width, dst->height); + } else +#endif /* XF86_CRTC_VERSION >= 4 */ + { + sync_region =RegionDuplicate (&remaining); +RegionTranslate (sync_region, -xf86_crtc->x, -xf86_crtc->y); + } + + gc =GetScratchGC (dst->depth, pScreen); +if (gc) { +ValidateGC (dst, gc); + gc->funcs->ChangeClip (gc,CT_REGION , sync_region,0 ); + sync_region =NULL ; + gc->ops->CopyArea (src, dst, gc,0 ,0 , dst->width, dst->height,0 ,0 ); +FreeScratchGC (gc); + } + + uninit: +if (sync_region) +RegionDestroy (sync_region); +RegionUninit (&remaining); +} + +#ifdef AMDGPU_PIXMAP_SHARING +static RegionPtr dirty_region (PixmapDirtyUpdatePtr dirty) {
@@ -579,10 +633,11 @@ static Bool amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id) {drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private; -DamagePtr pDamage; -RegionPtr pRegion; +RegionPtr pRegion =DamageRegion (drmmode_crtc->scanout_damage); +ScrnInfoPtr scrn = xf86_crtc->scrn; +ScreenPtr pScreen = scrn->pScreen; +AMDGPUInfoPtr info =AMDGPUPTR (scrn);DrawablePtr pDraw; -ScreenPtr pScreen;BoxRec extents; if (!xf86_crtc->enabled ||
@@ -590,21 +645,20 @@ amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id) !drmmode_crtc->scanout[scanout_id].pixmap)return FALSE; - pDamage = drmmode_crtc->scanout[scanout_id].damage; -if (!pDamage) -return FALSE; - - pRegion =DamageRegion (pDamage);if (!RegionNotEmpty (pRegion))return FALSE; pDraw = &drmmode_crtc->scanout[scanout_id].pixmap->drawable; - pScreen = pDraw->pScreen; extents = *RegionExtents (pRegion); -RegionEmpty (pRegion);if (!amdgpu_scanout_extents_intersect (xf86_crtc, &extents))return FALSE; +if (info->tear_free) { +amdgpu_sync_scanout_pixmaps (xf86_crtc, pRegion, scanout_id); +RegionCopy (&drmmode_crtc->scanout_last_region, pRegion); + } +RegionEmpty (pRegion); +#if XF86_CRTC_VERSION >=4 if (xf86_crtc->driverIsPerformingTransform) {SourceValidateProcPtr SourceValidate = pScreen->SourceValidate;
@@ -708,7 +762,7 @@ amdgpu_scanout_update(xf86CrtcPtr xf86_crtc) drmmode_crtc->pending_dpms_mode != DPMSModeOn)return ; - pDamage = drmmode_crtc->scanout[0 ].damage; + pDamage = drmmode_crtc->scanout_damage;if (!pDamage)return ;
src/drmmode_display.c +39 -41
115 lines not on this page · raw message
src/drmmode_display.h +2 -1
@@ -73,7 +73,6 @@ typedef struct {struct drmmode_scanout {struct amdgpu_buffer *bo;PixmapPtr pixmap; -DamagePtr damage;unsigned fb_id;int width, height; };
@@ -85,6 +84,8 @@ typedef struct {struct amdgpu_buffer *cursor_buffer;struct drmmode_scanout rotate;struct drmmode_scanout scanout[2 ]; +DamagePtr scanout_damage; +RegionRec scanout_last_region;unsigned scanout_id;Bool scanout_update_pending;int dpms_mode;
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 12/12 Make TearFree effective with PRIME slave scanout
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
TearFree can now prevent tearing with any possible display configuration.
Note that there may still be inter-GPU tearing if the primary GPU uses a different driver.
(Ported from radeon commit 38797a33117222dadbc89e5f21ed8cd5deef9bea)
--- src/amdgpu_kms.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++---- src/drmmode_display.c | 33 ++++++++++++--- src/drmmode_display.h | 1 + 3 files changed, 133 insertions(+), 13 deletions(-)
src/amdgpu_kms.c +104 -8
@@ -507,31 +507,56 @@ slave_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty)return slave_scrn->driverName == scrn->driverName; } -void -amdgpu_prime_scanout_update_handler (xf86CrtcPtr crtc,uint32_t frame,uint64_t usec, -void *event_data) +static Bool +amdgpu_prime_scanout_do_update (xf86CrtcPtr crtc,unsigned scanout_id) {ScrnInfoPtr scrn = crtc->scrn;ScreenPtr screen = scrn->pScreen; +AMDGPUInfoPtr info =AMDGPUPTR (scrn);drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;PixmapPtr scanoutpix = crtc->randr_crtc->scanout_pixmap;PixmapDirtyUpdatePtr dirty; +Bool ret = FALSE;xorg_list_for_each_entry (dirty, &screen->pixmap_dirty_list, ent) { -if (dirty->src == scanoutpix && - dirty->slave_dst == drmmode_crtc->scanout[0 ].pixmap) { +if (dirty->src == scanoutpix && dirty->slave_dst == + drmmode_crtc->scanout[scanout_id ^ info->tear_free].pixmap) {RegionPtr region;if (master_has_sync_shared_pixmap (scrn, dirty))amdgpu_sync_shared_pixmap (dirty); region =dirty_region (dirty); +if (RegionNil (region)) + goto destroy; + +if (info->tear_free) { +RegionTranslate (region, crtc->x, crtc->y); +amdgpu_sync_scanout_pixmaps (crtc, region, scanout_id); +amdgpu_glamor_flush (scrn); +RegionCopy (&drmmode_crtc->scanout_last_region, region); +RegionTranslate (region, -crtc->x, -crtc->y); + dirty->slave_dst = drmmode_crtc->scanout[scanout_id].pixmap; + } +redisplay_dirty (dirty, region); + ret = TRUE; + destroy:RegionDestroy (region);break ; } } +return ret; +} + +void +amdgpu_prime_scanout_update_handler (xf86CrtcPtr crtc,uint32_t frame,uint64_t usec, +void *event_data) +{ +drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + +amdgpu_prime_scanout_do_update (crtc,0 ); drmmode_crtc->scanout_update_pending = FALSE; }
@@ -590,8 +615,75 @@ amdgpu_prime_scanout_update(PixmapDirtyUpdatePtr dirty) }static void +amdgpu_prime_scanout_flip_abort (xf86CrtcPtr crtc,void *event_data) +{ +drmmode_crtc_private_ptr drmmode_crtc = event_data; + + drmmode_crtc->scanout_update_pending = FALSE; +drmmode_clear_pending_flip (crtc); +} + +static void +amdgpu_prime_scanout_flip (PixmapDirtyUpdatePtr ent) +{ +ScreenPtr screen = ent->slave_dst->drawable.pScreen; +ScrnInfoPtr scrn =xf86ScreenToScrn (screen); +AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn); +xf86CrtcConfigPtr xf86_config =XF86_CRTC_CONFIG_PTR (scrn); +xf86CrtcPtr crtc =NULL ; +drmmode_crtc_private_ptr drmmode_crtc =NULL ; +uintptr_t drm_queue_seq; +unsigned scanout_id; +int c; + +/* Find the CRTC which is scanning out from this slave pixmap */ +for (c =0 ; c < xf86_config->num_crtc; c++) { + crtc = xf86_config->crtc[c]; + drmmode_crtc = crtc->driver_private; + scanout_id = drmmode_crtc->scanout_id; +if (drmmode_crtc->scanout[scanout_id].pixmap == ent->slave_dst) +break ; + } + +if (c == xf86_config->num_crtc || + !crtc->enabled || + drmmode_crtc->scanout_update_pending || + !drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap || + drmmode_crtc->pending_dpms_mode != DPMSModeOn) +return ; + + scanout_id = drmmode_crtc->scanout_id ^1 ; +if (!amdgpu_prime_scanout_do_update (crtc, scanout_id)) +return ; + + drm_queue_seq =amdgpu_drm_queue_alloc (crtc, +AMDGPU_DRM_QUEUE_CLIENT_DEFAULT , +AMDGPU_DRM_QUEUE_ID_DEFAULT , + drmmode_crtc,NULL , + amdgpu_prime_scanout_flip_abort); +if (drm_queue_seq ==AMDGPU_DRM_QUEUE_ERROR ) { +xf86DrvMsg (scrn->scrnIndex,X_WARNING , +"Allocating DRM event queue entry failed for PRIME flip.\n" ); +return ; + } + +if (drmModePageFlip (pAMDGPUEnt->fd, drmmode_crtc->mode_crtc->crtc_id, + drmmode_crtc->scanout[scanout_id].fb_id, +DRM_MODE_PAGE_FLIP_EVENT , (void *)drm_queue_seq)) { +xf86DrvMsg (scrn->scrnIndex,X_WARNING ,"flip queue failed in %s: %s\n" , + __func__,strerror (errno)); +return ; + } + + drmmode_crtc->scanout_id = scanout_id; + drmmode_crtc->scanout_update_pending = TRUE; + drmmode_crtc->flip_pending = TRUE; +} + +static void amdgpu_dirty_update (ScrnInfoPtr scrn) { +AMDGPUInfoPtr info =AMDGPUPTR (scrn);ScreenPtr screen = scrn->pScreen;PixmapDirtyUpdatePtr ent;RegionPtr region;
@@ -611,10 +703,14 @@ amdgpu_dirty_update(ScrnInfoPtr scrn) region =dirty_region (region_ent); -if (RegionNotEmpty (region)) -amdgpu_prime_scanout_update (ent); -else +if (RegionNotEmpty (region)) { +if (info->tear_free) +amdgpu_prime_scanout_flip (ent); +else +amdgpu_prime_scanout_update (ent); + }else {DamageEmpty (region_ent->damage); + }RegionDestroy (region); }else {
src/drmmode_display.c +28 -5
@@ -467,10 +467,19 @@ drmmode_crtc_scanout_destroy(drmmode_ptr drmmode,static void drmmode_crtc_scanout_free (drmmode_crtc_private_ptr drmmode_crtc) { -drmmode_crtc_scanout_destroy (drmmode_crtc->drmmode, - &drmmode_crtc->scanout[0 ]); -drmmode_crtc_scanout_destroy (drmmode_crtc->drmmode, - &drmmode_crtc->scanout[1 ]); +if (drmmode_crtc->flip_pending) { + drmmode_crtc->scanout_destroy[0 ] = drmmode_crtc->scanout[0 ]; + drmmode_crtc->scanout[0 ].pixmap =NULL ; + drmmode_crtc->scanout[0 ].bo =NULL ; + drmmode_crtc->scanout_destroy[1 ] = drmmode_crtc->scanout[1 ]; + drmmode_crtc->scanout[1 ].pixmap =NULL ; + drmmode_crtc->scanout[1 ].bo =NULL ; + }else { +drmmode_crtc_scanout_destroy (drmmode_crtc->drmmode, + &drmmode_crtc->scanout[0 ]); +drmmode_crtc_scanout_destroy (drmmode_crtc->drmmode, + &drmmode_crtc->scanout[1 ]); + }if (drmmode_crtc->scanout_damage) {DamageDestroy (drmmode_crtc->scanout_damage);
@@ -1062,11 +1071,12 @@ drmmode_crtc_gamma_set(xf86CrtcPtr crtc, uint16_t * red, uint16_t * green,static Bool drmmode_set_scanout_pixmap (xf86CrtcPtr crtc,PixmapPtr ppix) {drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; +AMDGPUInfoPtr info =AMDGPUPTR (crtc->scrn);if (!ppix) {if (crtc->randr_crtc->scanout_pixmap)PixmapStopDirtyTracking (crtc->randr_crtc->scanout_pixmap, - drmmode_crtc->scanout[0 ].pixmap); + drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap);drmmode_crtc_scanout_free (drmmode_crtc);return TRUE; }
@@ -1076,6 +1086,14 @@ static Bool drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix) ppix->drawable.height))return FALSE; +if (info->tear_free && + !drmmode_crtc_scanout_create (crtc, &drmmode_crtc->scanout[1 ], + ppix->drawable.width, + ppix->drawable.height)) { +drmmode_crtc_scanout_free (drmmode_crtc); +return FALSE; + } +#ifdef HAS_DIRTYTRACKING_ROTATION PixmapStartDirtyTracking (ppix, drmmode_crtc->scanout[0 ].pixmap,0 ,0 ,0 ,0 , RR_Rotate_0);
@@ -2010,6 +2028,11 @@ drmmode_clear_pending_flip(xf86CrtcPtr crtc)drmmode_crtc_dpms (crtc, drmmode_crtc->pending_dpms_mode); } + +drmmode_crtc_scanout_destroy (drmmode_crtc->drmmode, + &drmmode_crtc->scanout_destroy[0 ]); +drmmode_crtc_scanout_destroy (drmmode_crtc->drmmode, + &drmmode_crtc->scanout_destroy[1 ]); } static void
src/drmmode_display.h +1 -0
@@ -84,6 +84,7 @@ typedef struct {struct amdgpu_buffer *cursor_buffer;struct drmmode_scanout rotate;struct drmmode_scanout scanout[2 ]; +struct drmmode_scanout scanout_destroy[2 ];DamagePtr scanout_damage;RegionRec scanout_last_region;unsigned scanout_id;
Signature · 6 lines
2.9.3 _______________________________________________ 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): 20160908100310.20051-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org
Deucher, Alexander
Reviewed-by Alex DeucherRE: [PATCH xf86-video-amdgpu 12/12] Make TearFree effective with PRIME slave scanout
Quoted 13 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Michel Dänzer
Sent: Thursday, September 08, 2016 6:03 AM
To: [email protected]
Subject: [PATCH xf86-video-amdgpu 12/12] Make TearFree effective with PRIME slave scanoutFrom: Michel Dänzer <[email protected]>
TearFree can now prevent tearing with any possible display configuration.
Quoted 6 lines
Note that there may still be inter-GPU tearing if the primary GPU uses a different driver.
(Ported from radeon commit
38797a33117222dadbc89e5f21ed8cd5deef9bea)Signed-off-by Michel Dänzer <[email protected]>
Series is:
Quoted 280 lines
--- src/amdgpu_kms.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++---- src/drmmode_display.c | 33 ++++++++++++--- src/drmmode_display.h | 1 + 3 files changed, 133 insertions(+), 13 deletions(-)src/amdgpu_kms.c +25
-5@@ -507,31 +507,56 @@ slave_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty)return slave_scrn->driverName == scrn->driverName; } -void -amdgpu_prime_scanout_update_handler (xf86CrtcPtr crtc,uint32_t frame,uint64_t usec, -void *event_data) +static Bool +amdgpu_prime_scanout_do_update(xf86CrtcPtr crtc, unsigned scanout_id) { ScrnInfoPtr scrn = crtc->scrn;ScreenPtr screen = scrn->pScreen; +AMDGPUInfoPtr info =AMDGPUPTR (scrn);drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;PixmapPtr scanoutpix = crtc->randr_crtc->scanout_pixmap;PixmapDirtyUpdatePtr dirty; +Bool ret = FALSE;xorg_list_for_each_entry (dirty, &screen->pixmap_dirty_list, ent) { -if (dirty->src == scanoutpix && - dirty->slave_dst == drmmode_crtc->scanout[0 ].pixmap) { +if (dirty->src == scanoutpix && dirty->slave_dst == + drmmode_crtc->scanout[scanout_id ^ info- >tear_free].pixmap) {RegionPtr region;if (master_has_sync_shared_pixmap (scrn, dirty))amdgpu_sync_shared_pixmap (dirty); region =dirty_region (dirty); +if (RegionNil (region)) + goto destroy; + +if (info->tear_free) { +RegionTranslate (region, crtc->x, crtc->y); +amdgpu_sync_scanout_pixmaps (crtc, region, scanout_id); +amdgpu_glamor_flush (scrn); +RegionCopy (&drmmode_crtc- >scanout_last_region, region); +RegionTranslate (region, -crtc->x, -crtc->y); + dirty->slave_dst = drmmode_crtc- >scanout[scanout_id].pixmap; + } +redisplay_dirty (dirty, region); + ret = TRUE; + destroy:RegionDestroy (region);break ; } } +return ret; +} + +void +amdgpu_prime_scanout_update_handler(xf86CrtcPtr crtc, uint32_t frame,
uint64_tusec,src/amdgpu_kms.c +54
-0+ void *event_data) +{ +drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; + +amdgpu_prime_scanout_do_update (crtc,0 ); drmmode_crtc->scanout_update_pending = FALSE; }@@ -590,8 +615,75 @@ amdgpu_prime_scanout_update(PixmapDirtyUpdatePtr dirty) }static void +amdgpu_prime_scanout_flip_abort (xf86CrtcPtr crtc,void *event_data) +{ +drmmode_crtc_private_ptr drmmode_crtc = event_data; + + drmmode_crtc->scanout_update_pending = FALSE; +drmmode_clear_pending_flip (crtc); +} + +static void +amdgpu_prime_scanout_flip (PixmapDirtyUpdatePtr ent) +{ +ScreenPtr screen = ent->slave_dst->drawable.pScreen; +ScrnInfoPtr scrn =xf86ScreenToScrn (screen); +AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (scrn); +xf86CrtcConfigPtr xf86_config =XF86_CRTC_CONFIG_PTR (scrn); +xf86CrtcPtr crtc =NULL ; +drmmode_crtc_private_ptr drmmode_crtc =NULL ; +uintptr_t drm_queue_seq; +unsigned scanout_id; +int c; + +/* Find the CRTC which is scanning out from this slave pixmap */ +for (c =0 ; c < xf86_config->num_crtc; c++) { + crtc = xf86_config->crtc[c]; + drmmode_crtc = crtc->driver_private; + scanout_id = drmmode_crtc->scanout_id; +if (drmmode_crtc->scanout[scanout_id].pixmap == ent- >slave_dst) +break ; + } + +if (c == xf86_config->num_crtc || + !crtc->enabled || + drmmode_crtc->scanout_update_pending || + !drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap || + drmmode_crtc->pending_dpms_mode != DPMSModeOn) +return ; + + scanout_id = drmmode_crtc->scanout_id ^1 ; +if (!amdgpu_prime_scanout_do_update (crtc, scanout_id)) +return ; + + drm_queue_seq =amdgpu_drm_queue_alloc (crtc, +AMDGPU_DRM_QUEUE_CLIENT_DEFAULT , +AMDGPU_DRM_QUEUE_ID_DEFAULT , + drmmode_crtc,NULL , + amdgpu_prime_scanout_flip_abort); +if (drm_queue_seq ==AMDGPU_DRM_QUEUE_ERROR ) { + xf86DrvMsg(scrn->scrnIndex, X_WARNING, + "Allocating DRM event queue entry failed for PRIMEflip.\n");
src/amdgpu_kms.c +4
-0+return ; + } + + if (drmModePageFlip(pAMDGPUEnt->fd, drmmode_crtc-Quoted 1 line
mode_crtc->crtc_id,src/amdgpu_kms.c +2
-0+ drmmode_crtc->scanout[scanout_id].fb_id, + DRM_MODE_PAGE_FLIP_EVENT,(void*)drm_queue_seq)) {
src/amdgpu_kms.c +1
-0+ xf86DrvMsg(scrn->scrnIndex, X_WARNING, "flip queuefailed in %s: %s\n",
src/amdgpu_kms.c +18
-3+ __func__, strerror(errno)); +return ; + } + + drmmode_crtc->scanout_id = scanout_id; + drmmode_crtc->scanout_update_pending = TRUE; + drmmode_crtc->flip_pending = TRUE; +} + +static void amdgpu_dirty_update (ScrnInfoPtr scrn) { +AMDGPUInfoPtr info =AMDGPUPTR (scrn);ScreenPtr screen = scrn->pScreen;PixmapDirtyUpdatePtr ent;RegionPtr region;@@ -611,10 +703,14 @@ amdgpu_dirty_update(ScrnInfoPtr scrn) region =dirty_region (region_ent); -if (RegionNotEmpty (region)) -amdgpu_prime_scanout_update (ent); -else +if (RegionNotEmpty (region)) { +if (info->tear_free) +amdgpu_prime_scanout_flip (ent); +else +amdgpu_prime_scanout_update (ent); + }else {DamageEmpty (region_ent->damage); + }RegionDestroy (region);src/amdgpu_kms.c +0
-0}else {src/drmmode_display.c +9
-4@@ -467,10 +467,19 @@ drmmode_crtc_scanout_destroy(drmmode_ptr drmmode, static voiddrmmode_crtc_scanout_free (drmmode_crtc_private_ptr drmmode_crtc) { -drmmode_crtc_scanout_destroy (drmmode_crtc->drmmode, - &drmmode_crtc->scanout[0 ]); -drmmode_crtc_scanout_destroy (drmmode_crtc->drmmode, - &drmmode_crtc->scanout[1 ]); +if (drmmode_crtc->flip_pending) { + drmmode_crtc->scanout_destroy[0 ] = drmmode_crtc- >scanout[0]; + drmmode_crtc->scanout[0 ].pixmap =NULL ; + drmmode_crtc->scanout[0 ].bo =NULL ; + drmmode_crtc->scanout_destroy[1 ] = drmmode_crtc- >scanout[1]; + drmmode_crtc->scanout[1 ].pixmap =NULL ; + drmmode_crtc->scanout[1 ].bo =NULL ; + }else { + drmmode_crtc_scanout_destroy(drmmode_crtc-Quoted 1 line
drmmode,
src/drmmode_display.c +2
-0+ &drmmode_crtc->scanout[0]); + drmmode_crtc_scanout_destroy(drmmode_crtc-Quoted 1 line
drmmode,
src/drmmode_display.c +4
-1+ &drmmode_crtc->scanout[1]); + }if (drmmode_crtc->scanout_damage) {DamageDestroy (drmmode_crtc->scanout_damage);@@ -1062,11 +1071,12 @@ drmmode_crtc_gamma_set(xf86CrtcPtr crtc, uint16_t * red, uint16_t * green, static Bool drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix) { drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; +AMDGPUInfoPtr info =AMDGPUPTR (crtc->scrn);if (!ppix) {if (crtc->randr_crtc->scanout_pixmap)PixmapStopDirtyTracking (crtc->randr_crtc- >scanout_pixmap, - drmmode_crtc- >scanout[0 ].pixmap); + drmmode_crtc-Quoted 1 line
scanout[drmmode_crtc->scanout_id].pixmap);
src/drmmode_display.c +8
-0drmmode_crtc_scanout_free (drmmode_crtc);return TRUE; }@@ -1076,6 +1086,14 @@ static Bool drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix) ppix->drawable.height)) return FALSE; +if (info->tear_free && + !drmmode_crtc_scanout_create (crtc, &drmmode_crtc- >scanout[1], + ppix->drawable.width, + ppix->drawable.height)) { +drmmode_crtc_scanout_free (drmmode_crtc); +return FALSE; + } +#ifdef HAS_DIRTYTRACKING_ROTATION src/drmmode_display.c +5
-0PixmapStartDirtyTracking (ppix, drmmode_crtc->scanout[0 ].pixmap,0 ,0 ,0 ,0 , RR_Rotate_0);@@ -2010,6 +2028,11 @@ drmmode_clear_pending_flip(xf86CrtcPtr crtc)drmmode_crtc_dpms (crtc, drmmode_crtc- >pending_dpms_mode); } + +drmmode_crtc_scanout_destroy (drmmode_crtc->drmmode, + &drmmode_crtc->scanout_destroy[0 ]); +drmmode_crtc_scanout_destroy (drmmode_crtc->drmmode, + &drmmode_crtc->scanout_destroy[1 ]); }static void
src/drmmode_display.h +1
-1@@ -84,6 +84,7 @@ typedef struct {struct amdgpu_buffer *cursor_buffer;struct drmmode_scanout rotate;struct drmmode_scanout scanout[2 ]; +struct drmmode_scanout scanout_destroy[2 ];DamagePtr scanout_damage;RegionRec scanout_last_region;unsigned scanout_id; --2.9.3
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx