VirtualBox

Changeset 65787 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Feb 14, 2017 4:36:37 PM (8 years ago)
Author:
vboxsync
Message:

bugref:8748: Additions/Graphics/Wayland: investigate EGLStreams support feasibility:

Removed more dependencies on native X11 visuals in the GLX code, with a view to stop using a visual ID as an fbconfig ID next. I tested the Mesa GLX demos before and after, and those which worked before to some extent still worked after, namely: glxcontexts, glxdemo, glxgears, glxgears_fbconfig, glxheads (one head of course), glxinfo, glxswapcontrol, manywin (with assertion), multictx, offset, pbinfo, shape, sharedtex (without the texture), texture_from_pixmap (without any animation), wincopy (without the copy), xfont and xrotfontdemo.

I did not test FBCONFIG_SGIX, as nothing I have available will use it if OpenGL 1.3 or later is available. I suspect that the code is broken from looking at it - the Mesa code it is presumably based on should work, but the Chromium code has diverged since then in ways which look incorrect.

Location:
trunk/src/VBox/Additions/common/crOpenGL
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/crOpenGL/context.c

    r63204 r65787  
    616616#endif
    617617
     618#ifndef GLX
    618619/**
    619620 * This creates a native GLX/WGL context.
     
    688689#endif
    689690}
     691#endif /* !GLX */
    690692
    691693
     
    12121214            }
    12131215        }
     1216#ifndef GLX
    12141217        else {
    12151218            /*
     
    12181221            if (!InstantiateNativeContext(window, context))
    12191222            {
    1220 #ifdef CHROMIUM_THREADSAFE
     1223# ifdef CHROMIUM_THREADSAFE
    12211224                crUnlockMutex(&stub.mutex);
    1222 #endif
     1225# endif
    12231226                return 0; /* false */
    12241227            }
    12251228            context->type = NATIVE;
    12261229        }
     1230#endif /* !GLX */
    12271231
    12281232#ifdef CHROMIUM_THREADSAFE
  • trunk/src/VBox/Additions/common/crOpenGL/glx.c

    r65572 r65787  
    6060static GLXDrawable currentReadDrawable = 0;
    6161
    62 /**
    63  * Keep a list of structures which associates X visual IDs with
    64  * 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 
    7462static void stubXshmUpdateImageRect(Display *dpy, GLXDrawable draw, GLX_Pixmap_t *pGlxPixmap, XRectangle *pRect);
    7563static void stubQueryXDamageExtension(Display *dpy, ContextInfo *pContext);
     64
     65static bool isGLXVisual(Display *dpy, XVisualInfo *vis)
     66{
     67    return vis->visualid == XVisualIDFromVisual(DefaultVisual(dpy, vis->screen));
     68}
     69
     70static 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
     79static GLXFBConfig defaultFBConfigForScreen(Display *dpy, int screen)
     80{
     81    return (GLXFBConfig) XVisualIDFromVisual(DefaultVisual(dpy, screen));
     82}
     83
     84static 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}
    7696
    7797DECLEXPORT(XVisualInfo *)
     
    272292    int visBits = CR_RGB_BIT | CR_DOUBLE_BIT | CR_DEPTH_BIT; /* default vis */
    273293
     294    (void)vis;
    274295    stubInit();
    275296
     
    298319
    299320    context->dpy = dpy;
    300     context->visual = vis;
    301321    context->direct = direct;
    302322
     
    397417}
    398418
    399 
    400419DECLEXPORT(GLXPixmap) VBOXGLXTAG(glXCreateGLXPixmap)( Display *dpy, XVisualInfo *vis, Pixmap pixmap )
    401420{
    402421    stubInit();
    403     return VBOXGLXTAG(glXCreatePixmap)(dpy, (GLXFBConfig)vis->visualid, pixmap, NULL);
     422    return VBOXGLXTAG(glXCreatePixmap)(dpy, fbConfigFromVisual(dpy, vis), pixmap, NULL);
    404423}
    405424
     
    411430DECLEXPORT(int) VBOXGLXTAG(glXGetConfig)( Display *dpy, XVisualInfo *vis, int attrib, int *value )
    412431{
    413     (void)dpy;
    414 
    415432    if (!vis) {
    416433        /* SGI OpenGL Performer hits this */
     
    426443
    427444        case GLX_USE_GL:
    428             *value = vis->visualid == XVisualIDFromVisual(DefaultVisual(dpy, vis->screen));
     445            *value = isGLXVisual(dpy, vis);
    429446            break;
    430447
     
    786803                                           Bool direct)
    787804{
     805    (void)config;
    788806    if (render_type!=GLX_RGBA_TYPE_SGIX)
    789807    {
     
    791809        return NULL;
    792810    }
    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);
    808812}
    809813
     
    812816                                         GLXFBConfig config)
    813817{
    814     return VBOXGLXTAG(glXGetVisualFromFBConfig)(dpy, config);
     818    return visualInfoFromFBConfig(dpy, config);
    815819}
    816820
     
    823827    }
    824828    /*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));
    826830}
    827831
     
    968972VBOXGLXTAG(glXCreateNewContext)(Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct)
    969973{
    970     XVisualInfo *vis;
    971 
    972974    (void) dpy;
    973975    (void) config;
     
    982984    }
    983985
    984     vis = VBOXGLXTAG(glXGetVisualFromFBConfig)(dpy, config);
    985     return VBOXGLXTAG(glXCreateContext)(dpy, vis, share_list, direct);
     986    return VBOXGLXTAG(glXCreateContext)(dpy, NULL, share_list, direct);
    986987}
    987988
     
    11901191    const char * pExt;
    11911192
    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 
    12011193    switch (attribute)
    12021194    {
     
    12561248        case GLX_VISUAL_ID:
    12571249            //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            }
    12581256            *value = pVisual->visualid;
     1257            XFree(pVisual);
    12591258            break;
    12601259        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?*/
    12621261            break;
    12631262        case GLX_RED_SIZE:
     
    12961295        default:
    12971296            crDebug("glXGetFBConfigAttrib: unknown attribute=0x%x", attribute);
    1298             XFree(pVisual);
    12991297            return GLX_BAD_ATTRIBUTE;
    13001298    }
    13011299
    1302     XFree(pVisual);
    13031300    return Success;
    13041301}
     
    13121309    *nelements = 1;
    13131310    XLOCK(dpy);
    1314     *pGLXFBConfigs = (GLXFBConfig) XVisualIDFromVisual(DefaultVisual(dpy, screen));
     1311    *pGLXFBConfigs = defaultFBConfigForScreen(dpy, screen);
    13151312    XUNLOCK(dpy);
    13161313
     
    13331330DECLEXPORT(XVisualInfo *) VBOXGLXTAG(glXGetVisualFromFBConfig)(Display *dpy, GLXFBConfig config)
    13341331{
    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);
    13871333}
    13881334
  • trunk/src/VBox/Additions/common/crOpenGL/stub.h

    r65537 r65787  
    142142    Display *dpy;
    143143    ContextInfo *share;
    144     XVisualInfo *visual;
    145144    Bool direct;
    146145    GLXContext glxContext;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette