Changeset 29883 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
- Timestamp:
- May 30, 2010 7:27:02 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
r29798 r29883 76 76 } 77 77 78 NTSTATUS vboxWddmGhDisplayPostInfoScreen (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation , D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)78 NTSTATUS vboxWddmGhDisplayPostInfoScreen (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation) 79 79 { 80 80 VBOXVIDEOOFFSET offVram = pAllocation->offVram; … … 83 83 // return STATUS_INVALID_PARAMETER; 84 84 85 // PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);86 85 /* Issue the screen info command. */ 87 86 void *p = vboxHGSMIBufferAlloc (pDevExt, … … 94 93 VBVAINFOSCREEN *pScreen = (VBVAINFOSCREEN *)p; 95 94 96 pScreen->u32ViewIndex = /*pPrimaryInfo->*/VidPnSourceId;95 pScreen->u32ViewIndex = pAllocation->SurfDesc.VidPnSourceId; 97 96 pScreen->i32OriginX = 0; 98 97 pScreen->i32OriginY = 0; 99 98 pScreen->u32StartOffset = 0; //(uint32_t)offVram; /* we pretend the view is located at the start of each framebuffer */ 100 pScreen->u32LineSize = pAllocation-> u.SurfInfo.pitch;101 pScreen->u32Width = pAllocation-> u.SurfInfo.width;102 pScreen->u32Height = pAllocation-> u.SurfInfo.height;103 pScreen->u16BitsPerPixel = (uint16_t)pAllocation-> u.SurfInfo.bpp;99 pScreen->u32LineSize = pAllocation->SurfDesc.pitch; 100 pScreen->u32Width = pAllocation->SurfDesc.width; 101 pScreen->u32Height = pAllocation->SurfDesc.height; 102 pScreen->u16BitsPerPixel = (uint16_t)pAllocation->SurfDesc.bpp; 104 103 pScreen->u16Flags = VBVA_SCREEN_F_ACTIVE; 105 104 … … 112 111 } 113 112 114 NTSTATUS vboxWddmGhDisplayPostInfoView (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)113 NTSTATUS vboxWddmGhDisplayPostInfoView(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation) 115 114 { 116 115 VBOXVIDEOOFFSET offVram = pAllocation->offVram; … … 119 118 return STATUS_INVALID_PARAMETER; 120 119 121 // PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);122 120 /* Issue the screen info command. */ 123 121 void *p = vboxHGSMIBufferAlloc (pDevExt, … … 130 128 VBVAINFOVIEW *pView = (VBVAINFOVIEW *)p; 131 129 132 pView->u32ViewIndex = /*pPrimaryInfo->*/VidPnSourceId;130 pView->u32ViewIndex = pAllocation->SurfDesc.VidPnSourceId; 133 131 pView->u32ViewOffset = (uint32_t)offVram; /* we pretend the view is located at the start of each framebuffer */ 134 132 pView->u32ViewSize = vboxWddmVramCpuVisibleSegmentSize(pDevExt)/pDevExt->cSources; … … 144 142 } 145 143 146 NTSTATUS vboxWddmGhDisplaySetMode (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)144 NTSTATUS vboxWddmGhDisplaySetMode(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation) 147 145 { 148 146 // PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 149 if (/*pPrimaryInfo->*/ VidPnSourceId)147 if (/*pPrimaryInfo->*/pAllocation->SurfDesc.VidPnSourceId) 150 148 return STATUS_SUCCESS; 151 149 152 if (VBoxVideoSetCurrentModePerform(pDevExt, pAllocation-> u.SurfInfo.width,153 pAllocation-> u.SurfInfo.height, pAllocation->u.SurfInfo.bpp,150 if (VBoxVideoSetCurrentModePerform(pDevExt, pAllocation->SurfDesc.width, 151 pAllocation->SurfDesc.height, pAllocation->SurfDesc.bpp, 154 152 (ULONG)pAllocation->offVram)) 155 153 return STATUS_SUCCESS; … … 166 164 #ifndef VBOXWDDM_RENDER_FROM_SHADOW 167 165 PVBOXWDDM_ALLOCATION pAllocation = pSource->pPrimaryAllocation; 168 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);169 166 #else 170 167 PVBOXWDDM_ALLOCATION pAllocation = pSource->pShadowAllocation; 171 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pSource->pPrimaryAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);172 168 #endif 173 169 VBOXVIDEOOFFSET offVram = vboxWddmValidatePrimary(pAllocation); … … 179 175 * Set the current mode into the hardware. 180 176 */ 181 NTSTATUS Status = vboxWddmGhDisplaySetMode (pDevExt, pAllocation, pPrimaryInfo->VidPnSourceId);177 NTSTATUS Status = vboxWddmGhDisplaySetMode(pDevExt, pAllocation); 182 178 Assert(Status == STATUS_SUCCESS); 183 179 if (Status == STATUS_SUCCESS) 184 180 { 185 Status = vboxWddmGhDisplayPostInfoView (pDevExt, pAllocation, pPrimaryInfo->VidPnSourceId);181 Status = vboxWddmGhDisplayPostInfoView(pDevExt, pAllocation); 186 182 Assert(Status == STATUS_SUCCESS); 187 183 if (Status == STATUS_SUCCESS) 188 184 { 189 Status = vboxWddmGhDisplayPostInfoScreen (pDevExt, pAllocation, pPrimaryInfo->VidPnSourceId);185 Status = vboxWddmGhDisplayPostInfoScreen(pDevExt, pAllocation); 190 186 Assert(Status == STATUS_SUCCESS); 191 187 if (Status != STATUS_SUCCESS) … … 407 403 } 408 404 409 UINT vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format)410 {411 switch (format)412 {413 case D3DDDIFMT_R8G8B8:414 return 24;415 case D3DDDIFMT_A8R8G8B8:416 case D3DDDIFMT_X8R8G8B8:417 return 32;418 case D3DDDIFMT_R5G6B5:419 case D3DDDIFMT_X1R5G5B5:420 case D3DDDIFMT_A1R5G5B5:421 case D3DDDIFMT_A4R4G4B4:422 return 16;423 case D3DDDIFMT_R3G3B2:424 case D3DDDIFMT_A8:425 return 8;426 case D3DDDIFMT_A8R3G3B2:427 case D3DDDIFMT_X4R4G4B4:428 return 16;429 case D3DDDIFMT_A2B10G10R10:430 case D3DDDIFMT_A8B8G8R8:431 case D3DDDIFMT_X8B8G8R8:432 case D3DDDIFMT_G16R16:433 case D3DDDIFMT_A2R10G10B10:434 return 32;435 case D3DDDIFMT_A16B16G16R16:436 return 64;437 case D3DDDIFMT_A8P8:438 return 16;439 case D3DDDIFMT_P8:440 return 8;441 default:442 AssertBreakpoint();443 return 0;444 }445 }446 447 405 D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo) 448 406 { … … 509 467 510 468 return D3DDDIFMT_UNKNOWN; 511 }512 513 UINT vboxWddmCalcPitch(UINT w, UINT bitsPerPixel)514 {515 UINT Pitch = bitsPerPixel * w;516 /* pitch is now in bits, translate in bytes */517 if(Pitch & 7)518 Pitch = (Pitch >> 3) + 1;519 else520 Pitch = (Pitch >> 3);521 522 return Pitch;523 469 } 524 470 … … 1434 1380 case VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE: 1435 1381 { 1436 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 1437 if (pAlloc->bAssigned) 1382 if (pAllocation->bAssigned) 1438 1383 { 1439 1384 /* @todo: do we need to notify host? */ 1440 vboxWddmAssignPrimary(pDevExt, &pDevExt->aSources[pAlloc ->VidPnSourceId], NULL, pAlloc->VidPnSourceId);1385 vboxWddmAssignPrimary(pDevExt, &pDevExt->aSources[pAllocation->SurfDesc.VidPnSourceId], NULL, pAllocation->SurfDesc.VidPnSourceId); 1441 1386 } 1442 1387 break; … … 1445 1390 case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE: 1446 1391 { 1447 PVBOXWDDM_ALLOCATION_SHADOWSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHADOWSURFACE); 1448 if (pAlloc->bAssigned) 1449 { 1450 Assert(pAlloc->VidPnSourceId != D3DDDI_ID_UNINITIALIZED); 1392 if (pAllocation->bAssigned) 1393 { 1394 Assert(pAllocation->SurfDesc.VidPnSourceId != D3DDDI_ID_UNINITIALIZED); 1451 1395 /* @todo: do we need to notify host? */ 1452 vboxWddmAssignShadow(pDevExt, &pDevExt->aSources[pAlloc ->VidPnSourceId], NULL, pAlloc->VidPnSourceId);1396 vboxWddmAssignShadow(pDevExt, &pDevExt->aSources[pAllocation->SurfDesc.VidPnSourceId], NULL, pAllocation->SurfDesc.VidPnSourceId); 1453 1397 } 1454 1398 break; … … 1468 1412 NTSTATUS Status = STATUS_SUCCESS; 1469 1413 1470 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE());1471 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE())1414 Assert(pAllocationInfo->PrivateDriverDataSize == sizeof (VBOXWDDM_ALLOCINFO)); 1415 if (pAllocationInfo->PrivateDriverDataSize >= sizeof (VBOXWDDM_ALLOCINFO)) 1472 1416 { 1473 1417 PVBOXWDDM_ALLOCINFO pAllocInfo = (PVBOXWDDM_ALLOCINFO)pAllocationInfo->pPrivateDriverData; 1474 switch (pAllocInfo->enmType) 1475 { 1476 case VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE: 1477 { 1478 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE)); 1479 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE)) 1480 { 1481 if (pAllocInfo->u.SurfInfo.bpp != 0) 1482 { 1483 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_SIZE(VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE)); 1484 Assert(pAllocation); 1485 if (pAllocation) 1486 { 1487 pAllocation->enmType = VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE; 1488 pAllocation->offVram = VBOXVIDEOOFFSET_VOID; 1489 pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo; 1490 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 1491 PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pAllocI = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE); 1492 pAlloc->RefreshRate = pAllocI->RefreshRate; 1493 pAlloc->VidPnSourceId = pAllocI->VidPnSourceId; 1494 // pAlloc->offAddress = VBOXVIDEOOFFSET_VOID; 1495 pAlloc->bVisible = FALSE; 1496 1497 pAllocationInfo->pPrivateDriverData = NULL; 1498 pAllocationInfo->PrivateDriverDataSize = 0; 1499 pAllocationInfo->Alignment = 0; 1500 pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height; 1501 pAllocationInfo->PitchAlignedSize = 0; 1502 pAllocationInfo->HintedBank.Value = 0; 1503 pAllocationInfo->PreferredSegment.Value = 0; 1504 #if 1 //defined(VBOXWDDM_RENDER_FROM_SHADOW) 1505 pAllocationInfo->SupportedReadSegmentSet = 1; 1506 pAllocationInfo->SupportedWriteSegmentSet = 1; 1507 #else 1508 pAllocationInfo->SupportedReadSegmentSet = 2; 1509 pAllocationInfo->SupportedWriteSegmentSet = 2; 1418 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(sizeof (VBOXWDDM_ALLOCATION)); 1419 Assert(pAllocation); 1420 if (pAllocation) 1421 { 1422 pAllocation->enmType = pAllocInfo->enmType; 1423 pAllocation->offVram = VBOXVIDEOOFFSET_VOID; 1424 pAllocation->SurfDesc = pAllocInfo->SurfDesc; 1425 pAllocation->bVisible = FALSE; 1426 pAllocation->bAssigned = FALSE; 1427 1428 pAllocationInfo->pPrivateDriverData = NULL; 1429 pAllocationInfo->PrivateDriverDataSize = 0; 1430 pAllocationInfo->Alignment = 0; 1431 pAllocationInfo->Size = pAllocInfo->SurfDesc.pitch * pAllocInfo->SurfDesc.height; 1432 pAllocationInfo->PitchAlignedSize = 0; 1433 pAllocationInfo->HintedBank.Value = 0; 1434 pAllocationInfo->PreferredSegment.Value = 0; 1435 pAllocationInfo->SupportedReadSegmentSet = 1; 1436 pAllocationInfo->SupportedWriteSegmentSet = 1; 1437 pAllocationInfo->EvictionSegmentSet = 0; 1438 pAllocationInfo->MaximumRenamingListLength = 0; 1439 pAllocationInfo->hAllocation = pAllocation; 1440 pAllocationInfo->Flags.Value = 0; 1441 pAllocationInfo->pAllocationUsageHint = NULL; 1442 pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL; 1443 1444 switch (pAllocInfo->enmType) 1445 { 1446 case VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE: 1447 #if 0 //defined(VBOXWDDM_RENDER_FROM_SHADOW) 1448 pAllocationInfo->SupportedReadSegmentSet = 2; 1449 pAllocationInfo->SupportedWriteSegmentSet = 2; 1510 1450 #endif 1511 pAllocationInfo->EvictionSegmentSet = 0;1512 pAllocationInfo->MaximumRenamingListLength = 0;1513 pAllocationInfo->hAllocation = pAllocation;1514 pAllocationInfo->Flags.Value = 0;1515 1451 #ifndef VBOXWDDM_RENDER_FROM_SHADOW 1516 1452 pAllocationInfo->Flags.CpuVisible = 1; 1517 1453 #endif 1518 pAllocationInfo->pAllocationUsageHint = NULL; 1519 pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL; 1520 } 1521 else 1522 { 1523 drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n")); 1524 Status = STATUS_NO_MEMORY; 1525 } 1526 } 1527 else 1528 { 1529 drprintf((__FUNCTION__ ": Invalid format (%d)\n", pAllocInfo->u.SurfInfo.format)); 1530 Status = STATUS_INVALID_PARAMETER; 1531 } 1532 } 1533 else 1534 { 1535 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE))); 1454 break; 1455 case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE: 1456 case VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE: 1457 case VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC: 1458 pAllocationInfo->Flags.Value = 0; 1459 pAllocationInfo->Flags.CpuVisible = 1; 1460 break; 1461 default: 1462 drprintf((__FUNCTION__ ": ERROR: invalid alloc info type(%d)\n", pAllocInfo->enmType)); 1463 AssertBreakpoint(); 1536 1464 Status = STATUS_INVALID_PARAMETER; 1537 } 1538 break; 1539 } 1540 case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE: 1541 #ifdef VBOXWDDM_RENDER_FROM_SHADOW 1542 { 1543 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE()); 1544 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE()) 1545 { 1546 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_SIZE(VBOXWDDM_ALLOCATION_SHADOWSURFACE)); 1547 Assert(pAllocation); 1548 if (pAllocation) 1549 { 1550 pAllocation->enmType = pAllocInfo->enmType; 1551 pAllocation->offVram = VBOXVIDEOOFFSET_VOID; 1552 pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo; 1553 1554 pAllocationInfo->pPrivateDriverData = NULL; 1555 pAllocationInfo->PrivateDriverDataSize = 0; 1556 pAllocationInfo->Alignment = 0; 1557 pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height; 1558 pAllocationInfo->PitchAlignedSize = 0; 1559 pAllocationInfo->HintedBank.Value = 0; 1560 pAllocationInfo->PreferredSegment.Value = 0; 1561 pAllocationInfo->SupportedReadSegmentSet = 1; 1562 pAllocationInfo->SupportedWriteSegmentSet = 1; 1563 pAllocationInfo->EvictionSegmentSet = 0; 1564 pAllocationInfo->MaximumRenamingListLength = 0; 1565 pAllocationInfo->hAllocation = pAllocation; 1566 pAllocationInfo->Flags.Value = 0; 1567 pAllocationInfo->Flags.CpuVisible = 1; 1568 pAllocationInfo->pAllocationUsageHint = NULL; 1569 pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL; 1570 PVBOXWDDM_ALLOCATION_SHADOWSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHADOWSURFACE); 1571 pAlloc->VidPnSourceId = D3DDDI_ID_UNINITIALIZED; 1572 // pAlloc->bVisible = FALSE; 1573 // pAlloc->bAssigned = FALSE; 1574 } 1575 else 1576 { 1577 drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n")); 1578 Status = STATUS_NO_MEMORY; 1579 } 1580 } 1581 else 1582 { 1583 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_HEADSIZE())); 1584 Status = STATUS_INVALID_PARAMETER; 1585 } 1586 break; 1587 } 1588 #endif 1589 case VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE: 1590 { 1591 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE()); 1592 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE()) 1593 { 1594 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_HEADSIZE()); 1595 Assert(pAllocation); 1596 if (pAllocation) 1597 { 1598 pAllocation->enmType = pAllocInfo->enmType; 1599 pAllocation->offVram = VBOXVIDEOOFFSET_VOID; 1600 pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo; 1601 1602 pAllocationInfo->pPrivateDriverData = NULL; 1603 pAllocationInfo->PrivateDriverDataSize = 0; 1604 pAllocationInfo->Alignment = 0; 1605 pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height; 1606 pAllocationInfo->PitchAlignedSize = 0; 1607 pAllocationInfo->HintedBank.Value = 0; 1608 pAllocationInfo->PreferredSegment.Value = 0; 1609 pAllocationInfo->SupportedReadSegmentSet = 1; 1610 pAllocationInfo->SupportedWriteSegmentSet = 1; 1611 pAllocationInfo->EvictionSegmentSet = 0; 1612 pAllocationInfo->MaximumRenamingListLength = 0; 1613 pAllocationInfo->hAllocation = pAllocation; 1614 pAllocationInfo->Flags.Value = 0; 1615 pAllocationInfo->Flags.CpuVisible = 1; 1616 pAllocationInfo->pAllocationUsageHint = NULL; 1617 pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL; 1618 } 1619 else 1620 { 1621 drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n")); 1622 Status = STATUS_NO_MEMORY; 1623 } 1624 } 1625 else 1626 { 1627 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_HEADSIZE())); 1628 Status = STATUS_INVALID_PARAMETER; 1629 } 1630 break; 1631 } 1632 default: 1633 drprintf((__FUNCTION__ ": ERROR: invalid alloc info type(%d)\n", pAllocInfo->enmType)); 1634 Status = STATUS_INVALID_PARAMETER; 1635 break; 1636 } 1465 break; 1466 } 1467 1468 if (Status != STATUS_SUCCESS) 1469 vboxWddmMemFree(pAllocation); 1470 } 1471 else 1472 { 1473 drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n")); 1474 Status = STATUS_NO_MEMORY; 1475 } 1476 1637 1477 } 1638 1478 else 1639 1479 { 1640 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than header size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_HEADSIZE()));1480 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than header size(%d)\n", pAllocationInfo->PrivateDriverDataSize, sizeof (VBOXWDDM_ALLOCINFO))); 1641 1481 Status = STATUS_INVALID_PARAMETER; 1642 1482 } … … 1658 1498 NTSTATUS Status = STATUS_SUCCESS; 1659 1499 1500 if (pCreateAllocation->PrivateDriverDataSize) 1501 { 1502 /* @todo: Implement Resource Data Handling */ 1503 drprintf((__FUNCTION__ ": WARNING: Implement Resource Data Handling\n")); 1504 } 1505 1660 1506 for (UINT i = 0; i < pCreateAllocation->NumAllocations; ++i) 1661 1507 { … … 1717 1563 1718 1564 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)pDescribeAllocation->hAllocation; 1719 pDescribeAllocation->Width = pAllocation-> u.SurfInfo.width;1720 pDescribeAllocation->Height = pAllocation-> u.SurfInfo.height;1721 pDescribeAllocation->Format = pAllocation-> u.SurfInfo.format;1565 pDescribeAllocation->Width = pAllocation->SurfDesc.width; 1566 pDescribeAllocation->Height = pAllocation->SurfDesc.height; 1567 pDescribeAllocation->Format = pAllocation->SurfDesc.format; 1722 1568 memset (&pDescribeAllocation->MultisampleMethod, 0, sizeof (pDescribeAllocation->MultisampleMethod)); 1723 1569 pDescribeAllocation->RefreshRate.Numerator = 60000; … … 1757 1603 { 1758 1604 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData; 1605 memset (pAllocInfo, 0, sizeof (VBOXWDDM_ALLOCINFO)); 1759 1606 pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE; 1760 pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width; 1761 pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Height; 1762 pAllocInfo->u.SurfInfo.format = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Format; 1763 pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format); 1764 pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width, pAllocInfo->u.SurfInfo.bpp); 1765 PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE); 1766 pInfo->RefreshRate = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->RefreshRate; 1767 pInfo->VidPnSourceId = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->VidPnSourceId; 1768 } 1769 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE); 1607 pAllocInfo->SurfDesc.width = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width; 1608 pAllocInfo->SurfDesc.height = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Height; 1609 pAllocInfo->SurfDesc.format = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Format; 1610 pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format); 1611 pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width, pAllocInfo->SurfDesc.bpp); 1612 pAllocInfo->SurfDesc.depth = 0; 1613 pAllocInfo->SurfDesc.slicePitch = 0; 1614 pAllocInfo->SurfDesc.RefreshRate = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->RefreshRate; 1615 pAllocInfo->SurfDesc.VidPnSourceId = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->VidPnSourceId; 1616 } 1617 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = sizeof (VBOXWDDM_ALLOCINFO); 1770 1618 1771 1619 pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0; … … 1788 1636 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData; 1789 1637 pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE; 1790 pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width; 1791 pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Height; 1792 pAllocInfo->u.SurfInfo.format = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Format; 1793 pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format); 1794 pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width, pAllocInfo->u.SurfInfo.bpp); 1795 1796 pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Pitch = pAllocInfo->u.SurfInfo.pitch; 1638 pAllocInfo->SurfDesc.width = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width; 1639 pAllocInfo->SurfDesc.height = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Height; 1640 pAllocInfo->SurfDesc.format = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Format; 1641 pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format); 1642 pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width, pAllocInfo->SurfDesc.bpp); 1643 pAllocInfo->SurfDesc.depth = 0; 1644 pAllocInfo->SurfDesc.slicePitch = 0; 1645 pAllocInfo->SurfDesc.RefreshRate.Numerator = 0; 1646 pAllocInfo->SurfDesc.RefreshRate.Denominator = 1000; 1647 pAllocInfo->SurfDesc.VidPnSourceId = D3DDDI_ID_UNINITIALIZED; 1648 1649 pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Pitch = pAllocInfo->SurfDesc.pitch; 1797 1650 } 1798 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_HEADSIZE();1651 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = sizeof (VBOXWDDM_ALLOCINFO); 1799 1652 1800 1653 pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0; … … 1814 1667 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData; 1815 1668 pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE; 1816 pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width; 1817 pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Height; 1818 pAllocInfo->u.SurfInfo.format = D3DDDIFMT_X8R8G8B8; /* staging has always always D3DDDIFMT_X8R8G8B8 */ 1819 pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format); 1820 pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width, pAllocInfo->u.SurfInfo.bpp); 1821 1822 pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Pitch = pAllocInfo->u.SurfInfo.pitch; 1823 } 1824 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_HEADSIZE(); 1669 pAllocInfo->SurfDesc.width = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width; 1670 pAllocInfo->SurfDesc.height = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Height; 1671 pAllocInfo->SurfDesc.format = D3DDDIFMT_X8R8G8B8; /* staging has always always D3DDDIFMT_X8R8G8B8 */ 1672 pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format); 1673 pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width, pAllocInfo->SurfDesc.bpp); 1674 pAllocInfo->SurfDesc.depth = 0; 1675 pAllocInfo->SurfDesc.slicePitch = 0; 1676 pAllocInfo->SurfDesc.RefreshRate.Numerator = 0; 1677 pAllocInfo->SurfDesc.RefreshRate.Denominator = 1000; 1678 pAllocInfo->SurfDesc.VidPnSourceId = D3DDDI_ID_UNINITIALIZED; 1679 1680 pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Pitch = pAllocInfo->SurfDesc.pitch; 1681 } 1682 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = sizeof (VBOXWDDM_ALLOCINFO); 1825 1683 1826 1684 pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0; … … 2929 2787 { 2930 2788 Assert(pAllocation->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE); 2931 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);2932 2789 pAllocation->offVram = (VBOXVIDEOOFFSET)pSetVidPnSourceAddress->PrimaryAddress.QuadPart; 2933 2790 pAllocation->SegmentId = pSetVidPnSourceAddress->PrimarySegment; 2934 2791 Assert (pAllocation->SegmentId); 2935 Assert (!p Primary->bVisible);2792 Assert (!pAllocation->bVisible); 2936 2793 #ifndef VBOXWDDM_RENDER_FROM_SHADOW 2937 if (p Primary->bVisible)2794 if (pAllocation->bVisible) 2938 2795 { 2939 2796 /* should not generally happen, but still inform host*/ … … 2983 2840 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pSetVidPnSourceVisibility->VidPnSourceId]; 2984 2841 PVBOXWDDM_ALLOCATION pAllocation = pSource->pPrimaryAllocation; 2985 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 2986 2987 Assert(pPrimary->bVisible != pSetVidPnSourceVisibility->Visible); 2988 if (pPrimary->bVisible != pSetVidPnSourceVisibility->Visible) 2989 { 2990 pPrimary->bVisible = pSetVidPnSourceVisibility->Visible; 2842 2843 Assert(pAllocation->bVisible != pSetVidPnSourceVisibility->Visible); 2844 if (pAllocation->bVisible != pSetVidPnSourceVisibility->Visible) 2845 { 2846 pAllocation->bVisible = pSetVidPnSourceVisibility->Visible; 2991 2847 #ifndef VBOXWDDM_RENDER_FROM_SHADOW 2992 if (p Primary->bVisible)2848 if (pAllocation->bVisible) 2993 2849 { 2994 2850 Status = vboxWddmGhDisplaySetInfo(pDevExt, pSource); … … 3368 3224 DECLINLINE(VOID) vboxWddmSurfDescFromAllocation(PVBOXWDDM_ALLOCATION pAllocation, PVBOXVDMA_SURF_DESC pDesc) 3369 3225 { 3370 pDesc->width = pAllocation-> u.SurfInfo.width;3371 pDesc->height = pAllocation-> u.SurfInfo.height;3372 pDesc->format = vboxWddmFromPixFormat(pAllocation-> u.SurfInfo.format);3373 pDesc->bpp = pAllocation-> u.SurfInfo.bpp;3374 pDesc->pitch = pAllocation-> u.SurfInfo.pitch;3226 pDesc->width = pAllocation->SurfDesc.width; 3227 pDesc->height = pAllocation->SurfDesc.height; 3228 pDesc->format = vboxWddmFromPixFormat(pAllocation->SurfDesc.format); 3229 pDesc->bpp = pAllocation->SurfDesc.bpp; 3230 pDesc->pitch = pAllocation->SurfDesc.pitch; 3375 3231 pDesc->fFlags = 0; 3376 3232 } … … 3384 3240 } 3385 3241 3386 DECLINLINE( PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE) vboxWddmCheckForVisiblePrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)3242 DECLINLINE(bool) vboxWddmCheckForVisiblePrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation) 3387 3243 { 3388 3244 if (pAllocation->enmType != VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE) 3389 return NULL; 3390 3391 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 3392 if (!pPrimary->bVisible) 3393 return NULL; 3394 3395 D3DDDI_VIDEO_PRESENT_SOURCE_ID id = pPrimary->VidPnSourceId; 3245 return false; 3246 3247 if (!pAllocation->bVisible) 3248 return false; 3249 3250 D3DDDI_VIDEO_PRESENT_SOURCE_ID id = pAllocation->SurfDesc.VidPnSourceId; 3396 3251 if (id >= pDevExt->cSources) 3397 return NULL;3252 return false; 3398 3253 3399 3254 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[id]; 3400 3255 if (pSource->pPrimaryAllocation != pAllocation) 3401 return NULL;3402 3403 return pPrimary;3256 return false; 3257 3258 return true; 3404 3259 } 3405 3260 … … 3456 3311 && pSrcAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE) 3457 3312 { 3458 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pDstAlloc, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 3459 Assert(pPrimaryInfo->bAssigned); 3460 Assert(pPrimaryInfo->bVisible); 3461 if (pPrimaryInfo->bAssigned 3462 && pPrimaryInfo->bVisible) 3313 Assert(pDstAlloc->bAssigned); 3314 Assert(pDstAlloc->bVisible); 3315 if (pDstAlloc->bAssigned 3316 && pDstAlloc->bVisible) 3463 3317 { 3464 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[p PrimaryInfo->VidPnSourceId];3465 vboxWddmAssignShadow(pDevExt, pSource, pSrcAlloc, p PrimaryInfo->VidPnSourceId);3318 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pDstAlloc->SurfDesc.VidPnSourceId]; 3319 vboxWddmAssignShadow(pDevExt, pSource, pSrcAlloc, pDstAlloc->SurfDesc.VidPnSourceId); 3466 3320 Assert(pPresent->SrcRect.left == pPresent->DstRect.left); 3467 3321 Assert(pPresent->SrcRect.right == pPresent->DstRect.right); … … 3507 3361 /* we do not know the shadow address yet, perform dummy DMA cycle */ 3508 3362 pPrivateData->rect = rect; 3509 pPrivateData->srcId = p PrimaryInfo->VidPnSourceId;3363 pPrivateData->srcId = pDstAlloc->SurfDesc.VidPnSourceId; 3510 3364 pPrivateData->enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_SHADOW2PRIMARY; 3511 3365 if (pSrc->SegmentId) … … 3537 3391 if (cbCmd >= VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE()) 3538 3392 { 3539 if (vboxWddmPixFormatConversionSupported(pSrcAlloc-> u.SurfInfo.format, pDstAlloc->u.SurfInfo.format))3393 if (vboxWddmPixFormatConversionSupported(pSrcAlloc->SurfDesc.format, pDstAlloc->SurfDesc.format)) 3540 3394 { 3541 3395 memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST)); … … 3582 3436 { 3583 3437 AssertBreakpoint(); 3584 drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc-> u.SurfInfo.format, pDstAlloc->u.SurfInfo.format));3438 drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc->SurfDesc.format, pDstAlloc->SurfDesc.format)); 3585 3439 Status = STATUS_GRAPHICS_CANNOTCOLORCONVERT; 3586 3440 } … … 3626 3480 if (pDstAlloc) 3627 3481 { 3628 if (vboxWddmPixFormatConversionSupported(pSrcAlloc-> u.SurfInfo.format, pDstAlloc->u.SurfInfo.format))3482 if (vboxWddmPixFormatConversionSupported(pSrcAlloc->SurfDesc.format, pDstAlloc->SurfDesc.format)) 3629 3483 { 3630 3484 memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST)); … … 3670 3524 { 3671 3525 AssertBreakpoint(); 3672 drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc-> u.SurfInfo.format, pDstAlloc->u.SurfInfo.format));3526 drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc->SurfDesc.format, pDstAlloc->SurfDesc.format)); 3673 3527 Status = STATUS_GRAPHICS_CANNOTCOLORCONVERT; 3674 3528 }
Note:
See TracChangeset
for help on using the changeset viewer.