Changeset 26630 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Feb 18, 2010 3:47:33 PM (15 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics/Miniport
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
r26556 r26630 760 760 if (DeviceExtension->CurrentMode == 0) 761 761 #else 762 if (!DeviceExtension->cSources || !DeviceExtension->aSources[0]. ulFrameBufferSize)762 if (!DeviceExtension->cSources || !DeviceExtension->aSources[0].pAllocation) 763 763 #endif 764 764 { … … 790 790 } 791 791 #else 792 if (DeviceExtension->cSources && DeviceExtension->aSources[0]. ulFrameBufferSize)792 if (DeviceExtension->cSources && DeviceExtension->aSources[0].pAllocation) 793 793 { 794 794 if (!xres) 795 xres = DeviceExtension->aSources[0]. VisScreenWidth;795 xres = DeviceExtension->aSources[0].pAllocation->u.SurfInfo.width; 796 796 if (!yres) 797 yres = DeviceExtension->aSources[0]. VisScreenHeight;797 yres = DeviceExtension->aSources[0].pAllocation->u.SurfInfo.height; 798 798 if (!bpp) 799 bpp = DeviceExtension->aSources[0]. BitsPerPlane;799 bpp = DeviceExtension->aSources[0].pAllocation->u.SurfInfo.bpp; 800 800 } 801 801 #endif … … 824 824 if (DeviceExtension->CurrentMode != 0) 825 825 #else 826 if (DeviceExtension->cSources && DeviceExtension->aSources[0]. ulFrameBufferSize)826 if (DeviceExtension->cSources && DeviceExtension->aSources[0].pAllocation) 827 827 #endif 828 828 { … … 904 904 if (DeviceExtension->CurrentMode == 0) 905 905 #else 906 if (!DeviceExtension->cSources || !DeviceExtension->aSources[0]. ulFrameBufferSize)906 if (!DeviceExtension->cSources || !DeviceExtension->aSources[0].pAllocation) 907 907 #endif 908 908 { … … 2498 2498 return TRUE; 2499 2499 } 2500 #else2501 Assert(!srcId);2502 2503 if (srcId)2504 {2505 dprintf(("VBoxVideo::VBoxVideoSetCurrentMode: Skipping for ? non-primary ? source ? %d\n",2506 srcId));2507 return TRUE;2508 }2509 #endif2510 2500 2511 2501 /* set the mode characteristics */ … … 2527 2517 */ 2528 2518 // VBoxVideoSetGraphicsCap(TRUE); 2519 #else 2520 Assert(!srcId); 2521 2522 if (srcId) 2523 { 2524 dprintf(("VBoxVideo::VBoxVideoSetCurrentMode: Skipping for ? non-primary ? source ? %d\n", 2525 srcId)); 2526 return TRUE; 2527 } 2528 2529 /* set the mode characteristics */ 2530 VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES); 2531 VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, (USHORT)ModeInfo->pAllocation->u.SurfInfo.width); 2532 VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES); 2533 VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, (USHORT)ModeInfo->pAllocation->u.SurfInfo.height); 2534 VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP); 2535 VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, (USHORT)ModeInfo->pAllocation->u.SurfInfo.bpp); 2536 /* enable the mode */ 2537 VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ENABLE); 2538 VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED); 2539 /** @todo read from the port to see if the mode switch was successful */ 2540 2541 /* Tell the host that we now support graphics in the additions. 2542 * @todo: Keep old behaviour, because VBoxVideoResetDevice is called on every graphics 2543 * mode switch and causes an OFF/ON sequence which is not handled by frontends 2544 * (for example Qt GUI debug build asserts when seamless is being enabled). 2545 */ 2546 // VBoxVideoSetGraphicsCap(TRUE); 2547 2548 #endif 2529 2549 return TRUE; 2530 2550 } -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
r26556 r26630 119 119 #include "wddm/VBoxVideoShgsmi.h" 120 120 #include "wddm/VBoxVideoVdma.h" 121 #include "wddm/VBoxVideoWddm.h" 121 122 122 123 typedef KSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK; … … 129 130 typedef struct VBOXWDDM_SOURCE 130 131 { 131 ULONG VisScreenWidth; 132 ULONG VisScreenHeight; 133 ULONG BitsPerPlane; 134 135 ULONG ulFrameBufferOffset; /* The framebuffer position in the VRAM. */ 136 ULONG ulFrameBufferSize; /* The size of the current framebuffer. */ 132 struct VBOXWDDM_ALLOCATION * pAllocation; 137 133 } VBOXWDDM_SOURCE, *PVBOXWDDM_SOURCE; 138 134 139 typedef enum140 {141 VBOXWDDM_ALLOC_UNEFINED = 0,142 VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE,143 VBOXWDDM_ALLOC_STD_SHADOWSURFACE,144 VBOXWDDM_ALLOC_STD_STAGINGSURFACE,145 /* this one is win 7-specific and hence unused for now */146 VBOXWDDM_ALLOC_STD_GDISURFACE147 /* custom allocation types requested from user-mode d3d module will go here */148 } VBOXWDDM_ALLOC_TYPE;149 150 typedef struct VBOXWDDM_ALLOCINFO151 {152 VBOXWDDM_ALLOC_TYPE enmType;153 char Body[1];154 } VBOXWDDM_ALLOCINFO, *PVBOXWDDM_ALLOCINFO;155 156 #define VBOXWDDM_ALLOCINFO_HEADSIZE() (RT_OFFSETOF(VBOXWDDM_ALLOCINFO, Body))157 #define VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(_s) (VBOXWDDM_ALLOCINFO_HEADSIZE() + (_s))158 #define VBOXWDDM_ALLOCINFO_SIZE(_tCmd) (VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(sizeof(_tCmd)))159 #define VBOXWDDM_ALLOCINFO_BODY(_p, _t) ((_t*)(_p)->Body)160 #define VBOXWDDM_ALLOCINFO_HEAD(_pb) ((VBOXWDDM_ALLOCINFO*)((uint8_t *)(_pb) - RT_OFFSETOF(VBOXWDDM_ALLOCINFO, Body)))161 162 typedef struct VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE163 {164 D3DKMDT_SHAREDPRIMARYSURFACEDATA SurfData;165 } VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE, *PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE;166 167 typedef struct VBOXWDDM_ALLOCINFO_SHADOWSURFACE168 {169 D3DKMDT_SHADOWSURFACEDATA SurfData;170 } VBOXWDDM_ALLOCINFO_SHADOWSURFACE, *PVBOXWDDM_ALLOCINFO_SHADOWSURFACE;171 172 typedef struct VBOXWDDM_ALLOCINFO_STAGINGSURFACE173 {174 D3DKMDT_STAGINGSURFACEDATA SurfData;175 } VBOXWDDM_ALLOCINFO_STAGINGSURFACE, *PVBOXWDDM_ALLOCINFO_STAGINGSURFACE;176 177 /* allocation */178 typedef struct VBOXWDDM_ALLOCATION179 {180 VBOXWDDM_ALLOC_TYPE enmType;181 char Body[1];182 } VBOXWDDM_ALLOCATION, *PVBOXWDDM_ALLOCATION;183 184 #define VBOXWDDM_ALLOCATION_HEADSIZE() (RT_OFFSETOF(VBOXWDDM_ALLOCATION, Body))185 #define VBOXWDDM_ALLOCATION_SIZE_FROMBODYSIZE(_s) (VBOXWDDM_ALLOCATION_HEADSIZE() + (_s))186 #define VBOXWDDM_ALLOCATION_SIZE(_tCmd) (VBOXWDDM_ALLOCATION_SIZE_FROMBODYSIZE(sizeof(_tCmd)))187 #define VBOXWDDM_ALLOCATION_BODY(_p, _t) ((_t*)(_p)->Body)188 #define VBOXWDDM_ALLOCATION_HEAD(_pb) ((VBOXWDDM_ALLOCATION*)((uint8_t *)(_pb) - RT_OFFSETOF(VBOXWDDM_ALLOCATION, Body)))189 190 typedef struct VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE191 {192 VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE AllocInfo;193 } VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE, *PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE;194 195 typedef struct VBOXWDDM_ALLOCATION_SHADOWSURFACE196 {197 VBOXWDDM_ALLOCINFO_SHADOWSURFACE AllocInfo;198 } VBOXWDDM_ALLOCATION_SHADOWSURFACE, *PVBOXWDDM_ALLOCATION_SHADOWSURFACE;199 200 typedef struct VBOXWDDM_ALLOCATION_STAGINGSURFACE201 {202 VBOXWDDM_ALLOCINFO_STAGINGSURFACE AllocInfo;203 } VBOXWDDM_ALLOCATION_STAGINGSURFACE, *PVBOXWDDM_ALLOCATION_STAGINGSURFACE;204 205 206 typedef struct VBOXWDDM_DEVICE207 {208 HANDLE hDevice; /* the handle that the driver should use when it calls back into the Microsoft DirectX graphics kernel subsystem */209 struct _DEVICE_EXTENSION * pAdapter; /* Adapder info */210 DXGK_CREATEDEVICEFLAGS fCreationFlags; /* device creation flags passed to DxgkDdiCreateDevice, not sure we need it */211 DXGK_DEVICEINFO DeviceInfo;212 } VBOXWDDM_DEVICE, *PVBOXWDDM_DEVICE;213 135 #endif 214 136 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
r26556 r26630 1032 1032 } 1033 1033 1034 /** 1035 * DxgkDdiQueryAdapterInfo 1036 */ 1034 1037 NTSTATUS APIENTRY DxgkDdiQueryAdapterInfo( 1035 1038 CONST HANDLE hAdapter, … … 1069 1072 pCaps->SchedulingCaps.Value = 0; 1070 1073 /* we might need it for Aero. 1071 * Setting this glag means we support DeviceContext, i.e.1074 * Setting this flag means we support DeviceContext, i.e. 1072 1075 * DxgkDdiCreateContext and DxgkDdiDestroyContext 1073 1076 */ … … 1131 1134 } 1132 1135 1136 /** 1137 * DxgkDdiCreateDevice 1138 */ 1133 1139 NTSTATUS APIENTRY DxgkDdiCreateDevice( 1134 1140 CONST HANDLE hAdapter, … … 1143 1149 1144 1150 PVBOXWDDM_DEVICE pDevice = (PVBOXWDDM_DEVICE)vboxWddmMemAllocZero(sizeof (VBOXWDDM_DEVICE)); 1145 pDevice->hDevice = pCreateDevice->hDevice; 1151 pCreateDevice->hDevice = pDevice; 1152 if (pCreateDevice->Flags.SystemDevice) 1153 pDevice->enmType = VBOXWDDM_DEVICE_TYPE_SYSTEM; 1154 else 1155 { 1156 AssertBreakpoint(); /* we do not support custom contexts for now */ 1157 drprintf((__FUNCTION__ ": we do not support custom devices for now, hAdapter (0x%x)\n", hAdapter)); 1158 } 1159 1146 1160 pDevice->pAdapter = pContext; 1147 pDevice->fCreationFlags = pCreateDevice->Flags; 1148 1149 pDevice->DeviceInfo.AllocationListSize = 1024; 1150 pDevice->DeviceInfo.DmaBufferSegmentSet = 0; 1151 pDevice->DeviceInfo.DmaBufferPrivateDataSize = 0; 1152 pDevice->DeviceInfo.AllocationListSize = 4; 1153 pDevice->DeviceInfo.PatchLocationListSize = 4; 1154 pDevice->DeviceInfo.Flags.Value = 0; 1155 pDevice->DeviceInfo.Flags.GuaranteedDmaBufferContract = 1; 1156 1157 pCreateDevice->pInfo = &pDevice->DeviceInfo; 1161 1158 1162 pCreateDevice->hDevice = pDevice; 1163 pCreateDevice->pInfo = NULL; 1159 1164 1160 1165 dfprintf(("<== "__FUNCTION__ ", context(0x%x), Status(0x%x)\n", hAdapter, Status)); … … 1187 1192 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE)) 1188 1193 { 1189 PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE); 1190 UINT bpp = vboxWddmCalcBitsPerPixel(pInfo->SurfData.Format); 1191 Assert(bpp); 1192 if (bpp != 0) 1194 if (pAllocInfo->u.SurfInfo.bpp != 0) 1193 1195 { 1194 1196 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_SIZE(VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE)); … … 1196 1198 if (pAllocation) 1197 1199 { 1198 UINT Pitch = vboxWddmCalcPitch(pInfo->SurfData.Width, bpp);1199 1200 pAllocation->enmType = VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE; 1201 pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo; 1200 1202 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocInfo, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 1201 memcpy(&pAlloc->AllocInfo, pInfo, sizeof (pAlloc->AllocInfo)); 1203 PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pAllocI = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE); 1204 // memcpy(&pAlloc->AllocInfo, pInfo, sizeof (pAlloc->AllocInfo)); 1205 pAlloc->RefreshRate = pAllocI->RefreshRate; 1206 pAlloc->VidPnSourceId = pAllocI->VidPnSourceId; 1207 pAlloc->offAddress = VBOXVIDEOOFFSET_VOID; 1208 pAlloc->bVisible = FALSE; 1202 1209 1203 1210 pAllocationInfo->pPrivateDriverData = NULL; 1204 1211 pAllocationInfo->PrivateDriverDataSize = 0; 1205 1212 pAllocationInfo->Alignment = 0; 1206 pAllocationInfo->Size = Pitch * pInfo->SurfData.Height;1213 pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height; 1207 1214 pAllocationInfo->PitchAlignedSize = 0; 1208 1215 pAllocationInfo->HintedBank.Value = 0; … … 1212 1219 pAllocationInfo->EvictionSegmentSet = 0; 1213 1220 pAllocationInfo->MaximumRenamingListLength = 0; 1214 pAllocationInfo->hAllocation = pAlloc ;1221 pAllocationInfo->hAllocation = pAllocation; 1215 1222 pAllocationInfo->Flags.Value = 0; 1216 1223 pAllocationInfo->Flags.CpuVisible = 1; … … 1226 1233 else 1227 1234 { 1228 drprintf((__FUNCTION__ ": Invalid format (%d)\n", p Info->SurfData.Format));1235 drprintf((__FUNCTION__ ": Invalid format (%d)\n", pAllocInfo->u.SurfInfo.format)); 1229 1236 Status = STATUS_INVALID_PARAMETER; 1230 1237 } … … 1232 1239 else 1233 1240 { 1234 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHA DOWSURFACE)));1241 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE))); 1235 1242 Status = STATUS_INVALID_PARAMETER; 1236 1243 } … … 1238 1245 } 1239 1246 case VBOXWDDM_ALLOC_STD_SHADOWSURFACE: 1240 { 1241 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHADOWSURFACE)); 1242 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHADOWSURFACE)) 1247 case VBOXWDDM_ALLOC_STD_STAGINGSURFACE: 1248 { 1249 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE()); 1250 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE()) 1243 1251 { 1244 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOC ATION_SIZE(VBOXWDDM_ALLOCATION_SHADOWSURFACE));1252 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCINFO_HEADSIZE()); 1245 1253 Assert(pAllocation); 1246 1254 if (pAllocation) 1247 1255 { 1248 pAllocation->enmType = VBOXWDDM_ALLOC_STD_SHADOWSURFACE; 1249 PVBOXWDDM_ALLOCATION_SHADOWSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocInfo, VBOXWDDM_ALLOCATION_SHADOWSURFACE); 1250 PVBOXWDDM_ALLOCINFO_SHADOWSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHADOWSURFACE); 1251 memcpy(&pAlloc->AllocInfo, pInfo, sizeof (pAlloc->AllocInfo)); 1256 pAllocation->enmType = pAllocInfo->enmType; 1257 pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo; 1252 1258 1253 1259 pAllocationInfo->pPrivateDriverData = NULL; 1254 1260 pAllocationInfo->PrivateDriverDataSize = 0; 1255 1261 pAllocationInfo->Alignment = 0; 1256 pAllocationInfo->Size = p Info->SurfData.Pitch * pInfo->SurfData.Height;1262 pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height; 1257 1263 pAllocationInfo->PitchAlignedSize = 0; 1258 1264 pAllocationInfo->HintedBank.Value = 0; … … 1262 1268 pAllocationInfo->EvictionSegmentSet = 0; 1263 1269 pAllocationInfo->MaximumRenamingListLength = 0; 1264 pAllocationInfo->hAllocation = pAlloc ;1270 pAllocationInfo->hAllocation = pAllocation; 1265 1271 pAllocationInfo->Flags.Value = 0; 1266 1272 pAllocationInfo->Flags.CpuVisible = 1; … … 1276 1282 else 1277 1283 { 1278 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than VBOXWDDM_ALLOC_STD_SHADOWSURFACE cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_ SIZE(VBOXWDDM_ALLOCINFO_SHADOWSURFACE)));1284 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than VBOXWDDM_ALLOC_STD_SHADOWSURFACE cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_HEADSIZE())); 1279 1285 Status = STATUS_INVALID_PARAMETER; 1280 1286 } 1281 break;1282 }1283 case VBOXWDDM_ALLOC_STD_STAGINGSURFACE:1284 {1285 /* @todo: impl */1286 AssertBreakpoint();1287 1287 break; 1288 1288 } … … 1366 1366 1367 1367 /** 1368 * 1368 * DxgkDdiGetStandardAllocationDriverData 1369 1369 */ 1370 1370 NTSTATUS … … 1391 1391 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData; 1392 1392 pAllocInfo->enmType = VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE; 1393 pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width; 1394 pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Height; 1395 pAllocInfo->u.SurfInfo.format = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Format; 1396 pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format); 1397 pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width, pAllocInfo->u.SurfInfo.bpp); 1393 1398 PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE); 1394 memcpy(&pInfo->SurfData, pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData, sizeof (pInfo->SurfData)); 1399 pInfo->RefreshRate = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->RefreshRate; 1400 pInfo->VidPnSourceId = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->VidPnSourceId; 1395 1401 } 1396 1402 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE); … … 1415 1421 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData; 1416 1422 pAllocInfo->enmType = VBOXWDDM_ALLOC_STD_SHADOWSURFACE; 1417 PVBOXWDDM_ALLOCINFO_SHADOWSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHADOWSURFACE); 1418 memcpy(&pInfo->SurfData, pGetStandardAllocationDriverData->pCreateShadowSurfaceData, sizeof (pInfo->SurfData)); 1423 pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width; 1424 pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Height; 1425 pAllocInfo->u.SurfInfo.format = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Format; 1426 pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format); 1427 pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width, pAllocInfo->u.SurfInfo.bpp); 1428 1429 pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Pitch = pAllocInfo->u.SurfInfo.pitch; 1419 1430 } 1420 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_ SIZE(VBOXWDDM_ALLOCINFO_SHADOWSURFACE);1431 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_HEADSIZE(); 1421 1432 1422 1433 pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0; … … 1436 1447 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData; 1437 1448 pAllocInfo->enmType = VBOXWDDM_ALLOC_STD_STAGINGSURFACE; 1438 PVBOXWDDM_ALLOCINFO_STAGINGSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_STAGINGSURFACE); 1439 memcpy(&pInfo->SurfData, pGetStandardAllocationDriverData->pCreateStagingSurfaceData, sizeof (pInfo->SurfData)); 1440 } 1441 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_STAGINGSURFACE); 1449 pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width; 1450 pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Height; 1451 pAllocInfo->u.SurfInfo.format = D3DDDIFMT_X8R8G8B8; /* staging has always always D3DDDIFMT_X8R8G8B8 */ 1452 pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format); 1453 pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width, pAllocInfo->u.SurfInfo.bpp); 1454 1455 pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Pitch = pAllocInfo->u.SurfInfo.pitch; 1456 } 1457 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_HEADSIZE(); 1442 1458 1443 1459 pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0; … … 1446 1462 //#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WIN7) 1447 1463 // case D3DKMDT_STANDARDALLOCATION_GDISURFACE: 1464 //# error port to Win7 DDI 1448 1465 // break; 1449 1466 //#endif … … 2054 2071 CONST DXGKARG_OPENALLOCATION *pOpenAllocation) 2055 2072 { 2056 return STATUS_NOT_IMPLEMENTED; 2073 /* DxgkDdiOpenAllocation should be made pageable. */ 2074 PAGED_CODE(); 2075 2076 NTSTATUS Status = STATUS_SUCCESS; 2077 2078 for (UINT i = 0; i < pOpenAllocation->NumAllocations; ++i) 2079 { 2080 DXGK_OPENALLOCATIONINFO* pInfo = &pOpenAllocation->pOpenAllocation[i]; 2081 PVBOXWDDM_OPENALLOCATION pOa = (PVBOXWDDM_OPENALLOCATION)vboxWddmMemAllocZero(sizeof (VBOXWDDM_OPENALLOCATION)); 2082 pOa->hAllocation = pInfo->hAllocation; 2083 pInfo->hDeviceSpecificAllocation = pOa; 2084 } 2085 2086 return Status; 2057 2087 } 2058 2088 … … 2072 2102 DXGKARG_RENDER *pRender) 2073 2103 { 2074 return STATUS_NOT_IMPLEMENTED; 2075 } 2076 2104 drprintf(("==> "__FUNCTION__ ", !!NOT_IMPLEMENTED!! hContext(0x%x)\n", hContext)); 2105 2106 AssertBreakpoint(); 2107 2108 drprintf(("<== "__FUNCTION__ ", !!NOT_IMPLEMENTED!! hContext(0x%x)\n", hContext)); 2109 2110 return STATUS_NOT_IMPLEMENTED; 2111 } 2112 2113 #define VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE() (VBOXVDMACMD_SIZE(VBOXVDMACMD_DMA_PRESENT_BLT)) 2114 #define VBOXVDMACMD_DMA_PRESENT_BLT_SIZE(_c) (VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, aDstSubRects[_c])) 2115 2116 DECLINLINE(PVBOXWDDM_ALLOCATION) vboxWddmGetAllocationFromOpenData(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_OPENALLOCATION pOa) 2117 { 2118 DXGKARGCB_GETHANDLEDATA GhData; 2119 GhData.hObject = pOa->hAllocation; 2120 GhData.Type = DXGK_HANDLE_ALLOCATION; 2121 GhData.Flags.Value = 0; 2122 return (PVBOXWDDM_ALLOCATION)pDevExt->u.primary.DxgkInterface.DxgkCbGetHandleData(&GhData); 2123 } 2124 2125 DECLINLINE(PVBOXWDDM_ALLOCATION) vboxWddmGetAllocationFromAllocList(PDEVICE_EXTENSION pDevExt, DXGK_ALLOCATIONLIST *pAllocList) 2126 { 2127 return vboxWddmGetAllocationFromOpenData(pDevExt, (PVBOXWDDM_OPENALLOCATION)pAllocList->hDeviceSpecificAllocation); 2128 } 2129 2130 DECLINLINE(VBOXVIDEOOFFSET) vboxWddmOffsetFromPhAddress(PHYSICAL_ADDRESS phAddr) 2131 { 2132 return (VBOXVIDEOOFFSET)(phAddr.QuadPart ? phAddr.QuadPart - VBE_DISPI_LFB_PHYSICAL_ADDRESS : VBOXVIDEOOFFSET_VOID); 2133 } 2134 2135 DECLINLINE(VOID) vboxWddmRectlFromRect(const RECT *pRect, PVBOXVDMA_RECTL pRectl) 2136 { 2137 pRectl->left = (int16_t)pRect->left; 2138 pRectl->width = (uint16_t)(pRect->right - pRect->left); 2139 pRectl->top = (int16_t)pRect->top; 2140 pRectl->height = (uint16_t)(pRect->bottom - pRect->top); 2141 } 2142 2143 DECLINLINE(VBOXVDMA_PIXEL_FORMAT) vboxWddmFromPixFormat(D3DDDIFORMAT format) 2144 { 2145 return (VBOXVDMA_PIXEL_FORMAT)format; 2146 } 2147 2148 DECLINLINE(VOID) vboxWddmSurfDescFromAllocation(PVBOXWDDM_ALLOCATION pAllocation, PVBOXVDMA_SURF_DESC pDesc) 2149 { 2150 pDesc->width = pAllocation->u.SurfInfo.width; 2151 pDesc->height = pAllocation->u.SurfInfo.height; 2152 pDesc->format = vboxWddmFromPixFormat(pAllocation->u.SurfInfo.format); 2153 pDesc->bpp = pAllocation->u.SurfInfo.bpp; 2154 pDesc->pitch = pAllocation->u.SurfInfo.pitch; 2155 pDesc->fFlags = 0; 2156 } 2157 2158 DECLINLINE(BOOLEAN) vboxWddmPixFormatConversionSupported(D3DDDIFORMAT From, D3DDDIFORMAT To) 2159 { 2160 Assert(From != D3DDDIFMT_UNKNOWN); 2161 Assert(To != D3DDDIFMT_UNKNOWN); 2162 Assert(From == To); 2163 return From == To; 2164 } 2165 2166 DECLINLINE(PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE) vboxWddmCheckForVisiblePrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation) 2167 { 2168 if (pAllocation->enmType != VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE) 2169 return NULL; 2170 2171 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 2172 if (!pPrimary->bVisible) 2173 return NULL; 2174 2175 D3DDDI_VIDEO_PRESENT_SOURCE_ID id = pPrimary->VidPnSourceId; 2176 if (id >= pDevExt->cSources) 2177 return NULL; 2178 2179 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[id]; 2180 if (pSource->pAllocation != pAllocation) 2181 return NULL; 2182 2183 return pPrimary; 2184 } 2185 2186 /** 2187 * DxgkDdiPresent 2188 */ 2077 2189 NTSTATUS 2078 2190 APIENTRY … … 2081 2193 DXGKARG_PRESENT *pPresent) 2082 2194 { 2083 return STATUS_NOT_IMPLEMENTED; 2195 PAGED_CODE(); 2196 2197 dfprintf(("==> "__FUNCTION__ ", hContext(0x%x)\n", hContext)); 2198 2199 NTSTATUS Status = STATUS_SUCCESS; 2200 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)hContext; 2201 PVBOXWDDM_DEVICE pDevice = pContext->pDevice; 2202 PDEVICE_EXTENSION pDevExt = pDevice->pAdapter; 2203 2204 if (pPresent->Flags.Blt) 2205 { 2206 Assert(pPresent->Flags.Value == 1); /* only Blt is set, we do not support anything else for now */ 2207 UINT cbCmd = pPresent->DmaSize; 2208 2209 UINT cmdSize = VBOXVDMACMD_DMA_PRESENT_BLT_SIZE(pPresent->SubRectCnt - pPresent->MultipassOffset); 2210 PVBOXVDMACMD pCmd = (PVBOXVDMACMD)pPresent->pDmaBuffer; 2211 pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + cmdSize; 2212 Assert(cbCmd >= VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE()); 2213 if (cbCmd >= VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE()) 2214 { 2215 DXGK_ALLOCATIONLIST *pSrc = &pPresent->pAllocationList[DXGK_PRESENT_SOURCE_INDEX]; 2216 DXGK_ALLOCATIONLIST *pDst = &pPresent->pAllocationList[DXGK_PRESENT_DESTINATION_INDEX]; 2217 PVBOXWDDM_ALLOCATION pSrcAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pSrc); 2218 Assert(pSrcAlloc); 2219 if (pSrcAlloc) 2220 { 2221 PVBOXWDDM_ALLOCATION pDstAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pDst); 2222 Assert(pDstAlloc); 2223 if (pDstAlloc) 2224 { 2225 if (vboxWddmPixFormatConversionSupported(pSrcAlloc->u.SurfInfo.format, pDstAlloc->u.SurfInfo.format)) 2226 { 2227 memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST)); 2228 pPresent->pPatchLocationListOut->PatchOffset = VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, offSrc); 2229 ++pPresent->pPatchLocationListOut; 2230 pPresent->pPatchLocationListOut->PatchOffset = VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, offDst); 2231 pPresent->pPatchLocationListOut->AllocationIndex = 1; 2232 ++pPresent->pPatchLocationListOut; 2233 2234 pCmd->enmType = VBOXVDMACMD_TYPE_DMA_PRESENT_BLT; 2235 pCmd->u32CmdSpecific = 0; 2236 PVBOXVDMACMD_DMA_PRESENT_BLT pTransfer = VBOXVDMACMD_BODY(pCmd, VBOXVDMACMD_DMA_PRESENT_BLT); 2237 pTransfer->offSrc = vboxWddmOffsetFromPhAddress(pSrc->PhysicalAddress); 2238 pTransfer->offDst = vboxWddmOffsetFromPhAddress(pDst->PhysicalAddress); 2239 vboxWddmSurfDescFromAllocation(pSrcAlloc, &pTransfer->srcDesc); 2240 vboxWddmSurfDescFromAllocation(pDstAlloc, &pTransfer->dstDesc); 2241 vboxWddmRectlFromRect(&pPresent->SrcRect, &pTransfer->srcRectl); 2242 vboxWddmRectlFromRect(&pPresent->DstRect, &pTransfer->dstRectl); 2243 UINT i = 0; 2244 cbCmd -= VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, aDstSubRects); 2245 Assert(cbCmd >= sizeof (VBOXVDMA_RECTL)); 2246 Assert(cbCmd < pPresent->DmaSize); 2247 for (; i < pPresent->SubRectCnt; ++i) 2248 { 2249 if (cbCmd < sizeof (VBOXVDMA_RECTL)) 2250 { 2251 Assert(i); 2252 pPresent->MultipassOffset += i; 2253 Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER; 2254 break; 2255 } 2256 vboxWddmRectlFromRect(&pPresent->pDstSubRects[i + pPresent->MultipassOffset], &pTransfer->aDstSubRects[i]); 2257 cbCmd -= sizeof (VBOXVDMA_RECTL); 2258 } 2259 Assert(i); 2260 pTransfer->cDstSubRects = i; 2261 } 2262 else 2263 { 2264 AssertBreakpoint(); 2265 drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc->u.SurfInfo.format, pDstAlloc->u.SurfInfo.format)); 2266 Status = STATUS_GRAPHICS_CANNOTCOLORCONVERT; 2267 } 2268 } 2269 else 2270 { 2271 /* this should not happen actually */ 2272 drprintf((__FUNCTION__": failed to get Dst Allocation info for hDeviceSpecificAllocation(0x%x)\n",pDst->hDeviceSpecificAllocation)); 2273 Status = STATUS_INVALID_HANDLE; 2274 } 2275 } 2276 else 2277 { 2278 /* this should not happen actually */ 2279 drprintf((__FUNCTION__": failed to get Src Allocation info for hDeviceSpecificAllocation(0x%x)\n",pSrc->hDeviceSpecificAllocation)); 2280 Status = STATUS_INVALID_HANDLE; 2281 } 2282 } 2283 else 2284 { 2285 /* this should not happen actually */ 2286 drprintf((__FUNCTION__": cbCmd too small!! (%d)\n", cbCmd)); 2287 Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER; 2288 } 2289 2290 } 2291 else 2292 { 2293 drprintf((__FUNCTION__": cmd NOT IMPLEMENTED!! Flags(0x%x)\n", pPresent->Flags.Value)); 2294 AssertBreakpoint(); 2295 } 2296 2297 dfprintf(("<== "__FUNCTION__ ", hContext(0x%x), Status(0x%x)\n", hContext, Status)); 2298 2299 return Status; 2084 2300 } 2085 2301 … … 2110 2326 } 2111 2327 2328 /** 2329 * DxgkDdiCreateContext 2330 */ 2112 2331 NTSTATUS 2113 2332 APIENTRY … … 2116 2335 DXGKARG_CREATECONTEXT *pCreateContext) 2117 2336 { 2118 return STATUS_NOT_IMPLEMENTED; 2337 /* DxgkDdiCreateContext should be made pageable */ 2338 PAGED_CODE(); 2339 2340 dfprintf(("==> "__FUNCTION__ ", hDevice(0x%x)\n", hDevice)); 2341 2342 NTSTATUS Status = STATUS_SUCCESS; 2343 PVBOXWDDM_DEVICE pDevice = (PVBOXWDDM_DEVICE)hDevice; 2344 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)vboxWddmMemAllocZero(sizeof (VBOXWDDM_CONTEXT)); 2345 2346 pContext->pDevice = pDevice; 2347 pContext->EngineAffinity = pCreateContext->EngineAffinity; 2348 pContext->NodeOrdinal = pCreateContext->NodeOrdinal; 2349 if (pCreateContext->Flags.SystemContext) 2350 pContext->enmType = VBOXWDDM_CONTEXT_TYPE_SYSTEM; 2351 else 2352 { 2353 AssertBreakpoint(); /* we do not support custom contexts for now */ 2354 drprintf((__FUNCTION__ ", we do not support custom contexts for now, hDevice (0x%x)\n", hDevice)); 2355 } 2356 2357 pCreateContext->hContext = pContext; 2358 pCreateContext->ContextInfo.DmaBufferSize = VBOXWDDM_C_DMA_BUFFER_SIZE; 2359 pCreateContext->ContextInfo.DmaBufferSegmentSet = 0; 2360 pCreateContext->ContextInfo.DmaBufferPrivateDataSize = sizeof (VBOXWDDM_DMA_PRIVATE_DATA); 2361 pCreateContext->ContextInfo.AllocationListSize = VBOXWDDM_C_ALLOC_LIST_SIZE; 2362 pCreateContext->ContextInfo.PatchLocationListSize = VBOXWDDM_C_PATH_LOCATION_LIST_SIZE; 2363 //#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WIN7) 2364 //# error port to Win7 DDI 2365 // //pCreateContext->ContextInfo.DmaBufferAllocationGroup = ???; 2366 //#endif // DXGKDDI_INTERFACE_VERSION 2367 2368 dfprintf(("<== "__FUNCTION__ ", hDevice(0x%x)\n", hDevice)); 2369 2370 return Status; 2119 2371 } 2120 2372 … … 2154 2406 ) 2155 2407 { 2408 PAGED_CODE(); 2409 2156 2410 dprintf(("VBoxVideoWddm::DriverEntry. Built %s %s\n", __DATE__, __TIME__)); 2157 2411 2158 2412 DRIVER_INITIALIZATION_DATA DriverInitializationData = {'\0'}; 2159 2160 PAGED_CODE();2161 2413 2162 2414 if (! ARGUMENT_PRESENT(DriverObject) || … … 2253 2505 2254 2506 //#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WIN7) 2255 // DriverInitializationData.DxgkDdiRenderKm = D3DDDIRenderKm; 2256 // DriverInitializationData.DxgkDdiRestartFromTimeout = D3DDDIRestartFromTimeout; 2507 //# error port to Win7 DDI 2508 // DriverInitializationData.DxgkDdiRenderKm = DxgkDdiRenderKm; 2509 // DriverInitializationData.DxgkDdiRestartFromTimeout = DxgkDdiRestartFromTimeout; 2257 2510 // DriverInitializationData.DxgkDdiSetVidPnSourceVisibility = DxgkDdiSetVidPnSourceVisibility; 2258 // DriverInitializationData.DxgkDdiUpdateActiveVidPnPresentPath = D 3DDDIUpdateActiveVidPnPresentPath;2259 // DriverInitializationData.DxgkDdiQueryVidPnHWCapability = D 3DDDI DxgkDdiQueryVidPnHWCapability;2511 // DriverInitializationData.DxgkDdiUpdateActiveVidPnPresentPath = DxgkDdiUpdateActiveVidPnPresentPath; 2512 // DriverInitializationData.DxgkDdiQueryVidPnHWCapability = DxgkDdiQueryVidPnHWCapability; 2260 2513 //#endif 2261 2514
Note:
See TracChangeset
for help on using the changeset viewer.