VirtualBox

Ignore:
Timestamp:
Oct 17, 2023 12:09:33 PM (16 months ago)
Author:
vboxsync
Message:

Main/ConsoleImpl: Use the common method to configure the graphics controller respecting monitor count and VRAM settings, bugref:10528

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImplConfigCommon.cpp

    r101474 r101477  
    50265026
    50275027
     5028int Console::i_configGraphicsController(PCFGMNODE pDevices,
     5029                                        const GraphicsControllerType_T enmGraphicsController,
     5030                                        BusAssignmentManager *pBusMgr,
     5031                                        const ComPtr<IMachine> &ptrMachine,
     5032                                        const ComPtr<IGraphicsAdapter> &ptrGraphicsAdapter,
     5033                                        const ComPtr<IFirmwareSettings> &ptrFirmwareSettings,
     5034                                        bool fForceVmSvga3, bool fExposeLegacyVga)
     5035{
     5036    // InsertConfig* throws
     5037    try
     5038    {
     5039        PCFGMNODE pDev, pInst, pCfg, pLunL0;
     5040        HRESULT hrc;
     5041        Bstr    bstr;
     5042        const char *pcszDevice = "vga";
     5043
     5044        InsertConfigNode(pDevices, pcszDevice, &pDev);
     5045        InsertConfigNode(pDev,     "0", &pInst);
     5046        InsertConfigInteger(pInst, "Trusted",              1); /* boolean */
     5047
     5048        hrc = pBusMgr->assignPCIDevice(pcszDevice, pInst);                                  H();
     5049        InsertConfigNode(pInst,    "Config", &pCfg);
     5050        ULONG cVRamMBs;
     5051        hrc = ptrGraphicsAdapter->COMGETTER(VRAMSize)(&cVRamMBs);                           H();
     5052        InsertConfigInteger(pCfg,  "VRamSize",             cVRamMBs * _1M);
     5053        ULONG cMonitorCount;
     5054        hrc = ptrGraphicsAdapter->COMGETTER(MonitorCount)(&cMonitorCount);                  H();
     5055        InsertConfigInteger(pCfg,  "MonitorCount",         cMonitorCount);
     5056
     5057        BOOL f3DEnabled;
     5058        hrc = ptrGraphicsAdapter->COMGETTER(Accelerate3DEnabled)(&f3DEnabled);              H();
     5059        InsertConfigInteger(pCfg,  "3DEnabled",            f3DEnabled);
     5060
     5061        i_attachStatusDriver(pInst, DeviceType_Graphics3D);
     5062
     5063#ifdef VBOX_WITH_VMSVGA
     5064        if (   enmGraphicsController == GraphicsControllerType_VMSVGA
     5065            || enmGraphicsController == GraphicsControllerType_VBoxSVGA)
     5066        {
     5067            InsertConfigInteger(pCfg, "VMSVGAEnabled", true);
     5068            if (enmGraphicsController == GraphicsControllerType_VMSVGA)
     5069            {
     5070                InsertConfigInteger(pCfg, "VMSVGAPciBarLayout", true);
     5071                InsertConfigInteger(pCfg, "VMSVGAPciId", true);
     5072            }
     5073# ifdef VBOX_WITH_VMSVGA3D
     5074            InsertConfigInteger(pCfg, "VMSVGA3dEnabled", f3DEnabled);
     5075# else
     5076            LogRel(("VMSVGA3d not available in this build!\n"));
     5077# endif /* VBOX_WITH_VMSVGA3D */
     5078
     5079            InsertConfigInteger(pCfg, "VmSvga3", fForceVmSvga3);
     5080            InsertConfigInteger(pCfg, "VmSvgaExposeLegacyVga", fExposeLegacyVga);
     5081        }
     5082#else
     5083        RT_NOREF(enmGraphicsController);
     5084#endif /* VBOX_WITH_VMSVGA */
     5085
     5086        /* Custom VESA mode list */
     5087        unsigned cModes = 0;
     5088        for (unsigned iMode = 1; iMode <= 16; ++iMode)
     5089        {
     5090            char szExtraDataKey[sizeof("CustomVideoModeXX")];
     5091            RTStrPrintf(szExtraDataKey, sizeof(szExtraDataKey), "CustomVideoMode%u", iMode);
     5092            hrc = ptrMachine->GetExtraData(Bstr(szExtraDataKey).raw(), bstr.asOutParam());  H();
     5093            if (bstr.isEmpty())
     5094                break;
     5095            InsertConfigString(pCfg, szExtraDataKey, bstr);
     5096            ++cModes;
     5097        }
     5098        InsertConfigInteger(pCfg, "CustomVideoModes", cModes);
     5099
     5100        /* VESA height reduction */
     5101        ULONG ulHeightReduction;
     5102        IFramebuffer *pFramebuffer = NULL;
     5103        hrc = i_getDisplay()->QueryFramebuffer(0, &pFramebuffer);
     5104        if (SUCCEEDED(hrc) && pFramebuffer)
     5105        {
     5106            hrc = pFramebuffer->COMGETTER(HeightReduction)(&ulHeightReduction);             H();
     5107            pFramebuffer->Release();
     5108            pFramebuffer = NULL;
     5109        }
     5110        else
     5111        {
     5112            /* If framebuffer is not available, there is no height reduction. */
     5113            ulHeightReduction = 0;
     5114        }
     5115        InsertConfigInteger(pCfg,  "HeightReduction", ulHeightReduction);
     5116
     5117        /*
     5118         * BIOS logo
     5119         */
     5120        BOOL fFadeIn;
     5121        hrc = ptrFirmwareSettings->COMGETTER(LogoFadeIn)(&fFadeIn);                             H();
     5122        InsertConfigInteger(pCfg,  "FadeIn",  fFadeIn ? 1 : 0);
     5123        BOOL fFadeOut;
     5124        hrc = ptrFirmwareSettings->COMGETTER(LogoFadeOut)(&fFadeOut);                           H();
     5125        InsertConfigInteger(pCfg,  "FadeOut", fFadeOut ? 1: 0);
     5126        ULONG logoDisplayTime;
     5127        hrc = ptrFirmwareSettings->COMGETTER(LogoDisplayTime)(&logoDisplayTime);                H();
     5128        InsertConfigInteger(pCfg,  "LogoTime", logoDisplayTime);
     5129        Bstr bstrLogoImagePath;
     5130        hrc = ptrFirmwareSettings->COMGETTER(LogoImagePath)(bstrLogoImagePath.asOutParam());    H();
     5131        InsertConfigString(pCfg,   "LogoFile", bstrLogoImagePath);
     5132
     5133        /*
     5134         * Boot menu
     5135         */
     5136        FirmwareBootMenuMode_T enmBootMenuMode;
     5137        int iShowBootMenu;
     5138        hrc = ptrFirmwareSettings->COMGETTER(BootMenuMode)(&enmBootMenuMode);                     H();
     5139        switch (enmBootMenuMode)
     5140        {
     5141            case FirmwareBootMenuMode_Disabled: iShowBootMenu = 0;  break;
     5142            case FirmwareBootMenuMode_MenuOnly: iShowBootMenu = 1;  break;
     5143            default:                        iShowBootMenu = 2;  break;
     5144        }
     5145        InsertConfigInteger(pCfg, "ShowBootMenu", iShowBootMenu);
     5146
     5147        /* Attach the display. */
     5148        InsertConfigNode(pInst,    "LUN#0", &pLunL0);
     5149        InsertConfigString(pLunL0, "Driver",               "MainDisplay");
     5150        InsertConfigNode(pLunL0,   "Config", &pCfg);
     5151    }
     5152    catch (ConfigError &x)
     5153    {
     5154        // InsertConfig threw something:
     5155        return x.m_vrc;
     5156    }
     5157
     5158    return VINF_SUCCESS;
     5159}
     5160
    50285161#undef H
    50295162#undef VRC
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