Changeset 104819 in vbox for trunk/src/VBox
- Timestamp:
- May 30, 2024 9:17:47 AM (6 months ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/PlatformPropertiesImpl.h
r104780 r104819 67 67 static ULONG s_getMaxNetworkAdapters(ChipsetType_T aChipset); 68 68 static ULONG s_getMaxNetworkAdaptersOfType(ChipsetType_T aChipset, NetworkAttachmentType_T aType); 69 static HRESULT s_getSupportedVRAMRange(GraphicsControllerType_T aGraphicsControllerType, BOOL fAccelerate3DEnabled, ULONG *aMinMB, ULONG *aMaxMB, ULONG *aStrideSizeMB); 69 70 70 71 private: -
trunk/src/VBox/Main/src-all/PlatformPropertiesImpl.cpp
r104786 r104819 822 822 } 823 823 824 HRESULT PlatformProperties::getSupportedVRAMRange(GraphicsControllerType_T aGraphicsControllerType, BOOL fAccelerate3DEnabled, 825 ULONG *aMinMB, ULONG *aMaxMB, ULONG *aStrideSizeMB) 824 /** 825 * Returns the [minimum, maximum] VRAM range and stride size for a given graphics controller. 826 * 827 * @returns HRESULT 828 * @param aGraphicsControllerType Graphics controller type to return values for. 829 * @param fAccelerate3DEnabled whether 3D acceleration is enabled / disabled for the selected graphics controller. 830 * @param aMinMB Where to return the minimum VRAM (in MB). 831 * @param aMaxMB Where to return the maximum VRAM (in MB). 832 * @param aStrideSizeMB Where to return stride size (in MB). Optional, can be NULL. 833 */ 834 /* static */ 835 HRESULT PlatformProperties::s_getSupportedVRAMRange(GraphicsControllerType_T aGraphicsControllerType, BOOL fAccelerate3DEnabled, 836 ULONG *aMinMB, ULONG *aMaxMB, ULONG *aStrideSizeMB) 826 837 { 827 838 #if !defined(VBOX_WITH_VMSVGA) || !defined(VBOX_WITH_VMSVGA3D) … … 860 871 cbMax = SVGA_VRAM_MAX_SIZE; 861 872 #else 862 return setError(VBOX_E_NOT_SUPPORTED, tr("Support for SVGA not available in this version"));873 return VBOX_E_NOT_SUPPORTED; 863 874 #endif 864 875 break; … … 874 885 875 886 default: 876 return setError(E_INVALIDARG, tr("The graphics controller type (%d) is invalid"), aGraphicsControllerType); 877 } 878 879 *aMinMB = (ULONG)(RT_ALIGN_64(cbMin, cbStride) / _1M); 880 *aMaxMB = (ULONG)(RT_ALIGN_64(cbMax, cbStride) / _1M); 881 *aStrideSizeMB = (ULONG)cbStride / _1M; 887 return E_INVALIDARG; 888 } 889 890 /* Convert bytes -> MB, align to stride. */ 891 cbMin = (ULONG)(RT_ALIGN_64(cbMin, cbStride) / _1M); 892 cbMax = (ULONG)(RT_ALIGN_64(cbMax, cbStride) / _1M); 893 cbStride = (ULONG)cbStride / _1M; 882 894 883 895 #define MAKE_POWER_OF_TWO(a_MB) \ … … 885 897 a_MB = a_MB + 1; \ 886 898 887 MAKE_POWER_OF_TWO( *aMinMB);888 MAKE_POWER_OF_TWO( *aMaxMB);889 MAKE_POWER_OF_TWO( *aStrideSizeMB);899 MAKE_POWER_OF_TWO(cbMin); 900 MAKE_POWER_OF_TWO(cbMax); 901 MAKE_POWER_OF_TWO(cbStride); 890 902 891 903 #undef MAKE_POWER_OF_TWO 904 905 /* Finally, clamp the values to our schema definitions before returning. */ 906 cbMin = RT_CLAMP(cbMin, (size_t)SchemaDefs::MinGuestVRAM, (size_t)SchemaDefs::MaxGuestVRAM); 907 cbMax = RT_CLAMP(cbMax, (size_t)SchemaDefs::MinGuestVRAM, (size_t)SchemaDefs::MaxGuestVRAM); 908 909 *aMinMB = (ULONG)cbMin; 910 *aMaxMB = (ULONG)cbMax; 911 if (aStrideSizeMB) 912 *aStrideSizeMB = (ULONG)cbStride; 913 914 return S_OK; 915 } 916 917 HRESULT PlatformProperties::getSupportedVRAMRange(GraphicsControllerType_T aGraphicsControllerType, BOOL fAccelerate3DEnabled, 918 ULONG *aMinMB, ULONG *aMaxMB, ULONG *aStrideSizeMB) 919 { 920 HRESULT hrc = PlatformProperties::s_getSupportedVRAMRange(aGraphicsControllerType, fAccelerate3DEnabled, aMinMB, aMaxMB, 921 aStrideSizeMB); 922 switch (hrc) 923 { 924 case VBOX_E_NOT_SUPPORTED: 925 return setError(VBOX_E_NOT_SUPPORTED, tr("Selected graphics controller not supported in this version")); 926 927 case E_INVALIDARG: 928 return setError(E_INVALIDARG, tr("The graphics controller type (%d) is invalid"), aGraphicsControllerType); 929 930 default: 931 break; 932 } 892 933 893 934 return S_OK; -
trunk/src/VBox/Main/src-server/GraphicsAdapterImpl.cpp
r101200 r104819 229 229 HRESULT GraphicsAdapter::setVRAMSize(ULONG aVRAMSize) 230 230 { 231 /* check VRAM limits */232 if (aVRAMSize > SchemaDefs::MaxGuestVRAM)233 return setError(E_INVALIDARG,234 tr("Invalid VRAM size: %lu MB (must be in range [%lu, %lu] MB)"),235 aVRAMSize, SchemaDefs::MinGuestVRAM, SchemaDefs::MaxGuestVRAM);236 237 231 /* the machine needs to be mutable */ 238 232 AutoMutableStateDependency adep(mParent); 239 233 if (FAILED(adep.hrc())) return adep.hrc(); 234 235 ULONG uMin, uMax; 236 HRESULT hrc = PlatformProperties::s_getSupportedVRAMRange(mData->graphicsControllerType, mData->fAccelerate3D, 237 &uMin, &uMax, NULL /* aStrideSizeMB */); 238 if (FAILED(hrc)) 239 return setError(hrc, 240 tr("Error getting VRAM range for selected graphics controller")); 241 242 /* check VRAM limits */ 243 if ( aVRAMSize < uMin 244 || aVRAMSize > uMax) 245 return setError(E_INVALIDARG, 246 tr("Invalid VRAM size: %lu MB (must be in range [%lu, %lu] MB)"), 247 aVRAMSize, uMin, uMax); 240 248 241 249 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
Note:
See TracChangeset
for help on using the changeset viewer.