VirtualBox

Changeset 104780 in vbox for trunk/src/VBox/Main/src-all


Ignore:
Timestamp:
May 24, 2024 2:15:44 PM (12 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
163351
Message:

Main: Added new API IPlatformProperties::getSupportedVRAMRange() to return the VRAM range of a given graphics controller. bugref:​10693

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-all/PlatformPropertiesImpl.cpp

    r102113 r104780  
    3232#include "Global.h"
    3333
     34#include "VBox/vmm/pdmcritsect.h"            /* required by DevVGA.h */
     35#include "VBox/param.h"                      /* Ditto. */
     36#include "DevVGA.h"
     37
    3438#include <iprt/cpp/utils.h>
    3539
     
    821825}
    822826
     827HRESULT PlatformProperties::getSupportedVRAMRange(GraphicsControllerType_T aGraphicsControllerType, BOOL fAccelerate3DEnabled,
     828                                                  ULONG *aMinMB, ULONG *aMaxMB, ULONG *aStrideSizeMB)
     829{
     830#if !defined(VBOX_WITH_VMSVGA) || !defined(VBOX_WITH_VMSVGA3D)
     831    RT_NOREF(fAccelerate3DEnabled);
     832#endif
     833
     834    size_t cbMin;
     835    size_t cbMax;
     836    size_t cbStride = _1M; /* Default stride for all controllers. */
     837
     838    switch (aGraphicsControllerType)
     839    {
     840        case GraphicsControllerType::VBoxVGA:
     841        {
     842            cbMin = VGA_VRAM_MIN;
     843            cbMax = VGA_VRAM_MAX;
     844            break;
     845        }
     846
     847        case GraphicsControllerType::VMSVGA:
     848        {
     849            cbMin = VGA_VRAM_MIN;
     850            cbMax = VGA_VRAM_MAX;
     851            break;
     852        }
     853
     854        case GraphicsControllerType::VBoxSVGA:
     855        {
     856#ifdef VBOX_WITH_VMSVGA
     857# ifdef VBOX_WITH_VMSVGA3D
     858            if (fAccelerate3DEnabled)
     859                cbMin = SVGA_VRAM_MIN_SIZE_3D;
     860            else
     861# endif /* VBOX_WITH_VMSVGA3D */
     862                cbMin = SVGA_VRAM_MIN_SIZE;
     863            cbMax = SVGA_VRAM_MAX_SIZE;
     864#else
     865            return setError(VBOX_E_NOT_SUPPORTED, tr("Support for SVGA not available in this version"));
     866#endif
     867            break;
     868        }
     869
     870        case GraphicsControllerType::QemuRamFB:
     871        {
     872            /* We seem to hardcode 32-bit (4 bytes) as BPP, see RAMFB_BPP in QemuRamfb.c. */
     873            cbMin = 4 /* BPP in bytes */ * 16    * 16;    /* Values taken from qemu/hw/display/ramfb.c */
     874            cbMax = 4 /* BPP in bytes */ * 16000 * 12000; /* Values taken from bochs-vbe.h. */
     875            break;
     876        }
     877
     878        default:
     879            return setError(E_INVALIDARG, tr("The graphics controller type (%d) is invalid"), aGraphicsControllerType);
     880    }
     881
     882    *aMinMB        = (ULONG)(RT_ALIGN_64(cbMin, cbStride) / _1M);
     883    *aMaxMB        = (ULONG)(RT_ALIGN_64(cbMax, cbStride) / _1M);
     884    *aStrideSizeMB = (ULONG)cbStride / _1M;
     885
     886#define MAKE_POWER_OF_TWO(a_MB) \
     887    while (!RT_IS_POWER_OF_TWO(a_MB)) \
     888        a_MB = a_MB + 1; \
     889
     890    MAKE_POWER_OF_TWO(*aMinMB);
     891    MAKE_POWER_OF_TWO(*aMaxMB);
     892    MAKE_POWER_OF_TWO(*aStrideSizeMB);
     893
     894#undef MAKE_POWER_OF_TWO
     895
     896    return S_OK;
     897}
     898
    823899HRESULT PlatformProperties::getSupportedAudioControllerTypes(std::vector<AudioControllerType_T> &aSupportedAudioControllerTypes)
    824900{
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette