VirtualBox

Changeset 44149 in vbox


Ignore:
Timestamp:
Dec 18, 2012 2:05:27 PM (12 years ago)
Author:
vboxsync
Message:

wddm/display-only: fix auto-resize

Location:
trunk/src/VBox/Additions/WINNT
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPCommon.h

    r42217 r44149  
    3333void VBoxMPCmnInitCustomVideoModes(PVBOXMP_DEVEXT pExt);
    3434VIDEO_MODE_INFORMATION* VBoxMPCmnGetCustomVideoModeInfo(ULONG ulIndex);
    35 VIDEO_MODE_INFORMATION* VBoxMPCmnGetVideoModeInfo(ULONG ulIndex);
    3635
    3736#ifdef VBOX_XPDM_MINIPORT
     37VIDEO_MODE_INFORMATION* VBoxMPCmnGetVideoModeInfo(ULONG ulIndex);
    3838VIDEO_MODE_INFORMATION* VBoxMPXpdmCurrentVideoMode(PVBOXMP_DEVEXT pExt);
    3939ULONG VBoxMPXpdmGetVideoModesCount();
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPVidModes.cpp

    r44040 r44149  
    2424#endif
    2525#include <wchar.h>
     26#include <VBox/Hardware/VBoxVideoVBE.h>
    2627
    2728#ifdef VBOX_WITH_WDDM
     
    3031
    3132/* Custom video modes which are being read from registry at driver startup. */
    32 static VIDEO_MODE_INFORMATION g_CustomVideoModes[64] = { 0 };
    33 
     33static VIDEO_MODE_INFORMATION g_CustomVideoModes[VBOX_VIDEO_MAX_SCREENS] = { 0 };
     34
     35#ifdef VBOX_XPDM_MINIPORT
    3436/* Standart video modes list.
    35  * Additional space is reserved for custom video modes for 64 guest monitors.
     37 * Additional space is reserved for custom video modes for VBOX_VIDEO_MAX_SCREENS guest monitors.
    3638 * The custom video mode index is alternating and 2 indexes are reserved for the last custom mode.
    3739 */
    38 static VIDEO_MODE_INFORMATION g_VideoModes[VBOXMP_MAX_VIDEO_MODES + 64 + 2] = { 0 };
     40static VIDEO_MODE_INFORMATION g_VideoModes[VBOXMP_MAX_VIDEO_MODES + VBOX_VIDEO_MAX_SCREENS + 2] = { 0 };
    3941
    4042/* Number of available video modes, set by VBoxMPCmnBuildVideoModesTable. */
    4143static uint32_t g_NumVideoModes = 0;
     44#endif
    4245
    4346static BOOLEAN
     
    210213}
    211214
     215#ifdef VBOX_XPDM_MINIPORT
    212216VIDEO_MODE_INFORMATION* VBoxMPCmnGetVideoModeInfo(ULONG ulIndex)
    213217{
    214218    return (ulIndex<RT_ELEMENTS(g_VideoModes)) ? &g_VideoModes[ulIndex] : NULL;
    215219}
     220#endif
    216221
    217222static bool VBoxMPVideoModesMatch(const PVIDEO_MODE_INFORMATION pMode1, const PVIDEO_MODE_INFORMATION pMode2)
     
    963968    Assert(pModes->cModes<=RT_ELEMENTS(pModes->aModes));
    964969
     970    if (!VBoxMPIsStartingUp(pExt, VidPnTargetId))
     971    {
     972        /* make sure we keep the current mode to avoid mode flickering */
     973        PVBOXWDDM_ALLOC_DATA pAllocData = pExt->aSources[VidPnTargetId].pPrimaryAllocation ?
     974                  &pExt->aSources[VidPnTargetId].pPrimaryAllocation->AllocData
     975                : &pExt->aSources[VidPnTargetId].AllocData;
     976        if (pModes->cModes < RT_ELEMENTS(pModes->aModes))
     977        {
     978            int foundIdx;
     979            VBoxFillVidModeInfo(&pModes->aModes[pModes->cModes], pAllocData->SurfDesc.width, pAllocData->SurfDesc.height, pAllocData->SurfDesc.bpp, 1/*index*/, 0);
     980            if ((foundIdx=VBoxMPFindVideoMode(pModes->aModes, pModes->cModes, &pModes->aModes[pModes->cModes]))>=0)
     981            {
     982                pModes->iPreferredMode = foundIdx;
     983            }
     984            else
     985            {
     986                pModes->iPreferredMode = pModes->cModes;
     987                ++pModes->cModes;
     988            }
     989
     990#ifdef VBOX_WITH_8BPP_MODES
     991            int bytesPerPixel=1;
     992#else
     993            int bytesPerPixel=2;
     994#endif
     995            for (; bytesPerPixel<=4; bytesPerPixel++)
     996            {
     997                int bpp = 8*bytesPerPixel;
     998
     999                if (bpp == pAllocData->SurfDesc.bpp)
     1000                    continue;
     1001
     1002                if (!VBoxMPValidateVideoModeParamsGuest(pExt, VidPnTargetId,
     1003                        pAllocData->SurfDesc.width, pAllocData->SurfDesc.height,
     1004                        bpp))
     1005                    continue;
     1006
     1007                if (pModes->cModes >= RT_ELEMENTS(pModes->aModes))
     1008                {
     1009                    WARN(("ran out of video modes 2"));
     1010                    break;
     1011                }
     1012
     1013                VBoxFillVidModeInfo(&pModes->aModes[pModes->cModes],
     1014                                        pAllocData->SurfDesc.width, pAllocData->SurfDesc.height,
     1015                                        bpp, pModes->cModes, 0);
     1016                if (VBoxMPFindVideoMode(pModes->aModes, pModes->cModes, &pModes->aModes[pModes->cModes]) < 0)
     1017                {
     1018                    ++pModes->cModes;
     1019                }
     1020            }
     1021        }
     1022        else
     1023        {
     1024            WARN(("ran out of video modes 1"));
     1025        }
     1026    }
     1027
    9651028    /* Check if there's a pending display change request for this adapter */
    9661029    VIDEO_MODE_INFORMATION specialMode;
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp

    r44136 r44149  
    120120                bSupported &= !!(pIf->modeData.wddm.pfnD3DKMTInvalidateActiveVidPn);
    121121
     122                pIf->modeData.wddm.pfnD3DKMTPollDisplayChildren = (PFND3DKMT_POLLDISPLAYCHILDREN)GetProcAddress(hGdi32, "D3DKMTPollDisplayChildren");
     123                Log((__FUNCTION__": pfnD3DKMTPollDisplayChildren = %p\n", pIf->modeData.wddm.pfnD3DKMTPollDisplayChildren));
     124                bSupported &= !!(pIf->modeData.wddm.pfnD3DKMTPollDisplayChildren);
     125
    122126                if (!bSupported)
    123127                {
     
    953957}
    954958
     959typedef struct VBOXDISPIF_REINITMODES_OP
     960{
     961    VBOXDISPIFESCAPE_REINITVIDEOMODESBYMASK EscData;
     962} VBOXDISPIF_REINITMODES_OP, *PVBOXDISPIF_REINITMODES_OP;
     963
     964static DECLCALLBACK(BOOLEAN) vboxDispIfReninitModesWDDMOp(PCVBOXDISPIF pIf, D3DKMT_HANDLE hAdapter, DISPLAY_DEVICE *pDev, PVOID pContext)
     965{
     966    PVBOXDISPIF_REINITMODES_OP pData = (PVBOXDISPIF_REINITMODES_OP)pContext;
     967    VBOXDISPIFWDDM_ESCAPEOP_CONTEXT Ctx = {0};
     968    Ctx.pEscape = &pData->EscData.EscapeHdr;
     969    Ctx.cbData = sizeof (pData->EscData) - sizeof (pData->EscData.EscapeHdr);
     970//    Ctx.EscapeFlags.HardwareAccess = 0;
     971    DWORD err = vboxDispIfWDDMAdapterOp(pIf, -1 /* iDisplay, -1 means primary */, vboxDispIfEscapeWDDMOp, &Ctx);
     972    if (err == NO_ERROR)
     973    {
     974        if (!Ctx.Status)
     975            err = NO_ERROR;
     976        else
     977        {
     978            if (Ctx.Status == 0xC00000BBL) /* not supported */
     979                err = ERROR_NOT_SUPPORTED;
     980            else
     981                err = ERROR_GEN_FAILURE;
     982            Log((__FUNCTION__": pfnD3DKMTEscape failed, Status (0x%x)\n", Ctx.Status));
     983        }
     984    }
     985    else
     986        Log((__FUNCTION__": vboxDispIfWDDMAdapterOp failed, err (%d)\n", err));
     987
     988    D3DKMT_POLLDISPLAYCHILDREN PollData = {0};
     989    PollData.hAdapter = hAdapter;
     990    PollData.NonDestructiveOnly = 1;
     991    NTSTATUS Status = pIf->modeData.wddm.pfnD3DKMTPollDisplayChildren(&PollData);
     992    if (Status != 0)
     993    {
     994        Log((__FUNCTION__": pfnD3DKMTPollDisplayChildren failed, Status (0x%x)\n", Status));
     995    }
     996    return TRUE;
     997}
     998
    955999static DWORD vboxDispIfReninitModesWDDM(PCVBOXDISPIF const pIf, uint8_t *pScreenIdMask, BOOL fReconnectDisplaysOnChange)
    9561000{
    957     VBOXDISPIFESCAPE_REINITVIDEOMODESBYMASK Data = {0};
    958     Data.EscapeHdr.escapeCode = VBOXESC_REINITVIDEOMODESBYMASK;
     1001    VBOXDISPIF_REINITMODES_OP OpData = {0};
     1002    OpData.EscData.EscapeHdr.escapeCode = VBOXESC_REINITVIDEOMODESBYMASK;
    9591003    if (fReconnectDisplaysOnChange)
    960         Data.EscapeHdr.u32CmdSpecific = VBOXWDDM_REINITVIDEOMODESBYMASK_F_RECONNECT_DISPLAYS_ON_CHANGE;
    961 
    962     memcpy(Data.ScreenMask, pScreenIdMask, sizeof (Data.ScreenMask));
    963 
    964     DWORD err = vboxDispIfEscapeWDDM(pIf, &Data.EscapeHdr, sizeof (Data) - sizeof (Data.EscapeHdr), fReconnectDisplaysOnChange ? FALSE /* hw access must be false here,
    965                                                              * otherwise the miniport driver would fail
    966                                                              * request to prevent a deadlock */
    967                                                         : TRUE);
    968     if (err != NO_ERROR)
    969     {
    970         Log((__FUNCTION__": VBoxDispIfEscape failed with err (%d)\n", err));
    971     }
     1004        OpData.EscData.EscapeHdr.u32CmdSpecific = VBOXWDDM_REINITVIDEOMODESBYMASK_F_RECONNECT_DISPLAYS_ON_CHANGE;
     1005
     1006    memcpy(OpData.EscData.ScreenMask, pScreenIdMask, sizeof (OpData.EscData.ScreenMask));
     1007
     1008    DWORD err = vboxDispIfWDDMAdapterOp(pIf, -1 /* iDisplay, -1 means primary */, vboxDispIfReninitModesWDDMOp, &OpData);
    9721009    return err;
    9731010}
     
    11521189        vboxDispIfReninitModesWDDM(pIf, ScreenMask, TRUE);
    11531190
    1154         for (UINT i = 0; i < 4; ++i)
    1155         {
    1156             WaitForSingleObject(g_VBoxDispIfWddm.hResizeEvent, 500);
    1157             winEr = vboxDispIfWddmValidateFixResize(pIf, paDisplayDevices, paDeviceModes, cDevModes);
    1158             if (winEr == NO_ERROR)
    1159                 break;
    1160         }
     1191        winEr = vboxDispIfWddmValidateFixResize(pIf, paDisplayDevices, paDeviceModes, cDevModes);
     1192
     1193//        for (UINT i = 0; i < 4; ++i)
     1194//        {
     1195//            WaitForSingleObject(g_VBoxDispIfWddm.hResizeEvent, 500);
     1196//            winEr = vboxDispIfWddmValidateFixResize(pIf, paDisplayDevices, paDeviceModes, cDevModes);
     1197//            if (winEr == NO_ERROR)
     1198//                break;
     1199//        }
    11611200
    11621201        Assert(winEr == NO_ERROR);
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.h

    r42232 r44149  
    6868            /* auto resize support */
    6969            PFND3DKMT_INVALIDATEACTIVEVIDPN pfnD3DKMTInvalidateActiveVidPn;
     70            PFND3DKMT_POLLDISPLAYCHILDREN pfnD3DKMTPollDisplayChildren;
    7071        } wddm;
    7172#endif
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