mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-04 06:12:04 +00:00
[client] report presentation cadence over LGMP
This commit is contained in:
@@ -56,6 +56,8 @@ static void presentationFeedbackPresented(void * opaque,
|
||||
uint32_t tvNsec, uint32_t refresh, uint32_t seqHi, uint32_t seqLo, uint32_t flags)
|
||||
{
|
||||
struct FrameData * data = opaque;
|
||||
if (refresh)
|
||||
atomic_store(&wlWm.presentationPeriod, refresh);
|
||||
struct timespec present = {
|
||||
.tv_sec = (uint64_t) tvSecHi << 32 | tvSecLo,
|
||||
.tv_nsec = tvNsec,
|
||||
@@ -69,6 +71,16 @@ static void presentationFeedbackPresented(void * opaque,
|
||||
wp_presentation_feedback_destroy(feedback);
|
||||
}
|
||||
|
||||
bool waylandGetFramePeriod(uint64_t * period)
|
||||
{
|
||||
const uint64_t value = atomic_load(&wlWm.presentationPeriod);
|
||||
if (!value)
|
||||
return false;
|
||||
|
||||
*period = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void presentationFeedbackDiscarded(void * data,
|
||||
struct wp_presentation_feedback * feedback)
|
||||
{
|
||||
|
||||
@@ -314,6 +314,7 @@ struct LG_DisplayServerOps LGDS_Wayland =
|
||||
.waitFrame = waylandWaitFrame,
|
||||
.skipFrame = waylandSkipFrame,
|
||||
.stopWaitFrame = waylandStopWaitFrame,
|
||||
.getFramePeriod = waylandGetFramePeriod,
|
||||
.guestPointerUpdated = waylandGuestPointerUpdated,
|
||||
.setPointer = waylandSetPointer,
|
||||
.grabPointer = waylandGrabPointer,
|
||||
|
||||
@@ -158,6 +158,7 @@ struct WaylandDSState
|
||||
|
||||
struct wp_presentation * presentation;
|
||||
clockid_t clkId;
|
||||
_Atomic(uint64_t) presentationPeriod;
|
||||
RingBuffer photonTimings;
|
||||
GraphHandle photonGraph;
|
||||
|
||||
@@ -399,6 +400,7 @@ bool waylandPollUnregister(int fd);
|
||||
bool waylandPresentationInit(void);
|
||||
void waylandPresentationFrame(void);
|
||||
void waylandPresentationFree(void);
|
||||
bool waylandGetFramePeriod(uint64_t * period);
|
||||
|
||||
// registry module
|
||||
bool waylandRegistryInit(void);
|
||||
|
||||
@@ -1487,6 +1487,15 @@ static void x11XPresentEvent(XGenericEventCookie *cookie)
|
||||
case PresentCompleteNotify:
|
||||
{
|
||||
XPresentCompleteNotifyEvent * e = cookie->data;
|
||||
const uint64_t previousMsc = atomic_load(&x11.presentMsc);
|
||||
const uint64_t previousUst = atomic_load(&x11.presentUst);
|
||||
if (previousMsc && e->msc > previousMsc && e->ust > previousUst)
|
||||
{
|
||||
const uint64_t period =
|
||||
(e->ust - previousUst) * 1000 / (e->msc - previousMsc);
|
||||
if (period)
|
||||
atomic_store(&x11.presentPeriod, period);
|
||||
}
|
||||
x11DoPresent(e->msc);
|
||||
atomic_store(&x11.presentMsc, e->msc);
|
||||
atomic_store(&x11.presentUst, e->ust);
|
||||
@@ -1496,6 +1505,16 @@ static void x11XPresentEvent(XGenericEventCookie *cookie)
|
||||
}
|
||||
}
|
||||
|
||||
static bool x11GetFramePeriod(uint64_t * period)
|
||||
{
|
||||
const uint64_t value = atomic_load(&x11.presentPeriod);
|
||||
if (!value)
|
||||
return false;
|
||||
|
||||
*period = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_EGL
|
||||
static EGLDisplay x11GetEGLDisplay(void)
|
||||
{
|
||||
@@ -2025,6 +2044,7 @@ struct LG_DisplayServerOps LGDS_X11 =
|
||||
#endif
|
||||
.waitFrame = x11WaitFrame,
|
||||
.stopWaitFrame = x11StopWaitFrame,
|
||||
.getFramePeriod = x11GetFramePeriod,
|
||||
.guestPointerUpdated = x11GuestPointerUpdated,
|
||||
.setPointer = x11SetPointer,
|
||||
.grabPointer = x11GrabPointer,
|
||||
|
||||
@@ -75,6 +75,7 @@ struct X11DSState
|
||||
int xpresentOp;
|
||||
bool jitRender;
|
||||
_Atomic(uint64_t) presentMsc, presentUst;
|
||||
_Atomic(uint64_t) presentPeriod;
|
||||
uint32_t presentSerial;
|
||||
Pixmap presentPixmap;
|
||||
XserverRegion presentRegion;
|
||||
|
||||
Reference in New Issue
Block a user