VirtualBox

Ignore:
Timestamp:
Dec 17, 2009 11:27:18 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56113
Message:

2d: more FBO support

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp

    r25441 r25453  
    309309}
    310310
    311 static VBoxVHWATextureImage* vboxVHWAImageCreate(const QRect & aRect, const VBoxVHWAColorFormat & aFormat, class VBoxVHWAGlProgramMngr * pMgr, bool bDisablePBO)
    312 {
    313 #ifdef VBOXVHWA_NEW_PBO
     311static VBoxVHWATextureImage* vboxVHWAImageCreate(const QRect & aRect, const VBoxVHWAColorFormat & aFormat, class VBoxVHWAGlProgramMngr * pMgr, VBOXVHWAIMG_TYPE flags)
     312{
    314313    const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(NULL);
    315     if(!bDisablePBO && info.getGlInfo().isPBOSupported())
    316     {
     314    if((flags & VBOXVHWAIMG_PBO) && !info.getGlInfo().isPBOSupported())
     315        flags &= ~VBOXVHWAIMG_PBO;
     316
     317    if((flags & VBOXVHWAIMG_PBOIMG) &&
     318            (!info.getGlInfo().isPBOSupported() || !info.getGlInfo().isPBOOffsetSupported()))
     319        flags &= ~VBOXVHWAIMG_PBOIMG;
     320
     321    if((flags & VBOXVHWAIMG_FBO) && !info.getGlInfo().isFBOSupported())
     322        flags &= ~VBOXVHWAIMG_FBO;
     323
     324    /* ensure we don't create a PBO-based texture in case we use a PBO-based image */
     325    if(flags & VBOXVHWAIMG_PBOIMG)
     326        flags &= ~VBOXVHWAIMG_PBO;
     327
     328    if(flags & VBOXVHWAIMG_PBOIMG)
     329    {
     330        if(flags & VBOXVHWAIMG_FBO)
     331        {
     332            VBOXQGLLOG(("FBO PBO Image\n"));
     333            return new VBoxVHWATextureImageFBO<VBoxVHWATextureImagePBO>(aRect, aFormat, pMgr, flags);
     334        }
    317335        VBOXQGLLOG(("PBO Image\n"));
    318         return new VBoxVHWATextureImagePBO(aRect, aFormat, pMgr);
    319     }
    320 #endif
     336        return new VBoxVHWATextureImagePBO(aRect, aFormat, pMgr, flags);
     337    }
     338    if(flags & VBOXVHWAIMG_FBO)
     339    {
     340        VBOXQGLLOG(("FBO Generic Image\n"));
     341        return new VBoxVHWATextureImageFBO<VBoxVHWATextureImage>(aRect, aFormat, pMgr, flags);
     342    }
    321343    VBOXQGLLOG(("Generic Image\n"));
    322     return new VBoxVHWATextureImage(aRect, aFormat, pMgr, bDisablePBO);
    323 }
    324 
    325 static VBoxVHWATexture* vboxVHWATextureCreate(const QGLContext * pContext, const QRect & aRect, const VBoxVHWAColorFormat & aFormat, bool bDisablePBO)
     344    return new VBoxVHWATextureImage(aRect, aFormat, pMgr, flags);
     345}
     346
     347static VBoxVHWATexture* vboxVHWATextureCreate(const QGLContext * pContext, const QRect & aRect, const VBoxVHWAColorFormat & aFormat, VBOXVHWAIMG_TYPE flags)
    326348{
    327349    const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(pContext);
    328     if(!bDisablePBO && info.getGlInfo().isPBOSupported())
     350    if((flags & VBOXVHWAIMG_PBO) && info.getGlInfo().isPBOSupported())
    329351    {
    330352        VBOXQGLLOG(("VBoxVHWATextureNP2RectPBO\n"));
     
    11951217    resetDefaultSrcOverlayCKey();
    11961218
    1197     mImage = vboxVHWAImageCreate(QRect(0,0,aSize.width(),aSize.height()), aColorFormat, getGlProgramMngr(), bVGA);
     1219    mImage = vboxVHWAImageCreate(QRect(0,0,aSize.width(),aSize.height()), aColorFormat, getGlProgramMngr(), bVGA ? 0 : (VBOXVHWAIMG_PBO | VBOXVHWAIMG_PBOIMG/* | VBOXVHWAIMG_FBO*/));
    11981220
    11991221    setRectValues(aTargRect, aSrcRect);
     
    19661988void VBoxGLWidget::adjustViewport(const QSize &display, const QRect &viewport)
    19671989{
    1968 #ifdef VBOXVHWA_OLD_COORD
    1969     /* viewport:  (viewport.x;viewport.y) (viewport.width;viewport.height)*/
    1970     glViewport(-((int)display.width() + viewport.x()),
    1971                 -((int)display.height() - viewport.y() + display.height() - viewport.height()),
    1972                 2*display.width(),
    1973                 2*display.height());
    1974 #else
    19751990    glViewport(-viewport.x(),
    19761991                   viewport.height() + viewport.y() - display.height(),
    19771992               display.width(),
    19781993               display.height());
    1979 
    1980 #endif
    19811994}
    19821995
    19831996void VBoxGLWidget::setupMatricies(const QSize &display)
    19841997{
    1985 #ifdef VBOXVHWA_OLD_COORD
    1986     glMatrixMode(GL_PROJECTION);
    1987     glLoadIdentity();
    1988     glFrustum(0., (GLdouble)display.width(), 0., (GLdouble)display.height(), 0., 0.);
    1989 
    1990     glMatrixMode(GL_MODELVIEW);
    1991     //    doSetupMatrix(bInverted ? &mRect.size() : &mTargSize.size(), bInverted);
    1992     doSetupMatrix(display, false);
    1993 #else
    19941998    glMatrixMode(GL_PROJECTION);
    19951999    glLoadIdentity();
     
    19982002    glMatrixMode(GL_MODELVIEW);
    19992003    glLoadIdentity();
    2000 #endif
    20012004}
    20022005
     
    49914994}
    49924995
    4993 VBoxVHWATextureImage::VBoxVHWATextureImage(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr, bool bDisablePBO) :
     4996VBoxVHWATextureImage::VBoxVHWATextureImage(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr, VBOXVHWAIMG_TYPE flags) :
    49944997        mVisibleDisplay(0),
    49954998        mpProgram(0),
     
    50005003        mbNotIntersected(false)
    50015004{
    5002     mpTex[0] = vboxVHWATextureCreate(NULL, size, format, bDisablePBO);
     5005    mpTex[0] = vboxVHWATextureCreate(NULL, size, format, flags);
    50035006    mColorFormat = format;
    50045007    if(mColorFormat.fourcc() == FOURCC_YV12)
    50055008    {
    50065009        QRect rect(size.x()/2,size.y()/2,size.width()/2,size.height()/2);
    5007         mpTex[1] = vboxVHWATextureCreate(NULL, rect, format, bDisablePBO);
    5008         mpTex[2] = vboxVHWATextureCreate(NULL, rect, format, bDisablePBO);
     5010        mpTex[1] = vboxVHWATextureCreate(NULL, rect, format, flags);
     5011        mpTex[2] = vboxVHWATextureCreate(NULL, rect, format, flags);
    50095012        mcTex = 3;
    50105013    }
     
    51615164{
    51625165    uint32_t type = calcProgramType(pDst, pDstCKey, pSrcCKey, bNotIntersected);
    5163 
    5164     if(pDstCKey != NULL)
    5165         type |= VBOXVHWA_PROGRAM_DSTCOLORKEY;
    5166     if(pSrcCKey)
    5167         type |= VBOXVHWA_PROGRAM_SRCCOLORKEY;
    5168     if((pDstCKey || pSrcCKey) && bNotIntersected)
    5169         type |= VBOXVHWA_PROGRAM_COLORKEYNODISCARD;
    51705166
    51715167    return mProgramMngr->getProgram(type, &colorFormat(), pDst ? &pDst->colorFormat() : NULL);
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.h

    r25445 r25453  
    2929//#define VBOXVHWADBG_RENDERCHECK
    3030
    31 //#define VBOXVHWA_NEW_PBO
    32 
    3331#include "COMDefs.h"
    3432#include <QGLWidget>
     
    377375};
    378376
     377#define VBOXVHWAIMG_PBO    0x00000001U
     378#define VBOXVHWAIMG_PBOIMG 0x00000002U
     379#define VBOXVHWAIMG_FBO    0x00000004U
     380typedef uint32_t VBOXVHWAIMG_TYPE;
     381
    379382class VBoxVHWATextureImage
    380383{
    381384public:
    382     VBoxVHWATextureImage(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr, bool bDisablePBO);
     385    VBoxVHWATextureImage(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr, VBOXVHWAIMG_TYPE flags);
    383386
    384387    virtual ~VBoxVHWATextureImage()
     
    549552{
    550553public:
    551     VBoxVHWATextureImagePBO(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr) :
    552             VBoxVHWATextureImage(size, format, aMgr, true),
     554    VBoxVHWATextureImagePBO(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr, VBOXVHWAIMG_TYPE flags) :
     555            VBoxVHWATextureImage(size, format, aMgr, flags & (~VBOXVHWAIMG_PBO)),
    553556            mPBO(0)
    554557    {
     
    15751578{
    15761579public:
    1577     VBoxVHWATextureImageFBO(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr) :
    1578             T(size, format, aMgr),
    1579             mFBOTex(size, VBoxVHWAColorFormat(32, 0xff0000, 0xff00, 0xff), aMgr)
    1580     {
     1580    VBoxVHWATextureImageFBO(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr, VBOXVHWAIMG_TYPE flags) :
     1581            T(size, format, aMgr, flags & (~VBOXVHWAIMG_FBO)),
     1582            mFBOTex(size, VBoxVHWAColorFormat(32, 0xff0000, 0xff00, 0xff), aMgr, flags & (~VBOXVHWAIMG_FBO)),
     1583            mpvFBOTexMem(NULL)
     1584    {
     1585    }
     1586
     1587    virtual ~VBoxVHWATextureImageFBO()
     1588    {
     1589        if(mpvFBOTexMem)
     1590            free(mpvFBOTexMem);
    15811591    }
    15821592
     
    15841594    {
    15851595        mFBO.init();
    1586         mFBOTex.init(NULL);
    1587         T:init(pvMem);
     1596        mpvFBOTexMem = (uchar*)malloc(mFBOTex.memSize());
     1597        mFBOTex.init(mpvFBOTexMem);
     1598        T::init(pvMem);
    15881599        mFBO.bind();
    1589         mFBO.attachBound(mFBOTex.mpTex[0]);
     1600        mFBO.attachBound(mFBOTex.component(0));
    15901601        mFBO.unbind();
    15911602    }
     
    15951606            GLuint *pDisplay, class VBoxVHWAGlProgramVHWA ** ppProgram)
    15961607    {
    1597         T::createDisplay(&mFBOTex, &mFBOTex.rect(), &rect(),
     1608        T::createDisplay(NULL, &mFBOTex.rect(), &rect(),
    15981609                NULL, NULL, false,
    15991610                pDisplay, ppProgram);
    16001611
    1601         return mFBOTex.createDisplay(pDst, pDstRect, pSrcRect,
    1602                 pDstCKey, pSrcCKey, bNotIntersected,
    1603                 pDisplay, ppProgram);
     1612        return mFBOTex.initDisplay(pDst, pDstRect, pSrcRect,
     1613                pDstCKey, pSrcCKey, bNotIntersected);
    16041614    }
    16051615
    16061616    virtual void update(const QRect * pRect)
    16071617    {
     1618        T::update(pRect);
     1619
     1620        VBoxGLWidget::pushSettingsAndSetupViewport(rect().size(), rect());
    16081621        mFBO.bind();
    1609         T:update(pRect);
    1610 
    1611         VBoxGLWidget::pushSettingsAndSetupViewport(rect(), rect());
    1612         mFBO.bind();
    1613         mFBOTex.display();
     1622        T::display();
    16141623        mFBO.unbind();
    16151624        VBoxGLWidget::popSettingsAfterSetupViewport();
     
    16311640    VBoxVHWAFBO mFBO;
    16321641    VBoxVHWATextureImage mFBOTex;
     1642    uchar * mpvFBOTexMem;
    16331643};
    16341644
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