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

Function readbackTest

server/fakerut.cpp:424–943  ·  view source on GitHub ↗

This tests the faker's readback heuristics

Source from the content-addressed store, hash-verified

422
423// This tests the faker's readback heuristics
424int readbackTest(bool stereo, bool doNamedFB)
425{
426 TestColor clr(0), sclr(3);
427 Display *dpy = NULL; Window win0 = 0, win1 = 0;
428 int dpyw, dpyh, lastFrame0 = 0, lastFrame1 = 0, retval = 1;
429 int glxattribs[] = { GLX_DOUBLEBUFFER, GLX_RGBA, GLX_RED_SIZE, 8,
430 GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, None, None };
431 int glxattribs13[] = { GLX_DOUBLEBUFFER, 1, GLX_RENDER_TYPE, GLX_RGBA_BIT,
432 GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8,
433 GLX_BLUE_SIZE, 8, None, None, None };
434 XVisualInfo *vis0 = NULL, *vis1 = NULL;
435 GLXFBConfig config = 0, *configs = NULL;
436 int n = 0;
437 GLXContext ctx0 = 0, ctx1 = 0;
438 XSetWindowAttributes swa;
439
440 if(stereo)
441 {
442 glxattribs[8] = glxattribs13[12] = GLX_STEREO;
443 glxattribs13[13] = 1;
444 }
445
446 printf("Readback heuristics test ");
447 if(stereo) printf("(Stereo RGB)\n\n");
448 else printf("(Mono RGB)\n\n");
449
450 try
451 {
452 if(!(dpy = XOpenDisplay(0))) THROW("Could not open display");
453 dpyw = DisplayWidth(dpy, DefaultScreen(dpy));
454 dpyh = DisplayHeight(dpy, DefaultScreen(dpy));
455
456 if((vis0 = glXChooseVisual(dpy, DefaultScreen(dpy), glxattribs)) == NULL)
457 THROW("Could not find a suitable visual");
458 if((configs = glXChooseFBConfig(dpy, DefaultScreen(dpy), glxattribs13, &n))
459 == NULL || n == 0)
460 THROW("Could not find a suitable FB config");
461 config = configs[0];
462 XFree(configs); configs = NULL;
463
464 Window root = RootWindow(dpy, DefaultScreen(dpy));
465 swa.colormap = XCreateColormap(dpy, root, vis0->visual, AllocNone);
466 swa.border_pixel = 0;
467 swa.event_mask = 0;
468 if((win0 = XCreateWindow(dpy, root, 0, 0, dpyw / 2, dpyh / 2, 0,
469 vis0->depth, InputOutput, vis0->visual,
470 CWBorderPixel | CWColormap | CWEventMask, &swa)) == 0)
471 THROW("Could not create window");
472 if(!(vis1 = glXGetVisualFromFBConfig(dpy, config)))
473 THROW("glXGetVisualFromFBConfig()");
474 swa.colormap = XCreateColormap(dpy, root, vis1->visual, AllocNone);
475 if((win1 = XCreateWindow(dpy, root, dpyw / 2, 0, dpyw / 2, dpyh / 2, 0,
476 vis1->depth, InputOutput, vis1->visual,
477 CWBorderPixel | CWColormap | CWEventMask, &swa)) == 0)
478 THROW("Could not create window");
479 XFree(vis1); vis1 = NULL;
480
481 if((ctx0 = glXCreateContext(dpy, vis0, 0, True)) == NULL)

Callers 1

mainFunction · 0.70

Calls 15

XOpenDisplayFunction · 0.85
glXChooseVisualFunction · 0.85
glXChooseFBConfigFunction · 0.85
XFreeFunction · 0.85
XCreateWindowFunction · 0.85
glXGetVisualFromFBConfigFunction · 0.85
glXCreateContextFunction · 0.85
glXCreateNewContextFunction · 0.85
glXMakeCurrentFunction · 0.85
stereoTestFunction · 0.85
doubleBufferTestFunction · 0.85
glGetTestFunction · 0.85

Tested by

no test coverage detected