VirtualBox

Changeset 47151 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Jul 15, 2013 10:47:42 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
87253
Message:

crOpenGL & wddm: auto dump file generation, fixes and cleanup

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.cpp

    r47070 r47151  
    11821182            vboxVdmaBltDirtyRectsUpdate(pDevExt, pSource, pBlt->Blt.DstRects.UpdateRects.cRects, pBlt->Blt.DstRects.UpdateRects.aRects);
    11831183
    1184         if (pSrcAlloc->AllocData.hostID || pSource->fHas3DVrs)
     1184        if (pSrcAlloc->AllocData.hostID || (pDevExt->fTexPresentEnabled ? pSource->fHas3DVrs : !!pDevExt->cContexts3D))
    11851185        {
    11861186            Status = vboxVdmaProcessVRegCmd(pDevExt, pContext, &pBlt->Blt.SrcAlloc, &pBlt->Blt.DstAlloc, &pBlt->Blt.SrcRect, &pBlt->Blt.DstRects);
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp

    r47070 r47151  
    30203020            vboxWddmAddrSetVram(&pSrcAlloc->AllocData.Addr, pBlt->Blt.SrcAlloc.segmentIdAlloc, pBlt->Blt.SrcAlloc.offAlloc);
    30213021
    3022             if (pDstAlloc->bAssigned &&
    3023                     (pDstAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE
    3024                         || pDstAlloc->enmType == VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D)
    3025                     )
     3022            if (VBOXWDDM_IS_REAL_FB_ALLOCATION(pDevExt, pDstAlloc))
    30263023            {
    30273024                VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pDstAlloc->AllocData.SurfDesc.VidPnSourceId];
     
    54515448        DXGK_ALLOCATIONLIST *pDst =  &pPresent->pAllocationList[DXGK_PRESENT_DESTINATION_INDEX];
    54525449        PVBOXWDDM_ALLOCATION pSrcAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pSrc);
    5453         Assert(pSrcAlloc);
    5454         if (pSrcAlloc)
    5455         {
    5456             PVBOXWDDM_ALLOCATION pDstAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pDst);
    5457             Assert(pDstAlloc);
    5458             if (pDstAlloc)
    5459             {
    5460                 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pDstAlloc->AllocData.SurfDesc.VidPnSourceId];
    5461                 do
    5462                 {
    5463 #ifdef VBOXWDDM_RENDER_FROM_SHADOW
    5464 #if 0
    5465                     Assert (pSrcAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE);
    5466                     Assert (pDstAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE);
    5467 #else
    5468                     if (pContext->enmType == VBOXWDDM_CONTEXT_TYPE_SYSTEM)
    5469                     {
    5470                         Assert ((pSrcAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE
    5471                                 && pDstAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE)
    5472                                 || (pSrcAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE
    5473                                         && pDstAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE));
    5474                     }
    5475 #endif
    5476                     /* issue VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE ONLY in case there are no 3D Visible Regions currently
    5477                      * otherwise we would need info about all rects being updated on primary for visible rect reporting */
    5478                     if (!cContexts2D && !pSource->fHas3DVrs)
    5479                     {
    5480                         if (pDstAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE
    5481                                 && pSrcAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE)
    5482                         {
    5483                             Assert(pContext->enmType == VBOXWDDM_CONTEXT_TYPE_SYSTEM);
    5484                             Assert(pDstAlloc->bAssigned);
    5485                             if (pDstAlloc->bAssigned)
    5486                             {
    5487 #ifdef VBOX_WITH_VIDEOHWACCEL
    5488 //                                if (vboxVhwaHlpOverlayListIsEmpty(pDevExt, pDstAlloc->AllocData.SurfDesc.VidPnSourceId))
    5489 #endif
    5490                                 {
    5491                                     Assert(pPresent->DmaBufferPrivateDataSize >= sizeof (VBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY));
    5492                                     if (pPresent->DmaBufferPrivateDataSize >= sizeof (VBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY))
    5493                                     {
    5494                                         Assert(pPresent->SrcRect.left == pPresent->DstRect.left);
    5495                                         Assert(pPresent->SrcRect.right == pPresent->DstRect.right);
    5496                                         Assert(pPresent->SrcRect.top == pPresent->DstRect.top);
    5497                                         Assert(pPresent->SrcRect.bottom == pPresent->DstRect.bottom);
    5498                                         RECT rect;
    5499                                         if (pPresent->SubRectCnt)
    5500                                         {
    5501                                             rect = pPresent->pDstSubRects[0];
    5502                                             for (UINT i = 1; i < pPresent->SubRectCnt; ++i)
    5503                                             {
    5504                                                 vboxWddmRectUnited(&rect, &rect, &pPresent->pDstSubRects[i]);
    5505                                             }
    5506                                         }
    5507                                         else
    5508                                             rect = pPresent->SrcRect;
    5509 
    5510 
    5511                                         pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + sizeof (VBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY);
    5512                                         pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    5513                                         Assert(pPresent->DmaSize >= VBOXWDDM_DUMMY_DMABUFFER_SIZE);
    5514                                         memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST));
    5515                                         pPresent->pPatchLocationListOut->PatchOffset = 0;
    5516                                         pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_SOURCE_INDEX;
    5517                                         ++pPresent->pPatchLocationListOut;
    5518                                         pPresent->pPatchLocationListOut->PatchOffset = 4;
    5519                                         pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_DESTINATION_INDEX;
    5520                                         ++pPresent->pPatchLocationListOut;
    5521 
    5522                                         pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_SHADOW2PRIMARY;
    5523                                         PVBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY pS2P = (PVBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY)pPrivateData;
    5524                                         /* we do not know the shadow address yet, perform dummy DMA cycle */
    5525                                         vboxWddmPopulateDmaAllocInfo(&pS2P->Shadow2Primary.ShadowAlloc, pSrcAlloc, pSrc);
    5526 //                                        vboxWddmPopulateDmaAllocInfo(&pPrivateData->DstAllocInfo, pDstAlloc, pDst);
    5527                                         pS2P->Shadow2Primary.SrcRect = rect;
    5528                                         pS2P->Shadow2Primary.VidPnSourceId = pDstAlloc->AllocData.SurfDesc.VidPnSourceId;
    5529                                         break;
    5530                                     }
    5531                                     else
    5532                                     {
    5533                                         Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    5534                                         break;
    5535                                     }
    5536                                 }
    5537                             }
    5538                         }
    5539                     }
    5540 
    5541                     /* we're here because this is NOT a shadow->primary update
    5542                      * or because there are d3d contexts and we need to report visible rects
    5543                      * or because we have overlays active and we need a special handling for primary */
    5544 #endif
    5545                     UINT cbCmd = pPresent->DmaBufferPrivateDataSize;
    5546                     pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_BLT;
    5547 
    5548                     PVBOXWDDM_DMA_PRIVATEDATA_BLT pBlt = (PVBOXWDDM_DMA_PRIVATEDATA_BLT)pPrivateData;
    5549 
    5550                     vboxWddmPopulateDmaAllocInfo(&pBlt->Blt.SrcAlloc, pSrcAlloc, pSrc);
    5551                     vboxWddmPopulateDmaAllocInfo(&pBlt->Blt.DstAlloc, pDstAlloc, pDst);
    5552 
    5553                     ASSERT_WARN(!pSrcAlloc->fRcFlags.SharedResource, ("Shared Allocatoin used in Present!"));
    5554 
    5555                     pBlt->Blt.SrcRect = pPresent->SrcRect;
    5556                     pBlt->Blt.DstRects.ContextRect = pPresent->DstRect;
    5557                     pBlt->Blt.DstRects.UpdateRects.cRects = 0;
    5558                     UINT cbHead = RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_BLT, Blt.DstRects.UpdateRects.aRects[0]);
    5559                     Assert(pPresent->SubRectCnt > pPresent->MultipassOffset);
    5560                     UINT cbRects = (pPresent->SubRectCnt - pPresent->MultipassOffset) * sizeof (RECT);
    5561                     pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + cbHead + cbRects;
    5562                     pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    5563                     Assert(pPresent->DmaSize >= VBOXWDDM_DUMMY_DMABUFFER_SIZE);
    5564                     cbCmd -= cbHead;
    5565                     Assert(cbCmd < UINT32_MAX/2);
    5566                     Assert(cbCmd > sizeof (RECT));
    5567                     if (cbCmd >= cbRects)
    5568                     {
    5569                         cbCmd -= cbRects;
    5570                         memcpy(&pBlt->Blt.DstRects.UpdateRects.aRects[pPresent->MultipassOffset], &pPresent->pDstSubRects[pPresent->MultipassOffset], cbRects);
    5571                         pBlt->Blt.DstRects.UpdateRects.cRects += cbRects/sizeof (RECT);
    5572                     }
    5573                     else
    5574                     {
    5575                         UINT cbFitingRects = (cbCmd/sizeof (RECT)) * sizeof (RECT);
    5576                         Assert(cbFitingRects);
    5577                         memcpy(&pBlt->Blt.DstRects.UpdateRects.aRects[pPresent->MultipassOffset], &pPresent->pDstSubRects[pPresent->MultipassOffset], cbFitingRects);
    5578                         cbCmd -= cbFitingRects;
    5579                         pPresent->MultipassOffset += cbFitingRects/sizeof (RECT);
    5580                         pBlt->Blt.DstRects.UpdateRects.cRects += cbFitingRects/sizeof (RECT);
    5581                         Assert(pPresent->SubRectCnt > pPresent->MultipassOffset);
    5582                         Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    5583                     }
    5584 
    5585                     memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST));
    5586                     pPresent->pPatchLocationListOut->PatchOffset = 0;
    5587                     pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_SOURCE_INDEX;
    5588                     ++pPresent->pPatchLocationListOut;
    5589                     pPresent->pPatchLocationListOut->PatchOffset = 4;
    5590                     pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_DESTINATION_INDEX;
    5591                     ++pPresent->pPatchLocationListOut;
    5592 
    5593                     break;
    5594 #ifdef VBOX_WITH_VDMA
    5595                     cbCmd = pPresent->DmaSize;
    5596 
    5597                     Assert(pPresent->SubRectCnt);
    5598                     UINT cmdSize = VBOXVDMACMD_DMA_PRESENT_BLT_SIZE(pPresent->SubRectCnt - pPresent->MultipassOffset);
    5599                     PVBOXVDMACMD pCmd = (PVBOXVDMACMD)pPresent->pDmaBuffer;
    5600                     pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + cmdSize;
    5601                     Assert(cbCmd >= VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE());
    5602                     if (cbCmd >= VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE())
    5603                     {
    5604                         if (vboxWddmPixFormatConversionSupported(pSrcAlloc->AllocData.SurfDesc.format, pDstAlloc->AllocData.SurfDesc.format))
    5605                         {
    5606                             memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST));
    5607             //                        pPresent->pPatchLocationListOut->PatchOffset = 0;
    5608             //                        ++pPresent->pPatchLocationListOut;
    5609                             pPresent->pPatchLocationListOut->PatchOffset = VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, offSrc);
    5610                             pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_SOURCE_INDEX;
    5611                             ++pPresent->pPatchLocationListOut;
    5612                             pPresent->pPatchLocationListOut->PatchOffset = VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, offDst);
    5613                             pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_DESTINATION_INDEX;
    5614                             ++pPresent->pPatchLocationListOut;
    5615 
    5616                             pCmd->enmType = VBOXVDMACMD_TYPE_DMA_PRESENT_BLT;
    5617                             pCmd->u32CmdSpecific = 0;
    5618                             PVBOXVDMACMD_DMA_PRESENT_BLT pTransfer = VBOXVDMACMD_BODY(pCmd, VBOXVDMACMD_DMA_PRESENT_BLT);
    5619                             pTransfer->offSrc = (VBOXVIDEOOFFSET)pSrc->PhysicalAddress.QuadPart;
    5620                             pTransfer->offDst = (VBOXVIDEOOFFSET)pDst->PhysicalAddress.QuadPart;
    5621                             vboxWddmSurfDescFromAllocation(pSrcAlloc, &pTransfer->srcDesc);
    5622                             vboxWddmSurfDescFromAllocation(pDstAlloc, &pTransfer->dstDesc);
    5623                             vboxWddmRectlFromRect(&pPresent->SrcRect, &pTransfer->srcRectl);
    5624                             vboxWddmRectlFromRect(&pPresent->DstRect, &pTransfer->dstRectl);
    5625                             UINT i = 0;
    5626                             cbCmd -= VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, aDstSubRects);
    5627                             Assert(cbCmd >= sizeof (VBOXVDMA_RECTL));
    5628                             Assert(cbCmd < pPresent->DmaSize);
    5629                             for (; i < pPresent->SubRectCnt; ++i)
    5630                             {
    5631                                 if (cbCmd < sizeof (VBOXVDMA_RECTL))
    5632                                 {
    5633                                     Assert(i);
    5634                                     pPresent->MultipassOffset += i;
    5635                                     Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    5636                                     break;
    5637                                 }
    5638                                 vboxWddmRectlFromRect(&pPresent->pDstSubRects[i + pPresent->MultipassOffset], &pTransfer->aDstSubRects[i]);
    5639                                 cbCmd -= sizeof (VBOXVDMA_RECTL);
    5640                             }
    5641                             Assert(i);
    5642                             pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_BLT;
    5643                             pTransfer->cDstSubRects = i;
    5644                             pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + sizeof(VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR);
    5645                         }
    5646                         else
    5647                         {
    5648                             AssertBreakpoint();
    5649                             LOGREL(("unsupported format conversion from(%d) to (%d)",pSrcAlloc->AllocData.SurfDesc.format, pDstAlloc->AllocData.SurfDesc.format));
    5650                             Status = STATUS_GRAPHICS_CANNOTCOLORCONVERT;
    5651                         }
    5652                     }
    5653                     else
    5654                     {
    5655                         /* this should not happen actually */
    5656                         LOGREL(("cbCmd too small!! (%d)", cbCmd));
    5657                         Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    5658                     }
    5659 #endif
    5660                 } while(0);
    5661             }
    5662             else
    5663             {
    5664                 /* this should not happen actually */
    5665                 LOGREL(("failed to get Dst Allocation info for hDeviceSpecificAllocation(0x%x)",pDst->hDeviceSpecificAllocation));
    5666                 Status = STATUS_INVALID_HANDLE;
    5667             }
     5450        if (!pSrcAlloc)
     5451        {
     5452            /* this should not happen actually */
     5453            WARN(("failed to get Src Allocation info for hDeviceSpecificAllocation(0x%x)",pSrc->hDeviceSpecificAllocation));
     5454            Status = STATUS_INVALID_HANDLE;
     5455            goto done;
     5456        }
     5457
     5458        PVBOXWDDM_ALLOCATION pDstAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pDst);
     5459        if (!pDstAlloc)
     5460        {
     5461            /* this should not happen actually */
     5462            WARN(("failed to get Dst Allocation info for hDeviceSpecificAllocation(0x%x)",pDst->hDeviceSpecificAllocation));
     5463            Status = STATUS_INVALID_HANDLE;
     5464            goto done;
     5465        }
     5466
     5467
     5468        UINT cbCmd = pPresent->DmaBufferPrivateDataSize;
     5469        pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_BLT;
     5470
     5471        PVBOXWDDM_DMA_PRIVATEDATA_BLT pBlt = (PVBOXWDDM_DMA_PRIVATEDATA_BLT)pPrivateData;
     5472
     5473        vboxWddmPopulateDmaAllocInfo(&pBlt->Blt.SrcAlloc, pSrcAlloc, pSrc);
     5474        vboxWddmPopulateDmaAllocInfo(&pBlt->Blt.DstAlloc, pDstAlloc, pDst);
     5475
     5476        ASSERT_WARN(!pSrcAlloc->fRcFlags.SharedResource, ("Shared Allocatoin used in Present!"));
     5477
     5478        pBlt->Blt.SrcRect = pPresent->SrcRect;
     5479        pBlt->Blt.DstRects.ContextRect = pPresent->DstRect;
     5480        pBlt->Blt.DstRects.UpdateRects.cRects = 0;
     5481        UINT cbHead = RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_BLT, Blt.DstRects.UpdateRects.aRects[0]);
     5482        Assert(pPresent->SubRectCnt > pPresent->MultipassOffset);
     5483        UINT cbRects = (pPresent->SubRectCnt - pPresent->MultipassOffset) * sizeof (RECT);
     5484        pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + cbHead + cbRects;
     5485        pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + VBOXWDDM_DUMMY_DMABUFFER_SIZE;
     5486        Assert(pPresent->DmaSize >= VBOXWDDM_DUMMY_DMABUFFER_SIZE);
     5487        cbCmd -= cbHead;
     5488        Assert(cbCmd < UINT32_MAX/2);
     5489        Assert(cbCmd > sizeof (RECT));
     5490        if (cbCmd >= cbRects)
     5491        {
     5492            cbCmd -= cbRects;
     5493            memcpy(&pBlt->Blt.DstRects.UpdateRects.aRects[pPresent->MultipassOffset], &pPresent->pDstSubRects[pPresent->MultipassOffset], cbRects);
     5494            pBlt->Blt.DstRects.UpdateRects.cRects += cbRects/sizeof (RECT);
    56685495        }
    56695496        else
    56705497        {
    5671             /* this should not happen actually */
    5672             LOGREL(("failed to get Src Allocation info for hDeviceSpecificAllocation(0x%x)",pSrc->hDeviceSpecificAllocation));
    5673             Status = STATUS_INVALID_HANDLE;
    5674         }
    5675 #if 0
    5676         UINT cbCmd = pPresent->DmaSize;
    5677 
    5678         Assert(pPresent->SubRectCnt);
    5679         UINT cmdSize = VBOXVDMACMD_DMA_PRESENT_BLT_SIZE(pPresent->SubRectCnt - pPresent->MultipassOffset);
    5680         PVBOXVDMACMD pCmd = (PVBOXVDMACMD)pPresent->pDmaBuffer;
    5681         pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + cmdSize;
    5682         Assert(cbCmd >= VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE());
    5683         if (cbCmd >= VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE())
    5684         {
    5685             DXGK_ALLOCATIONLIST *pSrc =  &pPresent->pAllocationList[DXGK_PRESENT_SOURCE_INDEX];
    5686             DXGK_ALLOCATIONLIST *pDst =  &pPresent->pAllocationList[DXGK_PRESENT_DESTINATION_INDEX];
    5687             PVBOXWDDM_ALLOCATION pSrcAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pSrc);
    5688             Assert(pSrcAlloc);
    5689             if (pSrcAlloc)
    5690             {
    5691                 PVBOXWDDM_ALLOCATION pDstAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pDst);
    5692                 Assert(pDstAlloc);
    5693                 if (pDstAlloc)
    5694                 {
    5695                     if (vboxWddmPixFormatConversionSupported(pSrcAlloc->AllocData.SurfDesc.format, pDstAlloc->AllocData.SurfDesc.format))
    5696                     {
    5697                         memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST));
    5698 //                        pPresent->pPatchLocationListOut->PatchOffset = 0;
    5699 //                        ++pPresent->pPatchLocationListOut;
    5700                         pPresent->pPatchLocationListOut->PatchOffset = VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, offSrc);
    5701                         pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_SOURCE_INDEX;
    5702                         ++pPresent->pPatchLocationListOut;
    5703                         pPresent->pPatchLocationListOut->PatchOffset = VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, offDst);
    5704                         pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_DESTINATION_INDEX;
    5705                         ++pPresent->pPatchLocationListOut;
    5706 
    5707                         pCmd->enmType = VBOXVDMACMD_TYPE_DMA_PRESENT_BLT;
    5708                         pCmd->u32CmdSpecific = 0;
    5709                         PVBOXVDMACMD_DMA_PRESENT_BLT pTransfer = VBOXVDMACMD_BODY(pCmd, VBOXVDMACMD_DMA_PRESENT_BLT);
    5710                         pTransfer->offSrc = (VBOXVIDEOOFFSET)pSrc->PhysicalAddress.QuadPart;
    5711                         pTransfer->offDst = (VBOXVIDEOOFFSET)pDst->PhysicalAddress.QuadPart;
    5712                         vboxWddmSurfDescFromAllocation(pSrcAlloc, &pTransfer->srcDesc);
    5713                         vboxWddmSurfDescFromAllocation(pDstAlloc, &pTransfer->dstDesc);
    5714                         vboxWddmRectlFromRect(&pPresent->SrcRect, &pTransfer->srcRectl);
    5715                         vboxWddmRectlFromRect(&pPresent->DstRect, &pTransfer->dstRectl);
    5716                         UINT i = 0;
    5717                         cbCmd -= VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, aDstSubRects);
    5718                         Assert(cbCmd >= sizeof (VBOXVDMA_RECTL));
    5719                         Assert(cbCmd < pPresent->DmaSize);
    5720                         for (; i < pPresent->SubRectCnt; ++i)
    5721                         {
    5722                             if (cbCmd < sizeof (VBOXVDMA_RECTL))
    5723                             {
    5724                                 Assert(i);
    5725                                 pPresent->MultipassOffset += i;
    5726                                 Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    5727                                 break;
    5728                             }
    5729                             vboxWddmRectlFromRect(&pPresent->pDstSubRects[i + pPresent->MultipassOffset], &pTransfer->aDstSubRects[i]);
    5730                             cbCmd -= sizeof (VBOXVDMA_RECTL);
    5731                         }
    5732                         Assert(i);
    5733                         pTransfer->cDstSubRects = i;
    5734                         pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + sizeof(VBOXWDDM_DMA_PRIVATEDATA_HDR);
    5735                     }
    5736                     else
    5737                     {
    5738                         AssertBreakpoint();
    5739                         LOGREL(("unsupported format conversion from(%d) to (%d)",pSrcAlloc->AllocData.SurfDesc.format, pDstAlloc->AllocData.SurfDesc.format));
    5740                         Status = STATUS_GRAPHICS_CANNOTCOLORCONVERT;
    5741                     }
    5742                 }
    5743                 else
    5744                 {
    5745                     /* this should not happen actually */
    5746                     LOGREL(("failed to get Dst Allocation info for hDeviceSpecificAllocation(0x%x)",pDst->hDeviceSpecificAllocation));
    5747                     Status = STATUS_INVALID_HANDLE;
    5748                 }
    5749             }
    5750             else
    5751             {
    5752                 /* this should not happen actually */
    5753                 LOGREL(("failed to get Src Allocation info for hDeviceSpecificAllocation(0x%x)",pSrc->hDeviceSpecificAllocation));
    5754                 Status = STATUS_INVALID_HANDLE;
    5755             }
    5756         }
    5757         else
    5758         {
    5759             /* this should not happen actually */
    5760             LOGREL(("cbCmd too small!! (%d)", cbCmd));
     5498            UINT cbFitingRects = (cbCmd/sizeof (RECT)) * sizeof (RECT);
     5499            Assert(cbFitingRects);
     5500            memcpy(&pBlt->Blt.DstRects.UpdateRects.aRects[pPresent->MultipassOffset], &pPresent->pDstSubRects[pPresent->MultipassOffset], cbFitingRects);
     5501            cbCmd -= cbFitingRects;
     5502            pPresent->MultipassOffset += cbFitingRects/sizeof (RECT);
     5503            pBlt->Blt.DstRects.UpdateRects.cRects += cbFitingRects/sizeof (RECT);
     5504            Assert(pPresent->SubRectCnt > pPresent->MultipassOffset);
    57615505            Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    57625506        }
    5763 #endif
     5507
     5508        memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST));
     5509        pPresent->pPatchLocationListOut->PatchOffset = 0;
     5510        pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_SOURCE_INDEX;
     5511        ++pPresent->pPatchLocationListOut;
     5512        pPresent->pPatchLocationListOut->PatchOffset = 4;
     5513        pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_DESTINATION_INDEX;
     5514        ++pPresent->pPatchLocationListOut;
    57645515    }
    57655516    else if (pPresent->Flags.Flip)
     
    57695520        DXGK_ALLOCATIONLIST *pSrc =  &pPresent->pAllocationList[DXGK_PRESENT_SOURCE_INDEX];
    57705521        PVBOXWDDM_ALLOCATION pSrcAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pSrc);
    5771         Assert(pSrcAlloc);
    5772         if (pSrcAlloc)
    5773         {
    5774             Assert(pDevExt->cContexts3D);
    5775             pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_FLIP;
    5776             PVBOXWDDM_DMA_PRIVATEDATA_FLIP pFlip = (PVBOXWDDM_DMA_PRIVATEDATA_FLIP)pPrivateData;
    5777 
    5778             vboxWddmPopulateDmaAllocInfo(&pFlip->Flip.Alloc, pSrcAlloc, pSrc);
    5779 
    5780             UINT cbCmd = sizeof (VBOXWDDM_DMA_PRIVATEDATA_FLIP);
    5781             pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + cbCmd;
    5782             pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    5783             Assert(pPresent->DmaSize >= VBOXWDDM_DUMMY_DMABUFFER_SIZE);
    5784 
    5785             memset(pPresent->pPatchLocationListOut, 0, sizeof (D3DDDI_PATCHLOCATIONLIST));
    5786             pPresent->pPatchLocationListOut->PatchOffset = 0;
    5787             pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_SOURCE_INDEX;
    5788             ++pPresent->pPatchLocationListOut;
    5789         }
    5790         else
     5522
     5523        if (!pSrcAlloc)
    57915524        {
    57925525            /* this should not happen actually */
    5793             LOGREL(("failed to get pSrc Allocation info for hDeviceSpecificAllocation(0x%x)",pSrc->hDeviceSpecificAllocation));
     5526            WARN(("failed to get pSrc Allocation info for hDeviceSpecificAllocation(0x%x)",pSrc->hDeviceSpecificAllocation));
    57945527            Status = STATUS_INVALID_HANDLE;
    5795         }
     5528            goto done;
     5529        }
     5530
     5531        Assert(pDevExt->cContexts3D);
     5532        pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_FLIP;
     5533        PVBOXWDDM_DMA_PRIVATEDATA_FLIP pFlip = (PVBOXWDDM_DMA_PRIVATEDATA_FLIP)pPrivateData;
     5534
     5535        vboxWddmPopulateDmaAllocInfo(&pFlip->Flip.Alloc, pSrcAlloc, pSrc);
     5536
     5537        UINT cbCmd = sizeof (VBOXWDDM_DMA_PRIVATEDATA_FLIP);
     5538        pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + cbCmd;
     5539        pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + VBOXWDDM_DUMMY_DMABUFFER_SIZE;
     5540        Assert(pPresent->DmaSize >= VBOXWDDM_DUMMY_DMABUFFER_SIZE);
     5541
     5542        memset(pPresent->pPatchLocationListOut, 0, sizeof (D3DDDI_PATCHLOCATIONLIST));
     5543        pPresent->pPatchLocationListOut->PatchOffset = 0;
     5544        pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_SOURCE_INDEX;
     5545        ++pPresent->pPatchLocationListOut;
    57965546    }
    57975547    else if (pPresent->Flags.ColorFill)
     
    58015551        DXGK_ALLOCATIONLIST *pDst =  &pPresent->pAllocationList[DXGK_PRESENT_DESTINATION_INDEX];
    58025552        PVBOXWDDM_ALLOCATION pDstAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pDst);
    5803         Assert(pDstAlloc);
    5804         if (pDstAlloc)
    5805         {
    5806             UINT cbCmd = pPresent->DmaBufferPrivateDataSize;
    5807             pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_CLRFILL;
    5808             PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL pCF = (PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL)pPrivateData;
    5809 
    5810             vboxWddmPopulateDmaAllocInfo(&pCF->ClrFill.Alloc, pDstAlloc, pDst);
    5811 
    5812             pCF->ClrFill.Color = pPresent->Color;
    5813             pCF->ClrFill.Rects.cRects = 0;
    5814             UINT cbHead = RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_CLRFILL, ClrFill.Rects.aRects[0]);
     5553        if (!pDstAlloc)
     5554        {
     5555
     5556            /* this should not happen actually */
     5557            WARN(("failed to get pDst Allocation info for hDeviceSpecificAllocation(0x%x)",pDst->hDeviceSpecificAllocation));
     5558            Status = STATUS_INVALID_HANDLE;
     5559            goto done;
     5560        }
     5561
     5562        UINT cbCmd = pPresent->DmaBufferPrivateDataSize;
     5563        pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_CLRFILL;
     5564        PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL pCF = (PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL)pPrivateData;
     5565
     5566        vboxWddmPopulateDmaAllocInfo(&pCF->ClrFill.Alloc, pDstAlloc, pDst);
     5567
     5568        pCF->ClrFill.Color = pPresent->Color;
     5569        pCF->ClrFill.Rects.cRects = 0;
     5570        UINT cbHead = RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_CLRFILL, ClrFill.Rects.aRects[0]);
     5571        Assert(pPresent->SubRectCnt > pPresent->MultipassOffset);
     5572        UINT cbRects = (pPresent->SubRectCnt - pPresent->MultipassOffset) * sizeof (RECT);
     5573        pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + cbHead + cbRects;
     5574        pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + VBOXWDDM_DUMMY_DMABUFFER_SIZE;
     5575        Assert(pPresent->DmaSize >= VBOXWDDM_DUMMY_DMABUFFER_SIZE);
     5576        cbCmd -= cbHead;
     5577        Assert(cbCmd < UINT32_MAX/2);
     5578        Assert(cbCmd > sizeof (RECT));
     5579        if (cbCmd >= cbRects)
     5580        {
     5581            cbCmd -= cbRects;
     5582            memcpy(&pCF->ClrFill.Rects.aRects[pPresent->MultipassOffset], pPresent->pDstSubRects, cbRects);
     5583            pCF->ClrFill.Rects.cRects += cbRects/sizeof (RECT);
     5584        }
     5585        else
     5586        {
     5587            UINT cbFitingRects = (cbCmd/sizeof (RECT)) * sizeof (RECT);
     5588            Assert(cbFitingRects);
     5589            memcpy(&pCF->ClrFill.Rects.aRects[pPresent->MultipassOffset], pPresent->pDstSubRects, cbFitingRects);
     5590            cbCmd -= cbFitingRects;
     5591            pPresent->MultipassOffset += cbFitingRects/sizeof (RECT);
     5592            pCF->ClrFill.Rects.cRects += cbFitingRects/sizeof (RECT);
    58155593            Assert(pPresent->SubRectCnt > pPresent->MultipassOffset);
    5816             UINT cbRects = (pPresent->SubRectCnt - pPresent->MultipassOffset) * sizeof (RECT);
    5817             pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + cbHead + cbRects;
    5818             pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    5819             Assert(pPresent->DmaSize >= VBOXWDDM_DUMMY_DMABUFFER_SIZE);
    5820             cbCmd -= cbHead;
    5821             Assert(cbCmd < UINT32_MAX/2);
    5822             Assert(cbCmd > sizeof (RECT));
    5823             if (cbCmd >= cbRects)
    5824             {
    5825                 cbCmd -= cbRects;
    5826                 memcpy(&pCF->ClrFill.Rects.aRects[pPresent->MultipassOffset], pPresent->pDstSubRects, cbRects);
    5827                 pCF->ClrFill.Rects.cRects += cbRects/sizeof (RECT);
    5828             }
    5829             else
    5830             {
    5831                 UINT cbFitingRects = (cbCmd/sizeof (RECT)) * sizeof (RECT);
    5832                 Assert(cbFitingRects);
    5833                 memcpy(&pCF->ClrFill.Rects.aRects[pPresent->MultipassOffset], pPresent->pDstSubRects, cbFitingRects);
    5834                 cbCmd -= cbFitingRects;
    5835                 pPresent->MultipassOffset += cbFitingRects/sizeof (RECT);
    5836                 pCF->ClrFill.Rects.cRects += cbFitingRects/sizeof (RECT);
    5837                 Assert(pPresent->SubRectCnt > pPresent->MultipassOffset);
    5838                 Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    5839             }
    5840 
    5841             memset(pPresent->pPatchLocationListOut, 0, sizeof (D3DDDI_PATCHLOCATIONLIST));
    5842             pPresent->pPatchLocationListOut->PatchOffset = 0;
    5843             pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_DESTINATION_INDEX;
    5844             ++pPresent->pPatchLocationListOut;
    5845         }
    5846         else
    5847         {
    5848             /* this should not happen actually */
    5849             LOGREL(("failed to get pDst Allocation info for hDeviceSpecificAllocation(0x%x)",pDst->hDeviceSpecificAllocation));
    5850             Status = STATUS_INVALID_HANDLE;
    5851         }
    5852 
     5594            Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
     5595        }
     5596
     5597        memset(pPresent->pPatchLocationListOut, 0, sizeof (D3DDDI_PATCHLOCATIONLIST));
     5598        pPresent->pPatchLocationListOut->PatchOffset = 0;
     5599        pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_DESTINATION_INDEX;
     5600        ++pPresent->pPatchLocationListOut;
    58535601    }
    58545602    else
    58555603    {
    5856         LOGREL(("cmd NOT IMPLEMENTED!! Flags(0x%x)", pPresent->Flags.Value));
    5857         AssertBreakpoint();
    5858     }
    5859 
     5604        WARN(("cmd NOT IMPLEMENTED!! Flags(0x%x)", pPresent->Flags.Value));
     5605        Status = STATUS_NOT_SUPPORTED;
     5606    }
     5607
     5608done:
    58605609//    LOGF(("LEAVE, hContext(0x%x), Status(0x%x)", hContext, Status));
    58615610
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette