- Timestamp:
- Oct 18, 2010 11:31:58 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
r33217 r33222 2545 2545 } 2546 2546 2547 #if 0 2548 static uint32_t vboxWddmSysMemElBuild(PVBOXVDMACMD_SYSMEMEL pEl, PMDL pMdl, uint32_t iPfn, uint32_t cPages, uint32_t cbBuffer, uint32_t *pcPagesRemaining) 2549 { 2550 uint32_t cbInitialBuffer = cbBuffer; 2551 if (cbBuf >= sizeof (*pEl)) 2552 { 2553 PFN_NUMBER cur = MmGetMdlPfnArray(pMdl)[iPfn]; 2554 uint32_t cbEl = sizeof (*pEl); 2555 uint32_t cBufs = 1; 2556 pEl->phBuf[0] = (cur << 12); 2557 --cPages; 2558 cbBuffer -= sizeof (*pEl); 2559 bool bArrayMode = false; 2560 while (cPages) 2561 { 2562 PFN_NUMBER next = MmGetMdlPfnArray(pMdl)[iPfn+cBufs]; 2563 if (!bArrayMode) 2564 { 2565 if (next == cur+1) 2566 { 2567 cur = next; 2568 ++cBufs; 2569 --cPages; 2570 } 2571 else if (cBufs > 1) 2572 { 2573 break; 2574 } 2575 else 2576 { 2577 bArrayMode = true; 2578 } 2579 } 2580 2581 /* array mode */ 2582 if (cbBuffer < sizeof (pEl->phBuf[0])) 2583 { 2584 break; 2585 } 2586 2587 pEl->phBuf[cBufs] = (next << 12); 2588 cbBuffer -= sizeof (pEl->phBuf[0]); 2589 ++cBufs; 2590 --cPages; 2591 } 2592 2593 pEl->cPages = cPages; 2594 if (bArrayMode) 2595 pEl->fFlags = VBOXVDMACMD_SYSMEMEL_F_PAGELIST; 2596 else 2597 pEl->fFlags = 0; 2598 } 2599 else 2600 { 2601 Assert(0); 2602 } 2603 2604 *pcPagesRemaining = cPages; 2605 return cbInitialBuffer - cbBuffer; 2606 } 2607 2608 static uint32_t vboxWddmBpbTransferVRamSysBuildEls(PVBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS pCmd, PMDL pMdl, uint32_t iPfn, uint32_t cPages, uint32_t cbBuffer, uint32_t *pcPagesRemaining) 2609 { 2610 uint32_t cInitPages = cPages; 2611 uint32_t cbBufferUsed = vboxWddmSysMemElBuild(&pCmd->FirstEl, pMdl, iPfn, cPages, cbBuffer, &cPages); 2612 if (cbBufferUsed) 2613 { 2614 uint32_t cEls = 1; 2615 PVBOXVDMACMD_SYSMEMEL pEl = &pCmd->FirstEl; 2616 while (cPages) 2617 { 2618 PVBOXVDMACMD_SYSMEMEL pEl = VBOXVDMACMD_SYSMEMEL_NEXT(pEl); 2619 cbBufferUsed = vboxWddmSysMemElBuild(pEl, pMdl, iPfn + cInitPages - cPages, cPages, cbBuffer - cbBufferUsed, &cPages); 2620 if (cbBufferUsed) 2621 { 2622 ++cEls; 2623 } 2624 else 2625 break; 2626 } 2627 } 2628 else 2629 { 2630 Assert(0); 2631 } 2632 2633 pCmd->cTransferPages = (cInitPages - cPages); 2634 *pcPagesRemaining = cPages; 2635 return cbBufferUsed; 2636 } 2637 #endif 2547 2638 /* 2548 2639 * DxgkDdiBuildPagingBuffer … … 2570 2661 { 2571 2662 #ifdef VBOX_WITH_VDMA 2663 #if 0 2664 if ((!pBuildPagingBuffer->Transfer.Source.SegmentId) != (!pBuildPagingBuffer->Transfer.Destination.SegmentId)) 2665 { 2666 PVBOXVDMACMD pCmd = (PVBOXVDMACMD)pBuildPagingBuffer->pDmaBuffer; 2667 pCmd->enmType = VBOXVDMACMD_TYPE_DMA_BPB_TRANSFER_VRAMSYS; 2668 pCmd->u32CmdSpecific = 0; 2669 PVBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS pBody = VBOXVDMACMD_BODY(pCmd, VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS); 2670 PMDL pMdl; 2671 uint32_t cPages = (pBuildPagingBuffer->Transfer.TransferSize + 0xfff) >> 12; 2672 cPages -= pBuildPagingBuffer->MultipassOffset; 2673 uint32_t iFirstPage = pBuildPagingBuffer->Transfer.MdlOffset + pBuildPagingBuffer->MultipassOffset; 2674 uint32_t cPagesRemaining; 2675 if (pBuildPagingBuffer->Transfer.Source.SegmentId) 2676 { 2677 uint64_t off = pBuildPagingBuffer->Transfer.Source.SegmentAddress.QuadPart; 2678 off += pBuildPagingBuffer->Transfer.TransferOffset + (pBuildPagingBuffer->MultipassOffset << 12); 2679 pBody->offVramBuf = off; 2680 pMdl = pBuildPagingBuffer->Transfer.Source.pMdl; 2681 pBody->fFlags = 0;//VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS_SYS2VRAM 2682 } 2683 else 2684 { 2685 uint64_t off = pBuildPagingBuffer->Transfer.Destination.SegmentAddress.QuadPart; 2686 off += pBuildPagingBuffer->Transfer.TransferOffset + (pBuildPagingBuffer->MultipassOffset << 12); 2687 pBody->offVramBuf = off; 2688 pMdl = pBuildPagingBuffer->Transfer.Destination.pMdl; 2689 pBody->fFlags = VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS_SYS2VRAM; 2690 } 2691 2692 uint32_t sbBufferUsed = vboxWddmBpbTransferVRamSysBuildEls(pBody, pMdl, iFirstPage, cPages, pBuildPagingBuffer->DmaSize, &cPagesRemaining); 2693 Assert(sbBufferUsed); 2694 } 2695 2696 #else 2572 2697 UINT cbCmd = VBOXVDMACMD_SIZE(VBOXVDMACMD_DMA_BPB_TRANSFER); 2573 2698 PVBOXVDMACBUF_DR pDr = vboxVdmaCBufDrCreate (&pDevExt->u.primary.Vdma, cbCmd); … … 2575 2700 if (pDr) 2576 2701 { 2577 // vboxVdmaCBufDrCreate zero initializes the pDr 2578 pDr->fFlags = VBOXVDMACBUF_FLAG_BUF_FOLLOWS_DR; 2579 pDr->cbBuf = cbCmd; 2580 pDr->rc = VERR_NOT_IMPLEMENTED; 2581 2702 SIZE_T cbTransfered = 0; 2703 SIZE_T cbTransferSize = pBuildPagingBuffer->Transfer.TransferSize; 2582 2704 PVBOXVDMACMD pHdr = VBOXVDMACBUF_DR_TAIL(pDr, VBOXVDMACMD); 2583 pHdr->enmType = VBOXVDMACMD_TYPE_DMA_BPB_TRANSFER; 2584 pHdr->u32CmdSpecific = 0; 2585 VBOXVDMACMD_DMA_BPB_TRANSFER *pBody = VBOXVDMACMD_BODY(pHdr, VBOXVDMACMD_DMA_BPB_TRANSFER); 2586 pBody->cbTransferSize = (uint32_t)pBuildPagingBuffer->Transfer.TransferSize; 2587 pBody->fFlags = 0; 2588 2589 if (pBuildPagingBuffer->Transfer.Source.SegmentId) 2705 do 2590 2706 { 2707 // vboxVdmaCBufDrCreate zero initializes the pDr 2708 pDr->fFlags = VBOXVDMACBUF_FLAG_BUF_FOLLOWS_DR; 2709 pDr->cbBuf = cbCmd; 2710 pDr->rc = VERR_NOT_IMPLEMENTED; 2711 2712 pHdr->enmType = VBOXVDMACMD_TYPE_DMA_BPB_TRANSFER; 2713 pHdr->u32CmdSpecific = 0; 2714 VBOXVDMACMD_DMA_BPB_TRANSFER *pBody = VBOXVDMACMD_BODY(pHdr, VBOXVDMACMD_DMA_BPB_TRANSFER); 2715 // pBody->cbTransferSize = (uint32_t)pBuildPagingBuffer->Transfer.TransferSize; 2716 pBody->fFlags = 0; 2717 SIZE_T cSrcPages = cbTransferSize; 2718 SIZE_T cDstPages = cbTransferSize; 2719 2720 if (pBuildPagingBuffer->Transfer.Source.SegmentId) 2721 { 2591 2722 #ifdef DEBUG_misha 2592 Assert(pBuildPagingBuffer->Transfer.Source.SegmentAddress.QuadPart);2723 Assert(pBuildPagingBuffer->Transfer.Source.SegmentAddress.QuadPart); 2593 2724 #endif 2594 uint64_t off = pBuildPagingBuffer->Transfer.Source.SegmentAddress.QuadPart; 2595 off += pBuildPagingBuffer->Transfer.TransferOffset; 2596 pBody->Src.offVramBuf = off; 2597 pBody->fFlags |= VBOXVDMACMD_DMA_BPB_TRANSFER_F_SRC_VRAMOFFSET; 2598 } 2599 else 2600 { 2601 pBody->Src.phBuf = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Source.pMdl)[pBuildPagingBuffer->Transfer.MdlOffset] << 12; 2602 #ifdef DEBUG 2725 uint64_t off = pBuildPagingBuffer->Transfer.Source.SegmentAddress.QuadPart; 2726 off += pBuildPagingBuffer->Transfer.TransferOffset + cbTransfered; 2727 pBody->Src.offVramBuf = off; 2728 pBody->fFlags |= VBOXVDMACMD_DMA_BPB_TRANSFER_F_SRC_VRAMOFFSET; 2729 } 2730 else 2603 2731 { 2604 PFN_NUMBER num = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Source.pMdl)[pBuildPagingBuffer->Transfer.MdlOffset]; 2605 for (UINT i = 1; i < ((pBuildPagingBuffer->Transfer.TransferSize + 0xfff) >> 12); ++i) 2732 UINT index = pBuildPagingBuffer->Transfer.MdlOffset + (cbTransfered>>12); 2733 pBody->Src.phBuf = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Source.pMdl)[index] << 12; 2734 PFN_NUMBER num = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Source.pMdl)[index]; 2735 cSrcPages = 1; 2736 for (UINT i = 1; i < ((cbTransferSize - cbTransfered + 0xfff) >> 12); ++i) 2606 2737 { 2607 PFN_NUMBER cur = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Source.pMdl)[pBuildPagingBuffer->Transfer.MdlOffset+1]; 2608 Assert(cur == ++num); 2738 PFN_NUMBER cur = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Source.pMdl)[index+i]; 2739 if(cur != ++num) 2740 { 2741 cSrcPages+= i-1; 2742 break; 2743 } 2609 2744 } 2610 2745 } 2746 2747 if (pBuildPagingBuffer->Transfer.Destination.SegmentId) 2748 { 2749 #ifdef DEBUG_misha 2750 Assert(pBuildPagingBuffer->Transfer.Destination.SegmentAddress.QuadPart); 2611 2751 #endif 2612 } 2613 2614 if (pBuildPagingBuffer->Transfer.Destination.SegmentId) 2615 { 2616 #ifdef DEBUG_misha 2617 Assert(pBuildPagingBuffer->Transfer.Destination.SegmentAddress.QuadPart); 2618 #endif 2619 uint64_t off = pBuildPagingBuffer->Transfer.Destination.SegmentAddress.QuadPart; 2620 off += pBuildPagingBuffer->Transfer.TransferOffset; 2621 pBody->Dst.offVramBuf = off; 2622 pBody->fFlags |= VBOXVDMACMD_DMA_BPB_TRANSFER_F_DST_VRAMOFFSET; 2623 } 2624 else 2625 { 2626 pBody->Dst.phBuf = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Destination.pMdl)[pBuildPagingBuffer->Transfer.MdlOffset] << 12; 2627 #ifdef DEBUG 2752 uint64_t off = pBuildPagingBuffer->Transfer.Destination.SegmentAddress.QuadPart; 2753 off += pBuildPagingBuffer->Transfer.TransferOffset; 2754 pBody->Dst.offVramBuf = off + cbTransfered; 2755 pBody->fFlags |= VBOXVDMACMD_DMA_BPB_TRANSFER_F_DST_VRAMOFFSET; 2756 } 2757 else 2628 2758 { 2629 PFN_NUMBER num = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Destination.pMdl)[pBuildPagingBuffer->Transfer.MdlOffset]; 2630 for (UINT i = 1; i < ((pBuildPagingBuffer->Transfer.TransferSize + 0xfff) >> 12); ++i) 2759 UINT index = pBuildPagingBuffer->Transfer.MdlOffset + (cbTransfered>>12); 2760 pBody->Dst.phBuf = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Destination.pMdl)[index] << 12; 2761 PFN_NUMBER num = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Destination.pMdl)[index]; 2762 cDstPages = 1; 2763 for (UINT i = 1; i < ((cbTransferSize - cbTransfered + 0xfff) >> 12); ++i) 2631 2764 { 2632 PFN_NUMBER cur = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Destination.pMdl)[pBuildPagingBuffer->Transfer.MdlOffset+1]; 2633 Assert(cur == ++num); 2765 PFN_NUMBER cur = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Destination.pMdl)[index+i]; 2766 if(cur != ++num) 2767 { 2768 cDstPages+= i-1; 2769 break; 2770 } 2634 2771 } 2635 2772 } 2636 #endif 2637 } 2638 2639 int rc = vboxVdmaCBufDrSubmitSynch(pDevExt, &pDevExt->u.primary.Vdma, pDr); 2640 AssertRC(rc); 2641 if (RT_SUCCESS(rc)) 2642 Status = STATUS_SUCCESS; 2643 else 2644 Status = STATUS_UNSUCCESSFUL; 2645 2773 2774 SIZE_T cbCurTransfer; 2775 cbCurTransfer = RT_MIN(cbTransferSize - cbTransfered, cSrcPages << 12); 2776 cbCurTransfer = RT_MIN(cbCurTransfer, cDstPages << 12); 2777 2778 pBody->cbTransferSize = cbCurTransfer; 2779 Assert(!(cbCurTransfer & 0xfff)); 2780 2781 int rc = vboxVdmaCBufDrSubmitSynch(pDevExt, &pDevExt->u.primary.Vdma, pDr); 2782 AssertRC(rc); 2783 if (RT_SUCCESS(rc)) 2784 { 2785 Status = STATUS_SUCCESS; 2786 cbTransfered += cbCurTransfer; 2787 } 2788 else 2789 Status = STATUS_UNSUCCESSFUL; 2790 } while (cbTransfered < cbTransferSize); 2791 Assert(cbTransfered == cbTransferSize); 2646 2792 vboxVdmaCBufDrFree(&pDevExt->u.primary.Vdma, pDr); 2647 2793 } … … 2652 2798 Status = STATUS_INSUFFICIENT_RESOURCES; 2653 2799 } 2800 #endif 2654 2801 #endif /* #ifdef VBOX_WITH_VDMA */ 2655 2802 break;
Note:
See TracChangeset
for help on using the changeset viewer.