Changeset 95234 in vbox for trunk/src/VBox
- Timestamp:
- Jun 8, 2022 4:31:28 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 151763
- Location:
- trunk/src/VBox/Additions
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/3D/win/VBoxGL/GaDrvEnvKMT.cpp
r93115 r95234 149 149 void *pvMap); 150 150 151 /* VGPU10 */ 152 static DECLCALLBACK(int) gaEnvGBSurfaceDefine(void *pvEnv, 153 SVGAGBSURFCREATE *pCreateParms); 154 151 155 /* 152 156 * Internal. … … 385 389 case SVGA3D_ARGB_S10E5: return D3DDDIFMT_A16B16G16R16F; 386 390 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; 387 396 default: break; 388 397 } … … 1063 1072 } 1064 1073 1074 /* static */ DECLCALLBACK(int) 1075 GaDrvEnvKmt::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 1065 1194 GaDrvEnvKmt::GaDrvEnvKmt() 1066 1195 : … … 1129 1258 mEnv.pfnRegionCreate = gaEnvRegionCreate; 1130 1259 mEnv.pfnRegionDestroy = gaEnvRegionDestroy; 1260 /* VGPU10 */ 1261 mEnv.pfnGBSurfaceDefine = gaEnvGBSurfaceDefine; 1131 1262 } 1132 1263 -
trunk/src/VBox/Additions/3D/win/VBoxGL/Makefile.kmk
r93115 r95234 26 26 27 27 VBoxGL_TEMPLATE = VBoxMesa3DGuestR3DllMinVista 28 VBoxGL_DEFS = VBOXGL 28 29 # -wd4005: '__useHeader' : redefinition 29 30 VBoxGL_CFLAGS := -wd4005 -
trunk/src/VBox/Additions/3D/win/VBoxGL/VBoxGL.c
r93115 r95234 28 28 29 29 #include <common/wddm/VBoxMPIf.h> 30 31 #include <Psapi.h> 30 32 31 33 static const char *g_pszSvgaDll = … … 103 105 } 104 106 105 NTSTATUS vboxKmtOpenSharedSurface(D3DKMT_HANDLE h Device, D3DKMT_HANDLE hSharedSurface, struct stw_shared_surface *pSurf)107 NTSTATUS vboxKmtOpenSharedSurface(D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, D3DKMT_HANDLE hSharedSurface, struct stw_shared_surface *pSurf) 106 108 { 107 109 D3DKMTFUNCTIONS const *d3dkmt = D3DKMTFunctions(); … … 157 159 if (Status == STATUS_SUCCESS) 158 160 { 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); 164 197 } 165 198 } … … 271 304 if (surface) 272 305 { 306 D3DKMT_HANDLE hAdapter = GaDrvEnvKmtAdapterHandle(pEnv); 273 307 D3DKMT_HANDLE hDevice = GaDrvEnvKmtDeviceHandle(pEnv); 274 NTSTATUS Status = vboxKmtOpenSharedSurface(h Device, (D3DKMT_HANDLE)(uintptr_t)hSharedSurface, surface);308 NTSTATUS Status = vboxKmtOpenSharedSurface(hAdapter, hDevice, (D3DKMT_HANDLE)(uintptr_t)hSharedSurface, surface); 275 309 if (Status != STATUS_SUCCESS) 276 310 { … … 356 390 }; 357 391 392 #ifdef DEBUG 393 typedef BOOL WINAPI FNGetModuleInformation(HANDLE hProcess, HMODULE hModule, LPMODULEINFO lpmodinfo, DWORD cb); 394 typedef FNGetModuleInformation *PFNGetModuleInformation; 395 396 static PFNGetModuleInformation g_pfnGetModuleInformation = NULL; 397 static HMODULE g_hModPsapi = NULL; 398 static PVOID g_VBoxWDbgVEHandler = NULL; 399 400 static 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 418 static 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 440 static 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 470 static 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 481 static 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 358 493 BOOL WINAPI DllMain(HINSTANCE hDLLInst, 359 494 DWORD fdwReason, … … 365 500 { 366 501 case DLL_PROCESS_ATTACH: 502 #ifdef DEBUG 503 vboxVDbgVEHandlerRegister(); 504 #endif 367 505 D3DKMTLoad(); 368 506 stw_init(&stw_winsys); … … 371 509 372 510 case DLL_PROCESS_DETACH: 511 #ifdef DEBUG 512 vboxVDbgVEHandlerUnregister(); 513 #endif 373 514 break; 374 515 -
trunk/src/VBox/Additions/3D/win/VBoxICD/Makefile.kmk
r93115 r95234 35 35 $(VBOX_PATH_3D)/win/include \ 36 36 $(PATH_ROOT)/src/VBox/Additions/WINNT/Graphics/Video \ 37 $(PATH_ROOT)/src/VBox/Devices/Graphics/vmsvga_include \ 37 38 $(VBOX_GRAPHICS_INCS) 38 39 VBoxICD_SOURCES = \ -
trunk/src/VBox/Additions/3D/win/VBoxSVGA/winsys/vmw_screen_ioctl.c
r86307 r95234 47 47 #include "svga3d_caps.h" 48 48 #include "svga3d_reg.h" 49 #include "svga3d_surfacedefs.h" 49 50 50 51 #include "../wddm_screen.h" … … 170 171 struct vmw_region **p_region) 171 172 { 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; 176 221 } 177 222 … … 195 240 boolean *needs_unref) 196 241 { 242 ASMBreakpoint(); 197 243 RT_NOREF4(vws, whandle, req, needs_unref); 198 244 // ??? … … 223 269 struct vmw_region **p_region) 224 270 { 271 ASMBreakpoint(); 225 272 RT_NOREF7(vws, whandle, flags, format, numMipLevels, handle, p_region); 226 273 // ??? DeviceCallbacks.pfnLockCb(pDevice->hDevice, ); … … 381 428 boolean allow_cs) 382 429 { 430 ASMBreakpoint(); 383 431 RT_NOREF4(region, dont_block, readonly, allow_cs); 384 432 // ??? … … 398 446 boolean allow_cs) 399 447 { 448 ASMBreakpoint(); 400 449 RT_NOREF3(region, readonly, allow_cs); 401 450 // ??? … … 471 520 uint32 code_len) 472 521 { 522 ASMBreakpoint(); 473 523 RT_NOREF3(vws, type, code_len); 474 524 // DeviceCallbacks.pfnAllocateCb(pDevice->hDevice, pDdiAllocate); … … 479 529 vmw_ioctl_shader_destroy(struct vmw_winsys_screen *vws, uint32 shid) 480 530 { 531 ASMBreakpoint(); 481 532 RT_NOREF2(vws, shid); 482 533 // ??? DeviceCallbacks.pfnDeallocateCb(pDevice->hDevice, pDdiAllocate); … … 549 600 { 550 601 case DRM_VMW_PARAM_NUM_STREAMS: 551 gp_arg->value = 1; /* const*/602 gp_arg->value = 1; /* not used */ 552 603 break; 553 604 case DRM_VMW_PARAM_NUM_FREE_STREAMS: 554 gp_arg->value = 1; /* const*/605 gp_arg->value = 1; /* not used */ 555 606 break; 556 607 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; 558 609 break; 559 610 case DRM_VMW_PARAM_HW_CAPS: … … 579 630 break; 580 631 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]; 582 636 break; 583 637 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); 587 642 break; 588 643 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; 590 645 break; 591 646 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]; 593 648 break; 594 649 case DRM_VMW_PARAM_SCREEN_TARGET: 595 gp_arg->value = 1; 650 gp_arg->value = 1; /* not used */ 596 651 break; 597 652 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*/]; 599 656 break; 600 657 default: return -1; … … 607 664 { 608 665 /* 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); 610 670 return 0; 611 671 } … … 616 676 { 617 677 struct drm_vmw_getparam_arg gp_arg; 618 // struct drm_vmw_get_3d_cap_arg cap_arg;619 678 unsigned int size; 620 679 int ret; 621 680 uint32_t *cap_buffer; 622 681 boolean drm_gb_capable; 623 boolean have_drm_2_5 = 1; /* unused */682 boolean have_drm_2_5 = 1; 624 683 625 684 struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws; … … 632 691 vws->ioctl.drm_execbuf_version = vws->ioctl.have_drm_2_9 ? 2 : 1; 633 692 634 drm_gb_capable = 1;693 drm_gb_capable = have_drm_2_5; 635 694 636 695 memset(&gp_arg, 0, sizeof(gp_arg)); … … 652 711 vws->ioctl.hwversion = gp_arg.value; 653 712 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); 664 721 665 722 if (vws->base.have_gb_objects && !drm_gb_capable) … … 759 816 } 760 817 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 765 818 ret = vboxGet3DCap(vws_wddm, cap_buffer, size); 766 819 … … 777 830 goto out_no_caps; 778 831 } 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 779 839 free(cap_buffer); 780 840 vmw_printf("%s OK\n", __FUNCTION__); -
trunk/src/VBox/Additions/3D/win/include/VBoxGaDriver.h
r93115 r95234 71 71 uint32_t u32GmrId, 72 72 void *pvMap)); 73 /* VGPU10 */ 74 DECLCALLBACKMEMBER(int, pfnGBSurfaceDefine,(void *pvEnv, 75 SVGAGBSURFCREATE *pCreateParms)); 73 76 } WDDMGalliumDriverEnv; 74 77 -
trunk/src/VBox/Additions/3D/win/include/VBoxGaHwSVGA.h
r93115 r95234 46 46 uint32_t au32Fifo[1024]; 47 47 48 /* Currently SVGA has 2 44caps, 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. 50 50 * Only valid if SVGA_CAP_GBOBJECTS is set in SVGA_REG_CAPABILITIES. 51 51 */ -
trunk/src/VBox/Additions/3D/win/include/VBoxGaTypes.h
r93115 r95234 23 23 24 24 #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() 25 30 26 31 #ifdef __cplusplus … … 71 76 } GAFENCEQUERY; 72 77 78 typedef 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 73 97 #ifdef __cplusplus 74 98 } -
trunk/src/VBox/Additions/WINNT/Graphics/Video/common/wddm/VBoxMPIf.h
r94990 r95234 34 34 #include <VBoxUhgsmi.h> 35 35 #include <VBox/VBoxGuestCoreTypes.h> /* for VBGLIOCHGCMCALL */ 36 37 #if defined(VBOXWDDMDISP) || defined(VBOX_WDDM_MINIPORT) 38 #include <VBoxGaTypes.h> 39 #endif 36 40 37 41 /* One would increase this whenever definitions in this file are changed */ … … 71 75 72 76 73 #if def VBOX_WITH_VMSVGA3D_DX77 #if defined(VBOX_WITH_VMSVGA3D_DX) || defined(VBOXWDDMDISP) || defined(VBOX_WDDM_MINIPORT) || defined(VBOXGL) 74 78 /* 75 79 * Structures for the new D3D user mode driver. … … 98 102 struct 99 103 { 100 SVGA3dSurfaceAllFlags surfaceFlags;104 uint64 surfaceFlags; /*SVGA3dSurfaceAllFlags*/ /** @todo Restore types after Mesa update. */ 101 105 SVGA3dSurfaceFormat format; 102 106 uint32 numMipLevels; 103 107 uint32 multisampleCount; 104 SVGA3dMSPattern multisamplePattern;105 SVGA3dMSQualityLevel qualityLevel;108 uint32 multisamplePattern; /*SVGA3dMSPattern*/ 109 uint32 qualityLevel; /*SVGA3dMSQualityLevel*/ 106 110 SVGA3dTextureFilter autogenFilter; 107 111 SVGA3dSize size; … … 122 126 } resourceInfo; 123 127 } VBOXDXALLOCATIONDESC, *PVBOXDXALLOCATIONDESC; 124 #endif /* VBOX_WITH_VMSVGA3D_DX*/128 #endif /* defined(VBOX_WITH_VMSVGA3D_DX) || defined(VBOXWDDMDISP) || defined(VBOX_WDDM_MINIPORT) || defined(VBOXGL) */ 125 129 126 130 /* create allocation func */ … … 136 140 , VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC 137 141 , VBOXWDDM_ALLOC_TYPE_UMD_HGSMI_BUFFER 138 #ifdef VBOX_WITH_VMSVGA3D_DX139 142 , VBOXWDDM_ALLOC_TYPE_D3D /* Direct3D UMD driver allocation. Actual type is a VBOXDXALLOCATIONTYPE value. */ 140 #endif /* VBOX_WITH_VMSVGA3D_DX */141 143 } VBOXWDDM_ALLOC_TYPE; 142 144 … … 505 507 #define VBOXESC_GAFENCEWAIT 0xA0000022 506 508 #define VBOXESC_GAFENCEUNREF 0xA0000023 509 #define VBOXESC_SVGAGBSURFACEDEFINE 0xA0010001 510 #define VBOXESC_SVGAGETSID 0xA0010002 507 511 508 512 /* Get Gallium context id (cid) of the WDDM context. */ … … 545 549 /* GASURFSIZE[cSizes] */ 546 550 } VBOXDISPIFESCAPE_GASURFACEDEFINE; 551 552 #if defined(VBOXWDDMDISP) || defined(VBOX_WDDM_MINIPORT) || defined(VBOXGL) 553 /* Create a GB host surface. */ 554 typedef struct VBOXDISPIFESCAPE_SVGAGBSURFACEDEFINE 555 { 556 VBOXDISPIFESCAPE EscapeHdr; 557 SVGAGBSURFCREATE CreateParms; 558 } VBOXDISPIFESCAPE_SVGAGBSURFACEDEFINE; 559 560 /* Get SVGA surface id (sid) of the allocation. */ 561 typedef struct VBOXDISPIFESCAPE_SVGAGETSID 562 { 563 VBOXDISPIFESCAPE EscapeHdr; 564 uint64_t hAllocation; 565 uint32_t u32Sid; 566 } VBOXDISPIFESCAPE_SVGAGETSID; 567 #endif /* defined(VBOXWDDMDISP) || defined(VBOX_WDDM_MINIPORT) || defined(VBOXGL) */ 547 568 548 569 /* Delete a host surface. */ -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/Makefile.kmk
r94584 r95234 161 161 wddm/gallium/VBoxD3DAdapter9.c 162 162 163 ifdef VBOX_WITH_VMSVGA3D_DX 164 VBoxDispD3D_DEFS += VBOX_WITH_VMSVGA3D_DX9 165 endif 166 163 167 ifdef VBOX_WITH_MESA3D_D3DTEST 164 168 VBoxDispD3D_DEFS += VBOX_WITH_MESA3D_D3DTEST -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxD3DIf.h
r93115 r95234 51 51 if (pAlloc->pD3DIf) 52 52 return pAlloc->pD3DIf; 53 54 #ifdef VBOX_WITH_VMSVGA3D_DX9 55 if (pAlloc->enmType == VBOXWDDM_ALLOC_TYPE_D3D) 56 return pAlloc->pRc->pDevice->pfnCreateSharedPrimary(pAlloc); 57 #endif 53 58 54 59 if (pAlloc->enmType != VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE) -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.h
r93115 r95234 245 245 uint32_t hostID; 246 246 #endif 247 #ifdef VBOX_WITH_VMSVGA3D_DX9 248 VBOXDXALLOCATIONDESC AllocDesc; 249 #endif 247 250 } VBOXWDDMDISP_ALLOCATION, *PVBOXWDDMDISP_ALLOCATION; 248 251 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/gallium/GaDdi.cpp
r93115 r95234 2147 2147 2148 2148 D3DDDI_OPENALLOCATIONINFO *pOAI = &pResource->pOpenAllocationInfo[i]; 2149 if (pOAI->PrivateDriverDataSize != sizeof (VBOXWDDM_ALLOCINFO)) 2149 if (pOAI->PrivateDriverDataSize == sizeof(VBOXWDDM_ALLOCINFO)) 2150 { 2151 Assert(pOAI->pPrivateDriverData); 2152 PVBOXWDDM_ALLOCINFO pWddmAllocInfo = (PVBOXWDDM_ALLOCINFO)pOAI->pPrivateDriverData; 2153 pAllocation->hAllocation = pOAI->hAllocation; 2154 pAllocation->enmType = pWddmAllocInfo->enmType; 2155 pAllocation->hSharedHandle = (HANDLE)pWddmAllocInfo->hSharedHandle; 2156 pAllocation->SurfDesc = pWddmAllocInfo->SurfDesc; 2157 pAllocation->pvMem = NULL; 2158 2159 Assert(!pAllocation->hSharedHandle == (pAllocation->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE)); 2160 } 2161 #ifdef VBOX_WITH_VMSVGA3D_DX9 2162 else if (pOAI->PrivateDriverDataSize == sizeof(VBOXDXALLOCATIONDESC)) 2163 { 2164 Assert(pOAI->pPrivateDriverData); 2165 VBOXDXALLOCATIONDESC *pAllocDesc = (VBOXDXALLOCATIONDESC *)pOAI->pPrivateDriverData; 2166 pAllocation->hAllocation = pOAI->hAllocation; 2167 pAllocation->enmType = VBOXWDDM_ALLOC_TYPE_D3D; 2168 pAllocation->hSharedHandle = 0; /* This is should be a sid of the allocation. Not needed here. */ 2169 pAllocation->AllocDesc = *pAllocDesc; 2170 pAllocation->pvMem = NULL; 2171 RT_ZERO(pAllocation->SurfDesc); 2172 pAllocation->SurfDesc.width = pAllocation->AllocDesc.surfaceInfo.size.width; 2173 pAllocation->SurfDesc.height = pAllocation->AllocDesc.surfaceInfo.size.height; 2174 pAllocation->SurfDesc.format = pAllocation->AllocDesc.enmDDIFormat; 2175 pAllocation->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocation->AllocDesc.enmDDIFormat); 2176 pAllocation->SurfDesc.pitch = vboxWddmCalcPitch(pAllocation->AllocDesc.surfaceInfo.size.width, pAllocation->AllocDesc.enmDDIFormat); 2177 pAllocation->SurfDesc.depth = pAllocation->AllocDesc.surfaceInfo.size.depth; 2178 pAllocation->SurfDesc.slicePitch = 0; 2179 pAllocation->SurfDesc.d3dWidth = pAllocation->SurfDesc.width; 2180 pAllocation->SurfDesc.cbSize = pAllocation->AllocDesc.cbAllocation; 2181 if (pAllocation->AllocDesc.fPrimary) 2182 { 2183 pAllocation->SurfDesc.VidPnSourceId = pAllocation->AllocDesc.PrimaryDesc.VidPnSourceId; 2184 pAllocation->SurfDesc.RefreshRate.Numerator = pAllocDesc->PrimaryDesc.ModeDesc.RefreshRate.Numerator; 2185 pAllocation->SurfDesc.RefreshRate.Denominator = pAllocDesc->PrimaryDesc.ModeDesc.RefreshRate.Denominator; 2186 } 2187 } 2188 #endif 2189 else 2150 2190 { 2151 2191 AssertFailed(); … … 2153 2193 break; 2154 2194 } 2155 Assert(pOAI->pPrivateDriverData);2156 2157 PVBOXWDDM_ALLOCINFO pWddmAllocInfo = (PVBOXWDDM_ALLOCINFO)pOAI->pPrivateDriverData;2158 pAllocation->hAllocation = pOAI->hAllocation;2159 pAllocation->enmType = pWddmAllocInfo->enmType;2160 pAllocation->hSharedHandle = (HANDLE)pWddmAllocInfo->hSharedHandle;2161 pAllocation->SurfDesc = pWddmAllocInfo->SurfDesc;2162 pAllocation->pvMem = NULL;2163 2164 Assert(!pAllocation->hSharedHandle == (pAllocation->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE));2165 2195 } 2166 2196 … … 2194 2224 Assert(pOAI->pPrivateDriverData); 2195 2225 Assert(pOAI->PrivateDriverDataSize >= sizeof(VBOXWDDM_ALLOCINFO)); 2196 if (pOAI->pPrivateDriverData && pOAI->PrivateDriverDataSize >= sizeof(VBOXWDDM_ALLOCINFO))2226 if (pOAI->pPrivateDriverData && pOAI->PrivateDriverDataSize == sizeof(VBOXWDDM_ALLOCINFO)) 2197 2227 { 2198 2228 PVBOXWDDM_ALLOCINFO pWddmAllocInfo = (PVBOXWDDM_ALLOCINFO)pOAI->pPrivateDriverData; … … 2212 2242 } 2213 2243 } 2244 #ifdef VBOX_WITH_VMSVGA3D_DX9 2245 else if (pOAI->pPrivateDriverData && pOAI->PrivateDriverDataSize == sizeof(VBOXDXALLOCATIONDESC)) 2246 { 2247 VBOXDXALLOCATIONDESC *pAllocDesc = (VBOXDXALLOCATIONDESC *)pOAI->pPrivateDriverData; 2248 pRc->RcDesc.fFlags.Primary = pAllocDesc->fPrimary; 2249 pRc->RcDesc.fFlags.RenderTarget = 1; 2250 //pRc->RcDesc.fFlags.NotLockable = 1; 2251 pRc->RcDesc.enmFormat = pAllocDesc->enmDDIFormat; 2252 if (pAllocDesc->fPrimary) 2253 { 2254 pRc->RcDesc.VidPnSourceId = pAllocDesc->PrimaryDesc.VidPnSourceId; 2255 pRc->RcDesc.RefreshRate.Numerator = pAllocDesc->PrimaryDesc.ModeDesc.RefreshRate.Numerator; 2256 pRc->RcDesc.RefreshRate.Denominator = pAllocDesc->PrimaryDesc.ModeDesc.RefreshRate.Denominator; 2257 } 2258 } 2259 #endif 2214 2260 else 2215 2261 hr = E_INVALIDARG; -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/gallium/GaDrvEnvWddm.cpp
r93115 r95234 700 700 RTMemFree(pvMap); 701 701 } 702 } 703 704 705 /* static */ DECLCALLBACK(int) 706 GaDrvEnvWddm::gaEnvWddmGBSurfaceDefine(void *pvEnv, 707 SVGAGBSURFCREATE *pCreateParms) 708 { 709 GaDrvEnvWddm *pThis = (GaDrvEnvWddm *)pvEnv; 710 711 HRESULT hr; 712 D3DDDICB_ESCAPE ddiEscape; 713 VBOXDISPIFESCAPE_SVGAGBSURFACEDEFINE data; 714 data.EscapeHdr.escapeCode = VBOXESC_SVGAGBSURFACEDEFINE; 715 data.EscapeHdr.u32CmdSpecific = 0; 716 data.CreateParms = *pCreateParms; 717 718 ddiEscape.hDevice = 0; // pThis->mWddmCallbacks.hDevice; 719 ddiEscape.Flags.Value = 0; 720 ddiEscape.Flags.HardwareAccess = 1; // Required, otherwise graphics corruption can happen. No idea why. 721 // Eventually we probably have to create allocations for surfaces, 722 // as a WDDM driver should do. Then the Escape hack will be removed. 723 ddiEscape.pPrivateDriverData = &data; 724 ddiEscape.PrivateDriverDataSize = sizeof(data); 725 ddiEscape.hContext = 0; 726 727 hr = pThis->mWddmCallbacks.DeviceCallbacks.pfnEscapeCb(pThis->mWddmCallbacks.hAdapter, &ddiEscape); 728 if (FAILED(hr)) 729 return -1; 730 731 pCreateParms->gmrid = data.CreateParms.gmrid; 732 pCreateParms->cbGB = data.CreateParms.cbGB; 733 pCreateParms->u64UserAddress = data.CreateParms.u64UserAddress; 734 pCreateParms->u32Sid = data.CreateParms.u32Sid; 735 return 0; 702 736 } 703 737 … … 748 782 mEnv.pfnRegionDestroy = gaEnvWddmRegionDestroy; 749 783 mEnv.pHWInfo = &mHWInfo; 784 /* VGPU10 */ 785 mEnv.pfnGBSurfaceDefine = gaEnvWddmGBSurfaceDefine; 750 786 } 751 787 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/gallium/GaDrvEnvWddm.h
r93115 r95234 95 95 uint32_t u32GmrId, 96 96 void *pvMap); 97 98 /* VGPU10 */ 99 static DECLCALLBACK(int) gaEnvWddmGBSurfaceDefine(void *pvEnv, 100 SVGAGBSURFCREATE *pCreateParms); 97 101 }; 98 102 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/gallium/GaWddm.cpp
r93115 r95234 389 389 PVBOXWDDMDISP_DEVICE pDevice = pRc->pDevice; 390 390 IDirect3DDevice9 *pDevice9If = VBOXDISP_D3DEV(pDevice); 391 AssertReturn(pDevice9If, E_FAIL); 392 391 393 HRESULT hr = E_FAIL; 392 394 … … 509 511 510 512 } 513 #ifdef VBOX_WITH_VMSVGA3D_DX9 514 else if (pAllocation->enmType == VBOXWDDM_ALLOC_TYPE_D3D) 515 { 516 hr = pDevice9If->CreateRenderTarget(pAllocation->AllocDesc.surfaceInfo.size.width, 517 pAllocation->AllocDesc.surfaceInfo.size.height, 518 d3dFormat, 519 d3dMultiSample, 520 d3dMultisampleQuality, 521 d3dLockable, 522 &pD3D9Surf, 523 NULL); 524 AssertBreak(SUCCEEDED(hr) && pD3D9Surf); 525 } 526 #endif 511 527 else 512 528 { … … 755 771 * In both cases we need a warning, because this is something unusual. 756 772 */ 773 774 #ifndef VBOX_WITH_VMSVGA3D_DX9 757 775 WARN(("another hostId %d is in use, using it instead", usedHostId)); 776 #else 777 /* This is most likely a _D3D surface, which is used as actual destination of the shared primary. */ 778 #endif 758 779 759 780 Assert(hostID != usedHostId); -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp
r95191 r95234 3458 3458 WARN(("failed to get allocation from handle")); 3459 3459 Status = STATUS_INVALID_PARAMETER; 3460 break; 3461 } 3462 3463 if (pAlloc->enmType == VBOXWDDM_ALLOC_TYPE_D3D) 3464 { 3465 pSetHostID->EscapeHdr.u32CmdSpecific = pAlloc->dx.sid; 3466 pSetHostID->rc = VERR_NOT_EQUAL; 3467 Status = STATUS_SUCCESS; 3460 3468 break; 3461 3469 } -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/Svga.cpp
r95158 r95234 89 89 { sizeof(SVGAOTableMobEntry), SVGA3D_MAX_MOBS }, /* SVGA_OTABLE_MOB */ 90 90 { sizeof(SVGAOTableSurfaceEntry), SVGA3D_MAX_SURFACE_IDS }, /* SVGA_OTABLE_SURFACE */ 91 { sizeof(SVGAOTableContextEntry), 0 /* not used */ },/* SVGA_OTABLE_CONTEXT */91 { sizeof(SVGAOTableContextEntry), SVGA3D_MAX_CONTEXT_IDS }, /* SVGA_OTABLE_CONTEXT */ 92 92 { sizeof(SVGAOTableShaderEntry), 0 /* not used */ }, /* SVGA_OTABLE_SHADER */ 93 93 { sizeof(SVGAOTableScreenTargetEntry), 64 /*VBOX_VIDEO_MAX_SCREENS*/ }, /* SVGA_OTABLE_SCREENTARGET */ … … 613 613 } 614 614 615 NTSTATUS SvgaGMRIdAlloc(PVBOXWDDM_EXT_VMSVGA pSvga,616 uint32_t *pu32GMRId)617 {618 return svgaIdAlloc(pSvga, pSvga->pu32GMRBits, pSvga->cbGMRBits,619 pSvga->u32GmrMaxIds, pu32GMRId);620 }621 622 NTSTATUS SvgaGMRIdFree(PVBOXWDDM_EXT_VMSVGA pSvga,623 uint32_t u32GMRId)624 {625 return svgaIdFree(pSvga, pSvga->pu32GMRBits, pSvga->cbGMRBits,626 pSvga->u32GmrMaxIds, u32GMRId);627 }628 629 615 NTSTATUS SvgaContextCreate(PVBOXWDDM_EXT_VMSVGA pSvga, 630 616 uint32_t u32Cid) … … 760 746 AssertReturn(SVGAHOSTOBJECTID(&pSO->ho) == pSO->u32SharedSid, STATUS_INVALID_PARAMETER); 761 747 762 /* The surface object to be mapped to. */ 763 SURFACEOBJECT *pSharedSO = SvgaSurfaceObjectQuery(pSvga, u32SharedSid); 764 AssertReturnStmt(pSharedSO, SvgaSurfaceObjectRelease(pSO), STATUS_INVALID_PARAMETER); 748 /* The surface object to be mapped to. Query it to reference it. 749 * If the surface id (u32SharedSid) is not in the surface objects, then it is OK. 750 * It means that it is most likely from _D3D context. 751 */ 752 SvgaSurfaceObjectQuery(pSvga, u32SharedSid); 765 753 766 754 pSO->u32SharedSid = u32SharedSid; … … 783 771 AssertReturn(SVGAHOSTOBJECTID(&pSO->ho) != pSO->u32SharedSid, STATUS_INVALID_PARAMETER); 784 772 785 /* The shared surface object, which the u32Sid was mapped to. */ 773 /* The shared surface object, which the u32Sid was mapped to. 774 * If the surface id (u32SharedSid) is not in the surface objects, then it is OK. 775 * It means that it is most likely from _D3D context. 776 */ 786 777 SURFACEOBJECT *pSharedSO = SvgaSurfaceObjectQuery(pSvga, pSO->u32SharedSid); 787 AssertReturnStmt(pSharedSO, SvgaSurfaceObjectRelease(pSO), STATUS_INVALID_PARAMETER);788 778 789 779 pSO->u32SharedSid = SVGAHOSTOBJECTID(&pSO->ho); 790 780 791 781 /* Remove the reference which was added by SvgaSharedSidInsert. */ 792 SvgaSurfaceObjectRelease(pSharedSO); 782 if (pSharedSO) 783 SvgaSurfaceObjectRelease(pSharedSO); 793 784 794 785 /* Release both surface objects. */ 795 SvgaSurfaceObjectRelease(pSharedSO); 786 if (pSharedSO) 787 SvgaSurfaceObjectRelease(pSharedSO); 796 788 SvgaSurfaceObjectRelease(pSO); 797 789 return STATUS_SUCCESS; … … 837 829 else 838 830 { 839 GALOGREL(32, ("WDDM: no surface for sid %u\n", u32Sid)); 840 AssertFailed(); 841 /* Ignore the error. */ 831 /* Ignore the error. This is most likely a sid from _D3D context.*/ 842 832 return STATUS_SUCCESS; 843 833 } … … 1020 1010 case SVGA_3D_CMD_BIND_GB_SURFACE_WITH_PITCH: 1021 1011 case SVGA_3D_CMD_COND_BIND_GB_SURFACE: 1022 case SVGA_3D_CMD_UPDATE_GB_SURFACE:1023 1012 case SVGA_3D_CMD_READBACK_GB_SURFACE: 1024 case SVGA_3D_CMD_INVALIDATE_GB_SURFACE:1025 case SVGA_3D_CMD_UPDATE_GB_IMAGE:1026 1013 case SVGA_3D_CMD_READBACK_GB_IMAGE: 1027 1014 case SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL: 1028 case SVGA_3D_CMD_INVALIDATE_GB_IMAGE:1029 1015 case SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL: 1030 1016 case SVGA_3D_CMD_BIND_GB_SCREENTARGET: … … 1035 1021 AssertFailed(); 1036 1022 break; 1023 case SVGA_3D_CMD_UPDATE_GB_IMAGE: 1024 case SVGA_3D_CMD_UPDATE_GB_SURFACE: 1025 case SVGA_3D_CMD_INVALIDATE_GB_IMAGE: 1026 case SVGA_3D_CMD_INVALIDATE_GB_SURFACE: 1027 break; 1028 case SVGA_3D_CMD_DX_SET_SINGLE_CONSTANT_BUFFER: 1029 { 1030 SVGA3dCmdDXSetSingleConstantBuffer *p = (SVGA3dCmdDXSetSingleConstantBuffer *)pCommand; 1031 Status = SvgaProcessSurface(pSvga, &p->sid, pHOA); 1032 } break; 1033 case SVGA_3D_CMD_DX_PRED_COPY_REGION: 1034 { 1035 SVGA3dCmdDXPredCopyRegion *p = (SVGA3dCmdDXPredCopyRegion *)pCommand; 1036 Status = SvgaProcessSurface(pSvga, &p->srcSid, pHOA); 1037 if (Status == STATUS_SUCCESS) 1038 Status = SvgaProcessSurface(pSvga, &p->dstSid, pHOA); 1039 } break; 1037 1040 default: 1038 1041 if (SVGA_3D_CMD_DX_MIN <= u32CmdId && u32CmdId <= SVGA_3D_CMD_DX_MAX) 1039 1042 { 1040 /** @todo Also do not support DX commands for now, they are not supported by the host. */ 1041 AssertFailed(); 1043 /** @todo Implement. */ 1042 1044 } 1043 1045 break; … … 1060 1062 * 1061 1063 * @param pSvga . 1064 * @param pSvgaContext . 1062 1065 * @param pvTarget . 1063 1066 * @param cbTarget . … … 1069 1072 */ 1070 1073 NTSTATUS SvgaRenderCommands(PVBOXWDDM_EXT_VMSVGA pSvga, 1074 struct VMSVGACONTEXT *pSvgaContext, 1071 1075 void *pvTarget, 1072 1076 uint32_t cbTarget, … … 1080 1084 AssertReturn(cbSource % sizeof(uint32_t) == 0, STATUS_ILLEGAL_INSTRUCTION); 1081 1085 1086 NTSTATUS Status = SvgaRenderCommandsD3D(pSvga, 1087 pSvgaContext, 1088 pvTarget, 1089 cbTarget, 1090 pvSource, 1091 cbSource, 1092 pu32TargetLength, 1093 pu32ProcessedLength); 1094 AssertReturn(NT_SUCCESS(Status), Status); 1095 1082 1096 SVGAHOSTOBJECTARRAY *pHO = (SVGAHOSTOBJECTARRAY *)GaMemAlloc(sizeof(SVGAHOSTOBJECTARRAY)); 1083 1097 if (!pHO) … … 1086 1100 pHO->u32Reserved = 0; 1087 1101 1088 NTSTATUS Status = STATUS_SUCCESS; 1089 1090 const uint8_t *pu8Src = (uint8_t *)pvSource; 1091 const uint8_t *pu8SrcEnd = (uint8_t *)pvSource + cbSource; 1092 uint8_t *pu8Dst = (uint8_t *)pvTarget; 1093 uint8_t *pu8DstEnd = (uint8_t *)pvTarget + cbTarget; 1094 1102 uint8_t *pu8Src = (uint8_t *)pvTarget; 1103 uint8_t *pu8SrcEnd = (uint8_t *)pvTarget + (*pu32TargetLength); 1095 1104 while (pu8SrcEnd > pu8Src) 1096 1105 { … … 1119 1128 } 1120 1129 1121 const uint32_t cbDstLeft = pu8DstEnd - pu8Dst; 1122 if (cbCmd > cbDstLeft) 1123 { 1124 Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER; 1125 break; 1126 } 1127 1128 memcpy(pu8Dst, pu8Src, cbCmd); 1129 1130 /* Update the command in dst place if necessary. */ 1131 Status = svgaUpdateCommand(pSvga, u32CmdId, pu8Dst, cbCmd, pHO); 1130 /* Update the command in source place if necessary. */ 1131 Status = svgaUpdateCommand(pSvga, u32CmdId, pu8Src, cbCmd, pHO); 1132 1132 if (Status != STATUS_SUCCESS) 1133 1133 { … … 1137 1137 1138 1138 pu8Src += cbCmd; 1139 pu8Dst += cbCmd;1140 1139 } 1141 1140 … … 1143 1142 || Status == STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER) 1144 1143 { 1145 *pu32TargetLength = pu8Dst - (uint8_t *)pvTarget;1146 *pu32ProcessedLength = pu8Src - (uint8_t *)pvSource;1147 1144 if (pHO->cObjects) 1148 1145 *ppHwRenderData = &pHO->hdr; … … 1793 1790 RTR0PTR pvR0; 1794 1791 RTR3PTR pvR3; 1795 /* The Guest Memory Region ID. */1796 uint32_t u32GmrId;1792 /* A corresponding MOB, which provides the Guest Memory Region ID. */ 1793 PVMSVGAMOB pMob; 1797 1794 /* The allocated size in pages. */ 1798 1795 uint32_t u32NumPages; … … 1801 1798 } GAWDDMREGION; 1802 1799 1800 static void svgaFreeGBMobForGMR(VBOXWDDM_EXT_VMSVGA *pSvga, PVMSVGAMOB pMob) 1801 { 1802 if (pMob) 1803 { 1804 if (RT_BOOL(pSvga->u32Caps & SVGA_CAP_DX)) 1805 { 1806 void *pvCmd = SvgaCmdBuf3dCmdReserve(pSvga, SVGA_3D_CMD_DESTROY_GB_MOB, sizeof(SVGA3dCmdDestroyGBMob), SVGA3D_INVALID_ID); 1807 if (pvCmd) 1808 { 1809 SVGA3dCmdDestroyGBMob *pCmd = (SVGA3dCmdDestroyGBMob *)pvCmd; 1810 pCmd->mobid = VMSVGAMOB_ID(pMob); 1811 SvgaCmdBufCommit(pSvga, sizeof(SVGA3dCmdDestroyGBMob)); 1812 } 1813 } 1814 1815 SvgaMobFree(pSvga, pMob); 1816 } 1817 } 1818 1819 static NTSTATUS svgaCreateGBMobForGMR(VBOXWDDM_EXT_VMSVGA *pSvga, GAWDDMREGION *pRegion) 1820 { 1821 /* Allocate a new mob. */ 1822 NTSTATUS Status = SvgaMobCreate(pSvga, &pRegion->pMob, pRegion->u32NumPages, 0); 1823 Assert(NT_SUCCESS(Status)); 1824 if (NT_SUCCESS(Status)) 1825 { 1826 Status = SvgaGboFillPageTableForArray(&pRegion->pMob->gbo, pRegion->u32NumPages, pRegion->aPhys); 1827 Assert(NT_SUCCESS(Status)); 1828 if (NT_SUCCESS(Status)) 1829 { 1830 if (RT_BOOL(pSvga->u32Caps & SVGA_CAP_DX)) 1831 { 1832 void *pvCmd = SvgaCmdBuf3dCmdReserve(pSvga, SVGA_3D_CMD_DEFINE_GB_MOB64, sizeof(SVGA3dCmdDefineGBMob64), SVGA3D_INVALID_ID); 1833 if (pvCmd) 1834 { 1835 SVGA3dCmdDefineGBMob64 *pCmd = (SVGA3dCmdDefineGBMob64 *)pvCmd; 1836 pCmd->mobid = VMSVGAMOB_ID(pRegion->pMob); 1837 pCmd->ptDepth = pRegion->pMob->gbo.enmMobFormat; 1838 pCmd->base = pRegion->pMob->gbo.base; 1839 pCmd->sizeInBytes = pRegion->pMob->gbo.cbGbo; 1840 SvgaCmdBufCommit(pSvga, sizeof(SVGA3dCmdDefineGBMob64)); 1841 } 1842 else 1843 AssertFailedStmt(Status = STATUS_INSUFFICIENT_RESOURCES); 1844 } 1845 1846 if (NT_SUCCESS(Status)) 1847 return STATUS_SUCCESS; 1848 } 1849 } 1850 1851 svgaFreeGBMobForGMR(pSvga, pRegion->pMob); 1852 pRegion->pMob = NULL; 1853 return Status; 1854 } 1855 1856 1803 1857 static void gmrFree(GAWDDMREGION *pRegion) 1804 1858 { … … 1852 1906 Assert(pRegion); 1853 1907 gmrFree(pRegion); 1854 SvgaGMRIdFree(pSvga, pRegion->u32GmrId);1908 svgaFreeGBMobForGMR(pSvga, pRegion->pMob); 1855 1909 GaMemFree(pRegion); 1856 1910 } … … 1873 1927 { 1874 1928 AssertReturn(pCtx->cIds < pCtx->cMaxIds, -1); 1875 pCtx->au32Ids[pCtx->cIds++] = pRegion->u32GmrId;1929 pCtx->au32Ids[pCtx->cIds++] = VMSVGAMOB_ID(pRegion->pMob); 1876 1930 } 1877 1931 return 0; … … 1904 1958 if (pRegion) 1905 1959 { 1906 Assert( pRegion->u32GmrId== pCtx->au32Ids[i]);1960 Assert(VMSVGAMOB_ID(pRegion->pMob) == pCtx->au32Ids[i]); 1907 1961 GALOG(("Deallocate gmrId %d, pv %p, aPhys[0] %RHp\n", 1908 pRegion->u32GmrId, pRegion->pvR3, pRegion->aPhys[0]));1962 VMSVGAMOB_ID(pRegion->pMob), pRegion->pvR3, pRegion->aPhys[0])); 1909 1963 1910 1964 gaRegionFree(pSvga, pRegion); … … 1930 1984 if (pRegion) 1931 1985 { 1932 Assert( pRegion->u32GmrId== u32GmrId);1986 Assert(VMSVGAMOB_ID(pRegion->pMob) == u32GmrId); 1933 1987 GALOG(("Freed gmrId %d, pv %p, aPhys[0] %RHp\n", 1934 pRegion->u32GmrId, pRegion->pvR3, pRegion->aPhys[0]));1988 VMSVGAMOB_ID(pRegion->pMob), pRegion->pvR3, pRegion->aPhys[0])); 1935 1989 gaRegionFree(pSvga, pRegion); 1990 return STATUS_SUCCESS; 1991 } 1992 1993 AssertFailed(); 1994 return STATUS_INVALID_PARAMETER; 1995 } 1996 1997 NTSTATUS SvgaRegionUserAddressAndSize(VBOXWDDM_EXT_VMSVGA *pSvga, 1998 uint32_t u32GmrId, 1999 uint64_t *pu64UserAddress, 2000 uint32_t *pu32Size) 2001 { 2002 AssertReturn(u32GmrId <= pSvga->u32GmrMaxIds, STATUS_INVALID_PARAMETER); 2003 2004 GALOG(("[%p] gmrId %d\n", pSvga, u32GmrId)); 2005 2006 ExAcquireFastMutex(&pSvga->SvgaMutex); 2007 2008 GAWDDMREGION *pRegion = (GAWDDMREGION *)RTAvlU32Get(&pSvga->GMRTree, u32GmrId); 2009 2010 ExReleaseFastMutex(&pSvga->SvgaMutex); 2011 2012 if (pRegion) 2013 { 2014 Assert(VMSVGAMOB_ID(pRegion->pMob) == u32GmrId); 2015 GALOG(("Get gmrId %d, UserAddress 0x%p\n", 2016 VMSVGAMOB_ID(pRegion->pMob), pRegion->pvR3)); 2017 *pu64UserAddress = (uintptr_t)pRegion->pvR3; 2018 *pu32Size = pRegion->u32NumPages * PAGE_SIZE; 1936 2019 return STATUS_SUCCESS; 1937 2020 } … … 1957 2040 if (pRegion) 1958 2041 { 1959 Status = SvgaGMRIdAlloc(pSvga, &pRegion->u32GmrId); 2042 /* Region id and VGPU10+ mobid are the same. So a mob is allocated along with the gmr. 2043 * The mob provides an id and also reported to the host on VGPU10. 2044 */ 2045 pRegion->pvOwner = pvOwner; 2046 pRegion->u32NumPages = u32NumPages; 2047 pRegion->MemObj = NIL_RTR0MEMOBJ; 2048 pRegion->MapObjR3 = NIL_RTR0MEMOBJ; 2049 2050 Status = gmrAlloc(pRegion); 1960 2051 Assert(NT_SUCCESS(Status)); 1961 2052 if (NT_SUCCESS(Status)) 1962 2053 { 1963 if (pRegion->u32GmrId < pSvga->u32GmrMaxIds) 2054 Status = svgaCreateGBMobForGMR(pSvga, pRegion); 2055 Assert(NT_SUCCESS(Status)); 2056 if (NT_SUCCESS(Status)) 1964 2057 { 1965 pRegion->pvOwner = pvOwner; 1966 pRegion->u32NumPages = u32NumPages; 1967 pRegion->MemObj = NIL_RTR0MEMOBJ; 1968 pRegion->MapObjR3 = NIL_RTR0MEMOBJ; 1969 1970 Status = gmrAlloc(pRegion); 1971 Assert(NT_SUCCESS(Status)); 1972 if (NT_SUCCESS(Status)) 2058 if (VMSVGAMOB_ID(pRegion->pMob) < pSvga->u32GmrMaxIds) 1973 2059 { 1974 2060 GALOG(("Allocated gmrId %d, pv %p, aPhys[0] %RHp\n", 1975 pRegion->u32GmrId, pRegion->pvR3, pRegion->aPhys[0]));2061 VMSVGAMOB_ID(pRegion->pMob), pRegion->pvR3, pRegion->aPhys[0])); 1976 2062 1977 2063 /* Report the GMR to the host vmsvga device. */ 1978 2064 Status = SvgaGMRReport(pSvga, 1979 pRegion->u32GmrId,2065 VMSVGAMOB_ID(pRegion->pMob), 1980 2066 SVGA_REMAP_GMR2_PPN32, 1981 2067 pRegion->u32NumPages, … … 1987 2073 ExAcquireFastMutex(&pSvga->SvgaMutex); 1988 2074 1989 pRegion->Core.Key = pRegion->u32GmrId;2075 pRegion->Core.Key = VMSVGAMOB_ID(pRegion->pMob); 1990 2076 RTAvlU32Insert(&pSvga->GMRTree, &pRegion->Core); 1991 2077 1992 2078 ExReleaseFastMutex(&pSvga->SvgaMutex); 1993 2079 1994 *pu32GmrId = pRegion->u32GmrId;2080 *pu32GmrId = VMSVGAMOB_ID(pRegion->pMob); 1995 2081 *pu64UserAddress = (uint64_t)pRegion->pvR3; 1996 2082 … … 1998 2084 return STATUS_SUCCESS; 1999 2085 } 2000 2001 gmrFree(pRegion);2002 2086 } 2087 else 2088 { 2089 AssertFailed(); 2090 Status = STATUS_INSUFFICIENT_RESOURCES; 2091 } 2092 2093 svgaFreeGBMobForGMR(pSvga, pRegion->pMob); 2003 2094 } 2004 else 2005 { 2006 AssertFailed(); 2007 Status = STATUS_INSUFFICIENT_RESOURCES; 2008 } 2009 2010 SvgaGMRIdFree(pSvga, pRegion->u32GmrId); 2095 2096 gmrFree(pRegion); 2011 2097 } 2012 2098 … … 2198 2284 for (unsigned i = 0; i < pGbo->cbGbo >> PAGE_SHIFT; ++i) 2199 2285 paPpnGbo[i] = RTR0MemObjGetPagePhysAddr(hMemObj, i) >> PAGE_SHIFT; 2286 } 2287 return STATUS_SUCCESS; 2288 } 2289 2290 2291 NTSTATUS SvgaGboFillPageTableForArray(PVMSVGAGBO pGbo, 2292 uint32_t u32NumPages, 2293 RTHCPHYS *paPhys) 2294 { 2295 if (pGbo->enmMobFormat == SVGA3D_MOBFMT_PTDEPTH64_0) 2296 { 2297 Assert(u32NumPages == 1); 2298 pGbo->base = paPhys[0] >> PAGE_SHIFT; 2299 } 2300 else 2301 { 2302 /* The first of pages is alway the base. It is either the level 2 page or the single level 1 page */ 2303 pGbo->base = RTR0MemObjGetPagePhysAddr(pGbo->hMemObjPT, 0) >> PAGE_SHIFT; 2304 2305 PPN64 *paPpn = (PPN64 *)RTR0MemObjAddress(pGbo->hMemObjPT); 2306 PPN64 *paPpnGbo; 2307 if (pGbo->enmMobFormat == SVGA3D_MOBFMT_PTDEPTH64_2) 2308 paPpnGbo = &paPpn[PAGE_SIZE / sizeof(PPN64)]; /* Level 1 pages follow the level 2 page. */ 2309 else if (pGbo->enmMobFormat == SVGA3D_MOBFMT_PTDEPTH64_1) 2310 paPpnGbo = paPpn; 2311 else 2312 AssertFailedReturn(STATUS_INVALID_PARAMETER); 2313 2314 /* Store page numbers into the level 1 description pages. */ 2315 for (unsigned i = 0; i < u32NumPages; ++i) 2316 paPpnGbo[i] = paPhys[i] >> PAGE_SHIFT; 2200 2317 } 2201 2318 return STATUS_SUCCESS; -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/Svga.h
r95086 r95234 327 327 */ 328 328 uint32_t u32SharedSid; 329 330 uint32_t mobid; 329 331 } SURFACEOBJECT; 330 332 AssertCompile(RT_OFFSETOF(SURFACEOBJECT, ho) == 0); … … 383 385 uint32_t cSizes, 384 386 uint32_t *pu32Sid); 387 NTSTATUS SvgaGBSurfaceCreate(VBOXWDDM_EXT_VMSVGA *pSvga, 388 void *pvOwner, 389 SVGAGBSURFCREATE *pCreateParms); 385 390 NTSTATUS SvgaSurfaceUnref(VBOXWDDM_EXT_VMSVGA *pSvga, 386 391 uint32_t u32Sid); … … 407 412 NTSTATUS SvgaSurfaceIdFree(PVBOXWDDM_EXT_VMSVGA pSvga, 408 413 uint32_t u32Sid); 409 NTSTATUS SvgaGMRIdAlloc(PVBOXWDDM_EXT_VMSVGA pSvga,410 uint32_t *pu32GMRId);411 NTSTATUS SvgaGMRIdFree(PVBOXWDDM_EXT_VMSVGA pSvga,412 uint32_t u32GMRId);413 414 414 415 415 416 NTSTATUS SvgaRenderCommands(PVBOXWDDM_EXT_VMSVGA pSvga, 417 struct VMSVGACONTEXT *pSvgaContext, 416 418 void *pvTarget, 417 419 uint32_t cbTarget, … … 558 560 uint32_t *pu32GmrId, 559 561 uint64_t *pu64UserAddress); 562 NTSTATUS SvgaRegionUserAddressAndSize(VBOXWDDM_EXT_VMSVGA *pSvga, 563 uint32_t u32GmrId, 564 uint64_t *pu64UserAddress, 565 uint32_t *pu32Size); 560 566 NTSTATUS SvgaRegionDestroy(VBOXWDDM_EXT_VMSVGA *pSvga, 561 567 uint32_t u32GmrId); … … 604 610 NTSTATUS SvgaGboFillPageTableForMemObj(PVMSVGAGBO pGbo, 605 611 RTR0MEMOBJ hMemObj); 612 NTSTATUS SvgaGboFillPageTableForArray(PVMSVGAGBO pGbo, 613 uint32_t u32NumPages, 614 RTHCPHYS *paPhys); 606 615 607 616 void SvgaMobFree(VBOXWDDM_EXT_VMSVGA *pSvga, -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/SvgaHostObjects.cpp
r93115 r95234 19 19 20 20 #include "Svga.h" 21 #include "SvgaFifo.h" 21 22 22 23 #include <iprt/asm.h> … … 261 262 uint32_t const u32Sid = pHO->u.avl.core.Key; 262 263 264 SURFACEOBJECT *pSO = (SURFACEOBJECT *)pHO; 265 263 266 /* Delete the surface. */ 264 267 GALOG(("deleted sid=%u\n", u32Sid)); 268 269 if (pSO->mobid != SVGA3D_INVALID_ID) 270 { 271 void *pvCmd = SvgaCmdBuf3dCmdReserve(pSvga, SVGA_3D_CMD_BIND_GB_SURFACE, sizeof(SVGA3dCmdBindGBSurface), SVGA3D_INVALID_ID); 272 if (pvCmd) 273 { 274 SVGA3dCmdBindGBSurface *pCmd = (SVGA3dCmdBindGBSurface *)pvCmd; 275 pCmd->sid = u32Sid; 276 pCmd->mobid = SVGA3D_INVALID_ID; 277 SvgaCmdBufCommit(pSvga, sizeof(SVGA3dCmdBindGBSurface)); 278 } 279 } 265 280 266 281 NTSTATUS Status = SvgaSurfaceDestroy(pSvga, u32Sid); … … 366 381 { 367 382 pSO->u32SharedSid = u32Sid; /* Initially. The user mode driver can change this for shared surfaces. */ 383 pSO->mobid = SVGA3D_INVALID_ID; 368 384 369 385 Status = svgaHostObjectInit(pSvga, &pSO->ho, SVGA_HOST_OBJECT_SURFACE, u32Sid, svgaSurfaceObjectDestroy); … … 392 408 return Status; 393 409 } 410 411 412 static NTSTATUS svgaGBSurfaceDefine(VBOXWDDM_EXT_VMSVGA *pSvga, 413 uint32_t u32Sid, 414 SVGAGBSURFCREATE *pCreateParms, 415 uint32_t mobid) 416 { 417 void *pvCmd = SvgaCmdBuf3dCmdReserve(pSvga, SVGA_3D_CMD_DEFINE_GB_SURFACE_V4, sizeof(SVGA3dCmdDefineGBSurface_v4), SVGA3D_INVALID_ID); 418 if (pvCmd) 419 { 420 SVGA3dCmdDefineGBSurface_v4 *pCmd = (SVGA3dCmdDefineGBSurface_v4 *)pvCmd; 421 pCmd->sid = u32Sid; 422 pCmd->surfaceFlags = pCreateParms->s.flags; 423 pCmd->format = pCreateParms->s.format; 424 pCmd->numMipLevels = pCreateParms->s.numMipLevels; 425 pCmd->multisampleCount = pCreateParms->s.sampleCount; 426 pCmd->autogenFilter = SVGA3D_TEX_FILTER_NONE; 427 pCmd->size = pCreateParms->s.size; 428 pCmd->arraySize = pCreateParms->s.numFaces; 429 pCmd->bufferByteStride = 0; 430 SvgaCmdBufCommit(pSvga, sizeof(SVGA3dCmdDefineGBSurface_v4)); 431 } 432 else 433 AssertFailedReturn(STATUS_INSUFFICIENT_RESOURCES); 434 435 pvCmd = SvgaCmdBuf3dCmdReserve(pSvga, SVGA_3D_CMD_BIND_GB_SURFACE, sizeof(SVGA3dCmdBindGBSurface), SVGA3D_INVALID_ID); 436 if (pvCmd) 437 { 438 SVGA3dCmdBindGBSurface *pCmd = (SVGA3dCmdBindGBSurface *)pvCmd; 439 pCmd->sid = u32Sid; 440 pCmd->mobid = mobid; 441 SvgaCmdBufCommit(pSvga, sizeof(SVGA3dCmdBindGBSurface)); 442 } 443 else 444 AssertFailedReturn(STATUS_INSUFFICIENT_RESOURCES); 445 446 return STATUS_SUCCESS; 447 } 448 449 450 static void svgaGBSurfaceDestroy(VBOXWDDM_EXT_VMSVGA *pSvga, uint32_t u32Sid) 451 { 452 SvgaSurfaceDestroy(pSvga, u32Sid); 453 } 454 455 456 NTSTATUS SvgaGBSurfaceCreate(VBOXWDDM_EXT_VMSVGA *pSvga, 457 void *pvOwner, 458 SVGAGBSURFCREATE *pCreateParms) 459 { 460 NTSTATUS Status = svgaHostObjectsProcessPending(pSvga); 461 AssertReturn(Status == STATUS_SUCCESS, Status); 462 463 GALOGG(GALOG_GROUP_SVGA, ("gmrid = %u\n", pCreateParms->gmrid)); 464 465 uint32_t cbGB = 0; 466 uint64_t u64UserAddress = 0; 467 /* Allocate GMR, if not already supplied. */ 468 if (pCreateParms->gmrid == SVGA3D_INVALID_ID) 469 { 470 uint32_t u32NumPages = (pCreateParms->cbGB + PAGE_SIZE - 1) >> PAGE_SHIFT; 471 Status = SvgaRegionCreate(pSvga, pvOwner, u32NumPages, &pCreateParms->gmrid, &u64UserAddress); 472 AssertReturn(NT_SUCCESS(Status), Status); 473 cbGB = u32NumPages * PAGE_SIZE; 474 } 475 else 476 { 477 Status = SvgaRegionUserAddressAndSize(pSvga, pCreateParms->gmrid, &u64UserAddress, &cbGB); 478 AssertReturn(NT_SUCCESS(Status), Status); 479 } 480 481 SURFACEOBJECT *pSO = (SURFACEOBJECT *)GaMemAllocZero(sizeof(SURFACEOBJECT)); 482 if (pSO) 483 { 484 uint32_t u32Sid; 485 Status = SvgaSurfaceIdAlloc(pSvga, &u32Sid); 486 if (NT_SUCCESS(Status)) 487 { 488 Status = svgaGBSurfaceDefine(pSvga, u32Sid, pCreateParms, pCreateParms->gmrid); 489 if (NT_SUCCESS(Status)) 490 { 491 pSO->u32SharedSid = u32Sid; /* Initially. The user mode driver can change this for shared surfaces. */ 492 pSO->mobid = pCreateParms->gmrid; 493 494 Status = svgaHostObjectInit(pSvga, &pSO->ho, SVGA_HOST_OBJECT_SURFACE, u32Sid, svgaSurfaceObjectDestroy); 495 if (NT_SUCCESS(Status)) 496 { 497 pCreateParms->cbGB = cbGB; 498 pCreateParms->u64UserAddress = u64UserAddress; 499 pCreateParms->u32Sid = u32Sid; 500 501 GALOG(("created sid=%u\n", u32Sid)); 502 return STATUS_SUCCESS; 503 } 504 505 AssertFailed(); 506 507 /* 508 * Cleanup on error. 509 */ 510 svgaGBSurfaceDestroy(pSvga, u32Sid); 511 } 512 SvgaSurfaceIdFree(pSvga, u32Sid); 513 } 514 GaMemFree(pSO); 515 } 516 else 517 Status = STATUS_INSUFFICIENT_RESOURCES; 518 519 return Status; 520 } -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/VBoxMPDX.cpp
r95191 r95234 953 953 *(uint32_t *)pPatchAddress = pAllocation->dx.mobid; 954 954 } 955 else 956 {957 AssertFailed();955 else if ( pAllocation->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE 956 || pAllocation->enmType == VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE) 957 { 958 958 uint32_t *poffVRAM = (uint32_t *)pPatchAddress; 959 959 *poffVRAM = pAllocationListEntry->PhysicalAddress.LowPart + pPatchListEntry->AllocationOffset; 960 960 } 961 else 962 AssertFailed(); 961 963 } 962 964 else -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/VBoxMPGaWddm.cpp
r95191 r95234 982 982 if (cbTarget > GA_DMA_MIN_SUBMIT_SIZE) 983 983 { 984 Status = SvgaRenderCommands(pGaDevExt->hw.pSvga, p vTarget, cbTarget, pvSource, cbSource,984 Status = SvgaRenderCommands(pGaDevExt->hw.pSvga, pContext->pSvgaContext, pvTarget, cbTarget, pvSource, cbSource, 985 985 &u32TargetLength, &u32ProcessedLength, &pHwRenderData); 986 986 } … … 1960 1960 break; 1961 1961 } 1962 case VBOXESC_SVGAGBSURFACEDEFINE: 1963 { 1964 if (pEscape->PrivateDriverDataSize < sizeof(VBOXDISPIFESCAPE_SVGAGBSURFACEDEFINE)) 1965 { 1966 Status = STATUS_INVALID_PARAMETER; 1967 break; 1968 } 1969 1970 VBOXDISPIFESCAPE_SVGAGBSURFACEDEFINE *pSurfaceDefine = (VBOXDISPIFESCAPE_SVGAGBSURFACEDEFINE *)pEscapeHdr; 1971 1972 VBOXWDDM_EXT_VMSVGA *pSvga = pDevExt->pGa->hw.pSvga; 1973 Status = SvgaGBSurfaceCreate(pSvga, pDevice, &pSurfaceDefine->CreateParms); 1974 break; 1975 } 1976 case VBOXESC_SVGAGETSID: 1977 { 1978 if (pEscape->PrivateDriverDataSize < sizeof(VBOXDISPIFESCAPE_SVGAGETSID)) 1979 { 1980 Status = STATUS_INVALID_PARAMETER; 1981 break; 1982 } 1983 1984 VBOXDISPIFESCAPE_SVGAGETSID *pGetSid = (VBOXDISPIFESCAPE_SVGAGETSID *)pEscapeHdr; 1985 1986 DXGKARGCB_GETHANDLEDATA GetHandleData; 1987 GetHandleData.hObject = (D3DKMT_HANDLE)pGetSid->hAllocation; 1988 GetHandleData.Type = DXGK_HANDLE_ALLOCATION; 1989 GetHandleData.Flags.Value = 0; 1990 1991 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)pDevExt->u.primary.DxgkInterface.DxgkCbGetHandleData(&GetHandleData); 1992 if (!pAllocation) 1993 { 1994 WARN(("failed to get allocation from handle")); 1995 Status = STATUS_INVALID_PARAMETER; 1996 break; 1997 } 1998 1999 if (pAllocation->enmType != VBOXWDDM_ALLOC_TYPE_D3D) 2000 { 2001 WARN(("Unexpected allocation type %d", pAllocation->enmType)); 2002 Status = STATUS_INVALID_PARAMETER; 2003 break; 2004 } 2005 2006 pGetSid->u32Sid = pAllocation->dx.sid; 2007 Status = STATUS_SUCCESS; 2008 break; 2009 } 1962 2010 default: 1963 2011 break;
Note:
See TracChangeset
for help on using the changeset viewer.