Changeset 69310 in vbox for trunk/src/VBox/Additions/common/crOpenGL/glx.c
- Timestamp:
- Oct 25, 2017 2:24:45 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/crOpenGL/glx.c
-
Property svn:keywords
set to
Id Revision
r69040 r69310 1 /* $Id: dri_drv.c 100879 2015-06-09 14:26:20Z bird $ */ 2 1 /* $Id$ */ 3 2 /** @file 4 3 * VBox OpenGL GLX implementation … … 40 39 #define CR_MAX_DAMAGE_REGIONS_TRACKED 50 41 40 42 /* Force "bigger" update (full or clip) if it's reducing number of regions updated 41 /* Force "bigger" update (full or clip) if it's reducing number of regions updated 43 42 * but doesn't increase updated area more than given number 44 43 */ 45 44 #define CR_MIN_DAMAGE_PROFIT_SIZE 64*64 46 45 47 /* @todo combine it in some other place*/46 /** @todo combine it in some other place*/ 48 47 /* Size of pack spu buffer - some delta for commands packing, see pack/packspu_config.c*/ 49 48 … … 218 217 pret = XGetVisualInfo(dpy, VisualIDMask, &searchvis, &nvisuals); 219 218 XUNLOCK(dpy); 220 219 221 220 if (nvisuals!=1) crWarning("glXChooseVisual: XGetVisualInfo returned %i visuals for %x", nvisuals, (unsigned int) searchvis.visualid); 222 221 if (pret) … … 232 231 ** There is a problem with glXCopyContext. 233 232 ** IRIX and Mesa both define glXCopyContext 234 ** to have the mask argument being a 233 ** to have the mask argument being a 235 234 ** GLuint. XFree 4 and oss.sgi.com 236 235 ** define it to be an unsigned long. … … 240 239 */ 241 240 DECLEXPORT(void) 242 VBOXGLXTAG(glXCopyContext)( Display *dpy, GLXContext src, GLXContext dst, 241 VBOXGLXTAG(glXCopyContext)( Display *dpy, GLXContext src, GLXContext dst, 243 242 #if defined(AIX) || defined(PLAYSTATION2) 244 243 GLuint mask … … 377 376 if (pGlxPixmap) 378 377 { 379 /* @todo*/378 /** @todo */ 380 379 crWarning("Unimplemented glxMakeCurrent call with GLXPixmap passed, unexpected things might happen."); 381 380 } … … 523 522 #if defined(SunOS) || 1 524 523 /* 525 I don't think this is even a valid attribute for glxGetConfig. 524 I don't think this is even a valid attribute for glxGetConfig. 526 525 No idea why this gets called under SunOS but we simply ignore it 527 526 -- jw … … 530 529 crWarning ("Ignoring Unsupported GLX Call: glxGetConfig with attrib 0x%x", attrib); 531 530 break; 532 #endif 531 #endif 533 532 534 533 case GLX_TRANSPARENT_TYPE: … … 679 678 680 679 case GLX_EXTENSIONS: 681 /* @todo should be a screen not a name...but it's not used anyway*/680 /** @todo should be a screen not a name...but it's not used anyway*/ 682 681 retval = glXQueryExtensionsString(dpy, name); 683 682 break; … … 730 729 #if GLX_EXTRAS 731 730 732 DECLEXPORT(GLXPbufferSGIX) 731 DECLEXPORT(GLXPbufferSGIX) 733 732 VBOXGLXTAG(glXCreateGLXPbufferSGIX)(Display *dpy, GLXFBConfigSGIX config, 734 733 unsigned int width, unsigned int height, … … 782 781 } 783 782 784 DECLEXPORT(GLXFBConfigSGIX *) 783 DECLEXPORT(GLXFBConfigSGIX *) 785 784 VBOXGLXTAG(glXChooseFBConfigSGIX)(Display *dpy, int screen, 786 785 int *attrib_list, int *nelements) … … 789 788 } 790 789 791 DECLEXPORT(GLXPixmap) 790 DECLEXPORT(GLXPixmap) 792 791 VBOXGLXTAG(glXCreateGLXPixmapWithConfigSGIX)(Display *dpy, 793 792 GLXFBConfig config, … … 797 796 } 798 797 799 DECLEXPORT(GLXContext) 798 DECLEXPORT(GLXContext) 800 799 VBOXGLXTAG(glXCreateContextWithConfigSGIX)(Display *dpy, GLXFBConfig config, 801 800 int render_type, … … 812 811 } 813 812 814 DECLEXPORT(XVisualInfo *) 813 DECLEXPORT(XVisualInfo *) 815 814 VBOXGLXTAG(glXGetVisualFromFBConfigSGIX)(Display *dpy, 816 815 GLXFBConfig config) … … 969 968 } 970 969 971 DECLEXPORT(GLXContext) 970 DECLEXPORT(GLXContext) 972 971 VBOXGLXTAG(glXCreateNewContext)(Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct) 973 972 { … … 987 986 } 988 987 989 DECLEXPORT(GLXPbuffer) 988 DECLEXPORT(GLXPbuffer) 990 989 VBOXGLXTAG(glXCreatePbuffer)(Display *dpy, GLXFBConfig config, ATTRIB_TYPE *attrib_list) 991 990 { … … 1000 999 * Instead we'd do necessary initialization on first use of those pixmaps. 1001 1000 */ 1002 DECLEXPORT(GLXPixmap) 1001 DECLEXPORT(GLXPixmap) 1003 1002 VBOXGLXTAG(glXCreatePixmap)(Display *dpy, GLXFBConfig config, Pixmap pixmap, ATTRIB_TYPE *attrib_list) 1004 1003 { … … 1085 1084 } 1086 1085 1087 DECLEXPORT(GLXWindow) 1086 DECLEXPORT(GLXWindow) 1088 1087 VBOXGLXTAG(glXCreateWindow)(Display *dpy, GLXFBConfig config, Window win, ATTRIB_TYPE *attrib_list) 1089 1088 { … … 1294 1293 break; 1295 1294 default: 1296 crDebug("glXGetFBConfigAttrib: unknown attribute=0x%x", attribute); 1295 crDebug("glXGetFBConfigAttrib: unknown attribute=0x%x", attribute); 1297 1296 return GLX_BAD_ATTRIBUTE; 1298 1297 } … … 1440 1439 crInfo("Using XSHM for GLX_EXT_texture_from_pixmap"); 1441 1440 1442 /*Anyway mark to be deleted when our process detaches it, in case of segfault etc*/ 1441 /*Anyway mark to be deleted when our process detaches it, in case of segfault etc*/ 1443 1442 1444 1443 /* Ramshankar: Solaris compiz fix */ … … 1453 1452 1454 1453 CRASSERT(pContext); 1455 1454 1456 1455 if (pContext->damageQueryFailed) 1457 1456 return; … … 1479 1478 int nReturnRects; 1480 1479 1481 /* Get the damage region as a server region */ 1480 /* Get the damage region as a server region */ 1482 1481 XserverRegion serverDamageRegion = XFixesCreateRegion (dpy, NULL, 0); 1483 1482 … … 1610 1609 pGlxPixmap->gc = XCreateGC(dpy, (Pixmap)draw, GCGraphicsExposures|GCSubwindowMode, &xgcv); 1611 1610 1612 pGlxPixmap->hShmPixmap = XShmCreatePixmap(dpy, pGlxPixmap->root, stub.xshmSI.shmaddr, &stub.xshmSI, 1611 pGlxPixmap->hShmPixmap = XShmCreatePixmap(dpy, pGlxPixmap->root, stub.xshmSI.shmaddr, &stub.xshmSI, 1613 1612 pGlxPixmap->w, pGlxPixmap->h, pGlxPixmap->depth); 1614 1613 } … … 1641 1640 } 1642 1641 1643 /* glTexSubImage2D generates GL_INVALID_OP if texture array hasn't been defined by a call to glTexImage2D first. 1642 /* glTexSubImage2D generates GL_INVALID_OP if texture array hasn't been defined by a call to glTexImage2D first. 1644 1643 * It's fine for small textures which would be updated in stubXshmUpdateWholeImage, but we'd never call glTexImage2D for big ones. 1645 1644 * Note that we're making empty texture by passing NULL as pixels pointer, so there's no overhead transferring data to host.*/ 1646 1645 if (CR_MAX_TRANSFER_SIZE < 4*pGlxPixmap->w*pGlxPixmap->h) 1647 1646 { 1648 stub.spu->dispatch_table.TexImage2D(pGlxPixmap->target, 0, pGlxPixmap->format, pGlxPixmap->w, pGlxPixmap->h, 0, 1647 stub.spu->dispatch_table.TexImage2D(pGlxPixmap->target, 0, pGlxPixmap->format, pGlxPixmap->w, pGlxPixmap->h, 0, 1649 1648 GL_BGRA, GL_UNSIGNED_BYTE, NULL); 1650 1649 } … … 1660 1659 /* To limit the size of transferring buffer, split bigger texture into regions 1661 1660 * which fit into connection buffer. Could be done in hgcm or packspu but implementation in this place allows to avoid 1662 * unnecessary memcpy. 1661 * unnecessary memcpy. 1663 1662 * This also workarounds guest driver failures when sending 6+mb texture buffers on linux. 1664 1663 */ … … 1691 1690 1692 1691 XLOCK(dpy); 1693 XCopyArea(dpy, (Pixmap)draw, pGlxPixmap->hShmPixmap, pGlxPixmap->gc, 1692 XCopyArea(dpy, (Pixmap)draw, pGlxPixmap->hShmPixmap, pGlxPixmap->gc, 1694 1693 pGlxPixmap->x, pGlxPixmap->y, pGlxPixmap->w, pGlxPixmap->h, 0, 0); 1695 1694 /* Have to make sure XCopyArea is processed */ 1696 1695 XSync(dpy, False); 1697 1696 XUNLOCK(dpy); 1698 1697 1699 1698 stubGetUnpackState(&unpackState); 1700 1699 stubSetUnpackState(&defaultPacking); 1701 stub.spu->dispatch_table.TexImage2D(pGlxPixmap->target, 0, pGlxPixmap->format, pGlxPixmap->w, pGlxPixmap->h, 0, 1700 stub.spu->dispatch_table.TexImage2D(pGlxPixmap->target, 0, pGlxPixmap->format, pGlxPixmap->w, pGlxPixmap->h, 0, 1702 1701 GL_BGRA, GL_UNSIGNED_BYTE, stub.xshmSI.shmaddr); 1703 1702 stubSetUnpackState(&unpackState); 1704 /*crDebug("Sync texture for drawable 0x%x(dmg handle 0x%x) [%i,%i,%i,%i]", 1705 (unsigned int) draw, (unsigned int)pGlxPixmap->hDamage, 1703 /*crDebug("Sync texture for drawable 0x%x(dmg handle 0x%x) [%i,%i,%i,%i]", 1704 (unsigned int) draw, (unsigned int)pGlxPixmap->hDamage, 1706 1705 pGlxPixmap->x, pGlxPixmap->y, pGlxPixmap->w, pGlxPixmap->h);*/ 1707 1706 } … … 1739 1738 1740 1739 XLOCK(dpy); 1741 XCopyArea(dpy, (Pixmap)draw, pGlxPixmap->hShmPixmap, pGlxPixmap->gc, 1740 XCopyArea(dpy, (Pixmap)draw, pGlxPixmap->hShmPixmap, pGlxPixmap->gc, 1742 1741 pRect->x, pRect->y, pRect->width, pRect->height, 0, 0); 1743 1742 /* Have to make sure XCopyArea is processed */ … … 1751 1750 stub.spu->dispatch_table.PixelStorei(GL_UNPACK_ROW_LENGTH, pGlxPixmap->w); 1752 1751 } 1753 stub.spu->dispatch_table.TexSubImage2D(pGlxPixmap->target, 0, pRect->x, pRect->y, pRect->width, pRect->height, 1752 stub.spu->dispatch_table.TexSubImage2D(pGlxPixmap->target, 0, pRect->x, pRect->y, pRect->width, pRect->height, 1754 1753 GL_BGRA, GL_UNSIGNED_BYTE, stub.xshmSI.shmaddr); 1755 1754 stubSetUnpackState(&unpackState); 1756 1755 1757 /*crDebug("Region sync texture for drawable 0x%x(dmg handle 0x%x) [%i,%i,%i,%i]", 1758 (unsigned int) draw, (unsigned int)pGlxPixmap->hDamage, 1756 /*crDebug("Region sync texture for drawable 0x%x(dmg handle 0x%x) [%i,%i,%i,%i]", 1757 (unsigned int) draw, (unsigned int)pGlxPixmap->hDamage, 1759 1758 pRect->x, pRect->y, pRect->width, pRect->height);*/ 1760 1759 } … … 1769 1768 ContextInfo *context = stubGetCurrentContext(); 1770 1769 XDamageNotifyEvent *e = (XDamageNotifyEvent *) event; 1771 /* we're interested in pixmaps only...and those have e->drawable set to 0 or other strange value for some odd reason 1770 /* we're interested in pixmaps only...and those have e->drawable set to 0 or other strange value for some odd reason 1772 1771 * so have to walk glxpixmaps hashtable to find if we have damage event handle assigned to some pixmap 1773 1772 */ … … 1782 1781 #endif 1783 1782 1784 /* @todo check what error codes could we throw for failures here*/1783 /** @todo check what error codes could we throw for failures here*/ 1785 1784 DECLEXPORT(void) VBOXGLXTAG(glXBindTexImageEXT)(Display *dpy, GLXDrawable draw, int buffer, const int *attrib_list) 1786 1785 { … … 1826 1825 if (stub.xshmSI.shmid<0) 1827 1826 { 1828 /* @todo add damage support here too*/1827 /** @todo add damage support here too*/ 1829 1828 XImage *pxim; 1830 1829 CRPixelPackState unpackState; … … 1860 1859 stubGetUnpackState(&unpackState); 1861 1860 stubSetUnpackState(&defaultPacking); 1862 stub.spu->dispatch_table.TexImage2D(pGlxPixmap->target, 0, pGlxPixmap->format, pxim->width, pxim->height, 0, 1861 stub.spu->dispatch_table.TexImage2D(pGlxPixmap->target, 0, pGlxPixmap->format, pxim->width, pxim->height, 0, 1863 1862 GL_BGRA, GL_UNSIGNED_BYTE, (void*)(&(pxim->data[0]))); 1864 1863 stubSetUnpackState(&unpackState); … … 1900 1899 { 1901 1900 crWarning("glXBindTexImageEXT, damage regions seems to be broken, forcing full update"); 1902 /*crDebug("**FULL** update for 0x%x, numRect=%li, *FS*=%li, CS=%li, DS=%li", 1901 /*crDebug("**FULL** update for 0x%x, numRect=%li, *FS*=%li, CS=%li, DS=%li", 1903 1902 (unsigned int)draw, pGlxPixmap->pDamageRegion->numRects, fullArea, clipdamageArea, damageArea);*/ 1904 1903 stubXshmUpdateWholeImage(dpy, draw, pGlxPixmap); … … 1908 1907 if (CR_MIN_DAMAGE_PROFIT_SIZE > (fullArea-damageArea)) 1909 1908 { 1910 /*crDebug("**FULL** update for 0x%x, numRect=%li, *FS*=%li, CS=%li, DS=%li", 1909 /*crDebug("**FULL** update for 0x%x, numRect=%li, *FS*=%li, CS=%li, DS=%li", 1911 1910 (unsigned int)draw, pGlxPixmap->pDamageRegion->numRects, fullArea, clipdamageArea, damageArea);*/ 1912 1911 stubXshmUpdateWholeImage(dpy, draw, pGlxPixmap); … … 1914 1913 else if (CR_MIN_DAMAGE_PROFIT_SIZE > (clipdamageArea-damageArea)) 1915 1914 { 1916 /*crDebug("**PARTIAL** update for 0x%x, numRect=%li, FS=%li, *CS*=%li, DS=%li", 1915 /*crDebug("**PARTIAL** update for 0x%x, numRect=%li, FS=%li, *CS*=%li, DS=%li", 1917 1916 (unsigned int)draw, pGlxPixmap->pDamageRegion->numRects, fullArea, clipdamageArea, damageArea);*/ 1918 1917 stubXshmUpdateImageRect(dpy, draw, pGlxPixmap, &damageClipBox); … … 1920 1919 else 1921 1920 { 1922 /*crDebug("**PARTIAL** update for 0x%x, numRect=*%li*, FS=%li, CS=%li, *DS*=%li", 1921 /*crDebug("**PARTIAL** update for 0x%x, numRect=*%li*, FS=%li, CS=%li, *DS*=%li", 1923 1922 (unsigned int)draw, pGlxPixmap->pDamageRegion->numRects, fullArea, clipdamageArea, damageArea);*/ 1924 1923 for (i=0; i<pGlxPixmap->pDamageRegion->numRects; ++i) … … 1926 1925 XRectangle rect; 1927 1926 BoxPtr pBox = &pGlxPixmap->pDamageRegion->rects[i]; 1928 1927 1929 1928 rect.x = pBox->x1; 1930 1929 rect.y = pBox->y1; -
Property svn:keywords
set to
Note:
See TracChangeset
for help on using the changeset viewer.