From 7b0e4adaf21d4c788657eff41cb51d5c89647309 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 26 Nov 2009 11:55:47 +0000 Subject: st/xorg: render throttling in block handler Similar to the classic swapbuffer throttling in GL drivers, put an upper bound on the number of outstanding chunks of rendering the state tracker can generate -- where calling the block handler denotes a chunk. Currently that number is set at around 4 "chunks", but could be tweaked up or down. If a better measure for the amount of outstanding rendering is found, that would be fine too. As it stands, this improves interactivity by preventing the X server from queueing up arbitary amounts of rendering. --- src/gallium/state_trackers/xorg/xorg_driver.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/gallium/state_trackers/xorg/xorg_driver.c') diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index c74fb28072..4c66354ad4 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -450,8 +450,24 @@ static void drv_block_handler(int i, pointer blockData, pointer pTimeout, pScreen->BlockHandler(i, blockData, pTimeout, pReadmask); pScreen->BlockHandler = drv_block_handler; - if (ms->ctx) - ms->ctx->flush(ms->ctx, PIPE_FLUSH_RENDER_CACHE, NULL); + if (ms->ctx) { + int j; + + ms->ctx->flush(ms->ctx, PIPE_FLUSH_RENDER_CACHE, &ms->fence[XORG_NR_FENCES-1]); + + if (ms->fence[0]) + ms->ctx->screen->fence_finish(ms->ctx->screen, ms->fence[0], 0); + + /* The amount of rendering generated by a block handler can be + * quite small. Let us get a fair way ahead of hardware before + * throttling. + */ + for (j = 0; j < XORG_NR_FENCES; j++) + ms->screen->fence_reference(ms->screen, + &ms->fence[j], + ms->fence[j+1]); + } + #ifdef DRM_MODE_FEATURE_DIRTYFB { -- cgit v1.2.3