Changeset 32823 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVhwa.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/VBoxVideoVhwa.cpp
r30973 r32823 18 18 #endif 19 19 20 #define VBOXVHWA_PRIMARY_ALLOCATION(_pSrc) ((_pSrc)->pPrimaryAllocation) 20 21 21 22 … … 342 343 } 343 344 345 DECLINLINE(VOID) vboxVhwaHlpOverlayListInit(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId) 346 { 347 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[VidPnSourceId]; 348 pSource->cOverlays = 0; 349 InitializeListHead(&pSource->OverlayList); 350 KeInitializeSpinLock(&pSource->OverlayListLock); 351 } 352 344 353 static void vboxVhwaInitSrc(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId) 345 354 { … … 347 356 VBOXVHWA_INFO *pSettings = &pDevExt->aSources[srcId].Vhwa.Settings; 348 357 memset (pSettings, 0, sizeof (VBOXVHWA_INFO)); 358 359 vboxVhwaHlpOverlayListInit(pDevExt, srcId); 349 360 350 361 VBOXVHWACMD_QUERYINFO1* pInfo1 = vboxVhwaQueryHostInfo1(pDevExt, srcId); … … 685 696 int vboxVhwaHlpDestroyPrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId) 686 697 { 687 PVBOXWDDM_ALLOCATION pFbSurf = VBOX WDDM_FB_ALLOCATION(pSource);698 PVBOXWDDM_ALLOCATION pFbSurf = VBOXVHWA_PRIMARY_ALLOCATION(pSource); 688 699 689 700 int rc = vboxVhwaHlpDestroySurface(pDevExt, pFbSurf, VidPnSourceId); … … 694 705 int vboxVhwaHlpCreatePrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId) 695 706 { 696 PVBOXWDDM_ALLOCATION pFbSurf = VBOX WDDM_FB_ALLOCATION(pSource);707 PVBOXWDDM_ALLOCATION pFbSurf = VBOXVHWA_PRIMARY_ALLOCATION(pSource); 697 708 Assert(pSource->Vhwa.cOverlaysCreated == 1); 698 709 Assert(pFbSurf->hHostHandle == VBOXVHWA_SURFHANDLE_INVALID); … … 739 750 else 740 751 { 741 PVBOXWDDM_ALLOCATION pFbSurf = VBOX WDDM_FB_ALLOCATION(pSource);752 PVBOXWDDM_ALLOCATION pFbSurf = VBOXVHWA_PRIMARY_ALLOCATION(pSource); 742 753 Assert(pFbSurf->hHostHandle); 743 754 if (pFbSurf->hHostHandle) … … 789 800 PVBOXWDDM_SOURCE pSource = &pOverlay->pDevExt->aSources[pOverlay->VidPnSourceId]; 790 801 Assert(!!(pSource->Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED)); 791 PVBOXWDDM_ALLOCATION pFbSurf = VBOX WDDM_FB_ALLOCATION(pSource);802 PVBOXWDDM_ALLOCATION pFbSurf = VBOXVHWA_PRIMARY_ALLOCATION(pSource); 792 803 Assert(pFbSurf); 793 804 Assert(pFbSurf->hHostHandle); … … 856 867 AssertCompile(RT_OFFSETOF(RECT, bottom) == RT_OFFSETOF(VBOXVHWA_RECTL, bottom)); 857 868 869 int vboxVhwaHlpColorFill(PVBOXWDDM_OVERLAY pOverlay, PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL pCF) 870 { 871 PVBOXWDDM_ALLOCATION pAlloc = pCF->ClrFill.Alloc.pAlloc; 872 Assert(pAlloc->pResource == pOverlay->pResource); 873 #ifdef VBOXWDDM_RENDER_FROM_SHADOW 874 if (pAlloc->bAssigned) 875 { 876 /* check if this is a primary surf */ 877 PVBOXWDDM_SOURCE pSource = &pOverlay->pDevExt->aSources[pOverlay->VidPnSourceId]; 878 if (pSource->pPrimaryAllocation == pAlloc) 879 { 880 pAlloc = pSource->pShadowAllocation; 881 Assert(pAlloc->pResource == pOverlay->pResource); 882 } 883 } 884 #endif 885 Assert(pAlloc->hHostHandle); 886 Assert(pAlloc->pResource); 887 Assert(pAlloc->offVram != VBOXVIDEOOFFSET_VOID); 888 889 int rc; 890 VBOXVHWACMD* pCmd = vboxVhwaCommandCreate(pOverlay->pDevExt, pOverlay->VidPnSourceId, 891 VBOXVHWACMD_TYPE_SURF_FLIP, RT_OFFSETOF(VBOXVHWACMD_SURF_COLORFILL, u.in.aRects[pCF->ClrFill.Rects.cRects])); 892 Assert(pCmd); 893 if(pCmd) 894 { 895 VBOXVHWACMD_SURF_COLORFILL * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_COLORFILL); 896 897 memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_COLORFILL)); 898 899 pBody->u.in.hSurf = pAlloc->hHostHandle; 900 pBody->u.in.offSurface = pAlloc->offVram; 901 pBody->u.in.cRects = pCF->ClrFill.Rects.cRects; 902 memcpy (pBody->u.in.aRects, pCF->ClrFill.Rects.aRects, pCF->ClrFill.Rects.cRects * sizeof (pCF->ClrFill.Rects.aRects[0])); 903 vboxVhwaCommandSubmitAsynchAndComplete(pOverlay->pDevExt, pCmd); 904 905 rc = VINF_SUCCESS; 906 } 907 else 908 rc = VERR_OUT_OF_RESOURCES; 909 910 return rc; 911 } 912 913 static void vboxVhwaHlpOverlayDstRectSet(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_OVERLAY pOverlay, const RECT *pRect) 914 { 915 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pOverlay->VidPnSourceId]; 916 KIRQL OldIrql; 917 KeAcquireSpinLock(&pSource->OverlayListLock, &OldIrql); 918 pOverlay->DstRect = *pRect; 919 KeReleaseSpinLock(&pSource->OverlayListLock, OldIrql); 920 } 921 922 AssertCompile(sizeof (RECT) == sizeof (VBOXVHWA_RECTL)); 923 AssertCompile(RT_SIZEOFMEMB(RECT, left) == RT_SIZEOFMEMB(VBOXVHWA_RECTL, left)); 924 AssertCompile(RT_SIZEOFMEMB(RECT, right) == RT_SIZEOFMEMB(VBOXVHWA_RECTL, right)); 925 AssertCompile(RT_SIZEOFMEMB(RECT, top) == RT_SIZEOFMEMB(VBOXVHWA_RECTL, top)); 926 AssertCompile(RT_SIZEOFMEMB(RECT, bottom) == RT_SIZEOFMEMB(VBOXVHWA_RECTL, bottom)); 927 AssertCompile(RT_OFFSETOF(RECT, left) == RT_OFFSETOF(VBOXVHWA_RECTL, left)); 928 AssertCompile(RT_OFFSETOF(RECT, right) == RT_OFFSETOF(VBOXVHWA_RECTL, right)); 929 AssertCompile(RT_OFFSETOF(RECT, top) == RT_OFFSETOF(VBOXVHWA_RECTL, top)); 930 AssertCompile(RT_OFFSETOF(RECT, bottom) == RT_OFFSETOF(VBOXVHWA_RECTL, bottom)); 931 858 932 int vboxVhwaHlpOverlayUpdate(PVBOXWDDM_OVERLAY pOverlay, const DXGK_OVERLAYINFO *pOverlayInfo) 859 933 { … … 866 940 PVBOXWDDM_SOURCE pSource = &pOverlay->pDevExt->aSources[pOverlay->VidPnSourceId]; 867 941 Assert(!!(pSource->Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED)); 868 PVBOXWDDM_ALLOCATION pFbSurf = VBOX WDDM_FB_ALLOCATION(pSource);942 PVBOXWDDM_ALLOCATION pFbSurf = VBOXVHWA_PRIMARY_ALLOCATION(pSource); 869 943 Assert(pFbSurf); 870 944 Assert(pFbSurf->hHostHandle); … … 924 998 pOverlay->pCurentAlloc = pAlloc; 925 999 1000 vboxVhwaHlpOverlayDstRectSet(pOverlay->pDevExt, pOverlay, &pOverlayInfo->DstRect); 1001 926 1002 rc = VINF_SUCCESS; 927 1003 } … … 1008 1084 return rc; 1009 1085 } 1086 1087 BOOLEAN vboxVhwaHlpOverlayListIsEmpty(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId) 1088 { 1089 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[VidPnSourceId]; 1090 return !ASMAtomicReadU32(&pSource->cOverlays); 1091 } 1092 1093 void vboxVhwaHlpOverlayListAdd(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_OVERLAY pOverlay) 1094 { 1095 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pOverlay->VidPnSourceId]; 1096 KIRQL OldIrql; 1097 KeAcquireSpinLock(&pSource->OverlayListLock, &OldIrql); 1098 ASMAtomicIncU32(&pSource->cOverlays); 1099 InsertHeadList(&pSource->OverlayList, &pOverlay->ListEntry); 1100 KeReleaseSpinLock(&pSource->OverlayListLock, OldIrql); 1101 } 1102 1103 void vboxVhwaHlpOverlayListRemove(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_OVERLAY pOverlay) 1104 { 1105 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pOverlay->VidPnSourceId]; 1106 KIRQL OldIrql; 1107 KeAcquireSpinLock(&pSource->OverlayListLock, &OldIrql); 1108 ASMAtomicDecU32(&pSource->cOverlays); 1109 RemoveEntryList(&pOverlay->ListEntry); 1110 KeReleaseSpinLock(&pSource->OverlayListLock, OldIrql); 1111 } 1112 1113 #define VBOXWDDM_OVERLAY_FROM_ENTRY(_pEntry) ((PVBOXWDDM_OVERLAY)(((uint8_t*)(_pEntry)) - RT_OFFSETOF(VBOXWDDM_OVERLAY, ListEntry))) 1114 1115 void vboxVhwaHlpOverlayDstRectUnion(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, RECT *pRect) 1116 { 1117 if (vboxVhwaHlpOverlayListIsEmpty(pDevExt, VidPnSourceId)) 1118 { 1119 memset(pRect, 0, sizeof (*pRect)); 1120 return; 1121 } 1122 1123 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[VidPnSourceId]; 1124 KIRQL OldIrql; 1125 KeAcquireSpinLock(&pSource->OverlayListLock, &OldIrql); 1126 if (pSource->cOverlays) 1127 { 1128 PVBOXWDDM_OVERLAY pOverlay = VBOXWDDM_OVERLAY_FROM_ENTRY(pSource->OverlayList.Flink); 1129 *pRect = pOverlay->DstRect; 1130 while (pOverlay->ListEntry.Flink != &pSource->OverlayList) 1131 { 1132 pOverlay = VBOXWDDM_OVERLAY_FROM_ENTRY(pOverlay->ListEntry.Flink); 1133 vboxWddmRectUnite(pRect, &pOverlay->DstRect); 1134 } 1135 } 1136 KeReleaseSpinLock(&pSource->OverlayListLock, OldIrql); 1137 } 1138 1139 void vboxVhwaHlpOverlayDstRectGet(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_OVERLAY pOverlay, RECT *pRect) 1140 { 1141 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pOverlay->VidPnSourceId]; 1142 KIRQL OldIrql; 1143 KeAcquireSpinLock(&pSource->OverlayListLock, &OldIrql); 1144 *pRect = pOverlay->DstRect; 1145 KeReleaseSpinLock(&pSource->OverlayListLock, OldIrql); 1146 }
Note:
See TracChangeset
for help on using the changeset viewer.