Changeset 65787 in vbox for trunk/src/VBox
- Timestamp:
- Feb 14, 2017 4:36:37 PM (8 years ago)
- Location:
- trunk/src/VBox/Additions/common/crOpenGL
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/crOpenGL/context.c
r63204 r65787 616 616 #endif 617 617 618 #ifndef GLX 618 619 /** 619 620 * This creates a native GLX/WGL context. … … 688 689 #endif 689 690 } 691 #endif /* !GLX */ 690 692 691 693 … … 1212 1214 } 1213 1215 } 1216 #ifndef GLX 1214 1217 else { 1215 1218 /* … … 1218 1221 if (!InstantiateNativeContext(window, context)) 1219 1222 { 1220 # ifdef CHROMIUM_THREADSAFE1223 # ifdef CHROMIUM_THREADSAFE 1221 1224 crUnlockMutex(&stub.mutex); 1222 # endif1225 # endif 1223 1226 return 0; /* false */ 1224 1227 } 1225 1228 context->type = NATIVE; 1226 1229 } 1230 #endif /* !GLX */ 1227 1231 1228 1232 #ifdef CHROMIUM_THREADSAFE -
trunk/src/VBox/Additions/common/crOpenGL/glx.c
r65572 r65787 60 60 static GLXDrawable currentReadDrawable = 0; 61 61 62 /**63 * Keep a list of structures which associates X visual IDs with64 * Chromium visual bitmasks.65 */66 struct VisualInfo {67 Display *dpy;68 int screen;69 VisualID visualid;70 int visBits;71 struct VisualInfo *next;72 };73 74 62 static void stubXshmUpdateImageRect(Display *dpy, GLXDrawable draw, GLX_Pixmap_t *pGlxPixmap, XRectangle *pRect); 75 63 static void stubQueryXDamageExtension(Display *dpy, ContextInfo *pContext); 64 65 static bool isGLXVisual(Display *dpy, XVisualInfo *vis) 66 { 67 return vis->visualid == XVisualIDFromVisual(DefaultVisual(dpy, vis->screen)); 68 } 69 70 static GLXFBConfig fbConfigFromVisual(Display *dpy, XVisualInfo *vis) 71 { 72 (void)dpy; 73 74 if (!isGLXVisual(dpy, vis)) 75 return 0; 76 return (GLXFBConfig)vis->visualid; 77 } 78 79 static GLXFBConfig defaultFBConfigForScreen(Display *dpy, int screen) 80 { 81 return (GLXFBConfig) XVisualIDFromVisual(DefaultVisual(dpy, screen)); 82 } 83 84 static XVisualInfo *visualInfoFromFBConfig(Display *dpy, GLXFBConfig config) 85 { 86 XVisualInfo info, *pret; 87 int nret; 88 89 info.visualid = (VisualID)config; 90 pret = XGetVisualInfo(dpy, VisualIDMask, &info, &nret); 91 if (nret == 1) 92 return pret; 93 XFree(pret); 94 return NULL; 95 } 76 96 77 97 DECLEXPORT(XVisualInfo *) … … 272 292 int visBits = CR_RGB_BIT | CR_DOUBLE_BIT | CR_DEPTH_BIT; /* default vis */ 273 293 294 (void)vis; 274 295 stubInit(); 275 296 … … 298 319 299 320 context->dpy = dpy; 300 context->visual = vis;301 321 context->direct = direct; 302 322 … … 397 417 } 398 418 399 400 419 DECLEXPORT(GLXPixmap) VBOXGLXTAG(glXCreateGLXPixmap)( Display *dpy, XVisualInfo *vis, Pixmap pixmap ) 401 420 { 402 421 stubInit(); 403 return VBOXGLXTAG(glXCreatePixmap)(dpy, (GLXFBConfig)vis->visualid, pixmap, NULL);422 return VBOXGLXTAG(glXCreatePixmap)(dpy, fbConfigFromVisual(dpy, vis), pixmap, NULL); 404 423 } 405 424 … … 411 430 DECLEXPORT(int) VBOXGLXTAG(glXGetConfig)( Display *dpy, XVisualInfo *vis, int attrib, int *value ) 412 431 { 413 (void)dpy;414 415 432 if (!vis) { 416 433 /* SGI OpenGL Performer hits this */ … … 426 443 427 444 case GLX_USE_GL: 428 *value = vis->visualid == XVisualIDFromVisual(DefaultVisual(dpy, vis->screen));445 *value = isGLXVisual(dpy, vis); 429 446 break; 430 447 … … 786 803 Bool direct) 787 804 { 805 (void)config; 788 806 if (render_type!=GLX_RGBA_TYPE_SGIX) 789 807 { … … 791 809 return NULL; 792 810 } 793 else 794 { 795 XVisualInfo *vis; 796 GLXContext ret; 797 798 vis = VBOXGLXTAG(glXGetVisualFromFBConfigSGIX)(dpy, config); 799 if (!vis) 800 { 801 crWarning("glXCreateContextWithConfigSGIX: no visuals for %p", config); 802 return NULL; 803 } 804 ret = VBOXGLXTAG(glXCreateContext)(dpy, vis, share_list, direct); 805 XFree(vis); 806 return ret; 807 } 811 return VBOXGLXTAG(glXCreateContext)(dpy, NULL, share_list, direct); 808 812 } 809 813 … … 812 816 GLXFBConfig config) 813 817 { 814 return VBOXGLXTAG(glXGetVisualFromFBConfig)(dpy, config);818 return visualInfoFromFBConfig(dpy, config); 815 819 } 816 820 … … 823 827 } 824 828 /*Note: Caller is supposed to call XFree on returned value, so can't just return (GLXFBConfig)vis->visualid*/ 825 return (GLXFBConfigSGIX) VBOXGLXTAG(glXGetVisualFromFBConfig)(dpy, (GLXFBConfig)vis->visualid);829 return (GLXFBConfigSGIX) visualInfoFromFBConfig(dpy, fbConfigFromVisual(dpy, vis)); 826 830 } 827 831 … … 968 972 VBOXGLXTAG(glXCreateNewContext)(Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct) 969 973 { 970 XVisualInfo *vis;971 972 974 (void) dpy; 973 975 (void) config; … … 982 984 } 983 985 984 vis = VBOXGLXTAG(glXGetVisualFromFBConfig)(dpy, config); 985 return VBOXGLXTAG(glXCreateContext)(dpy, vis, share_list, direct); 986 return VBOXGLXTAG(glXCreateContext)(dpy, NULL, share_list, direct); 986 987 } 987 988 … … 1190 1191 const char * pExt; 1191 1192 1192 pVisual = VBOXGLXTAG(glXGetVisualFromFBConfig)(dpy, config);1193 if (!pVisual)1194 {1195 crWarning("glXGetFBConfigAttrib for %p, failed to get XVisualInfo", config);1196 return GLX_BAD_ATTRIBUTE;1197 }1198 //crDebug("glXGetFBConfigAttrib 0x%x for 0x%x, visualid=0x%x, depth=%i", attribute, (int)config, (int)pVisual->visualid, pVisual->depth);1199 1200 1201 1193 switch (attribute) 1202 1194 { … … 1256 1248 case GLX_VISUAL_ID: 1257 1249 //crDebug("attribute=GLX_VISUAL_ID"); 1250 pVisual = visualInfoFromFBConfig(dpy, config); 1251 if (!pVisual) 1252 { 1253 crWarning("glXGetFBConfigAttrib for %p, failed to get XVisualInfo", config); 1254 return GLX_BAD_ATTRIBUTE; 1255 } 1258 1256 *value = pVisual->visualid; 1257 XFree(pVisual); 1259 1258 break; 1260 1259 case GLX_FBCONFIG_ID: 1261 *value = pVisual->visualid; /*or config, though those are the same at the moment but this could change one day?*/1260 *value = config; /*or config, though those are the same at the moment but this could change one day?*/ 1262 1261 break; 1263 1262 case GLX_RED_SIZE: … … 1296 1295 default: 1297 1296 crDebug("glXGetFBConfigAttrib: unknown attribute=0x%x", attribute); 1298 XFree(pVisual);1299 1297 return GLX_BAD_ATTRIBUTE; 1300 1298 } 1301 1299 1302 XFree(pVisual);1303 1300 return Success; 1304 1301 } … … 1312 1309 *nelements = 1; 1313 1310 XLOCK(dpy); 1314 *pGLXFBConfigs = (GLXFBConfig) XVisualIDFromVisual(DefaultVisual(dpy, screen));1311 *pGLXFBConfigs = defaultFBConfigForScreen(dpy, screen); 1315 1312 XUNLOCK(dpy); 1316 1313 … … 1333 1330 DECLEXPORT(XVisualInfo *) VBOXGLXTAG(glXGetVisualFromFBConfig)(Display *dpy, GLXFBConfig config) 1334 1331 { 1335 (void) dpy; 1336 (void) config; 1337 1338 /* 1339 struct VisualInfo *v; 1340 1341 for (v = VisualInfoList; v; v = v->next) { 1342 if (v->dpy == dpy && v->visualid == (VisualID)config) 1343 { 1344 XVisualInfo temp, *pret; 1345 int nret; 1346 1347 temp.visualid = v->visualid; 1348 pret = XGetVisualInfo(dpy, VisualIDMask, &temp, &nret); 1349 1350 if (nret!=1) crWarning("XGetVisualInfo returned %i visuals", nret); 1351 crDebug("glXGetVisualFromFBConfig(cfg/visid==0x%x): depth=%i", (int) config, pret->depth); 1352 return pret; 1353 } 1354 } 1355 */ 1356 { 1357 XVisualInfo temp, *pret; 1358 int nret; 1359 1360 temp.visualid = (VisualID)config; 1361 XLOCK(dpy); 1362 pret = XGetVisualInfo(dpy, VisualIDMask, &temp, &nret); 1363 XUNLOCK(dpy); 1364 1365 if (nret!=1) 1366 { 1367 crWarning("XGetVisualInfo returned %i visuals for %p", nret, config); 1368 /* Hack for glut based apps. 1369 We fail to patch first call to glXChooseFBConfigSGIX, which ends up in the mesa's fbconfigs being passed to this function later. 1370 */ 1371 if (!nret && config) 1372 { 1373 temp.visualid = (VisualID) ((__GLcontextModes*)config)->visualID; 1374 XLOCK(dpy); 1375 pret = XGetVisualInfo(dpy, VisualIDMask, &temp, &nret); 1376 XUNLOCK(dpy); 1377 crWarning("Retry with %#x returned %i visuals", ((__GLcontextModes*)config)->visualID, nret); 1378 } 1379 } 1380 //crDebug("glXGetVisualFromFBConfig(cfg/visid==0x%x): depth=%i", (int) config, pret->depth); 1381 //crDebug("here"); 1382 return pret; 1383 } 1384 1385 crDebug("glXGetVisualFromFBConfig unknown fbconfig %p", config); 1386 return NULL; 1332 return visualInfoFromFBConfig(dpy, config); 1387 1333 } 1388 1334 -
trunk/src/VBox/Additions/common/crOpenGL/stub.h
r65537 r65787 142 142 Display *dpy; 143 143 ContextInfo *share; 144 XVisualInfo *visual;145 144 Bool direct; 146 145 GLXContext glxContext;
Note:
See TracChangeset
for help on using the changeset viewer.