Changeset 105119 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jul 3, 2024 4:04:01 PM (8 months ago)
- svn:sync-xref-src-repo-rev:
- 163749
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r105104 r105119 1448 1448 } 1449 1449 1450 #ifdef VBOX_WITH_3D_ACCELERATION1451 /* static */1452 bool UICommon::isWddmCompatibleOsType(const QString &strGuestOSTypeId)1453 {1454 return strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("WindowsVista"))1455 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows7"))1456 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows8"))1457 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows81"))1458 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows10"))1459 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows11"))1460 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows2008"))1461 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows2012"))1462 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows2016"))1463 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows2019"));1464 }1465 #endif /* VBOX_WITH_3D_ACCELERATION */1466 1467 /* static */1468 quint64 UICommon::requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors /* = 1 */)1469 {1470 /* We create a list of the size of all available host monitors. This list1471 * is sorted by value and by starting with the biggest one, we calculate1472 * the memory requirements for every guest screen. This is of course not1473 * correct, but as we can't predict on which host screens the user will1474 * open the guest windows, this is the best assumption we can do, cause it1475 * is the worst case. */1476 const int cHostScreens = UIDesktopWidgetWatchdog::screenCount();1477 QVector<int> screenSize(qMax(cMonitors, cHostScreens), 0);1478 for (int i = 0; i < cHostScreens; ++i)1479 {1480 QRect r = gpDesktop->screenGeometry(i);1481 screenSize[i] = r.width() * r.height();1482 }1483 /* Now sort the vector: */1484 std::sort(screenSize.begin(), screenSize.end(), std::greater<int>());1485 /* For the case that there are more guest screens configured then host1486 * screens available, replace all zeros with the greatest value in the1487 * vector. */1488 for (int i = 0; i < screenSize.size(); ++i)1489 if (screenSize.at(i) == 0)1490 screenSize.replace(i, screenSize.at(0));1491 1492 quint64 uNeedBits = 0;1493 for (int i = 0; i < cMonitors; ++i)1494 {1495 /* Calculate summary required memory amount in bits: */1496 uNeedBits += (screenSize.at(i) * /* with x height */1497 32 + /* we will take the maximum possible bpp for now */1498 8 * _1M) + /* current cache per screen - may be changed in future */1499 8 * 4096; /* adapter info */1500 }1501 /* Translate value into megabytes with rounding to highest side: */1502 quint64 uNeedMBytes = uNeedBits % (8 * _1M)1503 ? uNeedBits / (8 * _1M) + 11504 : uNeedBits / (8 * _1M) /* convert to megabytes */;1505 1506 if (strGuestOSTypeId.startsWith("Windows"))1507 {1508 /* Windows guests need offscreen VRAM too for graphics acceleration features: */1509 #ifdef VBOX_WITH_3D_ACCELERATION1510 if (isWddmCompatibleOsType(strGuestOSTypeId))1511 {1512 /* WDDM mode, there are two surfaces for each screen: shadow & primary: */1513 uNeedMBytes *= 3;1514 }1515 else1516 #endif /* VBOX_WITH_3D_ACCELERATION */1517 {1518 uNeedMBytes *= 2;1519 }1520 }1521 1522 return uNeedMBytes * _1M;1523 }1524 1525 KGraphicsControllerType UICommon::getRecommendedGraphicsController(const QString &strGuestOSTypeId) const1526 {1527 return gpGlobalSession->guestOSTypeManager().getRecommendedGraphicsController(strGuestOSTypeId);1528 }1529 1530 1450 /* static */ 1531 1451 void UICommon::setHelpKeyword(QObject *pObject, const QString &strHelpKeyword) -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h
r105104 r105119 43 43 #endif 44 44 45 /* COM includes: */46 #include "KGraphicsControllerType.h"47 48 /* Other VBox includes: */49 #include <iprt/types.h>50 51 45 /* Forward declarations: */ 52 46 class QSessionManager; … … 308 302 /** @} */ 309 303 310 /** @name Display stuff.311 * @{ */312 #ifdef VBOX_WITH_3D_ACCELERATION313 /** Returns whether guest OS type with passed @a strGuestOSTypeId is WDDM compatible. */314 static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId);315 #endif316 /** Returns the required video memory in bytes for the current desktop317 * resolution at maximum possible screen depth in bpp. */318 static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);319 KGraphicsControllerType getRecommendedGraphicsController(const QString &strGuestOSTypeId) const;320 /** @} */321 322 304 /** @name Thread stuff. 323 305 * @{ */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIGuestOSType.cpp
r103906 r105119 5 5 6 6 /* 7 * Copyright (C) 2006-202 3Oracle and/or its affiliates.7 * Copyright (C) 2006-2024 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 28 28 /* GUI includes: */ 29 29 #include "UICommon.h" 30 #include "UIDesktopWidgetWatchdog.h" 30 31 #include "UIGlobalSession.h" 31 32 #include "UIGuestOSType.h" … … 36 37 #include "CSystemProperties.h" 37 38 39 /* VirtualBox interface declarations: */ 40 #include <VBox/com/VirtualBox.h> 41 42 43 /********************************************************************************************************************************* 44 * Class UIGuestOSTypeHelpers implementation. * 45 *********************************************************************************************************************************/ 46 47 #ifdef VBOX_WITH_3D_ACCELERATION 48 bool UIGuestOSTypeHelpers::isWddmCompatibleOsType(const QString &strGuestOSTypeId) 49 { 50 return strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("WindowsVista")) 51 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows7")) 52 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows8")) 53 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows81")) 54 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows10")) 55 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows11")) 56 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows2008")) 57 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows2012")) 58 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows2016")) 59 || strGuestOSTypeId.startsWith(GUEST_OS_ID_STR_PARTIAL("Windows2019")); 60 } 61 #endif /* VBOX_WITH_3D_ACCELERATION */ 62 63 quint64 UIGuestOSTypeHelpers::requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors /* = 1 */) 64 { 65 /* We create a list of the size of all available host monitors. This list 66 * is sorted by value and by starting with the biggest one, we calculate 67 * the memory requirements for every guest screen. This is of course not 68 * correct, but as we can't predict on which host screens the user will 69 * open the guest windows, this is the best assumption we can do, cause it 70 * is the worst case. */ 71 const int cHostScreens = UIDesktopWidgetWatchdog::screenCount(); 72 QVector<int> screenSize(qMax(cMonitors, cHostScreens), 0); 73 for (int i = 0; i < cHostScreens; ++i) 74 { 75 QRect r = gpDesktop->screenGeometry(i); 76 screenSize[i] = r.width() * r.height(); 77 } 78 /* Now sort the vector: */ 79 std::sort(screenSize.begin(), screenSize.end(), std::greater<int>()); 80 /* For the case that there are more guest screens configured then host 81 * screens available, replace all zeros with the greatest value in the 82 * vector. */ 83 for (int i = 0; i < screenSize.size(); ++i) 84 if (screenSize.at(i) == 0) 85 screenSize.replace(i, screenSize.at(0)); 86 87 quint64 uNeedBits = 0; 88 for (int i = 0; i < cMonitors; ++i) 89 { 90 /* Calculate summary required memory amount in bits: */ 91 uNeedBits += (screenSize.at(i) * /* with x height */ 92 32 + /* we will take the maximum possible bpp for now */ 93 8 * _1M) + /* current cache per screen - may be changed in future */ 94 8 * 4096; /* adapter info */ 95 } 96 /* Translate value into megabytes with rounding to highest side: */ 97 quint64 uNeedMBytes = uNeedBits % (8 * _1M) 98 ? uNeedBits / (8 * _1M) + 1 99 : uNeedBits / (8 * _1M) /* convert to megabytes */; 100 101 if (strGuestOSTypeId.startsWith("Windows")) 102 { 103 /* Windows guests need offscreen VRAM too for graphics acceleration features: */ 104 #ifdef VBOX_WITH_3D_ACCELERATION 105 if (isWddmCompatibleOsType(strGuestOSTypeId)) 106 { 107 /* WDDM mode, there are two surfaces for each screen: shadow & primary: */ 108 uNeedMBytes *= 3; 109 } 110 else 111 #endif /* VBOX_WITH_3D_ACCELERATION */ 112 { 113 uNeedMBytes *= 2; 114 } 115 } 116 117 return uNeedMBytes * _1M; 118 } 119 120 121 /********************************************************************************************************************************* 122 * Class UIGuestOSTypeManager implementation. * 123 *********************************************************************************************************************************/ 38 124 39 125 void UIGuestOSTypeManager::reCacheGuestOSTypes() -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIGuestOSType.h
r103906 r105119 5 5 6 6 /* 7 * Copyright (C) 2006-202 3Oracle and/or its affiliates.7 * Copyright (C) 2006-2024 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 39 39 /* COM includes: */ 40 40 #include "CGuestOSType.h" 41 42 /** Holds various Guest OS type helper stuff. */ 43 namespace UIGuestOSTypeHelpers 44 { 45 #ifdef VBOX_WITH_3D_ACCELERATION 46 /** Returns whether guest OS type with passed @a strGuestOSTypeId is WDDM compatible. */ 47 SHARED_LIBRARY_STUFF bool isWddmCompatibleOsType(const QString &strGuestOSTypeId); 48 #endif 49 50 /** Returns the required video memory in bytes for the current desktop 51 * resolution at maximum possible screen depth in bpp. */ 52 SHARED_LIBRARY_STUFF quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1); 53 } 41 54 42 55 /** Represents guest OS family info. */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIVideoMemoryEditor.cpp
r104313 r105119 5 5 6 6 /* 7 * Copyright (C) 2019-202 3Oracle and/or its affiliates.7 * Copyright (C) 2019-2024 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 35 35 /* GUI includes: */ 36 36 #include "QIAdvancedSlider.h" 37 #include "UICommon.h"38 37 #include "UIGlobalSession.h" 38 #include "UIGuestOSType.h" 39 39 #include "UIVideoMemoryEditor.h" 40 40 … … 323 323 324 324 /* Get monitors count and recommended VRAM: */ 325 int iNeedMBytes = UI Common::requiredVideoMemory(m_strGuestOSTypeId, m_cGuestScreenCount) / _1M;325 int iNeedMBytes = UIGuestOSTypeHelpers::requiredVideoMemory(m_strGuestOSTypeId, m_cGuestScreenCount) / _1M; 326 326 327 327 /* Adjust visible maximum VRAM to be no less than 128MB (if possible): */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp
r104313 r105119 5 5 6 6 /* 7 * Copyright (C) 2008-202 3Oracle and/or its affiliates.7 * Copyright (C) 2008-2024 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 38 38 #include "UIGlobalSession.h" 39 39 #include "UIGraphicsControllerEditor.h" 40 #ifdef VBOX_WITH_3D_ACCELERATION 41 # include "UIDisplayScreenFeaturesEditor.h" 42 #endif 40 #include "UIGuestOSType.h" 43 41 #include "UIMachineSettingsDisplay.h" 44 42 #include "UIMonitorCountEditor.h" … … 48 46 #include "UIVideoMemoryEditor.h" 49 47 #include "UIVRDESettingsEditor.h" 48 #ifdef VBOX_WITH_3D_ACCELERATION 49 # include "UIDisplayScreenFeaturesEditor.h" 50 #endif 50 51 51 52 /* COM includes: */ … … 336 337 #ifdef VBOX_WITH_3D_ACCELERATION 337 338 /* Check if WDDM mode supported by the guest OS type: */ 338 m_fWddmModeSupported = UI Common::isWddmCompatibleOsType(m_strGuestOSTypeId);339 m_fWddmModeSupported = UIGuestOSTypeHelpers::isWddmCompatibleOsType(m_strGuestOSTypeId); 339 340 m_pEditorVideoMemorySize->set3DAccelerationSupported(m_fWddmModeSupported); 340 341 #endif /* VBOX_WITH_3D_ACCELERATION */ 341 342 /* Acquire recommended graphics controller type: */ 342 m_enmGraphicsControllerTypeRecommended = uiCommon().getRecommendedGraphicsController(m_strGuestOSTypeId); 343 m_enmGraphicsControllerTypeRecommended = 344 gpGlobalSession->guestOSTypeManager().getRecommendedGraphicsController(m_strGuestOSTypeId); 343 345 /* Revalidate: */ 344 346 revalidate(); … … 638 640 if (shouldWeWarnAboutLowVRAM() && !m_strGuestOSTypeId.isEmpty()) 639 641 { 640 quint64 uNeedBytes = UI Common::requiredVideoMemory(m_strGuestOSTypeId, m_pEditorMonitorCount->value());642 quint64 uNeedBytes = UIGuestOSTypeHelpers::requiredVideoMemory(m_strGuestOSTypeId, m_pEditorMonitorCount->value()); 641 643 642 644 /* Basic video RAM amount test: */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp
r105081 r105119 5 5 6 6 /* 7 * Copyright (C) 2006-202 3Oracle and/or its affiliates.7 * Copyright (C) 2006-2024 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 31 31 32 32 /* GUI includes: */ 33 #include "UICommon.h"34 33 #include "UIGlobalSession.h" 35 34 #include "UIGuestOSType.h" … … 180 179 /* Correct the VRAM size since API does not take fullscreen memory requirements into account: */ 181 180 CGraphicsAdapter comGraphics = m_machine.GetGraphicsAdapter(); 182 comGraphics.SetVRAMSize(qMax(comGraphics.GetVRAMSize(), (ULONG)(UICommon::requiredVideoMemory(m_guestOSTypeId) / _1M))); 181 comGraphics.SetVRAMSize(qMax(comGraphics.GetVRAMSize(), 182 (ULONG)(UIGuestOSTypeHelpers::requiredVideoMemory(m_guestOSTypeId) / _1M))); 183 183 /* Enabled I/O APIC explicitly in we have more than 1 VCPU: */ 184 184 if (iVPUCount > 1) … … 242 242 return fResult; 243 243 244 /* Inform UI Commonabout it: */244 /* Inform UIMediumEnumerator about it: */ 245 245 gpMediumEnumerator->createMedium(UIMedium(newVirtualDisk, UIMediumDeviceType_HardDisk, KMediumState_Created)); 246 246
Note:
See TracChangeset
for help on using the changeset viewer.