Changeset 32823 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
- Timestamp:
- Sep 29, 2010 4:50:53 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
r32766 r32823 578 578 *NumberOfChildren = pContext->u.primary.cDisplays; 579 579 dprintf(("VBoxVideoWddm: sources(%d), children(%d)\n", *NumberOfVideoPresentSources, *NumberOfChildren)); 580 #ifdef VBOX_WITH_VIDEOHWACCEL 581 vboxVhwaInit(pContext); 582 #endif 580 581 vboxVdmaDdiQueueInit(pContext, &pContext->DdiCmdQueue); 583 582 vboxVideoCmInit(&pContext->CmMgr); 584 583 InitializeListHead(&pContext->SwapchainList3D); … … 586 585 ExInitializeFastMutex(&pContext->ContextMutex); 587 586 KeInitializeSpinLock(&pContext->SynchLock); 587 588 #ifdef VBOX_WITH_VIDEOHWACCEL 589 vboxVhwaInit(pContext); 590 #endif 588 591 } 589 592 else … … 907 910 VBOXSHGSMILIST VhwaCmdList; 908 911 #endif 912 LIST_ENTRY CompletedDdiCmdQueue; 909 913 BOOL bNotifyDpc; 910 914 } VBOXWDDM_DPCDATA, *PVBOXWDDM_DPCDATA; … … 927 931 vboxSHGSMIListDetach2List(&pdc->pDevExt->VhwaCmdList, &pdc->data.VhwaCmdList); 928 932 #endif 933 vboxVdmaDdiCmdGetCompletedListIsr(&pdc->pDevExt->DdiCmdQueue, &pdc->data.CompletedDdiCmdQueue); 934 929 935 pdc->data.bNotifyDpc = pdc->pDevExt->bNotifyDxDpc; 930 936 pdc->pDevExt->bNotifyDxDpc = FALSE; … … 974 980 } 975 981 #endif 982 983 vboxVdmaDdiCmdHandleCompletedList(pDevExt, &pDevExt->DdiCmdQueue, &context.data.CompletedDdiCmdQueue); 976 984 977 985 if (context.data.bNotifyDpc) … … 1887 1895 { 1888 1896 case VBOXVDMACMD_TYPE_DMA_PRESENT_SHADOW2PRIMARY: 1889 case VBOXVDMACMD_TYPE_DMA_PRESENT_BLT: 1890 { 1891 VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR *pPrivateData = (VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR*)pPrivateDataBase; 1897 { 1898 PVBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY pS2P = (PVBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY)pPrivateDataBase; 1892 1899 Assert(pPatch->PatchLocationListSubmissionLength == 2); 1893 1900 const D3DDDI_PATCHLOCATIONLIST* pPatchList = &pPatch->pPatchLocationList[pPatch->PatchLocationListSubmissionStart]; … … 1896 1903 const DXGK_ALLOCATIONLIST *pSrcAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex]; 1897 1904 Assert(pSrcAllocationList->SegmentId); 1898 pPrivateData->SrcAllocInfo.segmentIdAlloc = pSrcAllocationList->SegmentId; 1899 pPrivateData->SrcAllocInfo.offAlloc = (VBOXVIDEOOFFSET)pSrcAllocationList->PhysicalAddress.QuadPart; 1905 pS2P->Shadow2Primary.ShadowAlloc.segmentIdAlloc = pSrcAllocationList->SegmentId; 1906 pS2P->Shadow2Primary.ShadowAlloc.offAlloc = (VBOXVIDEOOFFSET)pSrcAllocationList->PhysicalAddress.QuadPart; 1907 // 1908 // pPatchList = &pPatch->pPatchLocationList[pPatch->PatchLocationListSubmissionStart + 1]; 1909 // Assert(pPatchList->AllocationIndex == DXGK_PRESENT_DESTINATION_INDEX); 1910 // Assert(pPatchList->PatchOffset == 4); 1911 // const DXGK_ALLOCATIONLIST *pDstAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex]; 1912 // Assert(pDstAllocationList->SegmentId); 1913 // pPrivateData->DstAllocInfo.segmentIdAlloc = pDstAllocationList->SegmentId; 1914 // pPrivateData->DstAllocInfo.offAlloc = (VBOXVIDEOOFFSET)pDstAllocationList->PhysicalAddress.QuadPart; 1915 break; 1916 } 1917 case VBOXVDMACMD_TYPE_DMA_PRESENT_BLT: 1918 { 1919 PVBOXWDDM_DMA_PRIVATEDATA_BLT pBlt = (PVBOXWDDM_DMA_PRIVATEDATA_BLT)pPrivateDataBase; 1920 Assert(pPatch->PatchLocationListSubmissionLength == 2); 1921 const D3DDDI_PATCHLOCATIONLIST* pPatchList = &pPatch->pPatchLocationList[pPatch->PatchLocationListSubmissionStart]; 1922 Assert(pPatchList->AllocationIndex == DXGK_PRESENT_SOURCE_INDEX); 1923 Assert(pPatchList->PatchOffset == 0); 1924 const DXGK_ALLOCATIONLIST *pSrcAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex]; 1925 Assert(pSrcAllocationList->SegmentId); 1926 pBlt->Blt.SrcAlloc.segmentIdAlloc = pSrcAllocationList->SegmentId; 1927 pBlt->Blt.SrcAlloc.offAlloc = (VBOXVIDEOOFFSET)pSrcAllocationList->PhysicalAddress.QuadPart; 1900 1928 1901 1929 pPatchList = &pPatch->pPatchLocationList[pPatch->PatchLocationListSubmissionStart + 1]; … … 1904 1932 const DXGK_ALLOCATIONLIST *pDstAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex]; 1905 1933 Assert(pDstAllocationList->SegmentId); 1906 p PrivateData->DstAllocInfo.segmentIdAlloc = pDstAllocationList->SegmentId;1907 p PrivateData->DstAllocInfo.offAlloc = (VBOXVIDEOOFFSET)pDstAllocationList->PhysicalAddress.QuadPart;1934 pBlt->Blt.DstAlloc.segmentIdAlloc = pDstAllocationList->SegmentId; 1935 pBlt->Blt.DstAlloc.offAlloc = (VBOXVIDEOOFFSET)pDstAllocationList->PhysicalAddress.QuadPart; 1908 1936 break; 1909 1937 } 1910 1938 case VBOXVDMACMD_TYPE_DMA_PRESENT_FLIP: 1911 1939 { 1912 VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR *pPrivateData = (VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR*)pPrivateDataBase;1940 PVBOXWDDM_DMA_PRIVATEDATA_FLIP pFlip = (PVBOXWDDM_DMA_PRIVATEDATA_FLIP)pPrivateDataBase; 1913 1941 Assert(pPatch->PatchLocationListSubmissionLength == 1); 1914 1942 const D3DDDI_PATCHLOCATIONLIST* pPatchList = &pPatch->pPatchLocationList[pPatch->PatchLocationListSubmissionStart]; … … 1917 1945 const DXGK_ALLOCATIONLIST *pSrcAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex]; 1918 1946 Assert(pSrcAllocationList->SegmentId); 1919 p PrivateData->SrcAllocInfo.segmentIdAlloc = pSrcAllocationList->SegmentId;1920 p PrivateData->SrcAllocInfo.offAlloc = (VBOXVIDEOOFFSET)pSrcAllocationList->PhysicalAddress.QuadPart;1947 pFlip->Flip.Alloc.segmentIdAlloc = pSrcAllocationList->SegmentId; 1948 pFlip->Flip.Alloc.offAlloc = (VBOXVIDEOOFFSET)pSrcAllocationList->PhysicalAddress.QuadPart; 1921 1949 break; 1922 1950 } 1923 1951 case VBOXVDMACMD_TYPE_DMA_PRESENT_CLRFILL: 1924 1952 { 1925 VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR *pPrivateData = (VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR*)pPrivateDataBase;1953 PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL pCF = (PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL)pPrivateDataBase; 1926 1954 Assert(pPatch->PatchLocationListSubmissionLength == 1); 1927 1955 const D3DDDI_PATCHLOCATIONLIST* pPatchList = &pPatch->pPatchLocationList[pPatch->PatchLocationListSubmissionStart]; … … 1930 1958 const DXGK_ALLOCATIONLIST *pDstAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex]; 1931 1959 Assert(pDstAllocationList->SegmentId); 1932 p PrivateData->DstAllocInfo.segmentIdAlloc = pDstAllocationList->SegmentId;1933 p PrivateData->DstAllocInfo.offAlloc = (VBOXVIDEOOFFSET)pDstAllocationList->PhysicalAddress.QuadPart;1960 pCF->ClrFill.Alloc.segmentIdAlloc = pDstAllocationList->SegmentId; 1961 pCF->ClrFill.Alloc.offAlloc = (VBOXVIDEOOFFSET)pDstAllocationList->PhysicalAddress.QuadPart; 1934 1962 break; 1935 1963 } … … 1975 2003 } 1976 2004 1977 typedef struct VBOXWDDM_SHADOW_UPDATE_COMPLETION1978 {1979 PDEVICE_EXTENSION pDevExt;1980 PVBOXWDDM_CONTEXT pContext;1981 UINT SubmissionFenceId;1982 } VBOXWDDM_SHADOW_UPDATE_COMPLETION, *PVBOXWDDM_SHADOW_UPDATE_COMPLETION;1983 1984 BOOLEAN vboxWddmNotifyShadowUpdateCompletion(PVOID Context)1985 {1986 PVBOXWDDM_SHADOW_UPDATE_COMPLETION pdc = (PVBOXWDDM_SHADOW_UPDATE_COMPLETION)Context;1987 PDEVICE_EXTENSION pDevExt = pdc->pDevExt;1988 DXGKARGCB_NOTIFY_INTERRUPT_DATA notify;1989 memset(¬ify, 0, sizeof(DXGKARGCB_NOTIFY_INTERRUPT_DATA));1990 1991 notify.InterruptType = DXGK_INTERRUPT_DMA_COMPLETED;1992 notify.DmaCompleted.SubmissionFenceId = pdc->SubmissionFenceId;1993 notify.DmaCompleted.NodeOrdinal = pdc->pContext->NodeOrdinal;1994 notify.DmaCompleted.EngineOrdinal = 0;1995 1996 pDevExt->u.primary.DxgkInterface.DxgkCbNotifyInterrupt(pDevExt->u.primary.DxgkInterface.DeviceHandle, ¬ify);1997 1998 pDevExt->bNotifyDxDpc = TRUE;1999 BOOLEAN bDpcQueued = pDevExt->u.primary.DxgkInterface.DxgkCbQueueDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);2000 Assert(bDpcQueued);2001 2002 return bDpcQueued;2003 }2004 2005 NTSTATUS vboxWddmDmaCmdNotifyCompletion(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_CONTEXT pContext, UINT SubmissionFenceId)2006 {2007 VBOXWDDM_SHADOW_UPDATE_COMPLETION context;2008 context.pDevExt = pDevExt;2009 context.pContext = pContext;2010 context.SubmissionFenceId = SubmissionFenceId;2011 BOOLEAN bRet;2012 NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbSynchronizeExecution(2013 pDevExt->u.primary.DxgkInterface.DeviceHandle,2014 vboxWddmNotifyShadowUpdateCompletion,2015 &context,2016 0, /* IN ULONG MessageNumber */2017 &bRet);2018 Assert(Status == STATUS_SUCCESS);2019 return Status;2020 }2021 2022 2005 typedef struct VBOXWDDM_CALL_ISR 2023 2006 { … … 2048 2031 } 2049 2032 2050 static void vboxWddmSubmitBltCmd(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAlloc, PVBOXWDDM_DMA_PRESENT_BLT pBlt) 2051 { 2052 PVBOXWDDM_SWAPCHAIN pSwapchain; 2053 if (pAlloc) 2054 { 2055 pSwapchain = vboxWddmSwapchainRetainByAlloc(pDevExt, pAlloc); 2056 if (!pSwapchain) 2057 return; 2033 static NTSTATUS vboxWddmSubmitCmd(PDEVICE_EXTENSION pDevExt, VBOXVDMAPIPE_CMD_DMACMD *pCmd) 2034 { 2035 NTSTATUS Status = vboxVdmaDdiCmdSubmitted(pDevExt, &pDevExt->DdiCmdQueue, &pCmd->DdiCmd); 2036 Assert(Status == STATUS_SUCCESS); 2037 if (Status == STATUS_SUCCESS) 2038 { 2039 if (pCmd->fFlags.bDecVBVAUnlock) 2040 { 2041 uint32_t cNew = ASMAtomicIncU32(&pDevExt->cUnlockedVBVADisabled); 2042 Assert(cNew < UINT32_MAX/2); 2043 } 2044 NTSTATUS submStatus = vboxVdmaGgCmdSubmit(&pDevExt->u.primary.Vdma.DmaGg, &pCmd->Hdr); 2045 Assert(submStatus == STATUS_SUCCESS); 2046 if (submStatus != STATUS_SUCCESS) 2047 { 2048 if (pCmd->fFlags.bDecVBVAUnlock) 2049 { 2050 uint32_t cNew = ASMAtomicDecU32(&pDevExt->cUnlockedVBVADisabled); 2051 Assert(cNew < UINT32_MAX/2); 2052 } 2053 vboxVdmaDdiCmdCompleted(pDevExt, &pDevExt->DdiCmdQueue, &pCmd->DdiCmd); 2054 } 2058 2055 } 2059 2056 else 2060 2057 { 2061 pSwapchain = NULL; 2062 } 2063 2064 PVBOXVDMAPIPE_CMD_RECTSINFO pRectsCmd = (PVBOXVDMAPIPE_CMD_RECTSINFO)vboxVdmaGgCmdCreate(&pDevExt->u.primary.Vdma.DmaGg, VBOXVDMAPIPE_CMD_TYPE_RECTSINFO, RT_OFFSETOF(VBOXVDMAPIPE_CMD_RECTSINFO, ContextsRects.UpdateRects.aRects[pBlt->DstRects.UpdateRects.cRects])); 2065 Assert(pRectsCmd); 2066 if (pRectsCmd) 2067 { 2068 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pBlt->Hdr.DstAllocInfo.srcId]; 2069 VBOXWDDM_CONTEXT *pContext = pBlt->Hdr.pContext; 2070 pRectsCmd->pContext = pContext; 2071 pRectsCmd->pSwapchain = pSwapchain; 2072 memcpy(&pRectsCmd->ContextsRects, &pBlt->DstRects, RT_OFFSETOF(VBOXVDMAPIPE_RECTS, UpdateRects.aRects[pBlt->DstRects.UpdateRects.cRects])); 2073 vboxWddmRectTranslate(&pRectsCmd->ContextsRects.ContextRect, pSource->VScreenPos.x, pSource->VScreenPos.y); 2074 for (UINT i = 0; i < pRectsCmd->ContextsRects.UpdateRects.cRects; ++i) 2075 { 2076 vboxWddmRectTranslate(&pRectsCmd->ContextsRects.UpdateRects.aRects[i], pSource->VScreenPos.x, pSource->VScreenPos.y); 2077 } 2078 NTSTATUS tmpStatus = vboxVdmaGgCmdSubmit(&pDevExt->u.primary.Vdma.DmaGg, &pRectsCmd->Hdr); 2079 Assert(tmpStatus == STATUS_SUCCESS); 2080 if (tmpStatus != STATUS_SUCCESS) 2081 vboxVdmaGgCmdDestroy(&pRectsCmd->Hdr); 2082 } 2058 vboxVdmaGgCmdDestroy(&pCmd->Hdr); 2059 } 2060 return Status; 2061 } 2062 2063 static NTSTATUS vboxWddmSubmitBltCmd(PDEVICE_EXTENSION pDevExt, VBOXWDDM_CONTEXT *pContext, UINT u32FenceId, PVBOXWDDM_DMA_PRIVATEDATA_BLT pBlt, VBOXVDMAPIPE_FLAGS_DMACMD fBltFlags) 2064 { 2065 NTSTATUS Status = STATUS_SUCCESS; 2066 2067 PVBOXVDMAPIPE_CMD_DMACMD_BLT pBltCmd = (PVBOXVDMAPIPE_CMD_DMACMD_BLT)vboxVdmaGgCmdCreate(&pDevExt->u.primary.Vdma.DmaGg, VBOXVDMAPIPE_CMD_TYPE_DMACMD, RT_OFFSETOF(VBOXVDMAPIPE_CMD_DMACMD_BLT, Blt.DstRects.UpdateRects.aRects[pBlt->Blt.DstRects.UpdateRects.cRects])); 2068 Assert(pBltCmd); 2069 if (pBltCmd) 2070 { 2071 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pBlt->Blt.DstAlloc.srcId]; 2072 vboxVdmaDdiCmdInit(&pBltCmd->Hdr.DdiCmd, u32FenceId, pContext, vboxVdmaGgDdiCmdDestroy, pBltCmd); 2073 pBltCmd->Hdr.pDevExt = pDevExt; 2074 pBltCmd->Hdr.fFlags = fBltFlags; 2075 pBltCmd->Hdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_BLT; 2076 memcpy(&pBltCmd->Blt, &pBlt->Blt, RT_OFFSETOF(VBOXVDMA_BLT, DstRects.UpdateRects.aRects[pBlt->Blt.DstRects.UpdateRects.cRects])); 2077 vboxWddmSubmitCmd(pDevExt, &pBltCmd->Hdr); 2078 } 2079 else 2080 { 2081 Status = vboxVdmaDdiCmdFenceComplete(pDevExt, pContext, u32FenceId); 2082 } 2083 2084 return Status; 2083 2085 } 2084 2086 … … 2097 2099 2098 2100 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter; 2101 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pSubmitCommand->hContext; 2102 Assert(pContext); 2103 Assert(pContext->pDevice); 2104 Assert(pContext->pDevice->pAdapter == pDevExt); 2099 2105 Assert(!pSubmitCommand->DmaBufferSegmentId); 2100 2106 … … 2118 2124 case VBOXVDMACMD_TYPE_DMA_PRESENT_SHADOW2PRIMARY: 2119 2125 { 2120 VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR *pPrivateData = (VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR*)pPrivateDataBase; 2121 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pPrivateData->SrcAllocInfo.srcId]; 2122 PVBOXWDDM_ALLOCATION pDstAlloc = pPrivateData->DstAllocInfo.pAlloc; 2123 PVBOXWDDM_ALLOCATION pSrcAlloc = pPrivateData->SrcAllocInfo.pAlloc; 2124 vboxWddmAssignShadow(pDevExt, pSource, pSrcAlloc, pDstAlloc->SurfDesc.VidPnSourceId); 2125 vboxWddmCheckUpdateShadowAddress(pDevExt, pSource, pDstAlloc->SurfDesc.VidPnSourceId, 2126 pPrivateData->SrcAllocInfo.segmentIdAlloc, pPrivateData->SrcAllocInfo.offAlloc); 2127 PVBOXWDDM_DMA_PRESENT_RENDER_FROM_SHADOW pRFS = (PVBOXWDDM_DMA_PRESENT_RENDER_FROM_SHADOW)pPrivateData; 2128 uint32_t cDMACmdsOutstanding = ASMAtomicReadU32(&pDevExt->cDMACmdsOutstanding); 2129 if (!cDMACmdsOutstanding) 2130 VBOXVBVA_OP(ReportDirtyRect, pDevExt, pSource, &pRFS->rect); 2126 PVBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY pS2P = (PVBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY)pPrivateDataBase; 2127 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pS2P->Shadow2Primary.VidPnSourceId]; 2128 PVBOXWDDM_ALLOCATION pSrcAlloc = pS2P->Shadow2Primary.ShadowAlloc.pAlloc; 2129 vboxWddmAssignShadow(pDevExt, pSource, pSrcAlloc, pS2P->Shadow2Primary.VidPnSourceId); 2130 vboxWddmCheckUpdateShadowAddress(pDevExt, pSource, pS2P->Shadow2Primary.VidPnSourceId, 2131 pS2P->Shadow2Primary.ShadowAlloc.segmentIdAlloc, pS2P->Shadow2Primary.ShadowAlloc.offAlloc); 2132 uint32_t cUnlockedVBVADisabled = ASMAtomicReadU32(&pDevExt->cUnlockedVBVADisabled); 2133 if (!cUnlockedVBVADisabled) 2134 VBOXVBVA_OP(ReportDirtyRect, pDevExt, pSource, &pS2P->Shadow2Primary.SrcRect); 2131 2135 else 2132 2136 { 2133 2137 Assert(KeGetCurrentIrql() == DISPATCH_LEVEL); 2134 VBOXVBVA_OP_WITHLOCK_ATDPC(ReportDirtyRect, pDevExt, pSource, &p RFS->rect);2138 VBOXVBVA_OP_WITHLOCK_ATDPC(ReportDirtyRect, pDevExt, pSource, &pS2P->Shadow2Primary.SrcRect); 2135 2139 } 2136 2140 /* get DPC data at IRQL */ 2137 2141 2138 Status = vbox WddmDmaCmdNotifyCompletion(pDevExt, pPrivateData->pContext, pSubmitCommand->SubmissionFenceId);2142 Status = vboxVdmaDdiCmdFenceComplete(pDevExt, pContext, pSubmitCommand->SubmissionFenceId); 2139 2143 break; 2140 2144 } … … 2143 2147 { 2144 2148 VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR *pPrivateData = (VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR*)pPrivateDataBase; 2145 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pSubmitCommand->hContext; 2146 Assert(pContext); 2147 Assert(pContext->pDevice); 2148 Assert(pContext->pDevice->pAdapter == pDevExt); 2149 PVBOXWDDM_DMA_PRESENT_BLT pBlt = (PVBOXWDDM_DMA_PRESENT_BLT)pPrivateData; 2150 PVBOXWDDM_ALLOCATION pDstAlloc = pPrivateData->DstAllocInfo.pAlloc; 2151 PVBOXWDDM_ALLOCATION pSrcAlloc = pPrivateData->SrcAllocInfo.pAlloc; 2149 PVBOXWDDM_DMA_PRIVATEDATA_BLT pBlt = (PVBOXWDDM_DMA_PRIVATEDATA_BLT)pPrivateData; 2150 PVBOXWDDM_ALLOCATION pDstAlloc = pBlt->Blt.DstAlloc.pAlloc; 2151 PVBOXWDDM_ALLOCATION pSrcAlloc = pBlt->Blt.SrcAlloc.pAlloc; 2152 2152 uint32_t cContexts3D = ASMAtomicReadU32(&pDevExt->cContexts3D); 2153 BOOLEAN bComplete = TRUE; 2153 2154 switch (pDstAlloc->enmType) 2154 2155 { … … 2158 2159 if (pDstAlloc->bAssigned) 2159 2160 { 2160 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[p PrivateData->DstAllocInfo.srcId];2161 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pDstAlloc->SurfDesc.VidPnSourceId]; 2161 2162 Assert(pSource->pPrimaryAllocation == pDstAlloc); 2162 2163 switch (pSrcAlloc->enmType) … … 2164 2165 case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE: 2165 2166 { 2166 RECT rect; 2167 VBOXVDMAPIPE_FLAGS_DMACMD fBltFlags; 2168 fBltFlags.Value = 0; 2169 fBltFlags.b3DRelated = !!cContexts3D; 2167 2170 Assert(pContext->enmType == VBOXWDDM_CONTEXT_TYPE_SYSTEM); 2168 2171 vboxWddmAssignShadow(pDevExt, pSource, pSrcAlloc, pDstAlloc->SurfDesc.VidPnSourceId); 2169 2172 vboxWddmCheckUpdateShadowAddress(pDevExt, pSource, 2170 pDstAlloc->SurfDesc.VidPnSourceId, p PrivateData->SrcAllocInfo.segmentIdAlloc, pPrivateData->SrcAllocInfo.offAlloc);2171 if ( pBlt->DstRects.UpdateRects.cRects)2173 pDstAlloc->SurfDesc.VidPnSourceId, pBlt->Blt.SrcAlloc.segmentIdAlloc, pBlt->Blt.SrcAlloc.offAlloc); 2174 if (vboxVhwaHlpOverlayListIsEmpty(pDevExt, pDstAlloc->SurfDesc.VidPnSourceId)) 2172 2175 { 2173 rect = pBlt->DstRects.UpdateRects.aRects[0];2174 for (UINT i = 1; i < pBlt->DstRects.UpdateRects.cRects; ++i)2176 RECT rect; 2177 if (pBlt->Blt.DstRects.UpdateRects.cRects) 2175 2178 { 2176 vboxWddmRectUnited(&rect, &rect, &pBlt->DstRects.UpdateRects.aRects[i]); 2179 rect = pBlt->Blt.DstRects.UpdateRects.aRects[0]; 2180 for (UINT i = 1; i < pBlt->Blt.DstRects.UpdateRects.cRects; ++i) 2181 { 2182 vboxWddmRectUnited(&rect, &rect, &pBlt->Blt.DstRects.UpdateRects.aRects[i]); 2183 } 2184 } 2185 else 2186 rect = pBlt->Blt.DstRects.ContextRect; 2187 2188 uint32_t cUnlockedVBVADisabled = ASMAtomicReadU32(&pDevExt->cUnlockedVBVADisabled); 2189 if (!cUnlockedVBVADisabled) 2190 VBOXVBVA_OP(ReportDirtyRect, pDevExt, pSource, &rect); 2191 else 2192 { 2193 Assert(KeGetCurrentIrql() == DISPATCH_LEVEL); 2194 VBOXVBVA_OP_WITHLOCK_ATDPC(ReportDirtyRect, pDevExt, pSource, &rect); 2177 2195 } 2178 2196 } 2179 2197 else 2180 rect = pBlt->DstRects.ContextRect;2181 2182 uint32_t cDMACmdsOutstanding = ASMAtomicReadU32(&pDevExt->cDMACmdsOutstanding);2183 if (!cDMACmdsOutstanding)2184 VBOXVBVA_OP(ReportDirtyRect, pDevExt, pSource, &rect);2185 else2186 2198 { 2187 Assert(KeGetCurrentIrql() == DISPATCH_LEVEL);2188 VBOXVBVA_OP_WITHLOCK_ATDPC(ReportDirtyRect, pDevExt, pSource, &rect);2199 fBltFlags.b2DRelated = 1; 2200 fBltFlags.bDecVBVAUnlock = 1; 2189 2201 } 2190 vboxWddmSubmitBltCmd(pDevExt, NULL, pBlt); 2202 2203 if (fBltFlags.Value) 2204 { 2205 Status = vboxWddmSubmitBltCmd(pDevExt, pContext, pSubmitCommand->SubmissionFenceId, pBlt, fBltFlags); 2206 bComplete = FALSE; 2207 } 2191 2208 break; 2192 2209 } … … 2197 2214 if (pSrcAlloc->fRcFlags.RenderTarget) 2198 2215 { 2199 vboxWddmSubmitBltCmd(pDevExt, pSrcAlloc, pBlt); 2216 VBOXVDMAPIPE_FLAGS_DMACMD fBltFlags; 2217 fBltFlags.Value = 0; 2218 fBltFlags.b3DRelated = 1; 2219 Status = vboxWddmSubmitBltCmd(pDevExt, pContext, pSubmitCommand->SubmissionFenceId, pBlt, fBltFlags); 2220 bComplete = FALSE; 2200 2221 } 2201 2222 break; … … 2213 2234 Assert(pSrcAlloc->enmType == VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC); 2214 2235 Assert(pSrcAlloc->fRcFlags.RenderTarget); 2215 Assert(vboxWddmRectIsEqual(&pBlt-> SrcRect, &pBlt->DstRects.ContextRect));2216 Assert(pBlt-> DstRects.UpdateRects.cRects == 1);2217 Assert(vboxWddmRectIsEqual(&pBlt-> SrcRect, pBlt->DstRects.UpdateRects.aRects));2236 Assert(vboxWddmRectIsEqual(&pBlt->Blt.SrcRect, &pBlt->Blt.DstRects.ContextRect)); 2237 Assert(pBlt->Blt.DstRects.UpdateRects.cRects == 1); 2238 Assert(vboxWddmRectIsEqual(&pBlt->Blt.SrcRect, pBlt->Blt.DstRects.UpdateRects.aRects)); 2218 2239 break; 2219 2240 } … … 2228 2249 } 2229 2250 2230 Status = vboxWddmDmaCmdNotifyCompletion(pDevExt, pPrivateData->pContext, pSubmitCommand->SubmissionFenceId); 2251 if (bComplete) 2252 { 2253 Status = vboxVdmaDdiCmdFenceComplete(pDevExt, pContext, pSubmitCommand->SubmissionFenceId); 2254 } 2231 2255 break; 2232 2256 } 2233 2257 case VBOXVDMACMD_TYPE_DMA_PRESENT_FLIP: 2234 2258 { 2235 VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR *pPrivateData = (VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR*)pPrivateDataBase; 2236 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pSubmitCommand->hContext; 2237 PVBOXWDDM_ALLOCATION pAlloc = pPrivateData->SrcAllocInfo.pAlloc; 2238 PVBOXWDDM_SWAPCHAIN pSwapchain = vboxWddmSwapchainRetainByAlloc(pDevExt, pAlloc); 2239 if (pSwapchain) 2240 { 2241 do 2242 { 2243 PVBOXVDMAPIPE_CMD_RECTSINFO pRectsCmd = (PVBOXVDMAPIPE_CMD_RECTSINFO)vboxVdmaGgCmdCreate(&pDevExt->u.primary.Vdma.DmaGg, VBOXVDMAPIPE_CMD_TYPE_RECTSINFO, RT_OFFSETOF(VBOXVDMAPIPE_CMD_RECTSINFO, ContextsRects.UpdateRects.aRects[1])); 2244 Assert(pRectsCmd); 2245 if (pRectsCmd) 2246 { 2247 2248 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pPrivateData->SrcAllocInfo.srcId]; 2249 pRectsCmd->pContext = pContext; 2250 pRectsCmd->pSwapchain = pSwapchain; 2251 RECT r; 2252 r.left = pSource->VScreenPos.x; 2253 r.top = pSource->VScreenPos.y; 2254 r.right = pAlloc->SurfDesc.width + pSource->VScreenPos.x; 2255 r.bottom = pAlloc->SurfDesc.height + pSource->VScreenPos.y; 2256 pRectsCmd->ContextsRects.ContextRect = r; 2257 pRectsCmd->ContextsRects.UpdateRects.cRects = 1; 2258 pRectsCmd->ContextsRects.UpdateRects.aRects[0] = r; 2259 NTSTATUS tmpStatus = vboxVdmaGgCmdSubmit(&pDevExt->u.primary.Vdma.DmaGg, &pRectsCmd->Hdr); 2260 Assert(tmpStatus == STATUS_SUCCESS); 2261 if (tmpStatus == STATUS_SUCCESS) 2262 break; 2263 vboxVdmaGgCmdDestroy(&pRectsCmd->Hdr); 2264 } 2265 vboxWddmSwapchainRelease(pSwapchain); 2266 } while (0); 2267 } 2268 Status = vboxWddmDmaCmdNotifyCompletion(pDevExt, pPrivateData->pContext, pSubmitCommand->SubmissionFenceId); 2259 VBOXWDDM_DMA_PRIVATEDATA_FLIP *pFlip = (VBOXWDDM_DMA_PRIVATEDATA_FLIP*)pPrivateDataBase; 2260 PVBOXVDMAPIPE_CMD_DMACMD_FLIP pFlipCmd = (PVBOXVDMAPIPE_CMD_DMACMD_FLIP)vboxVdmaGgCmdCreate( 2261 &pDevExt->u.primary.Vdma.DmaGg, VBOXVDMAPIPE_CMD_TYPE_DMACMD, sizeof (VBOXVDMAPIPE_CMD_DMACMD_FLIP)); 2262 Assert(pFlipCmd); 2263 if (pFlipCmd) 2264 { 2265 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pFlip->Flip.Alloc.srcId]; 2266 vboxVdmaDdiCmdInit(&pFlipCmd->Hdr.DdiCmd, pSubmitCommand->SubmissionFenceId, pContext, vboxVdmaGgDdiCmdDestroy, pFlipCmd); 2267 pFlipCmd->Hdr.pDevExt = pDevExt; 2268 pFlipCmd->Hdr.fFlags.Value = 0; 2269 pFlipCmd->Hdr.fFlags.b3DRelated = 1; 2270 pFlipCmd->Hdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_FLIP; 2271 memcpy(&pFlipCmd->Flip, &pFlip->Flip, sizeof (pFlipCmd->Flip)); 2272 Status = vboxWddmSubmitCmd(pDevExt, &pFlipCmd->Hdr); 2273 Assert(Status == STATUS_SUCCESS); 2274 } 2275 else 2276 { 2277 Status = vboxVdmaDdiCmdFenceComplete(pDevExt, pContext, pSubmitCommand->SubmissionFenceId); 2278 Assert(Status == STATUS_SUCCESS); 2279 } 2269 2280 break; 2270 2281 } 2271 2282 case VBOXVDMACMD_TYPE_DMA_PRESENT_CLRFILL: 2272 2283 { 2273 VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR *pPrivateData = (VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR*)pPrivateDataBase; 2274 PVBOXWDDM_DMA_PRESENT_CLRFILL pCF = (PVBOXWDDM_DMA_PRESENT_CLRFILL)pPrivateData; 2275 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pSubmitCommand->hContext; 2276 PVBOXVDMAPIPE_CMD_DMACMD_CLRFILL pCFCmd = (PVBOXVDMAPIPE_CMD_DMACMD_CLRFILL)vboxVdmaGgCmdCreate(&pDevExt->u.primary.Vdma.DmaGg, VBOXVDMAPIPE_CMD_TYPE_DMACMD_CLRFILL, RT_OFFSETOF(VBOXVDMAPIPE_CMD_DMACMD_CLRFILL, Rects.aRects[pCF->Rects.cRects])); 2277 NTSTATUS submStatus = STATUS_UNSUCCESSFUL; 2284 PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL pCF = (PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL)pPrivateDataBase; 2285 PVBOXVDMAPIPE_CMD_DMACMD_CLRFILL pCFCmd = (PVBOXVDMAPIPE_CMD_DMACMD_CLRFILL)vboxVdmaGgCmdCreate( 2286 &pDevExt->u.primary.Vdma.DmaGg, VBOXVDMAPIPE_CMD_TYPE_DMACMD, 2287 RT_OFFSETOF(VBOXVDMAPIPE_CMD_DMACMD_CLRFILL, ClrFill.Rects.aRects[pCF->ClrFill.Rects.cRects])); 2278 2288 Assert(pCFCmd); 2279 2289 if (pCFCmd) 2280 2290 { 2281 PVBOXWDDM_ALLOCATION pDstAlloc = pPrivateData->DstAllocInfo.pAlloc; 2282 Assert(pDstAlloc); 2283 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId; 2284 if (pDstAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE 2285 && pDstAlloc->bAssigned) 2286 { 2287 VidPnSourceId = pPrivateData->DstAllocInfo.srcId; 2288 #ifdef VBOXWDDM_RENDER_FROM_SHADOW 2289 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pPrivateData->DstAllocInfo.srcId]; 2290 Assert(pSource->pPrimaryAllocation == pDstAlloc); 2291 2292 Assert(pSource->pShadowAllocation); 2293 if (pSource->pShadowAllocation) 2294 pDstAlloc = pSource->pShadowAllocation; 2295 #endif 2296 } 2297 else 2298 { 2299 VidPnSourceId = D3DDDI_ID_UNINITIALIZED; 2300 } 2301 pCFCmd->pContext = pContext; 2302 pCFCmd->pAllocation = pDstAlloc; 2303 pCFCmd->SubmissionFenceId = pSubmitCommand->SubmissionFenceId; 2304 pCFCmd->VidPnSourceId = VidPnSourceId; 2305 pCFCmd->Color = pCF->Color; 2306 memcpy(&pCFCmd->Rects, &pCF->Rects, RT_OFFSETOF(VBOXWDDM_RECTS_INFO, aRects[pCF->Rects.cRects])); 2307 ASMAtomicIncU32(&pDevExt->cDMACmdsOutstanding); 2308 submStatus = vboxVdmaGgCmdSubmit(&pDevExt->u.primary.Vdma.DmaGg, &pCFCmd->Hdr); 2309 Assert(submStatus == STATUS_SUCCESS); 2310 if (submStatus != STATUS_SUCCESS) 2311 { 2312 uint32_t cNew = ASMAtomicDecU32(&pDevExt->cDMACmdsOutstanding); 2313 Assert(cNew < UINT32_MAX/2); 2314 vboxVdmaGgCmdDestroy(&pCFCmd->Hdr); 2315 } 2316 2317 } 2318 2319 Status = vboxWddmDmaCmdNotifyCompletion(pDevExt, pPrivateData->pContext, pSubmitCommand->SubmissionFenceId); 2320 Assert(Status == STATUS_SUCCESS); 2291 // VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pFlip->Flip.Alloc.srcId]; 2292 vboxVdmaDdiCmdInit(&pCFCmd->Hdr.DdiCmd, pSubmitCommand->SubmissionFenceId, pContext, vboxVdmaGgDdiCmdDestroy, pCFCmd); 2293 pCFCmd->Hdr.pDevExt = pDevExt; 2294 pCFCmd->Hdr.pDevExt = pDevExt; 2295 pCFCmd->Hdr.fFlags.Value = 0; 2296 pCFCmd->Hdr.fFlags.b2DRelated = 1; 2297 pCFCmd->Hdr.fFlags.bDecVBVAUnlock = 1; 2298 pCFCmd->Hdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_CLRFILL; 2299 memcpy(&pCFCmd->ClrFill, &pCF->ClrFill, RT_OFFSETOF(VBOXVDMA_CLRFILL, Rects.aRects[pCF->ClrFill.Rects.cRects])); 2300 Status = vboxWddmSubmitCmd(pDevExt, &pCFCmd->Hdr); 2301 Assert(Status == STATUS_SUCCESS); 2302 } 2303 else 2304 { 2305 Status = vboxVdmaDdiCmdFenceComplete(pDevExt, pContext, pSubmitCommand->SubmissionFenceId); 2306 Assert(Status == STATUS_SUCCESS); 2307 } 2321 2308 2322 2309 break; … … 2324 2311 case VBOXVDMACMD_TYPE_DMA_NOP: 2325 2312 { 2326 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pSubmitCommand->hContext; 2327 Assert(pContext); 2328 Status = vboxWddmDmaCmdNotifyCompletion(pDevExt, pContext, pSubmitCommand->SubmissionFenceId); 2313 Status = vboxVdmaDdiCmdFenceComplete(pDevExt, pContext, pSubmitCommand->SubmissionFenceId); 2329 2314 Assert(Status == STATUS_SUCCESS); 2330 2315 break; … … 3391 3376 pSource->offVram = VBOXVIDEOOFFSET_VOID; 3392 3377 #endif 3378 #if 0 /* tmp */ 3393 3379 Status = vboxWddmGhDisplaySetInfo(pDevExt, pSource, pSetVidPnSourceVisibility->VidPnSourceId); 3394 3380 Assert(Status == STATUS_SUCCESS); 3395 3381 if (Status != STATUS_SUCCESS) 3396 3382 drprintf((__FUNCTION__": vboxWddmGhDisplaySetInfo failed, Status (0x%x)\n", Status)); 3383 #endif 3397 3384 } 3398 3385 } … … 3678 3665 if (RT_SUCCESS(rc)) 3679 3666 { 3680 pCreateOverlay->hOverlay = pOverlay;; 3667 vboxVhwaHlpOverlayListAdd(pDevExt, pOverlay); 3668 #ifdef VBOXWDDM_RENDER_FROM_SHADOW 3669 RECT DstRect; 3670 vboxVhwaHlpOverlayDstRectGet(pDevExt, pOverlay, &DstRect); 3671 Status = vboxVdmaHlpUpdatePrimary(pDevExt, pCreateOverlay->VidPnSourceId, &DstRect); 3672 Assert(Status == STATUS_SUCCESS); 3673 /* ignore primary update failure */ 3674 Status = STATUS_SUCCESS; 3675 #endif 3676 pCreateOverlay->hOverlay = pOverlay; 3681 3677 } 3682 3678 else … … 3961 3957 3962 3958 PVBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR pPrivateData = (PVBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR)pPresent->pDmaBufferPrivateData; 3963 pPrivateData->pContext = pContext;3964 3959 pPrivateData->BaseHdr.fFlags.Value = 0; 3965 3960 uint32_t cContexts3D = ASMAtomicReadU32(&pDevExt->cContexts3D); … … 4007 4002 && pDstAlloc->bVisible) 4008 4003 { 4009 Assert(pPresent->DmaBufferPrivateDataSize >= sizeof (VBOXWDDM_DMA_PRESENT_RENDER_FROM_SHADOW)); 4010 if (pPresent->DmaBufferPrivateDataSize >= sizeof (VBOXWDDM_DMA_PRESENT_RENDER_FROM_SHADOW)) 4004 #ifdef VBOX_WITH_VIDEOHWACCEL 4005 if (vboxVhwaHlpOverlayListIsEmpty(pDevExt, pDstAlloc->SurfDesc.VidPnSourceId)) 4006 #endif 4011 4007 { 4012 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pDstAlloc->SurfDesc.VidPnSourceId]; 4013 vboxWddmAssignShadow(pDevExt, pSource, pSrcAlloc, pDstAlloc->SurfDesc.VidPnSourceId); 4014 Assert(pPresent->SrcRect.left == pPresent->DstRect.left); 4015 Assert(pPresent->SrcRect.right == pPresent->DstRect.right); 4016 Assert(pPresent->SrcRect.top == pPresent->DstRect.top); 4017 Assert(pPresent->SrcRect.bottom == pPresent->DstRect.bottom); 4018 RECT rect; 4019 if (pPresent->SubRectCnt) 4008 Assert(pPresent->DmaBufferPrivateDataSize >= sizeof (VBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY)); 4009 if (pPresent->DmaBufferPrivateDataSize >= sizeof (VBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY)) 4020 4010 { 4021 rect = pPresent->pDstSubRects[0]; 4022 for (UINT i = 1; i < pPresent->SubRectCnt; ++i) 4011 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pDstAlloc->SurfDesc.VidPnSourceId]; 4012 vboxWddmAssignShadow(pDevExt, pSource, pSrcAlloc, pDstAlloc->SurfDesc.VidPnSourceId); 4013 Assert(pPresent->SrcRect.left == pPresent->DstRect.left); 4014 Assert(pPresent->SrcRect.right == pPresent->DstRect.right); 4015 Assert(pPresent->SrcRect.top == pPresent->DstRect.top); 4016 Assert(pPresent->SrcRect.bottom == pPresent->DstRect.bottom); 4017 RECT rect; 4018 if (pPresent->SubRectCnt) 4023 4019 { 4024 vboxWddmRectUnited(&rect, &rect, &pPresent->pDstSubRects[i]); 4020 rect = pPresent->pDstSubRects[0]; 4021 for (UINT i = 1; i < pPresent->SubRectCnt; ++i) 4022 { 4023 vboxWddmRectUnited(&rect, &rect, &pPresent->pDstSubRects[i]); 4024 } 4025 4025 } 4026 else 4027 rect = pPresent->SrcRect; 4028 4029 4030 pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + sizeof (VBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY); 4031 pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + VBOXWDDM_DUMMY_DMABUFFER_SIZE; 4032 Assert(pPresent->DmaSize >= VBOXWDDM_DUMMY_DMABUFFER_SIZE); 4033 memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST)); 4034 pPresent->pPatchLocationListOut->PatchOffset = 0; 4035 pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_SOURCE_INDEX; 4036 ++pPresent->pPatchLocationListOut; 4037 pPresent->pPatchLocationListOut->PatchOffset = 4; 4038 pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_DESTINATION_INDEX; 4039 ++pPresent->pPatchLocationListOut; 4040 4041 pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_SHADOW2PRIMARY; 4042 PVBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY pS2P = (PVBOXWDDM_DMA_PRIVATEDATA_SHADOW2PRIMARY)pPrivateData; 4043 /* we do not know the shadow address yet, perform dummy DMA cycle */ 4044 vboxWddmPopulateDmaAllocInfo(&pS2P->Shadow2Primary.ShadowAlloc, pSrcAlloc, pSrc); 4045 // vboxWddmPopulateDmaAllocInfo(&pPrivateData->DstAllocInfo, pDstAlloc, pDst); 4046 pS2P->Shadow2Primary.SrcRect = rect; 4047 pS2P->Shadow2Primary.VidPnSourceId = pDstAlloc->SurfDesc.VidPnSourceId; 4048 break; 4026 4049 } 4027 4050 else 4028 rect = pPresent->SrcRect; 4029 4030 4031 pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + sizeof (VBOXWDDM_DMA_PRESENT_RENDER_FROM_SHADOW); 4032 pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + VBOXWDDM_DUMMY_DMABUFFER_SIZE; 4033 Assert(pPresent->DmaSize >= VBOXWDDM_DUMMY_DMABUFFER_SIZE); 4034 memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST)); 4035 pPresent->pPatchLocationListOut->PatchOffset = 0; 4036 pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_SOURCE_INDEX; 4037 ++pPresent->pPatchLocationListOut; 4038 pPresent->pPatchLocationListOut->PatchOffset = 4; 4039 pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_DESTINATION_INDEX; 4040 ++pPresent->pPatchLocationListOut; 4041 4042 4043 /* we do not know the shadow address yet, perform dummy DMA cycle */ 4044 pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_SHADOW2PRIMARY; 4045 vboxWddmPopulateDmaAllocInfo(&pPrivateData->SrcAllocInfo, pSrcAlloc, pSrc); 4046 vboxWddmPopulateDmaAllocInfo(&pPrivateData->DstAllocInfo, pDstAlloc, pDst); 4047 PVBOXWDDM_DMA_PRESENT_RENDER_FROM_SHADOW pRFS = (PVBOXWDDM_DMA_PRESENT_RENDER_FROM_SHADOW)pPrivateData; 4048 pRFS->rect = rect; 4049 break; 4050 } 4051 else 4052 { 4053 Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER; 4054 break; 4051 { 4052 Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER; 4053 break; 4054 } 4055 4055 } 4056 4056 } … … 4059 4059 4060 4060 /* we're here because this is NOT a shadow->primary update 4061 * or because there are d3d contexts and we need to report visible rects */ 4061 * or because there are d3d contexts and we need to report visible rects 4062 * or because we have overlays active and we need a special handling for primary */ 4062 4063 #endif 4063 4064 UINT cbCmd = pPresent->DmaBufferPrivateDataSize; 4064 4065 pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_BLT; 4065 4066 4066 vboxWddmPopulateDmaAllocInfo(&pPrivateData->SrcAllocInfo, pSrcAlloc, pSrc); 4067 vboxWddmPopulateDmaAllocInfo(&pPrivateData->DstAllocInfo, pDstAlloc, pDst); 4068 4069 PVBOXWDDM_DMA_PRESENT_BLT pBlt = (PVBOXWDDM_DMA_PRESENT_BLT)pPrivateData; 4070 pBlt->SrcRect = pPresent->SrcRect; 4071 pBlt->DstRects.ContextRect = pPresent->DstRect; 4072 pBlt->DstRects.UpdateRects.cRects = 0; 4073 UINT cbHead = RT_OFFSETOF(VBOXWDDM_DMA_PRESENT_BLT, DstRects.UpdateRects.aRects[0]); 4067 PVBOXWDDM_DMA_PRIVATEDATA_BLT pBlt = (PVBOXWDDM_DMA_PRIVATEDATA_BLT)pPrivateData; 4068 4069 vboxWddmPopulateDmaAllocInfo(&pBlt->Blt.SrcAlloc, pSrcAlloc, pSrc); 4070 vboxWddmPopulateDmaAllocInfo(&pBlt->Blt.DstAlloc, pDstAlloc, pDst); 4071 4072 pBlt->Blt.SrcRect = pPresent->SrcRect; 4073 pBlt->Blt.DstRects.ContextRect = pPresent->DstRect; 4074 pBlt->Blt.DstRects.UpdateRects.cRects = 0; 4075 UINT cbHead = RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_BLT, Blt.DstRects.UpdateRects.aRects[0]); 4074 4076 Assert(pPresent->SubRectCnt > pPresent->MultipassOffset); 4075 4077 UINT cbRects = (pPresent->SubRectCnt - pPresent->MultipassOffset) * sizeof (RECT); … … 4083 4085 { 4084 4086 cbCmd -= cbRects; 4085 memcpy(&pBlt-> DstRects.UpdateRects.aRects[pPresent->MultipassOffset], pPresent->pDstSubRects, cbRects);4086 pBlt-> DstRects.UpdateRects.cRects += cbRects/sizeof (RECT);4087 memcpy(&pBlt->Blt.DstRects.UpdateRects.aRects[pPresent->MultipassOffset], pPresent->pDstSubRects, cbRects); 4088 pBlt->Blt.DstRects.UpdateRects.cRects += cbRects/sizeof (RECT); 4087 4089 } 4088 4090 else … … 4090 4092 UINT cbFitingRects = (cbCmd/sizeof (RECT)) * sizeof (RECT); 4091 4093 Assert(cbFitingRects); 4092 memcpy(&pBlt-> DstRects.UpdateRects.aRects[pPresent->MultipassOffset], pPresent->pDstSubRects, cbFitingRects);4094 memcpy(&pBlt->Blt.DstRects.UpdateRects.aRects[pPresent->MultipassOffset], pPresent->pDstSubRects, cbFitingRects); 4093 4095 cbCmd -= cbFitingRects; 4094 4096 pPresent->MultipassOffset += cbFitingRects/sizeof (RECT); 4095 pBlt-> DstRects.UpdateRects.cRects += cbFitingRects/sizeof (RECT);4097 pBlt->Blt.DstRects.UpdateRects.cRects += cbFitingRects/sizeof (RECT); 4096 4098 Assert(pPresent->SubRectCnt > pPresent->MultipassOffset); 4097 4099 Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER; … … 4289 4291 Assert(cContexts3D); 4290 4292 pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_FLIP; 4291 4292 vboxWddmPopulateDmaAllocInfo(&pPrivateData->SrcAllocInfo, pSrcAlloc, pSrc); 4293 4294 UINT cbCmd = sizeof (VBOXVDMACMD_DMA_PRESENT_FLIP); 4293 PVBOXWDDM_DMA_PRIVATEDATA_FLIP pFlip = (PVBOXWDDM_DMA_PRIVATEDATA_FLIP)pPrivateData; 4294 4295 vboxWddmPopulateDmaAllocInfo(&pFlip->Flip.Alloc, pSrcAlloc, pSrc); 4296 4297 UINT cbCmd = sizeof (VBOXWDDM_DMA_PRIVATEDATA_FLIP); 4295 4298 pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + cbCmd; 4296 4299 pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + VBOXWDDM_DUMMY_DMABUFFER_SIZE; … … 4320 4323 UINT cbCmd = pPresent->DmaBufferPrivateDataSize; 4321 4324 pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_CLRFILL; 4322 4323 vboxWddmPopulateDmaAllocInfo(&pPrivateData->DstAllocInfo, pDstAlloc, pDst); 4324 4325 PVBOXWDDM_DMA_PRESENT_CLRFILL pClrFill = (PVBOXWDDM_DMA_PRESENT_CLRFILL)pPrivateData; 4326 pC lrFill->Color = pPresent->Color;4327 pC lrFill->Rects.cRects = 0;4328 UINT cbHead = RT_OFFSETOF(VBOXWDDM_DMA_PR ESENT_CLRFILL,Rects.aRects[0]);4325 PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL pCF = (PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL)pPrivateData; 4326 4327 vboxWddmPopulateDmaAllocInfo(&pCF->ClrFill.Alloc, pDstAlloc, pDst); 4328 4329 pCF->ClrFill.Color = pPresent->Color; 4330 pCF->ClrFill.Rects.cRects = 0; 4331 UINT cbHead = RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_CLRFILL, ClrFill.Rects.aRects[0]); 4329 4332 Assert(pPresent->SubRectCnt > pPresent->MultipassOffset); 4330 4333 UINT cbRects = (pPresent->SubRectCnt - pPresent->MultipassOffset) * sizeof (RECT); … … 4338 4341 { 4339 4342 cbCmd -= cbRects; 4340 memcpy(&pC lrFill->Rects.aRects[pPresent->MultipassOffset], pPresent->pDstSubRects, cbRects);4341 pC lrFill->Rects.cRects += cbRects/sizeof (RECT);4343 memcpy(&pCF->ClrFill.Rects.aRects[pPresent->MultipassOffset], pPresent->pDstSubRects, cbRects); 4344 pCF->ClrFill.Rects.cRects += cbRects/sizeof (RECT); 4342 4345 } 4343 4346 else … … 4345 4348 UINT cbFitingRects = (cbCmd/sizeof (RECT)) * sizeof (RECT); 4346 4349 Assert(cbFitingRects); 4347 memcpy(&pC lrFill->Rects.aRects[pPresent->MultipassOffset], pPresent->pDstSubRects, cbFitingRects);4350 memcpy(&pCF->ClrFill.Rects.aRects[pPresent->MultipassOffset], pPresent->pDstSubRects, cbFitingRects); 4348 4351 cbCmd -= cbFitingRects; 4349 4352 pPresent->MultipassOffset += cbFitingRects/sizeof (RECT); 4350 pC lrFill->Rects.cRects += cbFitingRects/sizeof (RECT);4353 pCF->ClrFill.Rects.cRects += cbFitingRects/sizeof (RECT); 4351 4354 Assert(pPresent->SubRectCnt > pPresent->MultipassOffset); 4352 4355 Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER; … … 4429 4432 PVBOXWDDM_OVERLAY pOverlay = (PVBOXWDDM_OVERLAY)hOverlay; 4430 4433 Assert(pOverlay); 4434 vboxVhwaHlpOverlayListRemove(pOverlay->pDevExt, pOverlay); 4431 4435 int rc = vboxVhwaHlpOverlayDestroy(pOverlay); 4432 4436 AssertRC(rc);
Note:
See TracChangeset
for help on using the changeset viewer.