diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2015-03-11 17:30:11 +0900 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2015-03-17 10:59:48 +0900 |
commit | ad27f16f308079d06a2b1c788b3cb0947531253a (patch) | |
tree | 0c819abfd8c1605f863bf058518bcd53c606084e /src | |
parent | b4af8a327ed8420f0ff4ea0f113f4a59406ed4d3 (diff) |
DRI2: Simplify blit fallback handling for scheduled swaps
Also use radeon_dri2_schedule_event when possible.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/radeon_dri2.c | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index 36ab4d03..31bd73c7 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; |