Changeset 105864 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Aug 26, 2024 6:45:15 PM (5 months ago)
- Location:
- trunk/src/VBox/Main/src-server
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/GraphicsAdapterImpl.cpp
r104819 r105864 37 37 38 38 #include <iprt/cpp/utils.h> 39 40 41 /** @def MY_VECTOR_ASSIGN_ARRAY 42 * Safe way to copy an array (static + const) into a vector w/ minimal typing. 43 * 44 * @param a_rVector The destination vector reference. 45 * @param a_aSrcArray The source array to assign to the vector. 46 */ 47 #if RT_GNUC_PREREQ(13, 0) && !RT_GNUC_PREREQ(14, 0) && defined(VBOX_WITH_GCC_SANITIZER) 48 /* Workaround for g++ 13.2 incorrectly failing on arrays with a single entry in ASAN builds. 49 This is restricted to [13.0, 14.0), assuming the issue was introduced in the 13 cycle 50 and will be fixed by the time 14 is done. If 14 doesn't fix it, extend the range 51 version by version till it is fixed. */ 52 # define MY_VECTOR_ASSIGN_ARRAY(a_rVector, a_aSrcArray) do { \ 53 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wstringop-overread\""); \ 54 (a_rVector).assign(&a_aSrcArray[0], &a_aSrcArray[RT_ELEMENTS(a_aSrcArray)]); \ 55 _Pragma("GCC diagnostic pop"); \ 56 } while (0) 57 #else 58 # define MY_VECTOR_ASSIGN_ARRAY(a_rVector, a_aSrcArray) do { \ 59 (a_rVector).assign(&a_aSrcArray[0], &a_aSrcArray[RT_ELEMENTS(a_aSrcArray)]); \ 60 } while (0) 61 #endif 39 62 40 63 … … 256 279 } 257 280 258 HRESULT GraphicsAdapter::getAccelerate3DEnabled(BOOL *aAccelerate3DEnabled) 259 { 260 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 261 262 *aAccelerate3DEnabled = mData->fAccelerate3D; 263 264 return S_OK; 265 } 266 267 HRESULT GraphicsAdapter::setAccelerate3DEnabled(BOOL aAccelerate3DEnabled) 281 /** 282 * Static helper function to return all supported features for a given graphics controller. 283 * 284 * @returns VBox status code. 285 * @param enmController Graphics controller to return supported features for. 286 * @param vecSupportedGraphicsControllerFeatures Returned features on success. 287 */ 288 /* static */ 289 int GraphicsAdapter::s_getSupportedFeatures(GraphicsControllerType_T enmController, 290 std::vector<GraphicsFeature_T> &vecSupportedGraphicsFeatures) 291 { 292 switch (enmController) 293 { 294 #ifdef VBOX_WITH_VMSVGA 295 case GraphicsControllerType_VBoxSVGA: 296 { 297 static const GraphicsFeature_T s_aGraphicsFeatures[] = 298 { 299 # ifdef VBOX_WITH_VIDEOHWACCEL 300 GraphicsFeature_Acceleration2DVideo, 301 # endif 302 # ifdef VBOX_WITH_3D_ACCELERATION 303 GraphicsFeature_Acceleration3D 304 # endif 305 }; 306 MY_VECTOR_ASSIGN_ARRAY(vecSupportedGraphicsFeatures, s_aGraphicsFeatures); 307 break; 308 } 309 #endif 310 case GraphicsControllerType_VBoxVGA: 311 RT_FALL_THROUGH(); 312 case GraphicsControllerType_QemuRamFB: 313 { 314 static const GraphicsFeature_T s_aGraphicsFeatures[] = 315 { 316 GraphicsFeature_None 317 }; 318 MY_VECTOR_ASSIGN_ARRAY(vecSupportedGraphicsFeatures, s_aGraphicsFeatures); 319 break; 320 } 321 322 default: 323 return VERR_INVALID_PARAMETER; 324 } 325 326 return VINF_SUCCESS; 327 } 328 329 /** 330 * Static helper function to return whether a given graphics feature for a graphics controller is enabled or not. 331 * 332 * @returns \c true if the given feature is supported, or \c false if not. 333 * @param enmController Graphics controlller to query a feature for. 334 * @param enmFeature Feature to query. 335 */ 336 /* static */ 337 bool GraphicsAdapter::s_isFeatureSupported(GraphicsControllerType_T enmController, GraphicsFeature_T enmFeature) 338 { 339 std::vector<GraphicsFeature_T> vecSupportedGraphicsFeatures; 340 int vrc = GraphicsAdapter::s_getSupportedFeatures(enmController, vecSupportedGraphicsFeatures); 341 if (RT_SUCCESS(vrc)) 342 return std::find(vecSupportedGraphicsFeatures.begin(), 343 vecSupportedGraphicsFeatures.end(), enmFeature) != vecSupportedGraphicsFeatures.end(); 344 return false; 345 } 346 347 HRESULT GraphicsAdapter::setFeature(GraphicsFeature_T aFeature, BOOL aEnabled) 268 348 { 269 349 /* the machine needs to be mutable */ … … 273 353 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 274 354 275 /** @todo check validity! */ 276 277 mParent->i_setModified(Machine::IsModified_GraphicsAdapter); 278 mData.backup(); 279 mData->fAccelerate3D = !!aAccelerate3DEnabled; 280 281 return S_OK; 282 } 283 284 285 HRESULT GraphicsAdapter::getAccelerate2DVideoEnabled(BOOL *aAccelerate2DVideoEnabled) 355 /* Validate if the given feature is supported by this graphics controller. */ 356 if (!GraphicsAdapter::s_isFeatureSupported(mData->graphicsControllerType, aFeature)) 357 return setError(VBOX_E_NOT_SUPPORTED, tr("The graphics controller does not support the given feature")); 358 359 bool *pfSetting = NULL; 360 switch (aFeature) 361 { 362 case GraphicsFeature_Acceleration2DVideo: 363 pfSetting = &mData->fAccelerate2DVideo; 364 break; 365 366 case GraphicsFeature_Acceleration3D: 367 pfSetting = &mData->fAccelerate3D; 368 break; 369 370 default: 371 break; 372 } 373 374 if (!pfSetting) 375 return setError(E_NOTIMPL, tr("The given feature is not implemented")); 376 377 if (*pfSetting != RT_BOOL(aEnabled)) 378 { 379 mParent->i_setModified(Machine::IsModified_GraphicsAdapter); 380 mData.backup(); 381 382 *pfSetting = RT_BOOL(aEnabled); 383 } 384 385 return S_OK; 386 } 387 388 HRESULT GraphicsAdapter::isFeatureEnabled(GraphicsFeature_T aFeature, BOOL *aEnabled) 286 389 { 287 390 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 288 391 289 /* bugref:9691 The legacy VHWA acceleration has been disabled completely. */ 290 *aAccelerate2DVideoEnabled = FALSE; 291 292 return S_OK; 293 } 294 295 HRESULT GraphicsAdapter::setAccelerate2DVideoEnabled(BOOL aAccelerate2DVideoEnabled) 296 { 297 /* the machine needs to be mutable */ 298 AutoMutableStateDependency adep(mParent); 299 if (FAILED(adep.hrc())) return adep.hrc(); 300 301 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 302 303 /** @todo check validity! */ 304 305 mParent->i_setModified(Machine::IsModified_GraphicsAdapter); 306 mData.backup(); 307 mData->fAccelerate2DVideo = !!aAccelerate2DVideoEnabled; 392 bool *pfSetting = NULL; 393 394 switch (aFeature) 395 { 396 #ifndef VBOX_WITH_VIRT_ARMV8 /* On macOS (ARM) we don't support any 2D/3D acceleration for now. */ 397 case GraphicsFeature_Acceleration2DVideo: 398 pfSetting = &mData->fAccelerate2DVideo; 399 *pfSetting = false; /* @bugref{9691} -- The legacy VHWA acceleration has been disabled completely. */ 400 break; 401 402 case GraphicsFeature_Acceleration3D: 403 pfSetting = &mData->fAccelerate3D; 404 break; 405 #endif 406 default: 407 break; 408 } 409 410 if (!pfSetting) 411 return VBOX_E_NOT_SUPPORTED; 412 413 *aEnabled = *pfSetting; 308 414 309 415 return S_OK; -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r105658 r105864 15232 15232 if (FAILED(hrc)) return hrc; 15233 15233 15234 hrc = mGraphicsAdapter->COMSETTER(Accelerate2DVideoEnabled)(fAccelerate2DVideoEnabled); 15235 if (FAILED(hrc)) return hrc; 15234 hrc = mGraphicsAdapter->SetFeature(GraphicsFeature_Acceleration2DVideo, fAccelerate2DVideoEnabled); 15235 if (FAILED(hrc)) 15236 { 15237 if (hrc != VBOX_E_NOT_SUPPORTED) 15238 return hrc; 15239 } 15236 15240 15237 15241 BOOL fAccelerate3DEnabled; … … 15239 15243 if (FAILED(hrc)) return hrc; 15240 15244 15241 hrc = mGraphicsAdapter->COMSETTER(Accelerate3DEnabled)(fAccelerate3DEnabled); 15242 if (FAILED(hrc)) return hrc; 15245 hrc = mGraphicsAdapter->SetFeature(GraphicsFeature_Acceleration2DVideo, fAccelerate3DEnabled); 15246 if (FAILED(hrc)) 15247 { 15248 if (hrc != VBOX_E_NOT_SUPPORTED) 15249 return hrc; 15250 } 15243 15251 15244 15252 /* Apply network adapters defaults */ -
trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp
r105455 r105864 1176 1176 } 1177 1177 1178 HRESULT SystemProperties::getSupportedGraphicsFeatures(std::vector<GraphicsFeature_T> &aSupportedGraphicsFeatures) 1179 { 1180 static const GraphicsFeature_T s_aGraphicsFeatures[] = 1181 { 1182 #ifdef VBOX_WITH_VIDEOHWACCEL 1183 GraphicsFeature_Acceleration2DVideo, 1184 #endif 1185 #ifdef VBOX_WITH_3D_ACCELERATION 1186 GraphicsFeature_Acceleration3D 1187 #endif 1188 }; 1189 MY_VECTOR_ASSIGN_ARRAY(aSupportedGraphicsFeatures, s_aGraphicsFeatures); 1190 1191 return S_OK; 1192 } 1193 1178 1194 HRESULT SystemProperties::getSupportedRecordingFeatures(std::vector<RecordingFeature_T> &aSupportedRecordingFeatures) 1179 1195 {
Note:
See TracChangeset
for help on using the changeset viewer.