void UIMachineSettingsDisplay::prepareScreenTab() { /* Prepare memory-size slider: */ CSystemProperties sys = vboxGlobal().virtualBox().GetSystemProperties(); m_iMinVRAM = sys.GetMinGuestVRAM(); m_iMaxVRAM = sys.GetMaxGuestVRAM(); m_iMaxVRAMVisible = m_iMaxVRAM; const uint cHostScreens = QApplication::desktop()->screenCount(); m_pSliderVideoMemorySize->setMinimum(m_iMinVRAM); m_pSliderVideoMemorySize->setMaximum(m_iMaxVRAMVisible); m_pSliderVideoMemorySize->setPageStep(calcPageStep(m_iMaxVRAMVisible)); m_pSliderVideoMemorySize->setSingleStep(m_pSliderVideoMemorySize->pageStep() / 4); m_pSliderVideoMemorySize->setTickInterval(m_pSliderVideoMemorySize->pageStep()); m_pSliderVideoMemorySize->setSnappingEnabled(true); m_pSliderVideoMemorySize->setErrorHint(0, 1); connect(m_pSliderVideoMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoMemorySizeSliderChange())); /* Prepare memory-size editor: */ vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorVideoMemorySize, 4); m_pEditorVideoMemorySize->setMinimum(m_iMinVRAM); m_pEditorVideoMemorySize->setMaximum(m_iMaxVRAMVisible); connect(m_pEditorVideoMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoMemorySizeEditorChange())); /* Prepare screen-count slider: */ const uint cMinGuestScreens = 1; const uint cMaxGuestScreens = sys.GetMaxGuestMonitors(); const uint cMaxGuestScreensForSlider = qMin(cMaxGuestScreens, (uint)8); m_pSliderVideoScreenCount->setMinimum(cMinGuestScreens); m_pSliderVideoScreenCount->setMaximum(cMaxGuestScreensForSlider); m_pSliderVideoScreenCount->setPageStep(1); m_pSliderVideoScreenCount->setSingleStep(1); m_pSliderVideoScreenCount->setTickInterval(1); m_pSliderVideoScreenCount->setOptimalHint(cMinGuestScreens, cHostScreens); m_pSliderVideoScreenCount->setWarningHint(cHostScreens, cMaxGuestScreensForSlider); connect(m_pSliderVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoScreenCountSliderChange())); /* Prepare screen-count editor: */ vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorVideoScreenCount, 3); m_pEditorVideoScreenCount->setMinimum(1); m_pEditorVideoScreenCount->setMaximum(cMaxGuestScreens); connect(m_pEditorVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoScreenCountEditorChange())); /* Prepare scale-factor slider: */ m_pSliderGuestScreenScale->setMinimum(100); m_pSliderGuestScreenScale->setMaximum(200); m_pSliderGuestScreenScale->setPageStep(10); m_pSliderGuestScreenScale->setSingleStep(1); m_pSliderGuestScreenScale->setTickInterval(10); m_pSliderGuestScreenScale->setSnappingEnabled(true); connect(m_pSliderGuestScreenScale, SIGNAL(valueChanged(int)), this, SLOT(sltHandleGuestScreenScaleSliderChange())); /* Prepare scale-factor editor: */ m_pEditorGuestScreenScale->setMinimum(100); m_pEditorGuestScreenScale->setMaximum(200); vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorGuestScreenScale, 5); connect(m_pEditorGuestScreenScale, SIGNAL(valueChanged(int)), this, SLOT(sltHandleGuestScreenScaleEditorChange())); }
void UIMachineSettingsDisplay::checkVRAMRequirements() { /* Make sure guest OS type is set: */ if (m_guestOSType.isNull()) return; /* Get monitors count and base video memory requirements: */ int cGuestScreenCount = m_pEditorVideoScreenCount->value(); quint64 uNeedMBytes = VBoxGlobal::requiredVideoMemory(m_guestOSType.GetId(), cGuestScreenCount) / _1M; /* Initial value: */ m_iMaxVRAMVisible = cGuestScreenCount * 32; /* No more than m_iMaxVRAM: */ if (m_iMaxVRAMVisible > m_iMaxVRAM) m_iMaxVRAMVisible = m_iMaxVRAM; /* No less than 128MB (if possible): */ if (m_iMaxVRAMVisible < 128 && m_iMaxVRAM >= 128) m_iMaxVRAMVisible = 128; /* No less than initial VRAM size (wtf?): */ if (m_iMaxVRAMVisible < m_iInitialVRAM) m_iMaxVRAMVisible = m_iInitialVRAM; #ifdef VBOX_WITH_VIDEOHWACCEL if (m_pCheckbox2DVideo->isChecked() && m_f2DVideoAccelerationSupported) { uNeedMBytes += VBoxGlobal::required2DOffscreenVideoMemory() / _1M; } #endif /* VBOX_WITH_VIDEOHWACCEL */ #ifdef VBOX_WITH_CRHGSMI if (m_pCheckbox3D->isChecked() && m_fWddmModeSupported) { # if 0 uNeedMBytes += VBoxGlobal::required3DWddmOffscreenVideoMemory(m_guestOSType.GetId(), cGuestScreenCount) / _1M; uNeedMBytes = qMax(uNeedMBytes, 128); uNeedMBytes = qMin(uNeedMBytes, 256); # endif /* No less than 256MB (if possible): */ if (m_iMaxVRAMVisible < 256 && m_iMaxVRAM >= 256) m_iMaxVRAMVisible = 256; } #endif /* VBOX_WITH_CRHGSMI */ m_pEditorVideoMemorySize->setMaximum(m_iMaxVRAMVisible); m_pSliderVideoMemorySize->setMaximum(m_iMaxVRAMVisible); m_pSliderVideoMemorySize->setPageStep(calcPageStep(m_iMaxVRAMVisible)); m_pSliderVideoMemorySize->setWarningHint(1, qMin((int)uNeedMBytes, m_iMaxVRAMVisible)); m_pSliderVideoMemorySize->setOptimalHint(qMin((int)uNeedMBytes, m_iMaxVRAMVisible), m_iMaxVRAMVisible); m_pLabelVideoMemorySizeMax->setText(tr("<qt>%1 MB</qt>").arg(m_iMaxVRAMVisible)); }
void UIMachineSettingsDisplay::prepareVideoTab() { /* Prepare memory-size slider: */ CSystemProperties sys = vboxGlobal().virtualBox().GetSystemProperties(); m_iMinVRAM = sys.GetMinGuestVRAM(); m_iMaxVRAM = sys.GetMaxGuestVRAM(); m_iMaxVRAMVisible = m_iMaxVRAM; const uint cHostScreens = QApplication::desktop()->screenCount(); m_pSliderVideoMemorySize->setMinimum(m_iMinVRAM); m_pSliderVideoMemorySize->setMaximum(m_iMaxVRAMVisible); m_pSliderVideoMemorySize->setPageStep(calcPageStep(m_iMaxVRAMVisible)); m_pSliderVideoMemorySize->setSingleStep(m_pSliderVideoMemorySize->pageStep() / 4); m_pSliderVideoMemorySize->setTickInterval(m_pSliderVideoMemorySize->pageStep()); m_pSliderVideoMemorySize->setSnappingEnabled(true); m_pSliderVideoMemorySize->setErrorHint(0, 1); connect(m_pSliderVideoMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoMemorySizeSliderChange())); /* Prepare memory-size editor: */ vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorVideoMemorySize, 4); m_pEditorVideoMemorySize->setMinimum(m_iMinVRAM); m_pEditorVideoMemorySize->setMaximum(m_iMaxVRAMVisible); connect(m_pEditorVideoMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoMemorySizeEditorChange())); /* Prepare screen-count slider: */ const uint cMinGuestScreens = 1; const uint cMaxGuestScreens = sys.GetMaxGuestMonitors(); const uint cMaxGuestScreensForSlider = qMin(cMaxGuestScreens, (uint)8); m_pSliderVideoScreenCount->setMinimum(cMinGuestScreens); m_pSliderVideoScreenCount->setMaximum(cMaxGuestScreensForSlider); m_pSliderVideoScreenCount->setPageStep(1); m_pSliderVideoScreenCount->setSingleStep(1); m_pSliderVideoScreenCount->setTickInterval(1); m_pSliderVideoScreenCount->setOptimalHint(cMinGuestScreens, cHostScreens); m_pSliderVideoScreenCount->setWarningHint(cHostScreens, cMaxGuestScreensForSlider); connect(m_pSliderVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoScreenCountSliderChange())); /* Prepare screen-count editor: */ vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorVideoScreenCount, 3); m_pEditorVideoScreenCount->setMinimum(1); m_pEditorVideoScreenCount->setMaximum(cMaxGuestScreens); connect(m_pEditorVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoScreenCountEditorChange())); #ifndef VBOX_WITH_VIDEOHWACCEL /* Hide check-box if not supported: */ m_pCheckbox2DVideo->setVisible(false); #endif /* VBOX_WITH_VIDEOHWACCEL */ }
void VBoxGuestRAMSlider::init() { ulong fullSize = vboxGlobal().host().GetMemorySize(); CSystemProperties sys = vboxGlobal().virtualBox().GetSystemProperties(); mMinRAM = sys.GetMinGuestRAM(); mMaxRAM = RT_MIN (RT_ALIGN (fullSize, _1G / _1M), sys.GetMaxGuestRAM()); /* Come up with some nice round percent boundaries relative to * the system memory. A max of 75% on a 256GB config is ridiculous, * even on an 8GB rig reserving 2GB for the OS is way to conservative. * The max numbers can be estimated using the following program: * * double calcMaxPct(uint64_t cbRam) * { * double cbRamOverhead = cbRam * 0.0390625; // 160 bytes per page. * double cbRamForTheOS = RT_MAX(RT_MIN(_512M, cbRam * 0.25), _64M); * double OSPct = (cbRamOverhead + cbRamForTheOS) * 100.0 / cbRam; * double MaxPct = 100 - OSPct; * return MaxPct; * } * * int main() * { * uint64_t cbRam = _1G; * for (; !(cbRam >> 33); cbRam += _1G) * printf("%8lluGB %.1f%% %8lluKB\n", cbRam >> 30, calcMaxPct(cbRam), * (uint64_t)(cbRam * calcMaxPct(cbRam) / 100.0) >> 20); * for (; !(cbRam >> 51); cbRam <<= 1) * printf("%8lluGB %.1f%% %8lluKB\n", cbRam >> 30, calcMaxPct(cbRam), * (uint64_t)(cbRam * calcMaxPct(cbRam) / 100.0) >> 20); * return 0; * } * * Note. We might wanna put these calculations somewhere global later. */ /* System RAM amount test */ mMaxRAMAlw = (uint)(0.75 * fullSize); mMaxRAMOpt = (uint)(0.50 * fullSize); if (fullSize < 3072) /* done */; else if (fullSize < 4096) /* 3GB */ mMaxRAMAlw = (uint)(0.80 * fullSize); else if (fullSize < 6144) /* 4-5GB */ { mMaxRAMAlw = (uint)(0.84 * fullSize); mMaxRAMOpt = (uint)(0.60 * fullSize); } else if (fullSize < 8192) /* 6-7GB */ { mMaxRAMAlw = (uint)(0.88 * fullSize); mMaxRAMOpt = (uint)(0.65 * fullSize); } else if (fullSize < 16384) /* 8-15GB */ { mMaxRAMAlw = (uint)(0.90 * fullSize); mMaxRAMOpt = (uint)(0.70 * fullSize); } else if (fullSize < 32768) /* 16-31GB */ { mMaxRAMAlw = (uint)(0.93 * fullSize); mMaxRAMOpt = (uint)(0.75 * fullSize); } else if (fullSize < 65536) /* 32-63GB */ { mMaxRAMAlw = (uint)(0.94 * fullSize); mMaxRAMOpt = (uint)(0.80 * fullSize); } else if (fullSize < 131072) /* 64-127GB */ { mMaxRAMAlw = (uint)(0.95 * fullSize); mMaxRAMOpt = (uint)(0.85 * fullSize); } else /* 128GB- */ { mMaxRAMAlw = (uint)(0.96 * fullSize); mMaxRAMOpt = (uint)(0.90 * fullSize); } /* Now check the calculated maximums are out of the range for the guest * RAM. If so change it accordingly. */ mMaxRAMAlw = RT_MIN (mMaxRAMAlw, mMaxRAM); mMaxRAMOpt = RT_MIN (mMaxRAMOpt, mMaxRAM); setPageStep (calcPageStep (mMaxRAM)); setSingleStep (pageStep() / 4); setTickInterval (pageStep()); /* Setup the scale so that ticks are at page step boundaries */ setMinimum ((mMinRAM / pageStep()) * pageStep()); setMaximum (mMaxRAM); setSnappingEnabled (true); setOptimalHint (mMinRAM, mMaxRAMOpt); setWarningHint (mMaxRAMOpt, mMaxRAMAlw); setErrorHint (mMaxRAMAlw, mMaxRAM); }