Changeset 29895 in vbox
- Timestamp:
- May 31, 2010 10:52:52 AM (15 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
r29884 r29895 734 734 } 735 735 736 static uint32_t vboxFormatToFourcc(D3DDDIFORMAT format)737 {738 uint32_t uFormat = (uint32_t)format;739 /* assume that in case both four bytes are non-zero, this is a fourcc */740 if ((format & 0xff000000)741 && (format & 0x00ff0000)742 && (format & 0x0000ff00)743 && (format & 0x000000ff)744 )745 return uFormat;746 return 0;747 }748 749 736 int vboxCapsInit(PVBOXWDDMDISP_ADAPTER pAdapter) 750 737 { … … 832 819 for (uint32_t j = 0; j < pVhwa->Settings.cFormats; ++j) 833 820 { 834 uint32_t fourcc = vbox FormatToFourcc(pVhwa->Settings.aFormats[j]);821 uint32_t fourcc = vboxWddmFormatToFourcc(pVhwa->Settings.aFormats[j]); 835 822 if (fourcc) 836 823 { … … 1600 1587 pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pSurf->Width, pAllocInfo->SurfDesc.bpp); 1601 1588 1589 pAllocInfo->SurfDesc.cbSize = pAllocInfo->SurfDesc.pitch * pAllocInfo->SurfDesc.height; 1602 1590 pAllocInfo->SurfDesc.depth = pSurf->Depth; 1603 1591 pAllocInfo->SurfDesc.slicePitch = pSurf->SysMemSlicePitch; -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
r29883 r29895 157 157 { 158 158 VBOXVHWA_INFO Settings; 159 bool cOverlaysCreated; 159 160 } VBOXWDDM_VHWA; 160 161 #endif -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h
r29883 r29895 50 50 UINT depth; 51 51 UINT slicePitch; 52 UINT cbSize; 52 53 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId; 53 54 D3DDDI_RATIONAL RefreshRate; … … 159 160 } 160 161 162 DECLINLINE(uint32_t) vboxWddmFormatToFourcc(D3DDDIFORMAT format) 163 { 164 uint32_t uFormat = (uint32_t)format; 165 /* assume that in case both four bytes are non-zero, this is a fourcc */ 166 if ((format & 0xff000000) 167 && (format & 0x00ff0000) 168 && (format & 0x0000ff00) 169 && (format & 0x000000ff) 170 ) 171 return uFormat; 172 return 0; 173 } 174 161 175 #define VBOXWDDM_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1)) 162 176 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVhwa.cpp
r29798 r29895 413 413 } 414 414 } 415 416 int vboxVhwaHlpTranslateFormat(VBOXVHWA_PIXELFORMAT *pFormat, D3DDDIFORMAT enmFormat) 417 { 418 pFormat->Reserved = 0; 419 switch (enmFormat) 420 { 421 case D3DDDIFMT_A8R8G8B8: 422 case D3DDDIFMT_X8R8G8B8: 423 pFormat->flags = VBOXVHWA_PF_RGB; 424 pFormat->c.rgbBitCount = 32; 425 pFormat->m1.rgbRBitMask = 0xff0000; 426 pFormat->m2.rgbGBitMask = 0xff00; 427 pFormat->m3.rgbBBitMask = 0xff; 428 /* always zero for now */ 429 pFormat->m4.rgbABitMask = 0; 430 return VINF_SUCCESS; 431 case D3DDDIFMT_R8G8B8: 432 pFormat->flags = VBOXVHWA_PF_RGB; 433 pFormat->c.rgbBitCount = 24; 434 pFormat->m1.rgbRBitMask = 0xff0000; 435 pFormat->m2.rgbGBitMask = 0xff00; 436 pFormat->m3.rgbBBitMask = 0xff; 437 /* always zero for now */ 438 pFormat->m4.rgbABitMask = 0; 439 return VINF_SUCCESS; 440 case D3DDDIFMT_R5G6B5: 441 pFormat->flags = VBOXVHWA_PF_RGB; 442 pFormat->c.rgbBitCount = 16; 443 pFormat->m1.rgbRBitMask = 0xf800; 444 pFormat->m2.rgbGBitMask = 0x7e0; 445 pFormat->m3.rgbBBitMask = 0x1f; 446 /* always zero for now */ 447 pFormat->m4.rgbABitMask = 0; 448 return VINF_SUCCESS; 449 case D3DDDIFMT_P8: 450 case D3DDDIFMT_A8: 451 case D3DDDIFMT_X1R5G5B5: 452 case D3DDDIFMT_A1R5G5B5: 453 case D3DDDIFMT_A4R4G4B4: 454 case D3DDDIFMT_R3G3B2: 455 case D3DDDIFMT_A8R3G3B2: 456 case D3DDDIFMT_X4R4G4B4: 457 case D3DDDIFMT_A2B10G10R10: 458 case D3DDDIFMT_A8B8G8R8: 459 case D3DDDIFMT_X8B8G8R8: 460 case D3DDDIFMT_G16R16: 461 case D3DDDIFMT_A2R10G10B10: 462 case D3DDDIFMT_A16B16G16R16: 463 case D3DDDIFMT_A8P8: 464 default: 465 { 466 uint32_t fourcc = vboxWddmFormatToFourcc(enmFormat); 467 Assert(fourcc); 468 if (fourcc) 469 { 470 pFormat->flags = VBOXVHWA_PF_FOURCC; 471 pFormat->fourCC = fourcc; 472 return VINF_SUCCESS; 473 } 474 return VERR_NOT_SUPPORTED; 475 } 476 } 477 } 478 479 int vboxVhwaHlpCreateSurface(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf, 480 uint32_t fFlags, uint32_t cBackBuffers, uint32_t fSCaps, 481 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId) 482 { 483 /* the first thing we need is to post create primary */ 484 VBOXVHWACMD* pCmd = vboxVhwaCommandCreate(pDevExt, VidPnSourceId, 485 VBOXVHWACMD_TYPE_SURF_CREATE, sizeof(VBOXVHWACMD_SURF_CREATE)); 486 Assert(pCmd); 487 if(pCmd) 488 { 489 VBOXVHWACMD_SURF_CREATE * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_CREATE); 490 int rc = VINF_SUCCESS; 491 492 memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_CREATE)); 493 494 pBody->SurfInfo.height = pSurf->SurfDesc.height; 495 pBody->SurfInfo.width = pSurf->SurfDesc.width; 496 pBody->SurfInfo.flags |= VBOXVHWA_SD_HEIGHT | VBOXVHWA_SD_WIDTH; 497 if (fFlags & VBOXVHWA_SD_PITCH) 498 { 499 pBody->SurfInfo.pitch = pSurf->SurfDesc.pitch; 500 pBody->SurfInfo.flags |= VBOXVHWA_SD_PITCH; 501 pBody->SurfInfo.sizeX = pSurf->SurfDesc.cbSize; 502 pBody->SurfInfo.sizeY = 1; 503 } 504 if (cBackBuffers) 505 { 506 pBody->SurfInfo.cBackBuffers = cBackBuffers; 507 pBody->SurfInfo.flags |= VBOXVHWA_SD_BACKBUFFERCOUNT; 508 } 509 else 510 pBody->SurfInfo.cBackBuffers = 0; 511 pBody->SurfInfo.Reserved = 0; 512 /* @todo: color keys */ 513 // pBody->SurfInfo.DstOverlayCK; 514 // pBody->SurfInfo.DstBltCK; 515 // pBody->SurfInfo.SrcOverlayCK; 516 // pBody->SurfInfo.SrcBltCK; 517 rc = vboxVhwaHlpTranslateFormat(&pBody->SurfInfo.PixelFormat, pSurf->SurfDesc.format); 518 AssertRC(rc); 519 if (RT_SUCCESS(rc)) 520 { 521 pBody->SurfInfo.flags |= VBOXVHWA_SD_PIXELFORMAT; 522 pBody->SurfInfo.surfCaps = fSCaps; 523 pBody->SurfInfo.flags |= VBOXVHWA_SD_CAPS; 524 pBody->SurfInfo.offSurface = pSurf->offVram; 525 526 vboxVhwaCommandSubmit(pDevExt, pCmd); 527 Assert(pCmd->rc == VINF_SUCCESS); 528 if(pCmd->rc == VINF_SUCCESS) 529 { 530 if (!(fFlags & VBOXVHWA_SD_PITCH)) 531 { 532 /* should be set by host */ 533 Assert(pBody->SurfInfo.flags & VBOXVHWA_SD_PITCH); 534 pSurf->SurfDesc.cbSize = pBody->SurfInfo.sizeX * pBody->SurfInfo.sizeY; 535 Assert(pSurf->SurfDesc.cbSize); 536 pSurf->SurfDesc.pitch = pBody->SurfInfo.pitch; 537 Assert(pSurf->SurfDesc.pitch); 538 } 539 else 540 { 541 Assert(pSurf->SurfDesc.cbSize == pBody->SurfInfo.sizeX); 542 Assert(pBody->SurfInfo.sizeY == 1); 543 Assert(pBody->SurfInfo.pitch == pSurf->SurfDesc.pitch); 544 if (pSurf->SurfDesc.cbSize != pBody->SurfInfo.sizeX 545 || pBody->SurfInfo.sizeY != 1 546 || pBody->SurfInfo.pitch != pSurf->SurfDesc.pitch) 547 { 548 rc = VERR_INVALID_PARAMETER; 549 } 550 } 551 552 if (RT_SUCCESS(rc)) 553 { 554 pSurf->hHostHandle = pBody->SurfInfo.hSurf; 555 } 556 } 557 else 558 rc = pCmd->rc; 559 } 560 vboxVhwaCommandFree(pDevExt, pCmd); 561 return rc; 562 } 563 564 return VERR_OUT_OF_RESOURCES; 565 } 566 567 int vboxVhwaHlpCreatePriary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId) 568 { 569 Assert(!!(pSource->Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED)); 570 if (!(pSource->Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED)) 571 return VERR_NOT_SUPPORTED; 572 573 #ifdef VBOXWDDM_RENDER_FROM_SHADOW 574 PVBOXWDDM_ALLOCATION pFbSurf = pSource->pShadowAllocation; 575 #else 576 PVBOXWDDM_ALLOCATION pFbSurf = pSource->pPrimaryAllocation; 577 #endif 578 579 Assert(!pSource->Vhwa.cOverlaysCreated); 580 if (pSource->Vhwa.cOverlaysCreated) 581 { 582 Assert(pFbSurf->hHostHandle); 583 if (pFbSurf->hHostHandle) 584 return VINF_ALREADY_INITIALIZED; 585 return VERR_INVALID_STATE; 586 } 587 588 int rc = vboxVhwaHlpCreateSurface(pDevExt, pFbSurf, 589 VBOXVHWA_SD_PITCH, 0, VBOXVHWA_SCAPS_PRIMARYSURFACE | VBOXVHWA_SCAPS_VIDEOMEMORY | VBOXVHWA_SCAPS_LOCALVIDMEM, 590 VidPnSourceId); 591 AssertRC(rc); 592 return rc; 593 } 594 595 int vboxVhwaHlpCreateOverlay(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf, uint32_t cBackBuffers, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId) 596 { 597 Assert(VidPnSourceId < pDevExt->cSources); 598 if (VidPnSourceId >= pDevExt->cSources) 599 return VERR_INVALID_PARAMETER; 600 601 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[VidPnSourceId]; 602 603 int rc = vboxVhwaHlpCreatePriary(pDevExt, pSource, VidPnSourceId); 604 AssertRC(rc); 605 if (RT_SUCCESS(rc)) 606 { 607 rc = vboxVhwaHlpCreateSurface(pDevExt, pSurf, 608 0, cBackBuffers, VBOXVHWA_SCAPS_OVERLAY | VBOXVHWA_SCAPS_VIDEOMEMORY | VBOXVHWA_SCAPS_LOCALVIDMEM | VBOXVHWA_SCAPS_COMPLEX, 609 VidPnSourceId); 610 AssertRC(rc); 611 if (RT_SUCCESS(rc)) 612 ++pSource->Vhwa.cOverlaysCreated; 613 } 614 615 return rc; 616 } -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVhwa.h
r29798 r29895 54 54 void vboxVHWAFree(PDEVICE_EXTENSION pDevExt); 55 55 56 int vboxVhwaHlpCreateOverlay(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf, uint32_t cBackBuffers, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId); 57 56 58 #endif /* #ifndef ___VBoxVideoVhwa_h___ */ -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
r29883 r29895 1406 1406 } 1407 1407 1408 NTSTATUS vboxWddmCreateAllocation(PDEVICE_EXTENSION pDevExt, DXGK_ALLOCATIONINFO* pAllocationInfo)1408 NTSTATUS vboxWddmCreateAllocation(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_RCINFO pRcInfo, DXGK_ALLOCATIONINFO* pAllocationInfo) 1409 1409 { 1410 1410 PAGED_CODE(); … … 1429 1429 pAllocationInfo->PrivateDriverDataSize = 0; 1430 1430 pAllocationInfo->Alignment = 0; 1431 pAllocationInfo->Size = pAllocInfo->SurfDesc. pitch * pAllocInfo->SurfDesc.height;1431 pAllocationInfo->Size = pAllocInfo->SurfDesc.cbSize; 1432 1432 pAllocationInfo->PitchAlignedSize = 0; 1433 1433 pAllocationInfo->HintedBank.Value = 0; … … 1453 1453 #endif 1454 1454 break; 1455 case VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC: 1456 #ifdef VBOX_WITH_VIDEOHWACCEL 1457 Assert(pRcInfo); 1458 if (pRcInfo) 1459 { 1460 Assert(pRcInfo->cAllocInfos); 1461 if (pRcInfo->cAllocInfos) 1462 { 1463 if (pRcInfo->RcDesc.fFlags.Overlay) 1464 { 1465 int rc = vboxVhwaHlpCreateOverlay(pDevExt, pAllocation, pRcInfo->cAllocInfos - 1, pRcInfo->RcDesc.VidPnSourceId); 1466 AssertRC(rc); 1467 if (RT_FAILURE(rc)) 1468 Status = STATUS_UNSUCCESSFUL; 1469 } 1470 } 1471 else 1472 Status = STATUS_INVALID_PARAMETER; 1473 } 1474 #endif 1475 /* do not break to set CPU visibility flag */ 1455 1476 case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE: 1456 1477 case VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE: 1457 case VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC:1458 1478 pAllocationInfo->Flags.Value = 0; 1459 1479 pAllocationInfo->Flags.CpuVisible = 1; … … 1496 1516 vboxVDbgBreakFv(); 1497 1517 1518 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter; 1498 1519 NTSTATUS Status = STATUS_SUCCESS; 1520 PVBOXWDDM_RCINFO pRcInfo = NULL; 1499 1521 1500 1522 if (pCreateAllocation->PrivateDriverDataSize) 1501 1523 { 1524 Assert(pCreateAllocation->PrivateDriverDataSize == sizeof (VBOXWDDM_RCINFO)); 1525 Assert(pCreateAllocation->pPrivateDriverData); 1526 if (pCreateAllocation->PrivateDriverDataSize >= sizeof (VBOXWDDM_RCINFO)) 1527 { 1528 pRcInfo = (PVBOXWDDM_RCINFO)pCreateAllocation->pPrivateDriverData; 1529 Assert(pRcInfo->RcDesc.VidPnSourceId < pDevExt->cSources); 1530 Assert(pRcInfo->cAllocInfos == pCreateAllocation->NumAllocations); 1531 } 1532 else 1533 Status = STATUS_INVALID_PARAMETER; 1502 1534 /* @todo: Implement Resource Data Handling */ 1503 1535 drprintf((__FUNCTION__ ": WARNING: Implement Resource Data Handling\n")); 1504 1536 } 1505 1537 1506 for (UINT i = 0; i < pCreateAllocation->NumAllocations; ++i) 1507 { 1508 Status = vboxWddmCreateAllocation((PDEVICE_EXTENSION)hAdapter, &pCreateAllocation->pAllocationInfo[i]); 1509 Assert(Status == STATUS_SUCCESS); 1510 if (Status != STATUS_SUCCESS) 1511 { 1512 drprintf((__FUNCTION__ ": ERROR: vboxWddmCreateAllocation error (0x%x)\n", Status)); 1513 /* note: i-th allocation is expected to be cleared in a fail handling code above */ 1514 for (UINT j = 0; j < i; ++j) 1515 { 1516 vboxWddmDestroyAllocation((PDEVICE_EXTENSION)hAdapter, (PVBOXWDDM_ALLOCATION)pCreateAllocation->pAllocationInfo[j].hAllocation); 1517 } 1518 } 1519 } 1520 1538 if (Status == STATUS_SUCCESS) 1539 { 1540 for (UINT i = 0; i < pCreateAllocation->NumAllocations; ++i) 1541 { 1542 Status = vboxWddmCreateAllocation(pDevExt, pRcInfo, &pCreateAllocation->pAllocationInfo[i]); 1543 Assert(Status == STATUS_SUCCESS); 1544 if (Status != STATUS_SUCCESS) 1545 { 1546 drprintf((__FUNCTION__ ": ERROR: vboxWddmCreateAllocation error (0x%x)\n", Status)); 1547 /* note: i-th allocation is expected to be cleared in a fail handling code above */ 1548 for (UINT j = 0; j < i; ++j) 1549 { 1550 vboxWddmDestroyAllocation(pDevExt, (PVBOXWDDM_ALLOCATION)pCreateAllocation->pAllocationInfo[j].hAllocation); 1551 } 1552 } 1553 } 1554 } 1521 1555 dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter)); 1522 1556 … … 1610 1644 pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format); 1611 1645 pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width, pAllocInfo->SurfDesc.bpp); 1646 pAllocInfo->SurfDesc.cbSize = pAllocInfo->SurfDesc.pitch * pAllocInfo->SurfDesc.height; 1612 1647 pAllocInfo->SurfDesc.depth = 0; 1613 1648 pAllocInfo->SurfDesc.slicePitch = 0; … … 1641 1676 pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format); 1642 1677 pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width, pAllocInfo->SurfDesc.bpp); 1678 pAllocInfo->SurfDesc.cbSize = pAllocInfo->SurfDesc.pitch * pAllocInfo->SurfDesc.height; 1643 1679 pAllocInfo->SurfDesc.depth = 0; 1644 1680 pAllocInfo->SurfDesc.slicePitch = 0; … … 1672 1708 pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format); 1673 1709 pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width, pAllocInfo->SurfDesc.bpp); 1710 pAllocInfo->SurfDesc.cbSize = pAllocInfo->SurfDesc.pitch * pAllocInfo->SurfDesc.height; 1674 1711 pAllocInfo->SurfDesc.depth = 0; 1675 1712 pAllocInfo->SurfDesc.slicePitch = 0; -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.h
r29883 r29895 54 54 UINT SegmentId; 55 55 VBOXVIDEOOFFSET offVram; 56 #ifdef VBOX_WITH_VIDEOHWACCEL 57 VBOXVHWA_SURFHANDLE hHostHandle; 58 #endif 56 59 BOOLEAN bVisible; 57 60 BOOLEAN bAssigned;
Note:
See TracChangeset
for help on using the changeset viewer.