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

Function readbackTestMS

server/fakerut.cpp:949–1073  ·  view source on GitHub ↗

This tests whether a multisampled off-screen buffer can be read back, both internally within frame trigger functions and externally with glReadPixels(), when using the EGL back end.

Source from the content-addressed store, hash-verified

947// internally within frame trigger functions and externally with
948// glReadPixels(), when using the EGL back end.
949int readbackTestMS(void)
950{
951 TestColor clr(0);
952 Display *dpy = NULL; Window win = 0;
953 int dpyw, dpyh, lastFrame = 0, retval = 1;
954 int glxattribs13[] = { GLX_DOUBLEBUFFER, 1, GLX_RENDER_TYPE, GLX_RGBA_BIT,
955 GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8,
956 GLX_BLUE_SIZE, 8, GLX_SAMPLES, 2, None };
957 XVisualInfo *vis = NULL;
958 GLXFBConfig config = 0, *configs = NULL;
959 int n = 0;
960 GLXContext ctx = 0;
961 XSetWindowAttributes swa;
962 GLuint fbo = 0, rbo0 = 0, rbo1 = 0;
963
964 printf("Multisampled readback test:\n\n");
965
966 try
967 {
968 if(!(dpy = XOpenDisplay(0))) THROW("Could not open display");
969 dpyw = DisplayWidth(dpy, DefaultScreen(dpy));
970 dpyh = DisplayHeight(dpy, DefaultScreen(dpy));
971
972 if((configs = glXChooseFBConfig(dpy, DefaultScreen(dpy), glxattribs13, &n))
973 == NULL || n == 0)
974 THROW("Could not find a suitable FB config");
975 config = configs[0];
976 XFree(configs); configs = NULL;
977 if((vis = glXGetVisualFromFBConfig(dpy, config)) == NULL)
978 THROW("glXGetVisualFromFBConfig()");
979
980 Window root = RootWindow(dpy, DefaultScreen(dpy));
981 swa.colormap = XCreateColormap(dpy, root, vis->visual, AllocNone);
982 swa.border_pixel = 0;
983 swa.event_mask = 0;
984 if((win = XCreateWindow(dpy, root, 0, 0, dpyw / 2, dpyh / 2, 0,
985 vis->depth, InputOutput, vis->visual,
986 CWBorderPixel | CWColormap | CWEventMask, &swa)) == 0)
987 THROW("Could not create window");
988 XFree(vis); vis = NULL;
989
990 if((ctx = glXCreateNewContext(dpy, config, GLX_RGBA_TYPE, NULL, True))
991 == NULL)
992 THROW("Could not establish GLX context");
993 if(!glXMakeContextCurrent(dpy, win, win, ctx))
994 THROW("Could not make context current");
995 checkCurrent(dpy, win, win, ctx, dpyw / 2, dpyh / 2);
996
997 XMapWindow(dpy, win);
998
999 clr.clear(GL_FRONT);
1000 VERIFY_BUF_COLOR(GL_FRONT, clr.bits(-1), "GL_FRONT");
1001 clr.clear(GL_BACK);
1002 VERIFY_BUF_COLOR(GL_BACK, clr.bits(-1), "GL_BACK");
1003 glGenFramebuffers(1, &fbo);
1004 glGenRenderbuffers(1, &rbo0);
1005 glGenRenderbuffers(1, &rbo1);
1006 glBindRenderbuffer(GL_RENDERBUFFER, rbo0);

Callers 1

mainFunction · 0.85

Calls 15

XOpenDisplayFunction · 0.85
glXChooseFBConfigFunction · 0.85
XFreeFunction · 0.85
glXGetVisualFromFBConfigFunction · 0.85
XCreateWindowFunction · 0.85
glXCreateNewContextFunction · 0.85
glXMakeContextCurrentFunction · 0.85
glBindFramebufferFunction · 0.85
glDrawBuffersFunction · 0.85
glReadBufferFunction · 0.85
glXSwapBuffersFunction · 0.85
checkBufferStateFunction · 0.85

Tested by

no test coverage detected