[PATCH xserver] glamor: Limit outstanding drawing queue with glClientWaitSync
Keith Packard
keithp at keithp.com
Sun Jun 5 03:29:19 UTC 2016
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 at keithp.com>
---
glamor/glamor.c | 7 +++++++
glamor/glamor_priv.h | 2 ++
2 files changed, 9 insertions(+)
diff --git a/glamor/glamor.c b/glamor/glamor.c
index 62b5c3a..226a10e 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -271,6 +271,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);
}
static void
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index c34eb84..4fd5460 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 {
--
2.8.1
More information about the xorg-devel
mailing list