mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 06:11:46 +00:00
[client] x11: prevent present event loop underruns
Queue up and maintain a list of presentation timestamps to avoid spikes caused by X11 event processing latency.
This commit is contained in:
parent
179eaef29d
commit
bc7e59c9d7
1 changed files with 68 additions and 19 deletions
|
@ -84,25 +84,74 @@ static void x11XPresentEvent(XGenericEventCookie *cookie);
|
|||
|
||||
static void x11DoPresent(void)
|
||||
{
|
||||
XPresentPixmap(
|
||||
x11.display,
|
||||
x11.window,
|
||||
x11.presentPixmap,
|
||||
x11.presentSerial++,
|
||||
x11.presentRegion, // valid
|
||||
x11.presentRegion, // update
|
||||
0, // x_off,
|
||||
0, // y_off,
|
||||
None, // target_crtc
|
||||
None, // wait_fence
|
||||
None, // idle_fence
|
||||
PresentOptionNone, // options
|
||||
0, // target_msc,
|
||||
0, // divisor,
|
||||
0, // remainder,
|
||||
NULL, // notifies
|
||||
0 // nnotifies
|
||||
);
|
||||
static bool startup = true;
|
||||
if (startup)
|
||||
{
|
||||
XPresentPixmap(
|
||||
x11.display,
|
||||
x11.window,
|
||||
x11.presentPixmap,
|
||||
x11.presentSerial++,
|
||||
x11.presentRegion, // valid
|
||||
x11.presentRegion, // update
|
||||
0, // x_off,
|
||||
0, // y_off,
|
||||
None, // target_crtc
|
||||
None, // wait_fence
|
||||
None, // idle_fence
|
||||
PresentOptionNone, // options
|
||||
0, // target_msc,
|
||||
0, // divisor,
|
||||
0, // remainder,
|
||||
NULL, // notifies
|
||||
0 // nnotifies
|
||||
);
|
||||
startup = false;
|
||||
return;
|
||||
}
|
||||
|
||||
static bool first = true;
|
||||
static uint64_t lastMsc = 0;
|
||||
uint64_t msc = atomic_load(&x11.presentMsc);
|
||||
|
||||
uint64_t refill;
|
||||
if (!first)
|
||||
refill = 50 - (lastMsc - msc);
|
||||
else
|
||||
{
|
||||
refill = 50;
|
||||
first = false;
|
||||
lastMsc = msc;
|
||||
}
|
||||
|
||||
if (refill < 25)
|
||||
return;
|
||||
|
||||
if (refill == 0)
|
||||
lastMsc = msc;
|
||||
|
||||
for(int i = 0; i < refill; ++i)
|
||||
{
|
||||
XPresentPixmap(
|
||||
x11.display,
|
||||
x11.window,
|
||||
x11.presentPixmap,
|
||||
x11.presentSerial++,
|
||||
x11.presentRegion, // valid
|
||||
x11.presentRegion, // update
|
||||
0, // x_off,
|
||||
0, // y_off,
|
||||
None, // target_crtc
|
||||
None, // wait_fence
|
||||
None, // idle_fence
|
||||
PresentOptionNone, // options
|
||||
++lastMsc, // target_msc,
|
||||
0, // divisor,
|
||||
0, // remainder,
|
||||
NULL, // notifies
|
||||
0 // nnotifies
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void x11Setup(void)
|
||||
|
|
Loading…
Reference in a new issue