MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / readbackTest

Function readbackTest

server/eglxfakerut.cpp:297–458  ·  view source on GitHub ↗

This tests the faker's readback heuristics

Source from the content-addressed store, hash-verified

295
296// This tests the faker's readback heuristics
297int readbackTest(void)
298{
299 TestColor clr(0), sclr(3);
300 Display *dpy = NULL; Window win0 = 0, win1 = 0;
301 EGLDisplay edpy = 0;
302 EGLSurface surface0 = 0, surface1 = 0;
303 int dpyw, dpyh, lastFrame0 = 0, lastFrame1 = 0, retval = 1;
304 int cfgAttribs[] = { EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8,
305 EGL_CONFORMANT, EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT,
306 EGL_NONE };
307 XVisualInfo *vis = NULL;
308 EGLConfig config = 0; EGLint nc = 0;
309 EGLContext ctxgl = 0, ctxes = 0;
310 XSetWindowAttributes swa;
311
312 printf("Readback heuristics test\n\n");
313
314 try
315 {
316 if(!(dpy = XOpenDisplay(0))) THROW("Could not open display");
317 dpyw = DisplayWidth(dpy, DefaultScreen(dpy));
318 dpyh = DisplayHeight(dpy, DefaultScreen(dpy));
319
320 EGLAttrib displayAttribs[] = { EGL_PLATFORM_X11_SCREEN_EXT,
321 DefaultScreen(dpy), EGL_NONE };
322 if((edpy = eglGetPlatformDisplay(EGL_PLATFORM_X11_EXT, dpy,
323 displayAttribs)) == EGL_NO_DISPLAY)
324 THROW_EGL("eglGetPlatformDisplay()");
325 if(!eglInitialize(edpy, NULL, NULL))
326 THROW_EGL("eglInitialize()");
327
328 if(!eglChooseConfig(edpy, cfgAttribs, &config, 1, &nc))
329 THROW_EGL("eglChooseConfig()");
330 if((vis = getVisualFromConfig(dpy, DefaultScreen(dpy), edpy,
331 config)) == NULL)
332 THROW("Could not find a suitable visual");
333
334 Window root = RootWindow(dpy, DefaultScreen(dpy));
335 swa.colormap = XCreateColormap(dpy, root, vis->visual, AllocNone);
336 swa.border_pixel = 0;
337 swa.event_mask = 0;
338 if((win0 = XCreateWindow(dpy, root, 0, 0, dpyw / 2, dpyh / 2, 0,
339 vis->depth, InputOutput, vis->visual,
340 CWBorderPixel | CWColormap | CWEventMask, &swa)) == 0)
341 THROW("Could not create window");
342 if((win1 = XCreateWindow(dpy, root, dpyw / 2, 0, dpyw / 2, dpyh / 2, 0,
343 vis->depth, InputOutput, vis->visual,
344 CWBorderPixel | CWColormap | CWEventMask, &swa)) == 0)
345 THROW("Could not create window");
346 XFree(vis); vis = NULL;
347
348 if(!eglBindAPI(EGL_OPENGL_ES_API))
349 THROW_EGL("eglBindAPI()");
350 if((ctxes = eglCreateContext(edpy, config, NULL, NULL)) == 0)
351 THROW_EGL("eglCreateContext()");
352 if(!eglBindAPI(EGL_OPENGL_API))
353 THROW_EGL("eglBindAPI()");
354 if((ctxgl = eglCreateContext(edpy, config, NULL, NULL)) == 0)

Callers 1

mainFunction · 0.70

Calls 15

XOpenDisplayFunction · 0.85
eglGetPlatformDisplayFunction · 0.85
eglInitializeFunction · 0.85
eglChooseConfigFunction · 0.85
XCreateWindowFunction · 0.85
XFreeFunction · 0.85
eglCreateContextFunction · 0.85
eglCreateWindowSurfaceFunction · 0.85
eglMakeCurrentFunction · 0.85
glReadPixelsFunction · 0.85
eglSwapBuffersFunction · 0.85

Tested by

no test coverage detected