VirtualBox

Ignore:
Timestamp:
Jan 9, 2014 4:13:28 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
91522
Message:

crOpenGL: crOpenGL: 1. workaround point sprite driver bugs; 2. workaround multi-string shader source driver bug; 3. proper GLhandle for OSX; 4. extended dumping; 5. misc fixes

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/VBox

  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c

    r49172 r50041  
    13981398int64_t g_CrDbgDumpPid = 0;
    13991399unsigned long g_CrDbgDumpEnabled = 0;
    1400 unsigned long g_CrDbgDumpDraw = CR_SERVER_DUMP_F_COMPILE_SHADER
     1400unsigned long g_CrDbgDumpDraw = 0
     1401#if 0
     1402        | CR_SERVER_DUMP_F_COMPILE_SHADER
    14011403        | CR_SERVER_DUMP_F_LINK_PROGRAM
     1404#endif
     1405        ;
     1406#if 0
    14021407        | CR_SERVER_DUMP_F_DRAW_BUFF_ENTER
    14031408        | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE
     
    14101415        | CR_SERVER_DUMP_F_DRAWEL
    14111416        | CR_SERVER_DUMP_F_SHADER_SOURCE
    1412         ; //CR_SERVER_DUMP_F_DRAW_BUFF_ENTER | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE;
     1417        ;
     1418#endif
    14131419unsigned long g_CrDbgDumpDrawFramesSettings = CR_SERVER_DUMP_F_DRAW_BUFF_ENTER
    14141420        | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE
     
    14221428unsigned long g_CrDbgDumpDrawFramesCount = 0;
    14231429
     1430uint32_t g_CrDbgDumpDrawCount = 0;
     1431uint32_t g_CrDbgDumpDumpOnCount = 10;
     1432uint32_t g_CrDbgDumpDumpOnCountEnabled = 0;
     1433uint32_t g_CrDbgDumpDumpOnCountPerform = 0;
     1434uint32_t g_CrDbgDumpDrawFlags = CR_SERVER_DUMP_F_COMPILE_SHADER
     1435        | CR_SERVER_DUMP_F_SHADER_SOURCE
     1436        | CR_SERVER_DUMP_F_COMPILE_SHADER
     1437        | CR_SERVER_DUMP_F_LINK_PROGRAM
     1438        | CR_SERVER_DUMP_F_DRAW_BUFF_ENTER
     1439        | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE
     1440        | CR_SERVER_DUMP_F_DRAW_TEX_ENTER
     1441        | CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_ENTER
     1442        | CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_ENTER
     1443        | CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER
     1444        | CR_SERVER_DUMP_F_DRAW_STATE_ENTER
     1445        | CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER
     1446        | CR_SERVER_DUMP_F_DRAWEL
     1447        | CR_SERVER_DUMP_F_TEXPRESENT;
     1448
    14241449void crServerDumpCheckTerm()
    14251450{
     
    14371462    CRMuralInfo *pBlitterMural;
    14381463
    1439     if (CrBltIsInitialized(&cr_server.RecorderBlitter))
    1440         return VINF_SUCCESS;
    1441 
    1442     pBlitterMural = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.visualBits);
    1443     if (!pBlitterMural)
    1444     {
    1445         crWarning("crServerGetDummyMural failed");
    1446         return VERR_GENERAL_FAILURE;
    1447     }
    1448 
    1449     crServerVBoxBlitterWinInit(&BltWin, pBlitterMural);
    1450     crServerVBoxBlitterCtxInit(&BltCtx, &cr_server.MainContextInfo);
    1451 
    1452     rc = CrBltInit(&cr_server.RecorderBlitter, &BltCtx, true, true, NULL, &cr_server.TmpCtxDispatch);
    1453     if (!RT_SUCCESS(rc))
    1454     {
    1455         crWarning("CrBltInit failed rc %d", rc);
    1456         return rc;
    1457     }
    1458 
    1459     rc = CrBltMuralSetCurrent(&cr_server.RecorderBlitter, &BltWin);
    1460     if (!RT_SUCCESS(rc))
    1461     {
    1462         crWarning("CrBltMuralSetCurrent failed rc %d", rc);
    1463         return rc;
     1464    if (!CrBltIsInitialized(&cr_server.RecorderBlitter))
     1465    {
     1466        pBlitterMural = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.visualBits);
     1467        if (!pBlitterMural)
     1468        {
     1469            crWarning("crServerGetDummyMural failed");
     1470            return VERR_GENERAL_FAILURE;
     1471        }
     1472
     1473        crServerVBoxBlitterWinInit(&BltWin, pBlitterMural);
     1474        crServerVBoxBlitterCtxInit(&BltCtx, &cr_server.MainContextInfo);
     1475
     1476        rc = CrBltInit(&cr_server.RecorderBlitter, &BltCtx, true, true, NULL, &cr_server.TmpCtxDispatch);
     1477        if (!RT_SUCCESS(rc))
     1478        {
     1479            crWarning("CrBltInit failed rc %d", rc);
     1480            return rc;
     1481        }
     1482
     1483        rc = CrBltMuralSetCurrent(&cr_server.RecorderBlitter, &BltWin);
     1484        if (!RT_SUCCESS(rc))
     1485        {
     1486            crWarning("CrBltMuralSetCurrent failed rc %d", rc);
     1487            return rc;
     1488        }
    14641489    }
    14651490
     
    14681493    cr_server.pDumper = &cr_server.DbgPrintDumper.Base;
    14691494#else
    1470     crDmpHtmlInit(&cr_server.HtmlDumper, "S:\\projects\\virtualbox\\3d\\dumps\\1", "index.html");
    1471     cr_server.pDumper = &cr_server.HtmlDumper.Base;
     1495    if (!crDmpHtmlIsInited(&cr_server.HtmlDumper))
     1496    {
     1497        static int cCounter = 0;
     1498//    crDmpHtmlInit(&cr_server.HtmlDumper, "S:\\projects\\virtualbox\\3d\\dumps\\1", "index.html");
     1499        crDmpHtmlInitF(&cr_server.HtmlDumper, "/Users/oracle-mac/vbox/dump/1", "index%d.html", cCounter);
     1500        cr_server.pDumper = &cr_server.HtmlDumper.Base;
     1501        ++cCounter;
     1502    }
    14721503#endif
    14731504
     
    16301661void crServerDumpFilterOpLeave(unsigned long event, CR_DUMPER *pDumper)
    16311662{
     1663    if (CR_SERVER_DUMP_F_DRAW_LEAVE_ALL & event)
     1664    {
     1665        g_CrDbgDumpDumpOnCountPerform = 0;
     1666    }
    16321667}
    16331668
    16341669bool crServerDumpFilterOpEnter(unsigned long event, CR_DUMPER *pDumper)
    16351670{
     1671    if ((CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER & event)
     1672            || (CR_SERVER_DUMP_F_TEXPRESENT & event))
     1673    {
     1674        if (g_CrDbgDumpDumpOnCountEnabled == 1)
     1675            g_CrDbgDumpDumpOnCountEnabled = 2;
     1676        else if (g_CrDbgDumpDumpOnCountEnabled)
     1677        {
     1678            g_CrDbgDumpDumpOnCountEnabled = 0;
     1679            if (cr_server.pDumper == &cr_server.HtmlDumper.Base)
     1680            {
     1681                crDmpHtmlTerm(&cr_server.HtmlDumper);
     1682                cr_server.pDumper = NULL;
     1683            }
     1684        }
     1685
     1686        g_CrDbgDumpDrawCount = 0;
     1687    }
     1688    else if (CR_SERVER_DUMP_F_DRAW_ENTER_ALL & event)
     1689    {
     1690        if (g_CrDbgDumpDumpOnCountEnabled == 2)
     1691        {
     1692            if (g_CrDbgDumpDumpOnCount == g_CrDbgDumpDrawCount)
     1693            {
     1694                g_CrDbgDumpDumpOnCountPerform = 1;
     1695            }
     1696            ++g_CrDbgDumpDrawCount;
     1697        }
     1698    }
     1699    if (g_CrDbgDumpDumpOnCountPerform)
     1700    {
     1701        if (g_CrDbgDumpDrawFlags & event)
     1702            return true;
     1703    }
    16361704    return CR_SERVER_DUMP_DEFAULT_FILTER_OP(event);
    16371705}
     
    16391707bool crServerDumpFilterDmp(unsigned long event, CR_DUMPER *pDumper)
    16401708{
     1709    if (g_CrDbgDumpDumpOnCountPerform)
     1710    {
     1711        if (g_CrDbgDumpDrawFlags & event)
     1712            return true;
     1713    }
    16411714    return CR_SERVER_DUMP_DEFAULT_FILTER_DMP(event);
    16421715}
     
    16731746}
    16741747#endif
    1675 /* */
     1748
     1749GLvoid crServerSpriteCoordReplEnable(GLboolean fEnable)
     1750{
     1751    CRContext *g = crStateGetCurrent();
     1752    CRTextureState *t = &(g->texture);
     1753    GLuint curTextureUnit = t->curTextureUnit;
     1754    GLuint curTextureUnitRestore = curTextureUnit;
     1755    GLuint i;
     1756
     1757    for (i = 0; i < g->limits.maxTextureUnits; ++i)
     1758    {
     1759        if (g->point.coordReplacement[i])
     1760        {
     1761            if (i != curTextureUnit)
     1762            {
     1763                curTextureUnit = i;
     1764                cr_server.head_spu->dispatch_table.ActiveTextureARB( i + GL_TEXTURE0_ARB );
     1765            }
     1766
     1767            cr_server.head_spu->dispatch_table.TexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, (GLint)fEnable);
     1768        }
     1769    }
     1770
     1771    if (curTextureUnit != curTextureUnitRestore)
     1772    {
     1773        cr_server.head_spu->dispatch_table.ActiveTextureARB( curTextureUnitRestore + GL_TEXTURE0_ARB );
     1774    }
     1775}
     1776
     1777GLvoid SERVER_DISPATCH_APIENTRY crServerDispatchDrawArrays(GLenum mode, GLint first, GLsizei count)
     1778{
     1779#ifdef DEBUG
     1780    GLenum status = cr_server.head_spu->dispatch_table.CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);
     1781    Assert(GL_FRAMEBUFFER_COMPLETE == status);
     1782#endif
     1783    if (mode == GL_POINTS)
     1784        crServerSpriteCoordReplEnable(GL_TRUE);
     1785    CR_SERVER_DUMP_DRAW_ENTER();
     1786    CR_GLERR_CHECK(cr_server.head_spu->dispatch_table.DrawArrays(mode, first, count););
     1787    CR_SERVER_DUMP_DRAW_LEAVE();
     1788    if (mode == GL_POINTS)
     1789        crServerSpriteCoordReplEnable(GL_FALSE);
     1790}
     1791
     1792GLvoid SERVER_DISPATCH_APIENTRY crServerDispatchDrawElements(GLenum mode,  GLsizei count,  GLenum type,  const GLvoid * indices)
     1793{
     1794#ifdef DEBUG
     1795    GLenum status = cr_server.head_spu->dispatch_table.CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);
     1796    Assert(GL_FRAMEBUFFER_COMPLETE == status);
     1797#endif
     1798    if (mode == GL_POINTS)
     1799        crServerSpriteCoordReplEnable(GL_TRUE);
     1800    CR_SERVER_DUMP_DRAW_ENTER();
     1801    CR_GLERR_CHECK(cr_server.head_spu->dispatch_table.DrawElements(mode, count, type, indices););
     1802    CR_SERVER_DUMP_DRAW_LEAVE();
     1803    if (mode == GL_POINTS)
     1804        crServerSpriteCoordReplEnable(GL_FALSE);
     1805}
     1806
     1807void SERVER_DISPATCH_APIENTRY crServerDispatchEnd( void )
     1808{
     1809    CRContext *g = crStateGetCurrent();
     1810    GLenum mode = g->current.mode;
     1811
     1812    crStateEnd();
     1813    cr_server.head_spu->dispatch_table.End();
     1814
     1815    CR_SERVER_DUMP_DRAW_LEAVE();
     1816
     1817    if (mode == GL_POINTS)
     1818        crServerSpriteCoordReplEnable(GL_FALSE);
     1819}
     1820
     1821#ifdef DEBUG
     1822extern GLuint g_VBoxTstNumVa;
     1823#endif
     1824
     1825void SERVER_DISPATCH_APIENTRY crServerDispatchBegin(GLenum mode)
     1826{
     1827#ifdef DEBUG
     1828    CRContext *ctx = crStateGetCurrent();
     1829    SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
     1830
     1831    g_VBoxTstNumVa = 0;
     1832
     1833    if (ctx->program.vpProgramBinding)
     1834    {
     1835        AssertRelease(ctx->program.currentVertexProgram);
     1836
     1837        if (ctx->program.currentVertexProgram->isARBprogram)
     1838        {
     1839            GLint pid=-1;
     1840            gl->GetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_BINDING_ARB, &pid);
     1841
     1842            if (pid != ctx->program.currentVertexProgram->id)
     1843            {
     1844                crWarning("pid(%d) != ctx->program.currentVertexProgram->id(%d)", pid, ctx->program.currentVertexProgram->id);
     1845            }
     1846            AssertRelease(pid == ctx->program.currentVertexProgram->id);
     1847        }
     1848        else
     1849        {
     1850            GLint pid=-1;
     1851
     1852            gl->GetIntegerv(GL_VERTEX_PROGRAM_BINDING_NV, &pid);
     1853            if (pid != ctx->program.currentVertexProgram->id)
     1854            {
     1855                crWarning("pid(%d) != ctx->program.currentVertexProgram->id(%d)", pid, ctx->program.currentVertexProgram->id);
     1856            }
     1857            AssertRelease(pid == ctx->program.currentVertexProgram->id);
     1858        }
     1859    }
     1860    else if (ctx->glsl.activeProgram)
     1861    {
     1862        GLint pid=-1;
     1863
     1864        gl->GetIntegerv(GL_CURRENT_PROGRAM, &pid);
     1865        crDebug("pid %i, state: id %i, hwid %i", pid, ctx->glsl.activeProgram->id, ctx->glsl.activeProgram->hwid);
     1866        if (pid != ctx->glsl.activeProgram->hwid)
     1867        {
     1868            crWarning("pid(%d) != ctx->glsl.activeProgram->hwid(%d)", pid, ctx->glsl.activeProgram->hwid);
     1869        }
     1870        AssertRelease(pid == ctx->glsl.activeProgram->hwid);
     1871    }
     1872#endif
     1873
     1874    if (mode == GL_POINTS)
     1875        crServerSpriteCoordReplEnable(GL_TRUE);
     1876
     1877    CR_SERVER_DUMP_DRAW_ENTER();
     1878
     1879    crStateBegin(mode);
     1880    cr_server.head_spu->dispatch_table.Begin(mode);
     1881}
     1882
Note: See TracChangeset for help on using the changeset viewer.

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