Low-Latency method to read Xorg or DRM framebuffer
0
votes
0
answers
559
views
I am trying to build an application that can measure the latency/processing time of graphics frameworks on Linux.
My idea is to implement simple programs that react to an input event (e.g. mouse click) by changing the screen's color (e.g. from black to white) with different graphics and UI frameworks (e.g. SDL, OpenGL, Qt, ...).
To measure each program's latency, I want to implement a separate program that measures the time from an input event arriving at the machine (I'm using evdev for this) to a pixel being updated in some kind of framebuffer (as close to the application as possible). The second program should also be independent of vblank events, as I'm interested in the time the rendering is done, not the time users might be able to see something.
My problem is getting the framebuffer content with the second program. I already managed to get framebuffer content with fbdev or libdrm (based on this tutorial ), but both require the programs to be run in a terminal without an active XServer (which I would prefer due to external validity).
I have also already tried to use MIT-XShm to retrieve the X framebuffer's content, but it seems too slow for my problem, even when reading only one pixel (around 4 milliseconds with harsh outliers).
This is how I currently use XShm, in case it might help.
// get one pixel at coordinates x/y with XShm
XShmGetImage(display, rootWindow, image, x, y, 0x00ffffff);
// store red value into variable
unsigned int color = image->data[2] ;
if(color != lastcolor)
{
log(time_micros(), color);
}
Is there a quick and reliable way to retrieve framebuffer content (either from X or from DRM) with an XServer running? Or is XShm the best we can do at the moment?
Asked by Andreas Schmid
(1 rep)
Nov 9, 2021, 10:29 PM