[PATCH 04/14] DRI2: Simplify blit fallback handling for scheduled swaps
Michel Dänzer
michel at daenzer.net
Wed Mar 11 23:10:46 PDT 2015
From: Michel Dänzer <michel.daenzer at amd.com>
Also use radeon_dri2_schedule_event when possible.
Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
src/radeon_dri2.c | 47 ++++++++++++++++++++---------------------------
1 file changed, 20 insertions(+), 27 deletions(-)
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 36ab4d0..31bd73c 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -1319,7 +1319,6 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
drmVBlank vbl;
int ret, flip = 0;
DRI2FrameEventPtr swap_info = NULL;
- enum DRI2FrameEventType swap_type = DRI2_SWAP;
CARD64 current_msc;
BoxRec box;
RegionRec region;
@@ -1345,6 +1344,7 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
if (!swap_info)
goto blit_fallback;
+ swap_info->type = DRI2_SWAP;
swap_info->drawable_id = draw->id;
swap_info->client = client;
swap_info->event_complete = func;
@@ -1384,9 +1384,7 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
"first get vblank counter failed: %s\n",
strerror(errno));
- *target_msc = 0;
- radeon_dri2_schedule_event(FALLBACK_SWAP_DELAY, swap_info);
- return TRUE;
+ goto blit_fallback;
}
current_msc = vbl.reply.sequence + radeon_get_interpolated_vblanks(crtc);
@@ -1394,13 +1392,11 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
/* Flips need to be submitted one frame before */
if (can_flip(scrn, draw, front, back)) {
- swap_type = DRI2_FLIP;
+ swap_info->type = DRI2_FLIP;
flip = 1;
}
- swap_info->type = swap_type;
-
- /* Correct target_msc by 'flip' if swap_type == DRI2_FLIP.
+ /* Correct target_msc by 'flip' if swap_info->type == DRI2_FLIP.
* Do it early, so handling of different timing constraints
* for divisor, remainder and msc vs. target_msc works.
*/
@@ -1437,9 +1433,7 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
"divisor 0 get vblank counter failed: %s\n",
strerror(errno));
- *target_msc = 0;
- radeon_dri2_schedule_event(FALLBACK_SWAP_DELAY, swap_info);
- return TRUE;
+ goto blit_fallback;
}
*target_msc = vbl.reply.sequence + flip;
@@ -1486,9 +1480,7 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
"final get vblank counter failed: %s\n",
strerror(errno));
- *target_msc = 0;
- radeon_dri2_schedule_event(FALLBACK_SWAP_DELAY, swap_info);
- return TRUE;
+ goto blit_fallback;
}
/* Adjust returned value for 1 fame pageflip offset of flip > 0 */
@@ -1499,22 +1491,23 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
return TRUE;
blit_fallback:
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = draw->width;
- box.y2 = draw->height;
- REGION_INIT(pScreen, ®ion, &box, 0);
+ if (swap_info) {
+ swap_info->type = DRI2_SWAP;
+ radeon_dri2_schedule_event(FALLBACK_SWAP_DELAY, swap_info);
+ } else {
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = draw->width;
+ box.y2 = draw->height;
+ REGION_INIT(pScreen, ®ion, &box, 0);
- radeon_dri2_copy_region(draw, ®ion, front, back);
+ radeon_dri2_copy_region(draw, ®ion, front, back);
- DRI2SwapComplete(client, draw, 0, 0, 0, DRI2_BLIT_COMPLETE, func, data);
- if (swap_info) {
- ListDelDRI2ClientEvents(swap_info->client, &swap_info->link);
- free(swap_info);
- }
+ DRI2SwapComplete(client, draw, 0, 0, 0, DRI2_BLIT_COMPLETE, func, data);
- radeon_dri2_unref_buffer(front);
- radeon_dri2_unref_buffer(back);
+ radeon_dri2_unref_buffer(front);
+ radeon_dri2_unref_buffer(back);
+ }
*target_msc = 0; /* offscreen, so zero out target vblank count */
return TRUE;
--
2.1.4
More information about the xorg-driver-ati
mailing list