VirtualBox

Ignore:
Timestamp:
Jan 17, 2014 4:34:07 PM (11 years ago)
Author:
vboxsync
Message:

crOpenGL: presentation infrastructure rework (still work in progress)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r50041 r50095  
    188188    crFreeHashtable(cr_server.muralTable, deleteMuralInfoCallback);
    189189
    190     crServerDisplayTermAll();
    191     CrDemTerm(&cr_server.PresentTexturepMap);
    192     CrDemTeGlobalTerm();
    193     memset(cr_server.DisplaysInitMap, 0, sizeof (cr_server.DisplaysInitMap));
    194     memset(cr_server.aDispplays, 0, sizeof (cr_server.aDispplays));
     190    CrPMgrTerm();
    195191
    196192    for (i = 0; i < cr_server.numClients; i++) {
     
    369365    cr_server.dummyMuralTable = crAllocHashtable();
    370366
    371     CrDemGlobalInit();
    372 
    373     CrDemInit(&cr_server.PresentTexturepMap);
    374     memset(cr_server.DisplaysInitMap, 0, sizeof (cr_server.DisplaysInitMap));
    375     memset(cr_server.aDispplays, 0, sizeof (cr_server.aDispplays));
     367    CrPMgrInit();
    376368
    377369    cr_server.fRootVrOn = GL_FALSE;
     
    486478    cr_server.dummyMuralTable = crAllocHashtable();
    487479
    488     CrDemGlobalInit();
    489 
    490     CrDemInit(&cr_server.PresentTexturepMap);
    491     memset(cr_server.DisplaysInitMap, 0, sizeof (cr_server.DisplaysInitMap));
    492     memset(cr_server.aDispplays, 0, sizeof (cr_server.aDispplays));
     480    CrPMgrInit();
    493481
    494482    cr_server.fRootVrOn = GL_FALSE;
     
    1005993            return NULL;
    1006994        }
    1007         id = crServerMuralInit(pMural, "", visualBits, 0, GL_TRUE);
     995        id = crServerMuralInit(pMural, "", visualBits, 0);
    1008996        if (id < 0)
    1009997        {
     
    11491137
    11501138    pEl = &pData->aElements[pData->cElements];
    1151     pEl->idFBO = pMural && (pMural->fPresentMode & CR_SERVER_REDIR_F_FBO) ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0;
     1139    pEl->idFBO = pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0;
    11521140    pEl->enmBuffer = pData->aElements[1].idFBO ? GL_COLOR_ATTACHMENT0 : GL_FRONT;
    11531141    pEl->posX = 0;
     
    11761164    {
    11771165        pEl = &pData->aElements[pData->cElements];
    1178         pEl->idFBO = pMural && (pMural->fPresentMode & CR_SERVER_REDIR_F_FBO) ? pMural->aidFBOs[CR_SERVER_FBO_BB_IDX(pMural)] : 0;
     1166        pEl->idFBO = pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_BB_IDX(pMural)] : 0;
    11791167        pEl->enmBuffer = pData->aElements[1].idFBO ? GL_COLOR_ATTACHMENT0 : GL_BACK;
    11801168        pEl->posX = 0;
     
    12061194            AssertCompile(sizeof (GLfloat) == 4);
    12071195            pEl = &pData->aElements[pData->cElements];
    1208             pEl->idFBO = pMural && (pMural->fPresentMode & CR_SERVER_REDIR_F_FBO) ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0;
     1196            pEl->idFBO = pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0;
    12091197            pEl->enmBuffer = 0; /* we do not care */
    12101198            pEl->posX = 0;
     
    12371225            AssertCompile(sizeof (GLuint) == 4);
    12381226            pEl = &pData->aElements[pData->cElements];
    1239             pEl->idFBO = pMural && (pMural->fPresentMode & CR_SERVER_REDIR_F_FBO) ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0;
     1227            pEl->idFBO = pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0;
    12401228            pEl->enmBuffer = 0; /* we do not care */
    12411229            pEl->posX = 0;
     
    12621250    {
    12631251        pEl = &pData->aElements[pData->cElements];
    1264         pEl->idFBO = pMural && (pMural->fPresentMode & CR_SERVER_REDIR_F_FBO) ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0;
     1252        pEl->idFBO = pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0;
    12651253        pEl->enmBuffer = 0; /* we do not care */
    12661254        pEl->posX = 0;
     
    17191707    }
    17201708
    1721     rc = crServerDisplaySaveState(pSSM);
     1709    rc = CrPMgrSaveState(pSSM);
    17221710    AssertRCReturn(rc, rc);
    17231711
     
    21372125            crFree(muralInfo.pVisibleRects);
    21382126        }
    2139 
    2140         Assert(!pActualMural->fDataPresented);
    2141 
    2142         if (version >= SHCROGL_SSM_VERSION_WITH_PRESENT_STATE)
    2143             pActualMural->fDataPresented = muralInfo.fDataPresented;
    2144         else
    2145             pActualMural->fDataPresented = crServerVBoxCompositionPresentNeeded(pActualMural);
    21462127    }
    21472128
     
    22312212        crVBoxServerFBImageDataTerm(&Data.data);
    22322213
    2233         if ((pMural->fPresentMode & CR_SERVER_REDIR_F_FBO) && pMural->fDataPresented && crServerVBoxCompositionPresentNeeded(pMural))
    2234         {
    2235             crServerPresentFBO(pMural);
    2236         }
     2214        crServerPresentFBO(pMural);
    22372215
    22382216        CRASSERT(cr_server.currentMural);
     
    26102588    if (version >= SHCROGL_SSM_VERSION_WITH_SCREEN_INFO)
    26112589    {
    2612         rc = crServerDisplayLoadState(pSSM, version);
     2590        HCR_FRAMEBUFFER hFb;
     2591
     2592        rc = CrPMgrLoadState(pSSM, version);
    26132593        AssertRCReturn(rc, rc);
    26142594    }
     
    26822662}
    26832663
     2664void crServerWindowReparent(CRMuralInfo *pMural)
     2665{
     2666    pMural->fHasParentWindow = !!cr_server.screen[pMural->screenId].winID;
     2667
     2668    renderspuReparentWindow(pMural->spuWindow);
     2669}
     2670
    26842671static void crVBoxServerReparentMuralCB(unsigned long key, void *data1, void *data2)
    26852672{
     
    26872674    int *sIndex = (int*) data2;
    26882675
    2689     Assert(pMI->cDisabled);
    2690 
    26912676    if (pMI->screenId == *sIndex)
    26922677    {
    26932678        crServerWindowReparent(pMI);
    26942679    }
    2695 }
    2696 
    2697 static void crVBoxServerCheckMuralCB(unsigned long key, void *data1, void *data2)
    2698 {
    2699     CRMuralInfo *pMI = (CRMuralInfo*) data1;
    2700     (void) data2;
    2701 
    2702     crServerCheckMuralGeometry(pMI);
    27032680}
    27042681
     
    27372714    if (MAPPED(SCREEN(sIndex)))
    27382715    {
    2739         PCR_DISPLAY pDisplay = crServerDisplayGetInitialized(sIndex);
    2740 
    27412716        SCREEN(sIndex).winID = 0;
    27422717        renderspuSetWindowId(0);
     
    27462721        crHashtableWalk(cr_server.dummyMuralTable, crVBoxServerReparentMuralCB, &sIndex);
    27472722
    2748         if (pDisplay)
    2749             CrDpReparent(pDisplay, &SCREEN(sIndex));
     2723        CrPMgrScreenChanged((uint32_t)sIndex);
    27502724    }
    27512725
    27522726    renderspuSetWindowId(SCREEN(0).winID);
    2753 
    2754     crHashtableWalk(cr_server.muralTable, crVBoxServerCheckMuralCB, NULL);
    27552727
    27562728/*    crVBoxServerNotifyEvent(sIndex, VBOX3D_NOTIFY_EVENT_TYPE_VISIBLE_3DDATA, NULL); */
     
    27832755    crHashtableWalk(cr_server.dummyMuralTable, crVBoxServerReparentMuralCB, &sIndex);
    27842756    renderspuSetWindowId(SCREEN(0).winID);
    2785 
    2786     crHashtableWalk(cr_server.muralTable, crVBoxServerCheckMuralCB, NULL);
    27872757
    27882758#ifndef WINDOWS
     
    28192789#endif
    28202790
    2821     {
    2822         PCR_DISPLAY pDisplay = crServerDisplayGetInitialized(sIndex);
    2823         if (pDisplay)
    2824             CrDpReparent(pDisplay, &SCREEN(sIndex));
    2825     }
     2791    CrPMgrScreenChanged((uint32_t)sIndex);
    28262792
    28272793    crVBoxServerNotifyEvent(sIndex, VBOX3D_NOTIFY_EVENT_TYPE_VISIBLE_3DDATA,
     
    28312797}
    28322798
    2833 int crVBoxServerUpdateMuralRootVisibleRegion(CRMuralInfo *pMI)
    2834 {
    2835     GLboolean fForcePresent;
    2836 
    2837     int rc = VINF_SUCCESS;
    2838 
    2839     fForcePresent = crServerVBoxCompositionPresentNeeded(pMI);
    2840 
    2841     crServerVBoxCompositionDisableEnter(pMI);
    2842 
    2843     if (cr_server.fRootVrOn)
    2844     {
    2845         if (!pMI->fRootVrOn)
    2846         {
    2847             CrVrScrCompositorInit(&pMI->RootVrCompositor);
    2848         }
    2849 
    2850         rc = crServerMuralSynchRootVr(pMI, NULL);
    2851         if (!RT_SUCCESS(rc))
    2852         {
    2853             crWarning("crServerMuralSynchRootVr failed, rc %d", rc);
    2854             goto end;
    2855         }
    2856     }
    2857     else
    2858     {
    2859         CrVrScrCompositorClear(&pMI->RootVrCompositor);
    2860     }
    2861 
    2862     pMI->fRootVrOn = cr_server.fRootVrOn;
    2863 
    2864     crServerWindowVisibleRegion(pMI);
    2865 
    2866 end:
    2867     crServerVBoxCompositionDisableLeave(pMI, fForcePresent);
    2868 
    2869     return rc;
    2870 }
    2871 
    2872 static void crVBoxServerSetRootVisibleRegionCB(unsigned long key, void *data1, void *data2)
    2873 {
    2874     CRMuralInfo *pMI = (CRMuralInfo*) data1;
    2875 
    2876     if (!pMI->CreateInfo.externalID)
    2877         return;
    2878     (void) data2;
    2879 
    2880     crVBoxServerUpdateMuralRootVisibleRegion(pMI);
    2881 }
    2882 
    28832799DECLEXPORT(int32_t) crVBoxServerSetRootVisibleRegion(GLint cRects, const RTRECT *pRects)
    28842800{
    28852801    int32_t rc = VINF_SUCCESS;
    2886     int i;
     2802    GLboolean fOldRootVrOn = cr_server.fRootVrOn;
    28872803
    28882804    /* non-zero rects pointer indicate rects are present and switched on
     
    29112827    }
    29122828
    2913     crHashtableWalk(cr_server.muralTable, crVBoxServerSetRootVisibleRegionCB, NULL);
    2914 
    2915     for (i = 0; i < cr_server.screenCount; ++i)
    2916     {
    2917         PCR_DISPLAY pDisplay = crServerDisplayGetInitialized((uint32_t)i);
    2918         if (!pDisplay)
    2919             continue;
    2920 
    2921         CrDpRootUpdate(pDisplay);
     2829    if (!fOldRootVrOn != !cr_server.fRootVrOn)
     2830    {
     2831        rc = CrPMgrModeRootVr(cr_server.fRootVrOn);
     2832        if (!RT_SUCCESS(rc))
     2833        {
     2834            crWarning("CrPMgrModeRootVr failed rc %d", rc);
     2835            return rc;
     2836        }
     2837    }
     2838    else if (cr_server.fRootVrOn)
     2839    {
     2840        rc = CrPMgrRootVrUpdate();
     2841        if (!RT_SUCCESS(rc))
     2842        {
     2843            crWarning("CrPMgrRootVrUpdate failed rc %d", rc);
     2844            return rc;
     2845        }
    29222846    }
    29232847
     
    29302854}
    29312855
    2932 int32_t crServerSetOffscreenRenderingMode(GLuint value)
    2933 {
    2934     /* sanitize values */
    2935     value = crServerRedirModeAdjust(value);
    2936 
    2937     if (value == CR_SERVER_REDIR_F_NONE)
    2938     {
    2939         crWarning("crServerSetOffscreenRenderingMode: value undefined");
    2940     }
    2941 
    2942     if (cr_server.fPresentMode==value)
    2943     {
    2944         return VINF_SUCCESS;
    2945     }
    2946 
    2947     if ((value & CR_SERVER_REDIR_F_FBO) && !crServerSupportRedirMuralFBO())
    2948     {
    2949         crWarning("crServerSetOffscreenRenderingMode: FBO not supported");
    2950         return VERR_NOT_SUPPORTED;
    2951     }
    2952 
    2953     cr_server.fPresentMode=value;
    2954 
    2955     crHashtableWalk(cr_server.muralTable, crVBoxServerCheckMuralCB, NULL);
    2956 
    2957     return VINF_SUCCESS;
    2958 }
    2959 
    29602856DECLEXPORT(int32_t) crVBoxServerSetOffscreenRendering(GLboolean value)
    29612857{
    2962     return crServerSetOffscreenRenderingMode(value ?
    2963             cr_server.fPresentModeDefault | CR_SERVER_REDIR_F_FBO_RAM_VRDP | cr_server.fVramPresentModeDefault
    2964             : cr_server.fPresentModeDefault);
    2965 }
    2966 
    2967 static void crVBoxServerOutputRedirectCB(unsigned long key, void *data1, void *data2)
    2968 {
    2969     CRMuralInfo *mural = (CRMuralInfo*) data1;
    2970 
    2971     if (!mural->CreateInfo.externalID)
    2972         return;
    2973 
    2974     if (cr_server.bUseOutputRedirect)
    2975         crServerPresentOutputRedirect(mural);
    2976     else
    2977         crServerOutputRedirectCheckEnableDisable(mural);
     2858    return CrPMgrModeVrdp(value);
    29782859}
    29792860
     
    29842865    {
    29852866        cr_server.outputRedirect = *pCallbacks;
    2986         cr_server.bUseOutputRedirect = true;
    29872867    }
    29882868    else
    29892869    {
    2990         cr_server.bUseOutputRedirect = false;
    2991     }
    2992 
    2993     /* dynamically intercept already existing output */
    2994     crHashtableWalk(cr_server.muralTable, crVBoxServerOutputRedirectCB, NULL);
     2870        memset (&cr_server.outputRedirect, 0, sizeof (cr_server.outputRedirect));
     2871    }
    29952872
    29962873    return VINF_SUCCESS;
    29972874}
    29982875
    2999 static void crVBoxServerUpdateScreenViewportCB(unsigned long key, void *data1, void *data2)
    3000 {
    3001     CRMuralInfo *mural = (CRMuralInfo*) data1;
    3002     int *sIndex = (int*) data2;
    3003 
    3004     if (mural->screenId != *sIndex)
    3005         return;
    3006 
    3007     crServerCheckMuralGeometry(mural);
    3008 }
    3009 
    3010 
    30112876DECLEXPORT(int32_t) crVBoxServerSetScreenViewport(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h)
    30122877{
    3013     CRScreenViewportInfo *pVieport;
    3014     GLboolean fPosChanged, fSizeChanged;
     2878    CRScreenViewportInfo *pViewport;
     2879    RTRECT NewRect;
     2880    GLboolean fChanged;
     2881    int rc;
    30152882
    30162883    crDebug("crVBoxServerSetScreenViewport(%i)", sIndex);
     
    30222889    }
    30232890
    3024     pVieport = &cr_server.screenVieport[sIndex];
    3025     fPosChanged = (pVieport->x != x || pVieport->y != y);
    3026     fSizeChanged = (pVieport->w != w || pVieport->h != h);
    3027 
    3028     if (!fPosChanged && !fSizeChanged)
     2891    NewRect.xLeft = x;
     2892    NewRect.yTop = y;
     2893    NewRect.xRight = x + w;
     2894    NewRect.yBottom = y + h;
     2895
     2896    pViewport = &cr_server.screenVieport[sIndex];
     2897
     2898    fChanged = !!memcmp(&NewRect, &pViewport->Rect, sizeof (NewRect));
     2899    if (!fChanged)
    30292900    {
    30302901        crDebug("crVBoxServerSetScreenViewport: no changes");
     
    30322903    }
    30332904
    3034     if (fPosChanged)
    3035     {
    3036         pVieport->x = x;
    3037         pVieport->y = y;
    3038 
    3039         crHashtableWalk(cr_server.muralTable, crVBoxServerUpdateScreenViewportCB, &sIndex);
    3040     }
    3041 
    3042     if (fSizeChanged)
    3043     {
    3044         pVieport->w = w;
    3045         pVieport->h = h;
    3046 
    3047         /* no need to do anything here actually */
    3048     }
    3049 
    3050     if (fPosChanged || fSizeChanged)
    3051     {
    3052         PCR_DISPLAY pDisplay = crServerDisplayGetInitialized(sIndex);
    3053         if (pDisplay)
    3054             CrDpResize(pDisplay, SCREEN(sIndex).x, SCREEN(sIndex).y, SCREEN(sIndex).w, SCREEN(sIndex).h);
    3055     }
     2905    pViewport->Rect = NewRect;
     2906    rc = CrPMgrViewportUpdate((uint32_t)sIndex);
     2907    if (!RT_SUCCESS(rc))
     2908    {
     2909        crWarning("CrPMgrViewportUpdate failed %d", rc);
     2910        return rc;
     2911    }
     2912
    30562913    return VINF_SUCCESS;
    30572914}
     
    33713228}
    33723229
    3373 
    33743230int32_t crVBoxServerCrHgsmiCmd(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, uint32_t cbCmd)
    33753231{
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