summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-06-04 20:21:51 -0700
committerKeith Packard <keithp@keithp.com>2016-06-04 20:30:51 -0700
commit317355cf4cbc91b57de80c6a2dc5a43e970e709b (patch)
tree2c70626956018a8e1016407c624abd084473d1a3
parent846523786826af6a0f65367517a22be943a2b20d (diff)
glamor: Limit outstanding drawing queue with glClientWaitSyncglamor-fence
The X server doesn't (generally) use SwapBuffers, so we need some other mechanism to avoid flooding the device with queued rendering requests when the server is busy. Limit the amount of outstanding rendering requests queued to the driver by glFenceSync objects and waiting on the next-to-last one in the block handler. This should let the device continue to process any operations queued since the previous block handler invocation and not slow down drawing too much. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--glamor/glamor.c7
-rw-r--r--glamor/glamor_priv.h2
2 files changed, 9 insertions, 0 deletions
diff --git a/glamor/glamor.c b/glamor/glamor.c
index 7d82ce806..030e7b4f1 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -266,6 +266,13 @@ _glamor_block_handler(ScreenPtr screen, void *timeout, void *readmask)
glamor_make_current(glamor_priv);
glFlush();
+ if (glamor_priv->sync[glamor_priv->sync_id]) {
+ glClientWaitSync(glamor_priv->sync[glamor_priv->sync_id],
+ 0,
+ GL_TIMEOUT_IGNORED);
+ }
+ glamor_priv->sync[glamor_priv->sync_id] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+ glamor_priv->sync_id = (glamor_priv->sync_id + 1) % ARRAY_SIZE(glamor_priv->sync);
screen->BlockHandler = glamor_priv->saved_procs.block_handler;
screen->BlockHandler(screen, timeout, readmask);
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index c34eb84c0..4fd5460a4 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -308,6 +308,8 @@ typedef struct glamor_screen_private {
glamor_program xv_prog;
struct glamor_context ctx;
+ GLsync sync[2];
+ int sync_id;
} glamor_screen_private;
typedef enum glamor_access {