VirtualBox

Changeset 43932 in vbox for trunk/src/VBox/HostServices


Ignore:
Timestamp:
Nov 21, 2012 7:28:05 PM (12 years ago)
Author:
vboxsync
Message:

crOpenGL: host offscreen rendering to fix gnome-shell issues, repaint problems and more

Location:
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h

    r43888 r43932  
    117117void crServerMuralSize(CRMuralInfo *mural, GLint width, GLint height);
    118118
    119 void crServerCreateInfoDeleteCB(void *data);
    120 
    121119GLint crServerGenerateID(GLint *pCounter);
    122120
     
    128126void crServerCheckMuralGeometry(CRMuralInfo *mural);
    129127GLboolean crServerSupportRedirMuralFBO(void);
    130 void crServerRedirMuralFBO(CRMuralInfo *mural, GLboolean redir);
     128
     129#define CR_SERVER_REDIR_NONE     0
     130#define CR_SERVER_REDIR_FBO_BLT  1
     131#define CR_SERVER_REDIR_FBO_RAM  2
     132#define CR_SERVER_REDIR_MAXVAL   CR_SERVER_REDIR_FBO_RAM
     133
     134int32_t crServerSetOffscreenRenderingMode(GLubyte value);
     135void crServerRedirMuralFBO(CRMuralInfo *mural, GLubyte redir);
    131136void crServerCreateMuralFBO(CRMuralInfo *mural);
    132137void crServerDeleteMuralFBO(CRMuralInfo *mural);
    133138void crServerPresentFBO(CRMuralInfo *mural);
    134139GLboolean crServerIsRedirectedToFBO();
     140PCR_BLITTER crServerGetFBOPresentBlitter(CRMuralInfo*pMural);
    135141
    136142int32_t crVBoxServerInternalClientRead(CRClient *pClient, uint8_t *pBuffer, uint32_t *pcbBuffer);
     143
     144PCR_DISPLAY crServerDisplayGetInitialized(uint32_t idScreen);
    137145
    138146RT_C_DECLS_END
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_blitter.cpp

    r43890 r43932  
    3131
    3232
    33 int CrBltInit(PCR_BLITTER pBlitter, CRMuralInfo *pCurrentMural, GLint visualBits)
     33int CrBltInit(PCR_BLITTER pBlitter, CRMuralInfo *pCurrentMural)
    3434{
    3535    memset(pBlitter, 0, sizeof (*pBlitter));
     
    4343
    4444    pBlitter->CtxInfo.CreateInfo.pszDpyName = "";
    45     pBlitter->CtxInfo.CreateInfo.visualBits = visualBits;
     45    pBlitter->CtxInfo.CreateInfo.visualBits = pCurrentMural->CreateInfo.visualBits;
    4646    pBlitter->CtxInfo.SpuContext = cr_server.head_spu->dispatch_table.CreateContext(pBlitter->CtxInfo.CreateInfo.pszDpyName,
    4747                                        pBlitter->CtxInfo.CreateInfo.visualBits,
     
    379379
    380380    if (pBlitter->pRestoreCtxInfo != &pBlitter->CtxInfo)
    381         cr_server.head_spu->dispatch_table.MakeCurrent(pBlitter->pRestoreMural->spuWindow, 0, pBlitter->pRestoreCtxInfo->SpuContext);
     381        cr_server.head_spu->dispatch_table.MakeCurrent(pBlitter->pRestoreMural->spuWindow, 0,
     382                pBlitter->pRestoreCtxInfo->SpuContext >= 0
     383                    ? pBlitter->pRestoreCtxInfo->SpuContext : cr_server.MainContextInfo.SpuContext);
    382384    else
    383385        cr_server.head_spu->dispatch_table.MakeCurrent(0, 0, 0);
     
    410412    int rc = crBltInitOnMakeCurent(pBlitter);
    411413    if (RT_SUCCESS(rc))
     414    {
     415        pBlitter->Flags.Initialized = 1;
    412416        return VINF_SUCCESS;
     417    }
    413418
    414419    crWarning("crBltInitOnMakeCurent failed, rc %d", rc);
     
    447452}
    448453
     454void CrBltPresent(PCR_BLITTER pBlitter)
     455{
     456    if (pBlitter->CtxInfo.CreateInfo.visualBits & CR_DOUBLE_BIT)
     457        cr_server.head_spu->dispatch_table.SwapBuffers(pBlitter->pCurrentMural->spuWindow, 0);
     458    else
     459        cr_server.head_spu->dispatch_table.Flush();
     460}
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.c

    r40691 r43932  
    5656
    5757    cr_server.screenCount = 0;
    58     cr_server.bForceOffscreenRendering = GL_FALSE;
     58    cr_server.bForceOffscreenRendering = CR_SERVER_REDIR_NONE;
     59    cr_server.bOffscreenRenderingDefault = cr_server.bForceOffscreenRendering;
    5960    cr_server.bUsePBOForReadback = GL_FALSE;
    6061    cr_server.bUseOutputRedirect = GL_FALSE;
     
    8081    char **clientchain, **clientlist;
    8182    GLint dims[4];
     83    char * env;
    8284
    8385    defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
     
    156158        crSPULoadChain(num_spus, spu_ids, spu_names, spu_dir, &cr_server);
    157159
     160    env = crGetenv( "CR_SERVER_DEFAULT_RENDER_TYPE" );
     161    if (env != NULL)
     162    {
     163        GLubyte redir = (env[0] - 0x30);
     164        if (redir <= CR_SERVER_REDIR_MAXVAL)
     165        {
     166            int rc = crServerSetOffscreenRenderingMode(redir);
     167            if (!RT_SUCCESS(rc))
     168                            crWarning("offscreen rendering unsupported, no offscreen rendering will be used..");
     169        }
     170        else
     171            crWarning("invalid redir option %c", redir);
     172    }
     173    cr_server.bOffscreenRenderingDefault = cr_server.bForceOffscreenRendering;
     174
    158175    /* Need to do this as early as possible */
    159176
     
    259276    int i;
    260277    GLint dims[4];
     278    char * env;
    261279
    262280    defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
     
    272290    if (!cr_server.head_spu)
    273291        return;
     292
     293    env = crGetenv( "CR_SERVER_DEFAULT_RENDER_TYPE" );
     294    if (env != NULL)
     295    {
     296        GLubyte redir = (env[0] - 0x30);
     297        if (redir <= CR_SERVER_REDIR_MAXVAL)
     298        {
     299            int rc = crServerSetOffscreenRenderingMode(redir);
     300            if (!RT_SUCCESS(rc))
     301                            crWarning("offscreen rendering unsupported, no offscreen rendering will be used..");
     302        }
     303        else
     304            crWarning("invalid redir option %c", redir);
     305    }
     306    cr_server.bOffscreenRenderingDefault = cr_server.bForceOffscreenRendering;
    274307
    275308    cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_POSITION_CR, 0, GL_INT, 2, &dims[0]);
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.c

    r43888 r43932  
    332332     * crStateSwichPrepare restores the FBO state to its default values before the context window switch,
    333333     * while crStateSwichPostprocess restores it back to the original values */
    334     oldCtx = crStateSwichPrepare(ctx, cr_server.bUseMultipleContexts, oldMural && oldMural->bUseFBO && crServerSupportRedirMuralFBO() ? oldMural->idFBO : 0);
     334    oldCtx = crStateSwichPrepare(ctx, cr_server.bUseMultipleContexts, oldMural && oldMural->fUseFBO && crServerSupportRedirMuralFBO() ? oldMural->idFBO : 0);
    335335
    336336    /*
     
    395395    crStateMakeCurrent( ctx );
    396396
    397     crStateSwichPostprocess(oldCtx, cr_server.bUseMultipleContexts, mural->bUseFBO && crServerSupportRedirMuralFBO() ? mural->idFBO : 0);
     397    crStateSwichPostprocess(oldCtx, cr_server.bUseMultipleContexts, mural->fUseFBO && crServerSupportRedirMuralFBO() ? mural->idFBO : 0);
    398398
    399399    if (!ctx->framebufferobject.drawFB
     
    401401        cr_server.curClient->currentMural->bFbDraw = GL_TRUE;
    402402
    403     if (!mural->bUseFBO)
     403    if (!mural->fUseFBO)
    404404    {
    405405        ctx->buffer.width = mural->width;
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r43182 r43932  
    150150    crFreeHashtable(cr_server.contextTable, deleteContextInfoCallback);
    151151
    152     /* Free context/window creation info */
    153     crFreeHashtable(cr_server.pWindowCreateInfoTable, crServerCreateInfoDeleteCB);
    154 
    155152    /* Free vertex programs */
    156153    crFreeHashtable(cr_server.programTable, crFree);
     
    386383     */
    387384    cr_server.contextTable = crAllocHashtable();
    388 //    cr_server.pContextCreateInfoTable = crAllocHashtable();
    389     cr_server.pWindowCreateInfoTable = crAllocHashtable();
    390385
    391386    crServerSetVBoxConfigurationHGCM();
     
    691686    CRASSERT(rc == VINF_SUCCESS);
    692687
    693     rc = SSMR3PutMem(pSSM, pMI, sizeof(*pMI));
     688    rc = SSMR3PutMem(pSSM, pMI, RT_OFFSETOF(CRMuralInfo, CreateInfo));
    694689    CRASSERT(rc == VINF_SUCCESS);
    695690
     
    708703
    709704    CRASSERT(pCreateInfo && pSSM);
     705
     706    /* Don't store default mural create info */
     707    if (!key) return;
    710708
    711709    rc = SSMR3PutMem(pSSM, &key, sizeof(key));
     
    844842
    845843    /* Save windows creation info */
    846     ui32 = crHashtableNumElements(cr_server.pWindowCreateInfoTable);
    847     rc = SSMR3PutU32(pSSM, (uint32_t) ui32);
     844    ui32 = crHashtableNumElements(cr_server.muralTable);
     845    /* There should be default mural always */
     846    CRASSERT(ui32>=1);
     847    rc = SSMR3PutU32(pSSM, (uint32_t) ui32-1);
    848848    AssertRCReturn(rc, rc);
    849     crHashtableWalk(cr_server.pWindowCreateInfoTable, crVBoxServerSaveCreateInfoCB, pSSM);
     849    crHashtableWalk(cr_server.muralTable, crVBoxServerSaveCreateInfoCB, pSSM);
    850850
    851851    /* Save cr_server.muralTable
    852852     * @todo we don't need it all, just geometry info actually
    853853     */
    854     ui32 = crHashtableNumElements(cr_server.muralTable);
    855     /* There should be default mural always */
    856     CRASSERT(ui32>=1);
    857854    rc = SSMR3PutU32(pSSM, (uint32_t) ui32-1);
    858855    AssertRCReturn(rc, rc);
     
    10281025        rc = SSMR3GetMem(pSSM, &key, sizeof(key));
    10291026        AssertRCReturn(rc, rc);
    1030         rc = SSMR3GetMem(pSSM, &muralInfo, sizeof(muralInfo));
     1027        rc = SSMR3GetMem(pSSM, &muralInfo, RT_OFFSETOF(CRMuralInfo, CreateInfo));
    10311028        AssertRCReturn(rc, rc);
    10321029
     
    13321329#endif
    13331330
     1331    {
     1332        PCR_DISPLAY pDisplay = crServerDisplayGetInitialized(sIndex);
     1333        if (pDisplay)
     1334            CrDpResize(pDisplay, w, h, w, h);
     1335    }
     1336
    13341337    return VINF_SUCCESS;
    13351338}
     
    13471350}
    13481351
     1352int32_t crServerSetOffscreenRenderingMode(GLubyte value)
     1353{
     1354    if (cr_server.bForceOffscreenRendering==value)
     1355    {
     1356        return VINF_SUCCESS;
     1357    }
     1358
     1359    if (value > CR_SERVER_REDIR_MAXVAL)
     1360    {
     1361        crWarning("crServerSetOffscreenRenderingMode: invalid arg: %d", value);
     1362        return VERR_INVALID_PARAMETER;
     1363    }
     1364
     1365    if (value && !crServerSupportRedirMuralFBO())
     1366    {
     1367        return VERR_NOT_SUPPORTED;
     1368    }
     1369
     1370    cr_server.bForceOffscreenRendering=value;
     1371
     1372    crHashtableWalk(cr_server.muralTable, crVBoxServerCheckMuralCB, NULL);
     1373
     1374    return VINF_SUCCESS;
     1375}
     1376
    13491377DECLEXPORT(int32_t) crVBoxServerSetOffscreenRendering(GLboolean value)
    13501378{
    1351     if (cr_server.bForceOffscreenRendering==value)
    1352     {
    1353         return VINF_SUCCESS;
    1354     }
    1355 
    1356     if (value && !crServerSupportRedirMuralFBO())
    1357     {
    1358         return VERR_NOT_SUPPORTED;
    1359     }
    1360 
    1361     cr_server.bForceOffscreenRendering=value;
    1362 
    1363     crHashtableWalk(cr_server.muralTable, crVBoxServerCheckMuralCB, NULL);
    1364 
    1365     return VINF_SUCCESS;
     1379    return crServerSetOffscreenRenderingMode(value ? CR_SERVER_REDIR_FBO_RAM : cr_server.bOffscreenRenderingDefault);
    13661380}
    13671381
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c

    r43287 r43932  
    264264}
    265265
    266 void crServerCreateInfoDeleteCB(void *data)
    267 {
    268     CRCreateInfo_t *pCreateInfo = (CRCreateInfo_t *) data;
    269     if (pCreateInfo->pszDpyName)
    270         crFree(pCreateInfo->pszDpyName);
    271     crFree(pCreateInfo);
    272 }
    273 
    274266GLint crServerGenerateID(GLint *pCounter)
    275267{
     
    875867            cr_server.curClient->currentMural->bFbDraw = GL_TRUE;
    876868
    877         if (cr_server.curClient->currentMural->bUseFBO && crServerIsRedirectedToFBO()
     869        if (crServerIsRedirectedToFBO()
    878870                && cr_server.curClient->currentMural->idFBO)
    879871        {
     
    903895    crStateReadBuffer( mode );
    904896
    905     if (cr_server.curClient->currentMural->bUseFBO && crServerIsRedirectedToFBO()
     897    if (crServerIsRedirectedToFBO()
    906898            && cr_server.curClient->currentMural->idFBO
    907899            && !crStateGetCurrent()->framebufferobject.readFB)
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_muralfbo.c

    r43182 r43932  
    108108        CRScreenViewportInfo *pVieport = &cr_server.screenVieport[mural->screenId];
    109109        CRASSERT(cr_server.screenCount>0);
     110        CRASSERT(mural->fUseFBO == CR_SERVER_REDIR_NONE);
    110111
    111112        mural->hX = mural->gX-cr_server.screen[0].x;
     
    163164        CRScreenViewportInfo *pVieport = &cr_server.screenVieport[mural->screenId];
    164165
    165         if (mural->bUseFBO)
    166         {
    167             crServerRedirMuralFBO(mural, GL_FALSE);
     166        if (mural->fUseFBO)
     167        {
     168            crServerRedirMuralFBO(mural, CR_SERVER_REDIR_NONE);
    168169            crServerDeleteMuralFBO(mural);
    169170        }
     
    173174    else
    174175    {
     176        GLubyte redir = overlappingScreenCount >= 2 ? CR_SERVER_REDIR_FBO_RAM : cr_server.bForceOffscreenRendering;
     177
    175178        if (mural->spuWindow)
    176179        {
    177             if (!mural->bUseFBO)
    178             {
    179                 crServerRedirMuralFBO(mural, GL_TRUE);
    180             }
    181             else
     180            if (mural->fUseFBO)
    182181            {
    183182                if (mural->width!=mural->fboWidth
    184183                    || mural->height!=mural->height)
    185184                {
    186                     crServerRedirMuralFBO(mural, GL_FALSE);
     185                    crServerRedirMuralFBO(mural, CR_SERVER_REDIR_NONE);
    187186                    crServerDeleteMuralFBO(mural);
    188                     crServerRedirMuralFBO(mural, GL_TRUE);
    189187                }
     188            }
     189
     190            if (mural->fUseFBO != redir)
     191            {
     192                crServerRedirMuralFBO(mural, redir);
    190193            }
    191194        }
     
    193196        else
    194197        {
    195             Assert(!mural->bUseFBO);
     198            Assert(!mural->fUseFBO);
    196199        }
    197200#endif
    198201
    199         if (!mural->bUseFBO)
     202        if (mural->fUseFBO != CR_SERVER_REDIR_FBO_RAM)
    200203        {
    201204            CRScreenViewportInfo *pVieport = &cr_server.screenVieport[mural->screenId];
     
    229232}
    230233
    231 void crServerRedirMuralFBO(CRMuralInfo *mural, GLboolean redir)
    232 {
     234void crServerRedirMuralFBO(CRMuralInfo *mural, GLubyte redir)
     235{
     236    if (mural->fUseFBO == redir)
     237    {
     238        crWarning("crServerRedirMuralFBO called with the same redir status %d", redir);
     239        return;
     240    }
     241
    233242    if (redir)
    234243    {
     
    239248        }
    240249
    241         cr_server.head_spu->dispatch_table.WindowShow(mural->spuWindow, GL_FALSE);
     250        if (redir == CR_SERVER_REDIR_FBO_RAM)
     251            cr_server.head_spu->dispatch_table.WindowShow(mural->spuWindow, GL_FALSE);
     252        else
     253            cr_server.head_spu->dispatch_table.WindowShow(mural->spuWindow, mural->bVisible);
    242254
    243255        if (mural->idFBO==0)
     
    263275    else
    264276    {
    265         cr_server.head_spu->dispatch_table.WindowShow(mural->spuWindow, mural->bVisible);
    266 
    267         if (mural->bUseFBO && crServerSupportRedirMuralFBO())
     277        if (mural->fUseFBO == CR_SERVER_REDIR_FBO_RAM)
     278            cr_server.head_spu->dispatch_table.WindowShow(mural->spuWindow, mural->bVisible);
     279
     280        if (mural->fUseFBO && crServerSupportRedirMuralFBO())
    268281        {
    269282            if (!crStateGetCurrent()->framebufferobject.drawFB)
     
    284297    }
    285298
    286     mural->bUseFBO = redir;
     299    mural->fUseFBO = redir;
    287300}
    288301
     
    371384void crServerDeleteMuralFBO(CRMuralInfo *mural)
    372385{
    373     CRASSERT(!mural->bUseFBO);
     386    CRASSERT(!mural->fUseFBO);
    374387
    375388    if (mural->idFBO!=0)
     
    452465    CRContext *ctx = crStateGetCurrent();
    453466
    454     CRASSERT(cr_server.pfnPresentFBO);
     467    CRASSERT(mural->fUseFBO);
     468    CRASSERT(cr_server.pfnPresentFBO || mural->fUseFBO == CR_SERVER_REDIR_FBO_BLT);
    455469
    456470    if (!mural->bVisible)
     
    461475    if (!mural->width || !mural->height)
    462476    {
     477        return;
     478    }
     479
     480    if (mural->fUseFBO == CR_SERVER_REDIR_FBO_BLT)
     481    {
     482        int rc;
     483        PCR_BLITTER pBlitter = crServerGetFBOPresentBlitter(mural);
     484        if (!pBlitter)
     485        {
     486            static int cPrintedWarnings = 0;
     487            if (++cPrintedWarnings <= 5)
     488            {
     489                crWarning("crServerGetFBOPresentBlitter returned no blitter %d", cPrintedWarnings);
     490                if (cPrintedWarnings == 5)
     491                    crWarning("won't print the above crServerGetFBOPresentBlitter warning any more", cPrintedWarnings);
     492            }
     493            return;
     494        }
     495
     496        CrBltMuralSetCurrent(pBlitter, mural);
     497        rc = CrBltEnter(pBlitter, cr_server.currentCtxInfo, cr_server.currentMural);
     498        if (RT_SUCCESS(rc))
     499        {
     500            CR_BLITTER_TEXTURE Tex;
     501            RTRECT Rect;
     502            Tex.width = mural->width;
     503            Tex.height = mural->height;
     504            Tex.target = GL_TEXTURE_2D;
     505            Tex.hwid = mural->idColorTex;
     506            Rect.xLeft = 0;
     507            Rect.yTop = 0;
     508            Rect.xRight = Tex.width;
     509            Rect.yBottom = Tex.height;
     510
     511            CrBltBlitTexMural(pBlitter, &Tex, &Rect, &Rect, 1, 0);
     512            CrBltPresent(pBlitter);
     513
     514            CrBltLeave(pBlitter);
     515        }
     516        else
     517        {
     518            crWarning("CrBltEnter failed rc %d", rc);
     519            return;
     520        }
    463521        return;
    464522    }
     
    588646    return cr_server.curClient
    589647           && cr_server.curClient->currentMural
    590            && cr_server.curClient->currentMural->bUseFBO;
    591 }
     648           && cr_server.curClient->currentMural->fUseFBO;
     649}
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp

    r43891 r43932  
    3232#include <iprt/mem.h>
    3333
    34 typedef DECLCALLBACK(int) FNCRDISPLAY_REGIONS_CHANGED(struct CR_PRESENTER *pPresenter);
    35 typedef FNCRDISPLAY_REGIONS_CHANGED *PFNCRDISPLAY_REGIONS_CHANGED;
    36 
    37 typedef DECLCALLBACK(int) FNCRDISPLAY_DRAW_ENTRY(struct CR_PRESENTER *pPresenter, struct CR_PRESENTER_ENTRY *pEntry, PCR_BLITTER pBlitter);
    38 typedef FNCRDISPLAY_DRAW_ENTRY *PFNCRDISPLAY_DRAW_ENTRY;
    39 
    40 typedef DECLCALLBACK(int) FNCRDISPLAY_DRAW_TEXTURE(struct CR_PRESENTER *pPresenter, PCR_BLITTER pBlitter,
    41                                             CR_BLITTER_TEXTURE *pTexture, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects);
    42 typedef FNCRDISPLAY_DRAW_TEXTURE *PFNCRDISPLAY_DRAW_TEXTURE;
    43 
    44 
    4534#define CR_DISPLAY_RECTS_UNDEFINED UINT32_MAX
    4635
     
    212201}
    213202
    214 DECLCALLBACK(int) CrPtCbDrawEntrySingle(struct CR_PRESENTER *pPresenter, struct CR_PRESENTER_ENTRY *pEntry, PCR_BLITTER pBlitter)
    215 {
     203DECLCALLBACK(int) CrPtCbDrawEntrySingle(struct CR_PRESENTER *pPresenter, struct CR_PRESENTER_ENTRY *pEntry, PCR_BLITTER pBlitter, bool *pfAllEntriesDrawn)
     204{
     205    if (pfAllEntriesDrawn)
     206        *pfAllEntriesDrawn = false;
     207
    216208    int rc = crPtRectsCheckInit(pPresenter);
    217209    if (!RT_SUCCESS(rc))
     
    241233    struct CR_PRESENTER_ENTRY *pEntry = CR_PRESENTER_ENTRY_FROM_ENTRY(pCEntry);
    242234    PCR_BLITTER pBlitter = (PCR_BLITTER)pvVisitor;
    243     int rc = CrPtCbDrawEntrySingle(pPresenter, pEntry, pBlitter);
     235    bool fAllEntriesDrawn;
     236    int rc = CrPtCbDrawEntrySingle(pPresenter, pEntry, pBlitter, &fAllEntriesDrawn);
    244237    if (!RT_SUCCESS(rc))
    245238    {
    246239        crWarning("CrPtCbDrawEntrySingle failed, rc %d", rc);
    247240    }
    248     return true;
    249 }
    250 
    251 DECLCALLBACK(int) CrPtCbDrawEntryAll(struct CR_PRESENTER *pPresenter, struct CR_PRESENTER_ENTRY *pEntry, PCR_BLITTER pBlitter)
     241    return !fAllEntriesDrawn;
     242}
     243
     244DECLCALLBACK(int) CrPtCbDrawEntryAll(struct CR_PRESENTER *pPresenter, struct CR_PRESENTER_ENTRY *pEntry, PCR_BLITTER pBlitter, bool *pfAllEntriesDrawn)
    252245{
    253246    int rc = crPtRectsCheckInit(pPresenter);
     
    258251    }
    259252
    260     VBoxVrCompositorVisit(&pPresenter->Compositor, crPtDrawEntryAllCb, pPresenter);
     253    VBoxVrCompositorVisit(&pPresenter->Compositor, crPtDrawEntryAllCb, pBlitter);
     254
     255    if (pfAllEntriesDrawn)
     256        *pfAllEntriesDrawn = true;
    261257
    262258    return VINF_SUCCESS;
     
    289285}
    290286
     287static int crPtEntryRegionsSet(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged)
     288{
     289    bool fChanged;
     290    int rc = VBoxVrCompositorEntryRegionsSet(&pPresenter->Compositor, &pEntry->Ce, cRegions, paRegions, &fChanged);
     291    if (!RT_SUCCESS(rc))
     292    {
     293        crWarning("VBoxVrCompositorEntryRegionsSet failed, rc %d", rc);
     294        return rc;
     295    }
     296
     297    if (fChanged)
     298    {
     299        crPtRectsInvalidate(pPresenter);
     300        rc = pPresenter->pfnRegionsChanged(pPresenter);
     301        if (!RT_SUCCESS(rc))
     302        {
     303            crWarning("pfnRegionsChanged failed, rc %d", rc);
     304            return rc;
     305        }
     306    }
     307
     308    if (pfChanged)
     309        *pfChanged = fChanged;
     310    return VINF_SUCCESS;
     311}
     312
    291313static void crPtEntryPositionSet(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, const RTPOINT *pPos)
    292314{
    293     if (pEntry && pEntry->Pos.x != pPos->x || pEntry->Pos.y != pPos->y)
    294     {
    295         VBoxVrCompositorEntryRemove(&pPresenter->Compositor, &pEntry->Ce);
    296         crPtRectsInvalidate(pPresenter);
     315    if (pEntry && (pEntry->Pos.x != pPos->x || pEntry->Pos.y != pPos->y))
     316    {
     317        if (VBoxVrCompositorEntryIsInList(&pEntry->Ce))
     318        {
     319            VBoxVrCompositorEntryRemove(&pPresenter->Compositor, &pEntry->Ce);
     320            crPtRectsInvalidate(pPresenter);
     321        }
    297322        pEntry->Pos = *pPos;
    298323    }
    299324}
    300325
    301 int CrPtEntryPresent(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions, PCR_BLITTER pBlitter)
     326int CrPtPresentEntry(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, PCR_BLITTER pBlitter)
     327{
     328    int rc = CrBltEnter(pBlitter, cr_server.currentCtxInfo, cr_server.currentMural);
     329    if (!RT_SUCCESS(rc))
     330    {
     331        crWarning("CrBltEnter failed, rc %d", rc);
     332        return rc;
     333    }
     334
     335    rc = pPresenter->pfnDrawEntry(pPresenter, pEntry, pBlitter, NULL);
     336
     337    CrBltLeave(pBlitter);
     338
     339    if (!RT_SUCCESS(rc))
     340    {
     341        crWarning("pfnDraw failed, rc %d", rc);
     342        return rc;
     343    }
     344
     345    return VINF_SUCCESS;
     346}
     347
     348static DECLCALLBACK(bool) crPtPresentCb(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pCEntry, void *pvVisitor)
     349{
     350    struct CR_PRESENTER *pPresenter = CR_PRESENTER_FROM_COMPOSITOR(pCompositor);
     351    struct CR_PRESENTER_ENTRY *pEntry = CR_PRESENTER_ENTRY_FROM_ENTRY(pCEntry);
     352    PCR_BLITTER pBlitter = (PCR_BLITTER)pvVisitor;
     353    bool fAllDrawn = false;
     354    int rc = pPresenter->pfnDrawEntry(pPresenter, pEntry, pBlitter, &fAllDrawn);
     355    if (!RT_SUCCESS(rc))
     356    {
     357        crWarning("pfnDrawEntry failed, rc %d", rc);
     358    }
     359    return !fAllDrawn;
     360}
     361
     362int CrPtPresent(PCR_PRESENTER pPresenter, PCR_BLITTER pBlitter)
     363{
     364    int rc = CrBltEnter(pBlitter, cr_server.currentCtxInfo, cr_server.currentMural);
     365    if (!RT_SUCCESS(rc))
     366    {
     367        crWarning("CrBltEnter failed, rc %d", rc);
     368        return rc;
     369    }
     370
     371    VBoxVrCompositorVisit(&pPresenter->Compositor, crPtPresentCb, pBlitter);
     372
     373    CrBltLeave(pBlitter);
     374
     375    if (!RT_SUCCESS(rc))
     376    {
     377        crWarning("pfnDraw failed, rc %d", rc);
     378        return rc;
     379    }
     380
     381    return VINF_SUCCESS;
     382}
     383
     384int CrPtEntryRegionsAdd(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions)
    302385{
    303386    crPtEntryPositionSet(pPresenter, pEntry, pPos);
     
    310393    }
    311394
    312     if (!pEntry)
    313         return VINF_SUCCESS;
    314 
    315     rc = CrBltEnter(pBlitter, cr_server.currentCtxInfo, cr_server.currentMural);
    316     if (!RT_SUCCESS(rc))
    317     {
    318         crWarning("CrBltEnter failed, rc %d", rc);
    319         return rc;
    320     }
    321 
    322     rc = pPresenter->pfnDrawEntry(pPresenter, pEntry, pBlitter);
    323 
    324     CrBltLeave(pBlitter);
    325 
    326     if (!RT_SUCCESS(rc))
    327     {
    328         crWarning("pfnDrawEntry failed, rc %d", rc);
    329         return rc;
    330     }
     395    return VINF_SUCCESS;
     396}
     397
     398int CrPtEntryRegionsSet(PCR_PRESENTER pPresenter, PCR_PRESENTER_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions)
     399{
     400    crPtEntryPositionSet(pPresenter, pEntry, pPos);
     401
     402    int rc = crPtEntryRegionsSet(pPresenter, pEntry, cRegions, paRegions, NULL);
     403    if (!RT_SUCCESS(rc))
     404    {
     405        crWarning("crPtEntryRegionsAdd failed, rc %d", rc);
     406        return rc;
     407    }
     408
    331409    return VINF_SUCCESS;
    332410}
     
    429507int CrDpInit(PCR_DISPLAY pDisplay)
    430508{
    431     const GLint visBits = CR_RGB_BIT;
    432     int rc = CrPtInit(&pDisplay->Presenter, crDpCbRegionsChanged, CrPtCbDrawEntrySingle, crDpCbDrawTextureWindow);
     509    const GLint visBits = CR_RGB_BIT | CR_DOUBLE_BIT;
     510    int rc = CrPtInit(&pDisplay->Presenter, crDpCbRegionsChanged, CrPtCbDrawEntryAll, crDpCbDrawTextureWindow);
    433511    if (RT_SUCCESS(rc))
    434512    {
     
    455533}
    456534
    457 bool CrDpBlitterTest(PCR_DISPLAY pDisplay, PCR_BLITTER pBlitter)
    458 {
    459     CrBltMuralSetCurrent(pBlitter, &pDisplay->Mural);
     535int CrDpBlitterTestWithMural(PCR_BLITTER pBlitter, CRMuralInfo *pMural)
     536{
     537    CrBltMuralSetCurrent(pBlitter, pMural);
    460538    /* try to enter to make sure the blitter is initialized completely and to make sure we actually can do that */
    461539    int rc = CrBltEnter(pBlitter, cr_server.currentCtxInfo, cr_server.currentMural);
     
    463541    {
    464542        CrBltLeave(pBlitter);
    465         return true;
     543        return VINF_SUCCESS;
    466544    }
    467545    else
     
    469547        crWarning("CrBltEnter failed, rc %d", rc);
    470548    }
    471     return false;
     549    return rc;
     550}
     551
     552int CrDpBlitterTest(PCR_DISPLAY pDisplay, PCR_BLITTER pBlitter)
     553{
     554    return CrDpBlitterTestWithMural(pBlitter, &pDisplay->Mural);
    472555}
    473556
     
    482565}
    483566
    484 int CrDpPresentTexture(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions)
    485 {
    486     return CrPtEntryPresent(&pDisplay->Presenter, &pEntry->Pe, pPos, cRegions, paRegions, pDisplay->pBlitter);
     567int CrDpEntryRegionsSet(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions)
     568{
     569    return CrPtEntryRegionsSet(&pDisplay->Presenter, &pEntry->Pe, pPos, cRegions, paRegions);
     570}
     571
     572int CrDpEntryRegionsAdd(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions)
     573{
     574    return CrPtEntryRegionsAdd(&pDisplay->Presenter, &pEntry->Pe, pPos, cRegions, paRegions);
     575}
     576
     577int CrDpPresentEntry(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry)
     578{
     579    return CrPtPresentEntry(&pDisplay->Presenter, &pEntry->Pe, pDisplay->pBlitter);
    487580}
    488581
     
    582675#define CR_PRESENT_GET_FLAGS(_cfg) ((_cfg) >> CR_PRESENT_FLAGS_OFFSET)
    583676
    584 static uint8_t crServerCheckInitDisplayBlitter()
     677int crServerBlitterInit(PCR_BLITTER pBlitter, CRMuralInfo*pMural)
     678{
     679    int rc = CrBltInit(pBlitter, pMural);
     680    if (RT_SUCCESS(rc))
     681    {
     682        rc = CrDpBlitterTestWithMural(pBlitter, pMural);
     683        if (RT_SUCCESS(rc))
     684            return VINF_SUCCESS;
     685        else
     686            crWarning("CrDpBlitterTestWithMural failed, rc %d", rc);
     687        CrBltTerm(pBlitter);
     688    }
     689    else
     690        crWarning("CrBltInit failed, rc %d", rc);
     691    return rc;
     692}
     693
     694PCR_BLITTER crServerGetFBOPresentBlitter(CRMuralInfo*pMural)
     695{
     696    if (cr_server.fFBOModeBlitterInited > 0)
     697        return &cr_server.FBOModeBlitter;
     698    if (!cr_server.fFBOModeBlitterInited)
     699    {
     700        int rc = crServerBlitterInit(&cr_server.FBOModeBlitter, pMural);
     701        if (RT_SUCCESS(rc))
     702        {
     703            cr_server.fFBOModeBlitterInited = 1;
     704            return &cr_server.FBOModeBlitter;
     705        }
     706        crWarning("crServerBlitterInit failed rc %d", rc);
     707        cr_server.fFBOModeBlitterInited = -1;
     708    }
     709    return NULL;
     710}
     711
     712static int8_t crServerCheckInitDisplayBlitter()
    585713{
    586714    if (cr_server.fPresentBlitterInited)
     
    597725        {
    598726            CRMuralInfo*pMural = CrDpGetMural(&cr_server.aDispplays[0]);
    599             CRCreateInfo_t*pCreateInfo = CrDpGetMuralCreateInfo(&cr_server.aDispplays[0]);
    600             rc = CrBltInit(&cr_server.PresentBlitter, pMural, pCreateInfo->visualBits);
     727            rc = crServerBlitterInit(&cr_server.PresentBlitter, pMural);
    601728            if (RT_SUCCESS(rc))
    602729            {
    603                 if (CrDpBlitterTest(&cr_server.aDispplays[0], &cr_server.PresentBlitter))
    604                 {
    605                     CrDpBlitterSet(&cr_server.aDispplays[0], &cr_server.PresentBlitter);
    606                     ASMBitSet(cr_server.DisplaysInitMap, 0);
    607                     cr_server.fPresentBlitterInited = 1;
    608                     return 1;
    609                 }
    610                 else
    611                 {
    612                     crWarning("CrDpBlitterTest failed");
    613                 }
    614                 CrBltTerm(&cr_server.PresentBlitter);
     730                CrDpBlitterSet(&cr_server.aDispplays[0], &cr_server.PresentBlitter);
     731                CrDpResize(&cr_server.aDispplays[0],
     732                            cr_server.screen[0].w, cr_server.screen[0].h,
     733                            cr_server.screen[0].w, cr_server.screen[0].h);
     734                ASMBitSet(cr_server.DisplaysInitMap, 0);
     735                cr_server.fPresentBlitterInited = 1;
     736                return 1;
    615737            }
    616738            else
    617739            {
    618                 crWarning("CrBltInit failed, rc %d", rc);
     740                crWarning("crServerBlitterInit failed, rc %d", rc);
    619741            }
    620742            CrDpTerm(&cr_server.aDispplays[0]);
     
    638760{
    639761    return crServerCheckInitDisplayBlitter() > 0;
     762}
     763
     764PCR_DISPLAY crServerDisplayGetInitialized(uint32_t idScreen)
     765{
     766    if (ASMBitTest(cr_server.DisplaysInitMap, idScreen))
     767        return &cr_server.aDispplays[idScreen];
     768    return NULL;
    640769}
    641770
     
    662791        {
    663792            CrDpBlitterSet(&cr_server.aDispplays[idScreen], &cr_server.PresentBlitter);
     793            CrDpResize(&cr_server.aDispplays[idScreen],
     794                    cr_server.screen[idScreen].w, cr_server.screen[idScreen].h,
     795                    cr_server.screen[idScreen].w, cr_server.screen[idScreen].h);
    664796            ASMBitSet(cr_server.DisplaysInitMap, idScreen);
    665797            return &cr_server.aDispplays[idScreen];
     
    697829
    698830    RTPOINT Point = {xPos, yPos};
    699     int rc = CrDpPresentTexture(pDisplay, pEntry, &Point, (uint32_t)cRects, (const RTRECT*)pRects);
    700     if (!RT_SUCCESS(rc))
    701     {
    702         crWarning("CrDpPresentTexture Failed rc %d", rc);
    703     }
    704 }
     831    int rc = CrDpEntryRegionsAdd(pDisplay, pEntry, &Point, (uint32_t)cRects, (const RTRECT*)pRects);
     832    if (!RT_SUCCESS(rc))
     833    {
     834        crWarning("CrDpEntrySetRegions Failed rc %d", rc);
     835        return;
     836    }
     837
     838    rc = CrDpPresentEntry(pDisplay, pEntry);
     839    if (!RT_SUCCESS(rc))
     840    {
     841        crWarning("CrDpEntrySetRegions Failed rc %d", rc);
     842        return;
     843    }
     844}
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_simpleget.py

    r41258 r43932  
    7676        CRASSERT(tablesize/sizeof(%s)==1);
    7777        fboid = crStateFBOHWIDtoID((GLuint) *get_values);
    78         if (cr_server.curClient->currentMural->bUseFBO
    79             && crServerIsRedirectedToFBO()
     78        if (crServerIsRedirectedToFBO()
    8079            && fboid==cr_server.curClient->currentMural->idFBO)
    8180        {
     
    8685    else if (GL_READ_BUFFER==pname)
    8786    {
    88         if (cr_server.curClient->currentMural->bUseFBO && crServerIsRedirectedToFBO()
     87        if (crServerIsRedirectedToFBO()
    8988            && cr_server.curClient->currentMural->idFBO
    9089            && !crStateGetCurrent()->framebufferobject.readFB)
     
    9594    else if (GL_DRAW_BUFFER==pname)
    9695    {
    97         if (cr_server.curClient->currentMural->bUseFBO && crServerIsRedirectedToFBO()
     96        if (crServerIsRedirectedToFBO()
    9897            && cr_server.curClient->currentMural->idFBO
    9998            && !crStateGetCurrent()->framebufferobject.drawFB)
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.c

    r43888 r43932  
    4444    mural->screenId = 0;
    4545    mural->bVisible = GL_FALSE;
    46     mural->bUseFBO = GL_FALSE;
     46    mural->fUseFBO = CR_SERVER_REDIR_NONE;
    4747
    4848    mural->cVisibleRects = 0;
     
    5858        windowID = preloadWinID<0 ? crServerGenerateID(&cr_server.idsPool.freeWindowID) : preloadWinID;
    5959
     60    mural->CreateInfo.visualBits = visBits;
     61    mural->CreateInfo.externalID = windowID;
     62    mural->CreateInfo.pszDpyName = dpyName ? crStrdup(dpyName) : NULL;
     63
    6064    crServerSetupOutputRedirect(mural);
    6165
     
    6872    CRMuralInfo *mural;
    6973    GLint windowID = -1;
    70     CRCreateInfo_t *pCreateInfo;
    7174
    7275    if (cr_server.sharedWindows) {
     
    119122    crHashtableAdd(cr_server.muralTable, windowID, mural);
    120123
    121     pCreateInfo = (CRCreateInfo_t *) crAlloc(sizeof(CRCreateInfo_t));
    122     pCreateInfo->pszDpyName = dpyName ? crStrdup(dpyName) : NULL;
    123     pCreateInfo->visualBits = visBits;
    124     crHashtableAdd(cr_server.pWindowCreateInfoTable, windowID, pCreateInfo);
    125 
    126124    crDebug("CRServer: client %p created new window %d (SPU window %d)",
    127125                    cr_server.curClient, windowID, mural->spuWindow);
     
    165163    }
    166164
    167     crServerRedirMuralFBO(mural, GL_FALSE);
     165    crServerRedirMuralFBO(mural, CR_SERVER_REDIR_NONE);
    168166    crServerDeleteMuralFBO(mural);
    169167
     
    270268    }
    271269
    272     crHashtableDelete(cr_server.pWindowCreateInfoTable, window, crServerCreateInfoDeleteCB);
     270    if (mural->CreateInfo.pszDpyName)
     271        crFree(mural->CreateInfo.pszDpyName);
    273272
    274273    crHashtableDelete(cr_server.muralTable, window, crFree);
     
    389388    }
    390389
    391     if (!mural->bUseFBO)
     390    if (mural->fUseFBO != CR_SERVER_REDIR_FBO_RAM)
    392391    {
    393392        cr_server.head_spu->dispatch_table.WindowShow(mural->spuWindow, state);
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