VirtualBox

Changeset 95234 in vbox for trunk/src/VBox/Additions/3D/win


Ignore:
Timestamp:
Jun 8, 2022 4:31:28 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
151763
Message:

WDDM: allow gallium based d3d9 and opengl drivers to work with VGPU10. bugref:9845

Location:
trunk/src/VBox/Additions/3D/win
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/3D/win/VBoxGL/GaDrvEnvKMT.cpp

    r93115 r95234  
    149149                                                     void *pvMap);
    150150
     151        /* VGPU10 */
     152        static DECLCALLBACK(int) gaEnvGBSurfaceDefine(void *pvEnv,
     153                                                      SVGAGBSURFCREATE *pCreateParms);
     154
    151155        /*
    152156         * Internal.
     
    385389        case SVGA3D_ARGB_S10E5:     return D3DDDIFMT_A16B16G16R16F;
    386390        case SVGA3D_ARGB_S23E8:     return D3DDDIFMT_A32B32G32R32F;
     391        case SVGA3D_B8G8R8A8_UNORM: return D3DDDIFMT_A8R8G8B8;
     392        case SVGA3D_B8G8R8X8_UNORM: return D3DDDIFMT_X8R8G8B8;
     393        case SVGA3D_R8_UNORM:       /* R8->A8 conversion is not correct, but it does not matter here,
     394                                     * because the D3DDDIFMT_ value is used only to compute bpp, pitch, etc. */
     395        case SVGA3D_A8_UNORM:       return D3DDDIFMT_A8;
    387396        default: break;
    388397    }
     
    10631072}
    10641073
     1074/* static */ DECLCALLBACK(int)
     1075GaDrvEnvKmt::gaEnvGBSurfaceDefine(void *pvEnv,
     1076                                  SVGAGBSURFCREATE *pCreateParms)
     1077{
     1078    GaDrvEnvKmt *pThis = (GaDrvEnvKmt *)pvEnv;
     1079
     1080    VBOXDISPIFESCAPE_SVGAGBSURFACEDEFINE data;
     1081    data.EscapeHdr.escapeCode     = VBOXESC_SVGAGBSURFACEDEFINE;
     1082    data.EscapeHdr.u32CmdSpecific = 0;
     1083    data.CreateParms              = *pCreateParms;
     1084
     1085    D3DKMT_ESCAPE EscapeData;
     1086    memset(&EscapeData, 0, sizeof(EscapeData));
     1087    EscapeData.hAdapter              = pThis->mKmtCallbacks.hAdapter;
     1088    EscapeData.hDevice               = pThis->mKmtCallbacks.hDevice;
     1089    EscapeData.Type                  = D3DKMT_ESCAPE_DRIVERPRIVATE;
     1090    EscapeData.Flags.HardwareAccess  = 1;
     1091    EscapeData.pPrivateDriverData    = &data;
     1092    EscapeData.PrivateDriverDataSize = sizeof(data);
     1093    // EscapeData.hContext              = 0;
     1094
     1095    NTSTATUS Status = pThis->mKmtCallbacks.d3dkmt->pfnD3DKMTEscape(&EscapeData);
     1096    if (Status == STATUS_SUCCESS)
     1097    {
     1098        pCreateParms->gmrid = data.CreateParms.gmrid;
     1099        pCreateParms->cbGB = data.CreateParms.cbGB;
     1100        pCreateParms->u64UserAddress = data.CreateParms.u64UserAddress;
     1101        pCreateParms->u32Sid = data.CreateParms.u32Sid;
     1102
     1103        /* Create a kernel mode allocation for render targets,
     1104         * because we will need kernel mode handles for Present.
     1105         */
     1106        if (pCreateParms->s.flags & SVGA3D_SURFACE_HINT_RENDERTARGET)
     1107        {
     1108            /* First check if the format is supported. */
     1109            D3DDDIFORMAT const ddiFormat = svgaToD3DDDIFormat((SVGA3dSurfaceFormat)pCreateParms->s.format);
     1110            if (ddiFormat != D3DDDIFMT_UNKNOWN)
     1111            {
     1112                GAWDDMSURFACEINFO *pSurfaceInfo = (GAWDDMSURFACEINFO *)malloc(sizeof(GAWDDMSURFACEINFO));
     1113                if (pSurfaceInfo)
     1114                {
     1115                    memset(pSurfaceInfo, 0, sizeof(GAWDDMSURFACEINFO));
     1116
     1117                    VBOXWDDM_ALLOCINFO wddmAllocInfo;
     1118                    memset(&wddmAllocInfo, 0, sizeof(wddmAllocInfo));
     1119
     1120                    wddmAllocInfo.enmType             = VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC;
     1121                    wddmAllocInfo.fFlags.RenderTarget = 1;
     1122                    wddmAllocInfo.hSharedHandle       = 0;
     1123                    wddmAllocInfo.hostID              = pCreateParms->u32Sid;
     1124                    wddmAllocInfo.SurfDesc.slicePitch = 0;
     1125                    wddmAllocInfo.SurfDesc.depth      = pCreateParms->s.size.depth;
     1126                    wddmAllocInfo.SurfDesc.width      = pCreateParms->s.size.width;
     1127                    wddmAllocInfo.SurfDesc.height     = pCreateParms->s.size.height;
     1128                    wddmAllocInfo.SurfDesc.format     = ddiFormat;
     1129                    wddmAllocInfo.SurfDesc.VidPnSourceId = 0;
     1130                    wddmAllocInfo.SurfDesc.bpp        = vboxWddmCalcBitsPerPixel(wddmAllocInfo.SurfDesc.format);
     1131                    wddmAllocInfo.SurfDesc.pitch      = vboxWddmCalcPitch(wddmAllocInfo.SurfDesc.width,
     1132                                                                          wddmAllocInfo.SurfDesc.format);
     1133                    wddmAllocInfo.SurfDesc.cbSize     = vboxWddmCalcSize(wddmAllocInfo.SurfDesc.pitch,
     1134                                                                         wddmAllocInfo.SurfDesc.height,
     1135                                                                         wddmAllocInfo.SurfDesc.format);
     1136                    wddmAllocInfo.SurfDesc.d3dWidth   = vboxWddmCalcWidthForPitch(wddmAllocInfo.SurfDesc.pitch,
     1137                                                                                  wddmAllocInfo.SurfDesc.format);
     1138
     1139                    D3DDDI_ALLOCATIONINFO AllocationInfo;
     1140                    memset(&AllocationInfo, 0, sizeof(AllocationInfo));
     1141                    // AllocationInfo.hAllocation           = NULL;
     1142                    // AllocationInfo.pSystemMem            = NULL;
     1143                    AllocationInfo.pPrivateDriverData    = &wddmAllocInfo;
     1144                    AllocationInfo.PrivateDriverDataSize = sizeof(wddmAllocInfo);
     1145
     1146                    D3DKMT_CREATEALLOCATION CreateAllocation;
     1147                    memset(&CreateAllocation, 0, sizeof(CreateAllocation));
     1148                    CreateAllocation.hDevice         = pThis->mKmtCallbacks.hDevice;
     1149                    CreateAllocation.NumAllocations  = 1;
     1150                    CreateAllocation.pAllocationInfo = &AllocationInfo;
     1151
     1152                    Status = pThis->mKmtCallbacks.d3dkmt->pfnD3DKMTCreateAllocation(&CreateAllocation);
     1153                    if (Status == STATUS_SUCCESS)
     1154                    {
     1155                        pSurfaceInfo->Core.Key    = pCreateParms->u32Sid;
     1156                        pSurfaceInfo->hAllocation = AllocationInfo.hAllocation;
     1157                        if (!RTAvlU32Insert(&pThis->mSurfaceTree, &pSurfaceInfo->Core))
     1158                        {
     1159                            Status = STATUS_NOT_SUPPORTED;
     1160                        }
     1161                    }
     1162
     1163                    if (Status != STATUS_SUCCESS)
     1164                    {
     1165                        free(pSurfaceInfo);
     1166                    }
     1167                }
     1168                else
     1169                {
     1170                    Status = STATUS_NOT_SUPPORTED;
     1171                }
     1172            }
     1173            else
     1174            {
     1175                /* Unsupported render target format. */
     1176                Assert(0);
     1177                Status = STATUS_NOT_SUPPORTED;
     1178            }
     1179        }
     1180
     1181        if (Status != STATUS_SUCCESS)
     1182        {
     1183            gaEnvSurfaceDestroy(pvEnv, pCreateParms->u32Sid);
     1184        }
     1185    }
     1186
     1187    if (Status == STATUS_SUCCESS)
     1188        return 0;
     1189
     1190    Assert(0);
     1191    return -1;
     1192}
     1193
    10651194GaDrvEnvKmt::GaDrvEnvKmt()
    10661195    :
     
    11291258        mEnv.pfnRegionCreate   = gaEnvRegionCreate;
    11301259        mEnv.pfnRegionDestroy  = gaEnvRegionDestroy;
     1260        /* VGPU10 */
     1261        mEnv.pfnGBSurfaceDefine  = gaEnvGBSurfaceDefine;
    11311262    }
    11321263
  • trunk/src/VBox/Additions/3D/win/VBoxGL/Makefile.kmk

    r93115 r95234  
    2626
    2727VBoxGL_TEMPLATE = VBoxMesa3DGuestR3DllMinVista
     28VBoxGL_DEFS     = VBOXGL
    2829# -wd4005: '__useHeader' : redefinition
    2930VBoxGL_CFLAGS  := -wd4005
  • trunk/src/VBox/Additions/3D/win/VBoxGL/VBoxGL.c

    r93115 r95234  
    2828
    2929#include <common/wddm/VBoxMPIf.h>
     30
     31#include <Psapi.h>
    3032
    3133static const char *g_pszSvgaDll =
     
    103105}
    104106
    105 NTSTATUS vboxKmtOpenSharedSurface(D3DKMT_HANDLE hDevice, D3DKMT_HANDLE hSharedSurface, struct stw_shared_surface *pSurf)
     107NTSTATUS vboxKmtOpenSharedSurface(D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, D3DKMT_HANDLE hSharedSurface, struct stw_shared_surface *pSurf)
    106108{
    107109    D3DKMTFUNCTIONS const *d3dkmt = D3DKMTFunctions();
     
    157159            if (Status == STATUS_SUCCESS)
    158160            {
    159                 Assert(OpenAllocationInfoData.PrivateDriverDataSize == sizeof(VBOXWDDM_ALLOCINFO));
    160                 VBOXWDDM_ALLOCINFO *pVBoxAllocInfo = (VBOXWDDM_ALLOCINFO *)OpenAllocationInfoData.pPrivateDriverData;
    161                 pSurf->hResource = OpenResourceData.hResource;
    162                 pSurf->hSurface = OpenAllocationInfoData.hAllocation;
    163                 pSurf->u32Sid = pVBoxAllocInfo->hostID;
     161                if (OpenAllocationInfoData.PrivateDriverDataSize == sizeof(VBOXWDDM_ALLOCINFO))
     162                {
     163                    VBOXWDDM_ALLOCINFO *pVBoxAllocInfo = (VBOXWDDM_ALLOCINFO *)OpenAllocationInfoData.pPrivateDriverData;
     164                    pSurf->hResource = OpenResourceData.hResource;
     165                    pSurf->hSurface = OpenAllocationInfoData.hAllocation;
     166                    pSurf->u32Sid = pVBoxAllocInfo->hostID;
     167                }
     168                else if (OpenAllocationInfoData.PrivateDriverDataSize == sizeof(VBOXDXALLOCATIONDESC))
     169                {
     170                    //VBOXDXALLOCATIONDESC *pAllocDesc = (VBOXDXALLOCATIONDESC *)OpenAllocationInfoData.PrivateDriverDataSize;
     171                    pSurf->hResource = OpenResourceData.hResource;
     172                    pSurf->hSurface = OpenAllocationInfoData.hAllocation;
     173
     174                    VBOXDISPIFESCAPE_SVGAGETSID data;
     175                    memset(&data, 0, sizeof(data));
     176                    data.EscapeHdr.escapeCode = VBOXESC_SVGAGETSID;
     177                    data.hAllocation = OpenAllocationInfoData.hAllocation;
     178                    // data.u32Sid = 0;
     179
     180                    D3DKMT_ESCAPE EscapeData;
     181                    memset(&EscapeData, 0, sizeof(EscapeData));
     182                    EscapeData.hAdapter              = hAdapter;
     183                    EscapeData.hDevice               = hDevice;
     184                    EscapeData.Type                  = D3DKMT_ESCAPE_DRIVERPRIVATE;
     185                    // EscapeData.Flags.HardwareAccess  = 0;
     186                    EscapeData.pPrivateDriverData    = &data;
     187                    EscapeData.PrivateDriverDataSize = sizeof(data);
     188                    // EscapeData.hContext              = 0;
     189                    Status = d3dkmt->pfnD3DKMTEscape(&EscapeData);
     190                    if (Status == STATUS_SUCCESS)
     191                        pSurf->u32Sid = data.u32Sid;
     192                    else
     193                        Assert(0);
     194                }
     195                else
     196                    Assert(0);
    164197            }
    165198        }
     
    271304        if (surface)
    272305        {
     306            D3DKMT_HANDLE hAdapter = GaDrvEnvKmtAdapterHandle(pEnv);
    273307            D3DKMT_HANDLE hDevice = GaDrvEnvKmtDeviceHandle(pEnv);
    274             NTSTATUS Status = vboxKmtOpenSharedSurface(hDevice, (D3DKMT_HANDLE)(uintptr_t)hSharedSurface, surface);
     308            NTSTATUS Status = vboxKmtOpenSharedSurface(hAdapter, hDevice, (D3DKMT_HANDLE)(uintptr_t)hSharedSurface, surface);
    275309            if (Status != STATUS_SUCCESS)
    276310            {
     
    356390};
    357391
     392#ifdef DEBUG
     393typedef BOOL WINAPI FNGetModuleInformation(HANDLE hProcess, HMODULE hModule, LPMODULEINFO lpmodinfo, DWORD cb);
     394typedef FNGetModuleInformation *PFNGetModuleInformation;
     395
     396static PFNGetModuleInformation g_pfnGetModuleInformation = NULL;
     397static HMODULE g_hModPsapi = NULL;
     398static PVOID g_VBoxWDbgVEHandler = NULL;
     399
     400static bool vboxVDbgIsAddressInModule(PVOID pv, const char *pszModuleName)
     401{
     402    HMODULE hMod = GetModuleHandleA(pszModuleName);
     403    if (!hMod)
     404        return false;
     405
     406    if (!g_pfnGetModuleInformation)
     407        return false;
     408
     409    HANDLE hProcess = GetCurrentProcess();
     410    MODULEINFO ModuleInfo = {0};
     411    if (!g_pfnGetModuleInformation(hProcess, hMod, &ModuleInfo, sizeof(ModuleInfo)))
     412        return false;
     413
     414    return    (uintptr_t)ModuleInfo.lpBaseOfDll <= (uintptr_t)pv
     415           && (uintptr_t)pv < (uintptr_t)ModuleInfo.lpBaseOfDll + ModuleInfo.SizeOfImage;
     416}
     417
     418static bool vboxVDbgIsExceptionIgnored(PEXCEPTION_RECORD pExceptionRecord)
     419{
     420    /* Module (dll) names for GetModuleHandle.
     421     * Exceptions originated from these modules will be ignored.
     422     */
     423    static const char *apszIgnoredModuleNames[] =
     424    {
     425        NULL
     426    };
     427
     428    int i = 0;
     429    while (apszIgnoredModuleNames[i])
     430    {
     431        if (vboxVDbgIsAddressInModule(pExceptionRecord->ExceptionAddress, apszIgnoredModuleNames[i]))
     432            return true;
     433
     434        ++i;
     435    }
     436
     437    return false;
     438}
     439
     440static LONG WINAPI vboxVDbgVectoredHandler(struct _EXCEPTION_POINTERS *pExceptionInfo) RT_NOTHROW_DEF
     441{
     442    static volatile bool g_fAllowIgnore = true; /* Might be changed in kernel debugger. */
     443
     444    PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord;
     445    /* PCONTEXT pContextRecord = pExceptionInfo->ContextRecord; */
     446
     447    switch (pExceptionRecord->ExceptionCode)
     448    {
     449        default:
     450            break;
     451        case EXCEPTION_BREAKPOINT:
     452        case EXCEPTION_ACCESS_VIOLATION:
     453        case EXCEPTION_STACK_OVERFLOW:
     454        case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
     455        case EXCEPTION_FLT_DIVIDE_BY_ZERO:
     456        case EXCEPTION_FLT_INVALID_OPERATION:
     457        case EXCEPTION_INT_DIVIDE_BY_ZERO:
     458        case EXCEPTION_ILLEGAL_INSTRUCTION:
     459            if (g_fAllowIgnore && vboxVDbgIsExceptionIgnored(pExceptionRecord))
     460                break;
     461            ASMBreakpoint();
     462            break;
     463        case 0x40010006: /* OutputDebugStringA? */
     464        case 0x4001000a: /* OutputDebugStringW? */
     465            break;
     466    }
     467    return EXCEPTION_CONTINUE_SEARCH;
     468}
     469
     470static void vboxVDbgVEHandlerRegister(void)
     471{
     472    Assert(!g_VBoxWDbgVEHandler);
     473    g_VBoxWDbgVEHandler = AddVectoredExceptionHandler(1, vboxVDbgVectoredHandler);
     474    Assert(g_VBoxWDbgVEHandler);
     475
     476    g_hModPsapi = GetModuleHandleA("Psapi.dll"); /* Usually already loaded. */
     477    if (g_hModPsapi)
     478        g_pfnGetModuleInformation = (PFNGetModuleInformation)GetProcAddress(g_hModPsapi, "GetModuleInformation");
     479}
     480
     481static void vboxVDbgVEHandlerUnregister(void)
     482{
     483    Assert(g_VBoxWDbgVEHandler);
     484    ULONG uResult = RemoveVectoredExceptionHandler(g_VBoxWDbgVEHandler);
     485    Assert(uResult); RT_NOREF(uResult);
     486    g_VBoxWDbgVEHandler = NULL;
     487
     488    g_hModPsapi = NULL;
     489    g_pfnGetModuleInformation = NULL;
     490}
     491#endif /* DEBUG */
     492
    358493BOOL WINAPI DllMain(HINSTANCE hDLLInst,
    359494                    DWORD fdwReason,
     
    365500    {
    366501        case DLL_PROCESS_ATTACH:
     502#ifdef DEBUG
     503            vboxVDbgVEHandlerRegister();
     504#endif
    367505            D3DKMTLoad();
    368506            stw_init(&stw_winsys);
     
    371509
    372510        case DLL_PROCESS_DETACH:
     511#ifdef DEBUG
     512            vboxVDbgVEHandlerUnregister();
     513#endif
    373514            break;
    374515
  • trunk/src/VBox/Additions/3D/win/VBoxICD/Makefile.kmk

    r93115 r95234  
    3535        $(VBOX_PATH_3D)/win/include \
    3636        $(PATH_ROOT)/src/VBox/Additions/WINNT/Graphics/Video \
     37        $(PATH_ROOT)/src/VBox/Devices/Graphics/vmsvga_include \
    3738        $(VBOX_GRAPHICS_INCS)
    3839VBoxICD_SOURCES  = \
  • trunk/src/VBox/Additions/3D/win/VBoxSVGA/winsys/vmw_screen_ioctl.c

    r86307 r95234  
    4747#include "svga3d_caps.h"
    4848#include "svga3d_reg.h"
     49#include "svga3d_surfacedefs.h"
    4950
    5051#include "../wddm_screen.h"
     
    170171                            struct vmw_region **p_region)
    171172{
    172     RT_NOREF10(vws, flags, format, usage, size, numFaces, numMipLevels, sampleCount, buffer_handle, p_region);
    173     // guest-backed surface
    174     // DeviceCallbacks.pfnAllocateCb(pDevice->hDevice, pDdiAllocate);
    175     return (uint32_t)-1;
     173    struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws;
     174
     175    struct vmw_region *region = NULL;
     176    if (p_region)
     177    {
     178       region = CALLOC_STRUCT(vmw_region);
     179       if (!region)
     180          return SVGA3D_INVALID_ID;
     181    }
     182
     183    SVGAGBSURFCREATE createParms;
     184    createParms.s.flags = flags;
     185    createParms.s.format = format;
     186    createParms.s.usage = usage;
     187    createParms.s.size = size;
     188    createParms.s.numFaces = numFaces;
     189    createParms.s.numMipLevels = numMipLevels;
     190    createParms.s.sampleCount = sampleCount;
     191    if (buffer_handle)
     192        createParms.gmrid = buffer_handle;
     193    else
     194        createParms.gmrid = SVGA3D_INVALID_ID;
     195    createParms.u64UserAddress = 0; /* out */
     196    createParms.u32Sid = 0; /* out */
     197
     198    createParms.cbGB = svga3dsurface_get_serialized_size(format,
     199                                                         size,
     200                                                         numMipLevels,
     201                                                         numFaces);
     202
     203    int ret = vws_wddm->pEnv->pfnGBSurfaceDefine(vws_wddm->pEnv->pvEnv, &createParms);
     204    if (ret)
     205    {
     206        FREE(region);
     207        return SVGA3D_INVALID_ID;
     208    }
     209
     210    if (p_region)
     211    {
     212        region->handle      = createParms.gmrid;
     213        region->map_handle  = 0;
     214        region->data        = (void *)(uintptr_t)createParms.u64UserAddress;
     215        region->map_count   = 0;
     216        region->size        = createParms.cbGB;
     217        region->vws_wddm    = vws_wddm;
     218        *p_region = region;
     219    }
     220    return createParms.u32Sid;
    176221}
    177222
     
    195240                      boolean *needs_unref)
    196241{
     242    ASMBreakpoint();
    197243    RT_NOREF4(vws, whandle, req, needs_unref);
    198244    // ???
     
    223269                         struct vmw_region **p_region)
    224270{
     271    ASMBreakpoint();
    225272    RT_NOREF7(vws, whandle, flags, format, numMipLevels, handle, p_region);
    226273    // ??? DeviceCallbacks.pfnLockCb(pDevice->hDevice, );
     
    381428                     boolean allow_cs)
    382429{
     430    ASMBreakpoint();
    383431    RT_NOREF4(region, dont_block, readonly, allow_cs);
    384432    // ???
     
    398446                         boolean allow_cs)
    399447{
     448    ASMBreakpoint();
    400449    RT_NOREF3(region, readonly, allow_cs);
    401450    // ???
     
    471520                        uint32 code_len)
    472521{
     522    ASMBreakpoint();
    473523    RT_NOREF3(vws, type, code_len);
    474524    // DeviceCallbacks.pfnAllocateCb(pDevice->hDevice, pDdiAllocate);
     
    479529vmw_ioctl_shader_destroy(struct vmw_winsys_screen *vws, uint32 shid)
    480530{
     531    ASMBreakpoint();
    481532    RT_NOREF2(vws, shid);
    482533    // ??? DeviceCallbacks.pfnDeallocateCb(pDevice->hDevice, pDdiAllocate);
     
    549600    {
    550601        case DRM_VMW_PARAM_NUM_STREAMS:
    551             gp_arg->value = 1; /* const */
     602            gp_arg->value = 1; /* not used */
    552603            break;
    553604        case DRM_VMW_PARAM_NUM_FREE_STREAMS:
    554             gp_arg->value = 1; /* const */
     605            gp_arg->value = 1; /* not used */
    555606            break;
    556607        case DRM_VMW_PARAM_3D:
    557             gp_arg->value = 1; /** @todo */
     608            gp_arg->value = (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES] & SVGA_CAP_3D) != 0;
    558609            break;
    559610        case DRM_VMW_PARAM_HW_CAPS:
     
    579630            break;
    580631        case DRM_VMW_PARAM_MAX_SURF_MEMORY:
    581             gp_arg->value = vws_wddm->HwInfo.au32Regs[SVGA_REG_MEMORY_SIZE];
     632            if (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES] & SVGA_CAP_GBOBJECTS)
     633                gp_arg->value = vws_wddm->HwInfo.au32Regs[SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB] * 1024 / 2;
     634            else
     635                gp_arg->value = vws_wddm->HwInfo.au32Regs[SVGA_REG_MEMORY_SIZE];
    582636            break;
    583637        case DRM_VMW_PARAM_3D_CAPS_SIZE:
    584             gp_arg->value = (SVGA_FIFO_3D_CAPS_LAST -
    585                                 SVGA_FIFO_3D_CAPS + 1) *
    586                                 sizeof(uint32_t);
     638            if (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES] & SVGA_CAP_GBOBJECTS)
     639                gp_arg->value = SVGA3D_DEVCAP_MAX * sizeof(uint32_t);
     640            else
     641                gp_arg->value = (SVGA_FIFO_3D_CAPS_LAST - SVGA_FIFO_3D_CAPS + 1) * sizeof(uint32_t);
    587642            break;
    588643        case DRM_VMW_PARAM_MAX_MOB_MEMORY:
    589             gp_arg->value = 0;
     644            gp_arg->value = vws_wddm->HwInfo.au32Regs[SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB] * 1024;
    590645            break;
    591646        case DRM_VMW_PARAM_MAX_MOB_SIZE:
    592             gp_arg->value = 0;
     647            gp_arg->value = vws_wddm->HwInfo.au32Regs[SVGA_REG_MOB_MAX_SIZE];
    593648            break;
    594649        case DRM_VMW_PARAM_SCREEN_TARGET:
    595             gp_arg->value = 1;
     650            gp_arg->value = 1; /* not used */
    596651            break;
    597652        case DRM_VMW_PARAM_VGPU10:
    598             gp_arg->value = 0;
     653            gp_arg->value = (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES] & SVGA_CAP_GBOBJECTS)
     654                         && (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES] & SVGA_CAP_CMD_BUFFERS_3/*SVGA_CAP_DX*/)
     655                         && vws_wddm->HwInfo.au32Caps[SVGA3D_DEVCAP_DX/*CONTEXT*/];
    599656            break;
    600657        default: return -1;
     
    607664{
    608665    /* DRM_VMW_GET_3D_CAP */
    609     memcpy(pvCap, &vws_wddm->HwInfo.au32Fifo[SVGA_FIFO_3D_CAPS], cbCap);
     666    if (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES] & SVGA_CAP_GBOBJECTS)
     667        memcpy(pvCap, vws_wddm->HwInfo.au32Caps, cbCap);
     668    else
     669        memcpy(pvCap, &vws_wddm->HwInfo.au32Fifo[SVGA_FIFO_3D_CAPS], cbCap);
    610670    return 0;
    611671}
     
    616676{
    617677   struct drm_vmw_getparam_arg gp_arg;
    618    // struct drm_vmw_get_3d_cap_arg cap_arg;
    619678   unsigned int size;
    620679   int ret;
    621680   uint32_t *cap_buffer;
    622681   boolean drm_gb_capable;
    623    boolean have_drm_2_5 = 1; /* unused */
     682   boolean have_drm_2_5 = 1;
    624683
    625684   struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws;
     
    632691   vws->ioctl.drm_execbuf_version = vws->ioctl.have_drm_2_9 ? 2 : 1;
    633692
    634    drm_gb_capable = 1;
     693   drm_gb_capable = have_drm_2_5;
    635694
    636695   memset(&gp_arg, 0, sizeof(gp_arg));
     
    652711   vws->ioctl.hwversion = gp_arg.value;
    653712
    654    //memset(&gp_arg, 0, sizeof(gp_arg));
    655    //gp_arg.param = DRM_VMW_PARAM_HW_CAPS;
    656    //ret = vboxGetParam(vws_wddm, &gp_arg);
    657    //if (ret)
    658    //   vws->base.have_gb_objects = FALSE;
    659    //else
    660    //   vws->base.have_gb_objects =
    661    //      !!(gp_arg.value & (uint64_t) SVGA_CAP_GBOBJECTS);
    662    /* The driver does not support this feature. */
    663    vws->base.have_gb_objects = FALSE;
     713   memset(&gp_arg, 0, sizeof(gp_arg));
     714   gp_arg.param = DRM_VMW_PARAM_HW_CAPS;
     715   ret = vboxGetParam(vws_wddm, &gp_arg);
     716   if (ret)
     717      vws->base.have_gb_objects = FALSE;
     718   else
     719      vws->base.have_gb_objects =
     720         !!(gp_arg.value & (uint64_t) SVGA_CAP_GBOBJECTS);
    664721   
    665722   if (vws->base.have_gb_objects && !drm_gb_capable)
     
    759816   }
    760817     
    761 //   memset(&cap_arg, 0, sizeof(cap_arg));
    762 //   cap_arg.buffer = (uint64_t) (unsigned long) (cap_buffer);
    763 //   cap_arg.max_size = size;
    764 
    765818   ret = vboxGet3DCap(vws_wddm, cap_buffer, size);
    766819
     
    777830      goto out_no_caps;
    778831   }
     832   if (vws->base.have_vgpu10) {
     833
     834      vws->base.have_generate_mipmap_cmd = TRUE;
     835      vws->base.have_set_predication_cmd = TRUE;
     836      vws->base.have_fence_fd = TRUE;
     837   }
     838
    779839   free(cap_buffer);
    780840   vmw_printf("%s OK\n", __FUNCTION__);
  • trunk/src/VBox/Additions/3D/win/include/VBoxGaDriver.h

    r93115 r95234  
    7171                                               uint32_t u32GmrId,
    7272                                               void *pvMap));
     73    /* VGPU10 */
     74    DECLCALLBACKMEMBER(int, pfnGBSurfaceDefine,(void *pvEnv,
     75                                                SVGAGBSURFCREATE *pCreateParms));
    7376} WDDMGalliumDriverEnv;
    7477
  • trunk/src/VBox/Additions/3D/win/include/VBoxGaHwSVGA.h

    r93115 r95234  
    4646    uint32_t au32Fifo[1024];
    4747
    48     /* Currently SVGA has 244 caps, 512 should be ok for near future.
    49      * This is a copy of SVGA_REG_DEV_CAP enumeration.
     48    /* Currently SVGA has 260 caps, 512 should be ok for near future.
     49     * This is a copy of SVGA3D_DEVCAP_* values returned by the host.
    5050     * Only valid if SVGA_CAP_GBOBJECTS is set in SVGA_REG_CAPABILITIES.
    5151     */
  • trunk/src/VBox/Additions/3D/win/include/VBoxGaTypes.h

    r93115 r95234  
    2323
    2424#include <iprt/types.h>
     25
     26#pragma pack(1) /* VMSVGA structures are '__packed'. */
     27#include <svga3d_caps.h>
     28#include <svga3d_reg.h>
     29#pragma pack()
    2530
    2631#ifdef __cplusplus
     
    7176} GAFENCEQUERY;
    7277
     78typedef struct SVGAGBSURFCREATE
     79{
     80    /* Surface data. */
     81    struct
     82    {
     83        uint64_t flags; /* SVGA3dSurfaceAllFlags */
     84        SVGA3dSurfaceFormat format;
     85        unsigned usage;
     86        SVGA3dSize size;
     87        uint32_t numFaces;
     88        uint32_t numMipLevels;
     89        unsigned sampleCount;
     90    } s;
     91    uint32_t gmrid; /* In/Out: Backing GMR. */
     92    uint32_t cbGB; /* Out: Size of backing memory. */
     93    uint64_t u64UserAddress; /* Out: R3 mapping of the backing memory. */
     94    uint32_t u32Sid; /* Out: Surface id. */
     95} SVGAGBSURFCREATE, *PSVGAGBSURFCREATE;
     96
    7397#ifdef __cplusplus
    7498}
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