VirtualBox

Changeset 50827 in vbox


Ignore:
Timestamp:
Mar 19, 2014 4:57:33 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
92889
Message:

crOpenGL: new command submission continued

Location:
trunk/src/VBox/HostServices/SharedOpenGL
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserver/crservice.cpp

    r50812 r50827  
    4545static uint32_t g_u32ScreenCount = 0;
    4646static PVM g_pVM = NULL;
     47static uint32_t g_u32fCrHgcmDisabled = 0;
    4748
    4849#ifndef RT_OS_WINDOWS
     
    558559
    559560    NOREF(pvClient);
     561
     562    if (g_u32fCrHgcmDisabled)
     563    {
     564        WARN(("cr hgcm disabled!"));
     565        return;
     566    }
    560567
    561568    Log(("SHARED_CROPENGL svcCall: u32ClientID = %d, fn = %d, cParms = %d, pparms = %d\n", u32ClientID, u32Function, cParms, paParms));
     
    15191526                    if (paParms->u.pointer.size != sizeof (VBOXCRCMDCTL))
    15201527                        WARN(("invalid param size"));
    1521                     return crVBoxServerHgcmDisable();
     1528                    int rc = crVBoxServerHgcmDisable();
     1529                    if (RT_SUCCESS(rc))
     1530                        g_u32fCrHgcmDisabled = 1;
     1531                    else
     1532                        WARN(("crVBoxServerHgcmDisable failed %d", rc));
     1533                    return rc;
    15221534                }
    15231535                case VBOXCRCMDCTL_TYPE_ENABLE:
     
    15261538                        WARN(("invalid param size"));
    15271539                    VBOXCRCMDCTL_ENABLE *pEnable = (VBOXCRCMDCTL_ENABLE*)pCtl;
    1528                     return crVBoxServerHgcmEnable(pEnable->hRHCmd, pEnable->pfnRHCmd);
     1540                    int rc = crVBoxServerHgcmEnable(pEnable->hRHCmd, pEnable->pfnRHCmd);
     1541                    if (RT_SUCCESS(rc))
     1542                        g_u32fCrHgcmDisabled = 0;
     1543                    else
     1544                        WARN(("crVBoxServerHgcmEnable failed %d", rc));
     1545                    return rc;
    15291546                }
    15301547                default:
     
    15361553        }
    15371554        default:
     1555            if (g_u32fCrHgcmDisabled)
     1556            {
     1557                WARN(("cr hgcm disabled!"));
     1558                return VERR_INVALID_STATE;
     1559            }
    15381560            return svcHostCallPerform(u32Function, cParms, paParms);
    15391561    }
     
    15621584        {
    15631585            g_pHelpers = ptable->pHelpers;
     1586
     1587            g_u32fCrHgcmDisabled = 0;
    15641588
    15651589            ptable->cbClient = sizeof (void*);
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r50817 r50827  
    33553355        if (RT_SUCCESS(rc))
    33563356        {
    3357             rc = CrHTablePutToSlot(&cr_server.clientTable, u32ClientId, pClient);
     3357            rc = crVBoxServerClientObjSetVersion(pClient, pConnect->u32MajorVersion, pConnect->u32MinorVersion);
    33583358            if (RT_SUCCESS(rc))
    3359                 return VINF_SUCCESS;
     3359            {
     3360                rc = crVBoxServerClientObjSetPID(pClient, pConnect->u64Pid);
     3361                if (RT_SUCCESS(rc))
     3362                {
     3363                    rc = CrHTablePutToSlot(&cr_server.clientTable, u32ClientId, pClient);
     3364                    if (RT_SUCCESS(rc))
     3365                        return VINF_SUCCESS;
     3366                    else
     3367                        WARN(("CrHTablePutToSlot failed %d", rc));
     3368                }
     3369                else
     3370                    WARN(("crVBoxServerClientObjSetPID failed %d", rc));
     3371            }
    33603372            else
    3361                 WARN(("CrHTablePutToSlot failed %d", rc));
     3373                WARN(("crVBoxServerClientObjSetVersion failed %d", rc));
    33623374
    33633375            crVBoxServerRemoveClientObj(pClient);
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp

    r50773 r50827  
    681681}
    682682
    683 #if 0
    684 static int crFbBltPutContentsVram(HCR_FRAMEBUFFER hFb, const RTPOINT *pDstPoint, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg, float strX, float strY)
     683static void crFbBltPutContentsVram(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect, const RTRECT *pDstRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
    685684{
    686685    const RTRECT *pCompRect = CrVrScrCompositorRectGet(&hFb->Compositor);
    687     const RTPOINT ZeroPoint = {0};
    688 
    689     uint32_t fbWidth = (pCompRect->xRight - pCompRect->xLeft);
    690     uint32_t fbHeight = pCompRect->yBottom - pCompRect->yTop;
    691 
    692     uint32_t stretchedWidth = CR_FLOAT_RCAST(uint32_t, strX * fbWidth);
    693     uint32_t stretchedHeight = CR_FLOAT_RCAST(uint32_t, strY * fbHeight);
    694686
    695687    CR_BLITTER_IMG FbImg;
    696688
    697     bool fScale = fbWidth != stretchedWidth || fbHeight != stretchedHeight;
    698 
    699689    crFbImgFromFb(hFb, &FbImg);
    700690
     691    int32_t srcWidth = pSrcRect->xRight - pSrcRect->xLeft;
     692    int32_t srcHeight = pSrcRect->yBottom - pSrcRect->yTop;
     693    int32_t dstWidth = pDstRect->xRight - pDstRect->xLeft;
     694    int32_t dstHeight = pDstRect->yBottom - pDstRect->yTop;
     695
     696    RTPOINT DstPoint = {pDstRect->xLeft, pDstRect->yTop};
     697    float strX = ((float)dstWidth) / srcWidth;
     698    float strY = ((float)dstHeight) / srcHeight;
     699    bool fScale = (dstWidth != srcWidth || dstHeight != srcHeight);
     700
    701701    RTRECT Intersection;
     702    const RTPOINT ZeroPoint = {0, 0};
    702703
    703704    for (uint32_t i = 0; i < cRects; ++i)
     
    709710            continue;
    710711
     712        RTRECT ScaledSrcRect;
     713        ScaledSrcRect.xLeft = 0;
     714        ScaledSrcRect.yTop = 0;
     715        ScaledSrcRect.xRight = CR_FLOAT_RCAST(int32_t, strX * pImg->width);
     716        ScaledSrcRect.yBottom = CR_FLOAT_RCAST(int32_t, strY * pImg->height);
     717
     718        VBoxRectTranslate(&ScaledSrcRect, pDstRect->xLeft, pDstRect->yTop);
     719
     720        VBoxRectIntersect(&Intersection, &ScaledSrcRect);
     721
     722        if (VBoxRectIsZero(&Intersection))
     723            continue;
     724
    711725        if (!fScale)
    712             crFbBltImg(pImg, pDstPoint, false, &Intersection, &ZeroPoint, &FbImg);
     726            crFbBltImg(pImg, &DstPoint, false, &Intersection, &ZeroPoint, &FbImg);
    713727        else
    714             crFbBltImgScaled(pImg, pDstPoint, false, &Intersection, &ZeroPoint, strX, strY, &FbImg);
     728            crFbBltImgScaled(pImg, &DstPoint, false, &Intersection, &ZeroPoint, strX, strY, &FbImg);
     729    }
     730}
     731
     732static int crFbBltPutContentsNonscaled(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect, const RTRECT *pDstRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
     733{
     734    crFbBltPutContentsVram(hFb, pSrcRect, pDstRect, cRects, pRects, pImg);
     735
     736    RTPOINT DstPoint = {pDstRect->xLeft, pDstRect->yTop};
     737
     738    int rc = CrFbEntryRegionsAdd(hFb, NULL, &DstPoint, cRects, pRects, false);
     739    if (!RT_SUCCESS(rc))
     740    {
     741        WARN(("CrFbEntryRegionsAdd failed %d", rc));
     742        return rc;
    715743    }
    716744
     
    718746}
    719747
    720 int CrFbBltPutContents(HCR_FRAMEBUFFER hFb, const RTRECT *pDstRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
    721 {
    722     RTPOINT DstPoint = {pDstRect->xLeft, pDstRect->yTop};
    723     float strX = ((float)pImg->width) / (pDstRect->xRight - pDstRect->xLeft);
    724     float strY = ((float)pImg->height) / (pDstRect->yBottom - pDstRect->yTop);
    725 
    726     int rc = CrFbEntryRegionsAdd(hFb, NULL, const RTPOINT *pPos, cRects, pRects, true)
     748int CrFbBltPutContents(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect, const RTRECT *pDstRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
     749{
    727750    if (!hFb->cUpdating)
    728751    {
    729         WARN(("not updating\n"));
     752        WARN(("framebuffer not updating"));
    730753        return VERR_INVALID_STATE;
    731754    }
    732 }
    733 
    734 int CrFbBltPutContentsNe(HCR_FRAMEBUFFER hFb, const RTRECT *pDstRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
    735 {
     755
     756    int32_t srcWidth = pSrcRect->xRight - pSrcRect->xLeft;
     757    int32_t srcHeight = pSrcRect->yBottom - pSrcRect->yTop;
     758    int32_t dstWidth = pDstRect->xRight - pDstRect->xLeft;
     759    int32_t dstHeight = pDstRect->yBottom - pDstRect->yTop;
     760
     761    bool fScale = (dstWidth != srcWidth || dstHeight != srcHeight);
     762    if (fScale)
     763    {
     764        WARN(("scaling not supported"));
     765        return VERR_NOT_IMPLEMENTED;
     766    }
     767
     768    return crFbBltPutContentsNonscaled(hFb, pSrcRect, pDstRect, cRects, pRects, pImg);
     769}
     770
     771int CrFbBltPutContentsNe(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect, const RTRECT *pDstRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
     772{
     773    int32_t srcWidth = pSrcRect->xRight - pSrcRect->xLeft;
     774    int32_t srcHeight = pSrcRect->yBottom - pSrcRect->yTop;
     775    int32_t dstWidth = pDstRect->xRight - pDstRect->xLeft;
     776    int32_t dstHeight = pDstRect->yBottom - pDstRect->yTop;
     777
     778    bool fScale = (dstWidth != srcWidth || dstHeight != srcHeight);
     779    if (fScale)
     780    {
     781        WARN(("scaling not supported"));
     782        return VERR_NOT_IMPLEMENTED;
     783    }
     784
    736785    uint32_t cCompRects;
    737786    const RTRECT *pCompRects;
     
    746795    for (uint32_t i = 0; i < cCompRects; ++i)
    747796    {
    748         const RTRECT *pCompRect = pCompRects[i];
     797        const RTRECT *pCompRect = &pCompRects[i];
    749798        for (uint32_t j = 0; j < cRects; ++j)
    750799        {
    751             const RTRECT *pRect = pRects[j];
     800            const RTRECT *pRect = &pRects[j];
    752801            if (VBoxRectIsIntersect(pCompRect, pRect))
    753802            {
     
    763812        if (RT_SUCCESS(rc))
    764813        {
    765             rc = CrFbBltPutContents(hFb, pDstRect, cRects, pRects, pImg);
     814            rc = CrFbBltPutContents(hFb, pSrcRect, pDstRect, cRects, pRects, pImg);
    766815            if (!RT_SUCCESS(rc))
    767816                WARN(("CrFbBltPutContents failed rc %d", rc));
     
    774823    }
    775824
    776     return crFbBltPutContentsVram(HCR_FRAMEBUFFER hFb, const RTPOINT *pDstPoint, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg, float strX, float strY);
    777 
    778     const RTPOINT ZeroPoint = {0, 0};
    779 
    780     c2DRects = VBoxVrListRectsCount(&List);
    781     if (c2DRects)
    782     {
    783         if (g_CrPresenter.cbTmpBuf2 < c2DRects * sizeof (RTRECT))
    784         {
    785             if (g_CrPresenter.pvTmpBuf2)
    786                 RTMemFree(g_CrPresenter.pvTmpBuf2);
    787 
    788             g_CrPresenter.cbTmpBuf2 = (c2DRects + 10) * sizeof (RTRECT);
    789             g_CrPresenter.pvTmpBuf2 = RTMemAlloc(g_CrPresenter.cbTmpBuf2);
    790             if (!g_CrPresenter.pvTmpBuf2)
    791             {
    792                 WARN(("RTMemAlloc failed!"));
    793                 g_CrPresenter.cbTmpBuf2 = 0;
    794                 rc = VERR_NO_MEMORY;
    795                 goto end;
    796             }
    797         }
    798 
    799         RTRECT *p2DRects  = (RTRECT *)g_CrPresenter.pvTmpBuf2;
    800 
    801         rc = VBoxVrListRectsGet(&List, c2DRects, p2DRects);
    802         if (!RT_SUCCESS(rc))
    803         {
    804             WARN(("VBoxVrListRectsGet failed, rc %d", rc));
    805             goto end;
    806         }
    807 
    808         RTPOINT Pos = {0};
    809         const RTRECT *pCompRect = CrVrScrCompositorRectGet(&hFb->Compositor);
    810 
    811         CR_BLITTER_IMG FbImg;
    812 
    813         crFbImgFromFb(hFb, &FbImg);
    814 
    815         for (uint32_t i = 0; i < cRects; ++i)
    816         {
    817             const RTRECT * pRect = &pRects[i];
    818             for (uint32_t j = 0; j < c2DRects; ++j)
    819             {
    820                 const RTRECT * p2DRect = &p2DRects[j];
    821                 RTRECT Intersection;
    822                 VBoxRectIntersected(pRect, p2DRect, &Intersection);
    823                 if (VBoxRectIsZero(&Intersection))
    824                     continue;
    825 
    826                 if (!fScale)
    827                     crFbBltImg(&FbImg, &ZeroPoint, false, &Intersection, &SrcPoint, pImg);
    828                 else
    829                     crFbBltImgScaled(&FbImg, &ZeroPoint, false, &Intersection, &SrcPoint, strX, strY, pImg);
    830             }
    831         }
    832     }
    833 
    834 end:
    835 
    836     if (pEnteredTex)
    837         CrTdBltLeave(pEnteredTex);
    838 
    839     if (pEnteredBlitter)
    840         CrBltLeave(pEnteredBlitter);
    841 
    842     VBoxVrListClear(&List);
    843 
    844     return rc;
    845 }
    846 #endif
     825    crFbBltPutContentsVram(hFb, pSrcRect, pDstRect, cRects, pRects, pImg);
     826    return VINF_SUCCESS;
     827}
    847828
    848829int CrFbResize(CR_FRAMEBUFFER *pFb, const struct VBVAINFOSCREEN * pScreen, void *pvVRAM)
     
    46934674            {
    46944675                /* blit to primary from non-primary */
    4695                 uint32_t texId;
    46964676                if (u8Flags & VBOXCMDVBVA_OPF_ALLOC_DSTID)
    46974677                {
    46984678                    /* TexPresent */
    4699                     texId = pBlt->alloc.u.id;
     4679                    uint32_t texId = pBlt->alloc.u.id;
     4680
     4681                    crServerDispatchVBoxTexPresent(texId, u8PrimaryID, pBlt->Pos.x, pBlt->Pos.y, cRects, (const GLint*)pRects);
    47004682                }
    47014683                else
     
    47134695
    47144696                    uint8_t *pu8Buf = g_pvVRamBase + offVRAM;
    4715                     texId = 0;
    4716 //                    cr_server.CrCmdClientInfo.pfnCltScrUpdateBegin(cr_server.CrCmdClientInfo.hCltScr);
    4717                     /*todo: notify VGA device to perform updates */
     4697                    const RTRECT *pCompRect = CrVrScrCompositorRectGet(&hFb->Compositor);
     4698                    CR_BLITTER_IMG Img;
     4699                    crFbImgFromScreenVram(pScreen, pu8Buf, &Img);
     4700                    int rc = CrFbBltPutContentsNe(hFb, pCompRect, pCompRect, cRects, pRects, &Img);
     4701                    if (!RT_SUCCESS(rc))
     4702                    {
     4703                        WARN(("CrFbBltPutContentsNe failed %d", rc));
     4704                        return rc;
     4705                    }
     4706
     4707                    if (cRects)
     4708                    {
     4709                        bool fDirtyEmpty = true;
     4710                        RTRECT dirtyRect;
     4711                        cr_server.CrCmdClientInfo.pfnCltScrUpdateBegin(cr_server.CrCmdClientInfo.hCltScr, u8PrimaryID);
     4712
     4713                        VBVACMDHDR hdr;
     4714                        for (uint32_t i = 0; i < cRects; ++i)
     4715                        {
     4716                            hdr.x = pRects[i].xLeft;
     4717                            hdr.y = pRects[i].yTop;
     4718                            hdr.w = hdr.x + pRects[i].xRight;
     4719                            hdr.h = hdr.y + pRects[i].yBottom;
     4720
     4721                            cr_server.CrCmdClientInfo.pfnCltScrUpdateProcess(cr_server.CrCmdClientInfo.hCltScr, u8PrimaryID, &hdr, sizeof (hdr));
     4722
     4723                            if (fDirtyEmpty)
     4724                            {
     4725                                /* This is the first rectangle to be added. */
     4726                                dirtyRect.xLeft   = pRects[i].xLeft;
     4727                                dirtyRect.yTop    = pRects[i].yTop;
     4728                                dirtyRect.xRight  = pRects[i].xRight;
     4729                                dirtyRect.yBottom = pRects[i].yBottom;
     4730                                fDirtyEmpty       = false;
     4731                            }
     4732                            else
     4733                            {
     4734                                /* Adjust region coordinates. */
     4735                                if (dirtyRect.xLeft > pRects[i].xLeft)
     4736                                {
     4737                                    dirtyRect.xLeft = pRects[i].xLeft;
     4738                                }
     4739
     4740                                if (dirtyRect.yTop > pRects[i].yTop)
     4741                                {
     4742                                    dirtyRect.yTop = pRects[i].yTop;
     4743                                }
     4744
     4745                                if (dirtyRect.xRight < pRects[i].xRight)
     4746                                {
     4747                                    dirtyRect.xRight = pRects[i].xRight;
     4748                                }
     4749
     4750                                if (dirtyRect.yBottom < pRects[i].yBottom)
     4751                                {
     4752                                    dirtyRect.yBottom = pRects[i].yBottom;
     4753                                }
     4754                            }
     4755                        }
     4756
     4757                        if (dirtyRect.xRight - dirtyRect.xLeft)
     4758                        {
     4759                            cr_server.CrCmdClientInfo.pfnCltScrUpdateEnd(cr_server.CrCmdClientInfo.hCltScr, u8PrimaryID, dirtyRect.xLeft, dirtyRect.yTop,
     4760                                                               dirtyRect.xRight - dirtyRect.xLeft, dirtyRect.yBottom - dirtyRect.yTop);
     4761                        }
     4762                        else
     4763                        {
     4764                            cr_server.CrCmdClientInfo.pfnCltScrUpdateEnd(cr_server.CrCmdClientInfo.hCltScr, u8PrimaryID, 0, 0, 0, 0);
     4765                        }
     4766                    }
    47184767                }
    4719 
    4720                 crServerDispatchVBoxTexPresent(texId, u8PrimaryID, pBlt->Pos.x, pBlt->Pos.y, cRects, (const GLint*)pRects);
     4768                return VINF_SUCCESS;
    47214769            }
    47224770            else
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