[PATCH xf86-video-amdgpu 08/10] Pass extents to amdgpu_scanout_do_update

Michel Dänzer michel at daenzer.net
Fri Aug 18 08:53:20 UTC 2017


From: Michel Dänzer <michel.daenzer at amd.com>

Preparation for following change, no functional change intended yet.

(Ported from radeon commit 65e0c5ea1b4adff21d673dbf54af99704c429627)

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/amdgpu_drv.h      |  2 +-
 src/amdgpu_kms.c      | 41 +++++++++++++++++++++--------------------
 src/drmmode_display.c |  3 ++-
 3 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h
index 515d46625..13237470a 100644
--- a/src/amdgpu_drv.h
+++ b/src/amdgpu_drv.h
@@ -341,7 +341,7 @@ Bool amdgpu_dri3_screen_init(ScreenPtr screen);
 
 /* amdgpu_kms.c */
 Bool amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
-			       DrawablePtr src_draw);
+			       DrawablePtr src_draw, BoxPtr extents);
 void AMDGPUWindowExposures_oneshot(WindowPtr pWin, RegionPtr pRegion
 #if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,16,99,901,0)
 				   , RegionPtr pBSRegion
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index 230a779fc..aedb3f066 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -793,32 +793,27 @@ amdgpu_dirty_update(ScrnInfoPtr scrn)
 
 Bool
 amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
-			  DrawablePtr src_draw)
+			 DrawablePtr src_draw, BoxPtr extents)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
-	RegionPtr pRegion = DamageRegion(drmmode_crtc->scanout_damage);
+	RegionRec region = { .extents = *extents, .data = NULL };
 	ScrnInfoPtr scrn = xf86_crtc->scrn;
 	ScreenPtr pScreen = scrn->pScreen;
 	DrawablePtr pDraw;
-	BoxRec extents;
 
 	if (!xf86_crtc->enabled ||
-	    !drmmode_crtc->scanout[scanout_id].pixmap)
-		return FALSE;
-
-	if (!RegionNotEmpty(pRegion))
+	    !drmmode_crtc->scanout[scanout_id].pixmap ||
+	    extents->x1 >= extents->x2 || extents->y1 >= extents->y2)
 		return FALSE;
 
 	pDraw = &drmmode_crtc->scanout[scanout_id].pixmap->drawable;
-	extents = *RegionExtents(pRegion);
-	if (!amdgpu_scanout_extents_intersect(xf86_crtc, &extents))
+	if (!amdgpu_scanout_extents_intersect(xf86_crtc, extents))
 		return FALSE;
 
 	if (drmmode_crtc->tear_free) {
-		amdgpu_sync_scanout_pixmaps(xf86_crtc, pRegion, scanout_id);
-		RegionCopy(&drmmode_crtc->scanout_last_region, pRegion);
+		amdgpu_sync_scanout_pixmaps(xf86_crtc, &region, scanout_id);
+		RegionCopy(&drmmode_crtc->scanout_last_region, &region);
 	}
-	RegionEmpty(pRegion);
 
 #if XF86_CRTC_VERSION >= 4
 	if (xf86_crtc->driverIsPerformingTransform) {
@@ -856,9 +851,9 @@ amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
 		pScreen->SourceValidate = NULL;
 		CompositePicture(PictOpSrc,
 				 src, NULL, dst,
-				 extents.x1, extents.y1, 0, 0, extents.x1,
-				 extents.y1, extents.x2 - extents.x1,
-				 extents.y2 - extents.y1);
+				 extents->x1, extents->y1, 0, 0, extents->x1,
+				 extents->y1, extents->x2 - extents->x1,
+				 extents->y2 - extents->y1);
 		pScreen->SourceValidate = SourceValidate;
 
  free_dst:
@@ -873,9 +868,9 @@ amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
 
 		ValidateGC(pDraw, gc);
 		(*gc->ops->CopyArea)(src_draw, pDraw, gc,
-				     xf86_crtc->x + extents.x1, xf86_crtc->y + extents.y1,
-				     extents.x2 - extents.x1, extents.y2 - extents.y1,
-				     extents.x1, extents.y1);
+				     xf86_crtc->x + extents->x1, xf86_crtc->y + extents->y1,
+				     extents->x2 - extents->x1, extents->y2 - extents->y1,
+				     extents->x1, extents->y1);
 		FreeScratchGC(gc);
 	}
 
@@ -898,9 +893,12 @@ amdgpu_scanout_update_handler(xf86CrtcPtr crtc, uint32_t frame, uint64_t usec,
 {
 	drmmode_crtc_private_ptr drmmode_crtc = event_data;
 	ScreenPtr screen = crtc->scrn->pScreen;
+	RegionPtr region = DamageRegion(drmmode_crtc->scanout_damage);
 
 	amdgpu_scanout_do_update(crtc, drmmode_crtc->scanout_id,
-				 &screen->GetWindowPixmap(screen->root)->drawable);
+				 &screen->GetWindowPixmap(screen->root)->drawable,
+				 &region->extents);
+	RegionEmpty(region);
 
 	amdgpu_scanout_update_abort(crtc, event_data);
 }
@@ -977,6 +975,7 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,
 					xf86CrtcPtr xf86_crtc)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
+	RegionPtr region = DamageRegion(drmmode_crtc->scanout_damage);
 	ScrnInfoPtr scrn = xf86_crtc->scrn;
 	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
 	uintptr_t drm_queue_seq;
@@ -988,8 +987,10 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,
 
 	scanout_id = drmmode_crtc->scanout_id ^ 1;
 	if (!amdgpu_scanout_do_update(xf86_crtc, scanout_id,
-				      &pScreen->GetWindowPixmap(pScreen->root)->drawable))
+				      &pScreen->GetWindowPixmap(pScreen->root)->drawable,
+				      &region->extents))
 		return;
+	RegionEmpty(region);
 
 	drm_queue_seq = amdgpu_drm_queue_alloc(xf86_crtc,
 					       AMDGPU_DRM_QUEUE_CLIENT_DEFAULT,
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 972a6f217..fa19fd7ab 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -771,7 +771,8 @@ drmmode_crtc_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
 		*x = *y = 0;
 
 		amdgpu_scanout_do_update(crtc, scanout_id,
-					 &screen->GetWindowPixmap(screen->root)->drawable);
+					 &screen->GetWindowPixmap(screen->root)->drawable,
+					 box);
 		amdgpu_glamor_finish(scrn);
 	}
 }
-- 
2.14.1



More information about the amd-gfx mailing list