VirtualBox

Changeset 45507 in vbox for trunk/src/VBox/GuestHost


Ignore:
Timestamp:
Apr 12, 2013 8:27:12 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84977
Message:

crOpenGL: blitter enhancements for OSX

Location:
trunk/src/VBox/GuestHost/OpenGL
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/include/cr_blitter.h

    r45348 r45507  
    4444        uint32_t CtxCreated          : 1;
    4545        uint32_t SupportsFBO         : 1;
    46         uint32_t SupportsFBOBlit     : 1;
    4746        uint32_t CurrentMuralChanged : 1;
    4847        uint32_t LastWasFBODraw      : 1;
     48        uint32_t ForceDrawBlit       : 1;
    4949        uint32_t Reserved            : 26;
    5050    };
     
    103103}
    104104
    105 VBOXBLITTERDECL(int) CrBltInit(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pCtxBase, bool fCreateNewCtx, SPUDispatchTable *pDispatch);
     105VBOXBLITTERDECL(int) CrBltInit(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pCtxBase, bool fCreateNewCtx, bool fForceDrawBlt, SPUDispatchTable *pDispatch);
     106
    106107VBOXBLITTERDECL(void) CrBltTerm(PCR_BLITTER pBlitter);
    107108
     
    132133}
    133134
    134 VBOXBLITTERDECL(void) CrBltMuralSetCurrent(PCR_BLITTER pBlitter, const CR_BLITTER_WINDOW *pMural);
     135VBOXBLITTERDECL(int) CrBltMuralSetCurrent(PCR_BLITTER pBlitter, const CR_BLITTER_WINDOW *pMural);
    135136DECLINLINE(const CR_BLITTER_WINDOW *) CrBltMuralGetCurrentInfo(PCR_BLITTER pBlitter)
    136137{
  • trunk/src/VBox/GuestHost/OpenGL/util/blitter.cpp

    r45201 r45507  
    2929
    3030
    31 int CrBltInit(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pCtxBase, bool fCreateNewCtx, SPUDispatchTable *pDispatch)
    32 {
    33     if (pCtxBase->Base.id == 0 || pCtxBase->Base.id < -1)
     31/* @param pCtxBase      - contains the blitter context info. Its value is treated differently depending on the fCreateNewCtx value
     32 * @param fCreateNewCtx - if true  - the pCtxBase must NOT be NULL. its visualBits is used as a visual bits info for the new context,
     33 *                                   its id field is used to specified the shared context id to be used for blitter context.
     34 *                                   The id can be null to specify no shared context is needed
     35 *                        if false - if pCtxBase is NOT null AND its id field is NOT null -
     36 *                                     specified the blitter context to be used
     37 *                                     blitter treats it as if it has default ogl state.
     38 *                                   otherwise -
     39 *                                     the blitter works in a "no-context" mode, i.e. a caller is responsible
     40 *                                     to making a proper context current before calling the blitter.
     41 *                                     Note that BltEnter/Leave MUST still be called, but the proper context
     42 *                                     must be set before doing BltEnter, and ResoreContext info is ignored in that case.
     43 *                                     Also note that blitter caches the current window info, and assumes the current context's values are preserved
     44 *                                     wrt that window before the calls, so if one uses different contexts for one blitter,
     45 *                                     the blitter current window values must be explicitly reset by doing CrBltMuralSetCurrent(pBlitter, NULL)
     46 * @param fForceDrawBlt - if true  - forces the blitter to always use glDrawXxx-based blits even if GL_EXT_framebuffer_blit.
     47 *                                   This is needed because BlitFramebufferEXT is known to be often buggy, and glDrawXxx-based blits appear to be more reliable
     48 */
     49int CrBltInit(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pCtxBase, bool fCreateNewCtx, bool fForceDrawBlt, SPUDispatchTable *pDispatch)
     50{
     51    if (pCtxBase && pCtxBase->Base.id < 0)
    3452    {
    3553        crWarning("Default share context not initialized!");
     
    3755    }
    3856
     57    if (!pCtxBase && fCreateNewCtx)
     58    {
     59        crWarning("pCtxBase is zero while fCreateNewCtx is set!");
     60        return VERR_INVALID_PARAMETER;
     61    }
     62
    3963    memset(pBlitter, 0, sizeof (*pBlitter));
    4064
    4165    pBlitter->pDispatch = pDispatch;
    42     pBlitter->CtxInfo = *pCtxBase;
     66    if (pCtxBase)
     67        pBlitter->CtxInfo = *pCtxBase;
     68
     69    pBlitter->Flags.ForceDrawBlit = fForceDrawBlt;
     70
    4371    if (fCreateNewCtx)
    4472    {
     
    6290}
    6391
    64 void CrBltMuralSetCurrent(PCR_BLITTER pBlitter, const CR_BLITTER_WINDOW *pMural)
     92int CrBltMuralSetCurrent(PCR_BLITTER pBlitter, const CR_BLITTER_WINDOW *pMural)
    6593{
    6694    if (pMural)
    6795    {
    6896        if (!memcmp(&pBlitter->CurrentMural, pMural, sizeof (pBlitter->CurrentMural)))
    69             return;
     97            return VINF_SUCCESS;
    7098        memcpy(&pBlitter->CurrentMural, pMural, sizeof (pBlitter->CurrentMural));
    7199    }
     
    73101    {
    74102        if (!pBlitter->CurrentMural.Base.id)
    75             return;
     103            return VINF_SUCCESS;
    76104        pBlitter->CurrentMural.Base.id = 0;
    77105    }
     
    80108
    81109    if (!CrBltIsEntered(pBlitter))
    82         return;
     110        return VINF_SUCCESS;
     111    else if (!pBlitter->CtxInfo.Base.id)
     112    {
     113        crWarning("setting current mural for entered no-context blitter");
     114        return VERR_INVALID_STATE;
     115    }
     116
     117    pBlitter->pDispatch->Flush();
    83118
    84119    if (pMural)
     
    86121    else
    87122        pBlitter->pDispatch->MakeCurrent(0, 0, 0);
     123
     124    return VINF_SUCCESS;
    88125}
    89126
     
    436473    }
    437474
     475    pBlitter->pDispatch->BindTexture(pSrc->target, 0);
     476
    438477    return VINF_SUCCESS;
    439478}
     
    453492    /* BlitFramebuffer seems to be buggy on Intel,
    454493     * try always glDrawXxx for now */
    455     if (0 && crStrstr(pszExtension, "GL_EXT_framebuffer_blit"))
    456     {
    457         pBlitter->Flags.SupportsFBOBlit = 1;
     494    if (!pBlitter->Flags.ForceDrawBlit && crStrstr(pszExtension, "GL_EXT_framebuffer_blit"))
     495    {
    458496        pBlitter->pfnBlt = crBltBlitTexBufImplFbo;
    459497    }
     
    486524    pBlitter->pDispatch->Flush();
    487525
    488     if (pBlitter->pRestoreCtxInfo != &pBlitter->CtxInfo)
    489     {
    490         pBlitter->pDispatch->MakeCurrent(pBlitter->pRestoreMural->Base.id, 0, pBlitter->pRestoreCtxInfo->Base.id);
    491     }
    492     else
    493     {
    494         pBlitter->pDispatch->MakeCurrent(0, 0, 0);
     526    if (pBlitter->CtxInfo.Base.id)
     527    {
     528        if (pBlitter->pRestoreCtxInfo != &pBlitter->CtxInfo)
     529        {
     530            pBlitter->pDispatch->MakeCurrent(pBlitter->pRestoreMural->Base.id, 0, pBlitter->pRestoreCtxInfo->Base.id);
     531        }
     532        else
     533        {
     534            pBlitter->pDispatch->MakeCurrent(0, 0, 0);
     535        }
    495536    }
    496537
     
    512553    }
    513554
     555    if (pBlitter->CurrentMural.Base.id) /* <- pBlitter->CurrentMural.Base.id can be null if the blitter is in a "no-context" mode (see comments to BltInit for detail)*/
     556    {
     557        pBlitter->pDispatch->MakeCurrent(pBlitter->CurrentMural.Base.id, pBlitter->i32MakeCurrentUserData, pBlitter->CtxInfo.Base.id);
     558    }
     559    else
     560    {
     561        if (pRestoreCtxInfo)
     562        {
     563            crWarning("pRestoreCtxInfo is not NULL for \"no-context\" blitter");
     564            pRestoreCtxInfo = NULL;
     565        }
     566    }
     567
    514568    if (pRestoreCtxInfo)
    515569    {
     
    523577        pBlitter->pRestoreCtxInfo = &pBlitter->CtxInfo;
    524578    }
    525 
    526     pBlitter->pDispatch->MakeCurrent(pBlitter->CurrentMural.Base.id, pBlitter->i32MakeCurrentUserData, pBlitter->CtxInfo.Base.id);
    527579
    528580    if (pBlitter->Flags.Initialized)
     
    573625
    574626    crBltBlitTexBuf(pBlitter, pSrc, pSrcRect, GL_DRAW_FRAMEBUFFER, &DstSize, pDstRect, cRects, fFlags);
     627
     628    pBlitter->pDispatch->FramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, pDst->target, 0, 0);
    575629}
    576630
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