VirtualBox

Changeset 104780 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 24, 2024 2:15:44 PM (6 months ago)
Author:
vboxsync
Message:

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

Location:
trunk/src/VBox/Main
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/Makefile.kmk

    r104683 r104780  
    212212VBOX_MAIN_DEFS += VBOX_WITH_NEW_SYS_V_KEYGEN
    213213
     214# Main graphics include paths. Used by VBoxC and VBoxSVC.
     215VBOX_MAIN_GRAPHICS_INCS = \
     216        $(PATH_ROOT)/src/VBox/Devices/Graphics/ \
     217        $(if $(VBOX_WITH_VMSVGA),$(PATH_ROOT)/src/VBox/Devices/Graphics/vmsvga_include,) \
     218        $(VBOX_GRAPHICS_INCS)
    214219
    215220VBOX_IDL_FILE.MSCOM    = $(VBOX_PATH_SDK)/bindings/mscom/idl/VirtualBox.idl
     
    568573        $(dir $(VBOX_XML_SCHEMADEFS_H)) \
    569574        $(VBOX_MAIN_APIWRAPPER_INCS) \
     575        $(VBOX_MAIN_GRAPHICS_INCS) \
    570576        . \
    571         $(VBOX_GRAPHICS_INCS)
    572577 VBoxSVC_INCS.win = \
    573578        $(VBoxCOM_0_OUTDIR)
     
    10691074        $(dir $(VBOX_XML_SCHEMADEFS_H)) \
    10701075        $(VBOX_MAIN_APIWRAPPER_DIR)/dtrace \
    1071         $(VBOX_GRAPHICS_INCS)
     1076        $(VBOX_MAIN_GRAPHICS_INCS)
    10721077 VBoxC_INCS.win     = \
    10731078        $(VBoxCOM_0_OUTDIR) \
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r103553 r104780  
    1282412824    name="IPlatformProperties"
    1282512825    extends="$unknown"
    12826     uuid="45def725-ab32-4a0a-a85e-fae56249d547"
     12826    uuid="a23502e4-cc54-490f-a344-c8ca8813f906"
    1282712827    wsmap="managed"
    1282812828    rest="managed"
     
    1308113081      <param name="maxInstances" type="unsigned long" dir="return">
    1308213082        <desc>The maximum number of instances for the given storage bus.</desc>
     13083      </param>
     13084    </method>
     13085
     13086    <method name="getSupportedVRAMRange">
     13087      <desc>
     13088        Returns the VRAM range of a given graphics controller.
     13089      </desc>
     13090
     13091      <param name="graphicsControllerType" type="GraphicsControllerType" dir="in">
     13092        <desc>Graphics controller type to return VRAM range for.</desc>
     13093      </param>
     13094
     13095      <param name="accelerate3DEnabled" type="boolean" dir="in">
     13096        <desc>Whether 3D acceleration for the graphics controller type is enabled or not.
     13097          Ignored if the given graphics controller does not support 3D acceleration.</desc>
     13098      </param>
     13099
     13100      <param name="minMB" type="unsigned long" dir="out">
     13101        <desc>The minimum size (in MB) the graphics controller supports.</desc>
     13102      </param>
     13103
     13104      <param name="maxMB" type="unsigned long" dir="out">
     13105        <desc>The maximum size (in MB) the graphics controller supports.</desc>
     13106      </param>
     13107
     13108      <param name="strideSizeMB" type="unsigned long" dir="return">
     13109        <desc>The stride size the graphics controller supports. This marks the allowed steps between the values
     13110          when increasing / decreasing the VRAM size.</desc>
    1308313111      </param>
    1308413112    </method>
  • trunk/src/VBox/Main/include/PlatformPropertiesImpl.h

    r103977 r104780  
    108108                                        StorageBus_T aBus,
    109109                                        ULONG *aMaxInstances) RT_OVERRIDE;
     110    HRESULT getSupportedVRAMRange(GraphicsControllerType_T aGraphicsControllerType, BOOL fAccelerate3DEnabled,
     111                                  ULONG *aMinMB, ULONG *aMaxMB, ULONG *aStrideSizeMB) RT_OVERRIDE;
    110112    HRESULT getDeviceTypesForStorageBus(StorageBus_T aBus,
    111113                                        std::vector<DeviceType_T> &aDeviceTypes) RT_OVERRIDE;
  • 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{
  • trunk/src/VBox/Main/testcase/tstAPI.cpp

    r99775 r104780  
    11481148    RTPrintf("\n");
    11491149#endif
     1150
     1151    do {
     1152        PlatformArchitecture_T platformArch = PlatformArchitecture_x86;
     1153        ComPtr<IPlatformProperties> platformProperties;
     1154        CHECK_ERROR_BREAK(virtualBox, GetPlatformProperties(platformArch, platformProperties.asOutParam()));
     1155        ULONG uMinMB, uMaxMB, uStrideMB;
     1156        CHECK_ERROR_BREAK(platformProperties, GetSupportedVRAMRange(GraphicsControllerType_VBoxVGA, TRUE /* fAccelerate3DEnabled */, &uMinMB, &uMaxMB, &uStrideMB));
     1157        ASSERT_BREAK(uMinMB && RT_IS_POWER_OF_TWO(uMinMB));
     1158        ASSERT_BREAK(uMaxMB && RT_IS_POWER_OF_TWO(uMaxMB));
     1159        ASSERT_BREAK(uStrideMB && RT_IS_POWER_OF_TWO(uStrideMB));
     1160    } while (0);
    11501161
    11511162#if 1
Note: See TracChangeset for help on using the changeset viewer.

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