Changeset 30483 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Display
- Timestamp:
- Jun 28, 2010 7:00:55 PM (14 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics/Display
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk
r30462 r30483 76 76 endif 77 77 VBoxDispD3D_TEMPLATE = VBOXGUESTR3DLL 78 VBoxDispD3D_DEFS = UNICODE _UNICODE VBOXWDDM VBOXVDMA 78 VBoxDispD3D_DEFS = UNICODE _UNICODE VBOXWDDM VBOXVDMA VBOXWDDMDISP 79 VBoxDispD3D_DEFS += VBOXDISPMP_TEST 79 80 ifdef VBOXWDDM_WITH_VBVA 80 81 VBoxDispD3D_DEFS += VBOXWDDM_WITH_VBVA -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispCm.cpp
r30462 r30483 166 166 return E_INVALIDARG; 167 167 168 DWORD dwResult = WaitForSingleObject(pSession->hEvent, dwMilliseconds);169 switch(dwResult)170 {171 case WAIT_OBJECT_0:168 do 169 { 170 DWORD dwResult = WaitForSingleObject(pSession->hEvent, dwMilliseconds); 171 switch(dwResult) 172 172 { 173 HRESULT hr = S_OK; 174 D3DDDICB_ESCAPE DdiEscape; 175 DdiEscape.Flags.Value = 0; 176 DdiEscape.pPrivateDriverData = pCmd; 177 DdiEscape.PrivateDriverDataSize = cbCmd; 178 179 pCmd->EscapeHdr.escapeCode = VBOXESC_GETVBOXVIDEOCMCMD; 180 /* lock to ensure the context is not distructed */ 181 EnterCriticalSection(&pSession->CritSect); 182 /* use any context for identifying the kernel CmSession. We're using the first one */ 183 PVBOXWDDMDISP_CONTEXT pContext = RTListNodeGetFirst(&pSession->CtxList, VBOXWDDMDISP_CONTEXT, ListNode); 184 if (pContext) 173 case WAIT_OBJECT_0: 185 174 { 186 PVBOXWDDMDISP_DEVICE pDevice = pContext->pDevice; 187 DdiEscape.hDevice = pDevice->hDevice; 188 DdiEscape.hContext = pContext->ContextInfo.hContext; 189 Assert (DdiEscape.hContext); 190 Assert (DdiEscape.hDevice); 191 hr = pDevice->RtCallbacks.pfnEscapeCb(pDevice->pAdapter->hAdapter, &DdiEscape); 192 Assert(hr == S_OK); 193 LeaveCriticalSection(&pSession->CritSect); 175 HRESULT hr = S_OK; 176 D3DDDICB_ESCAPE DdiEscape; 177 DdiEscape.Flags.Value = 0; 178 DdiEscape.pPrivateDriverData = pCmd; 179 DdiEscape.PrivateDriverDataSize = cbCmd; 180 181 pCmd->EscapeHdr.escapeCode = VBOXESC_GETVBOXVIDEOCMCMD; 182 /* lock to ensure the context is not distructed */ 183 EnterCriticalSection(&pSession->CritSect); 184 /* use any context for identifying the kernel CmSession. We're using the first one */ 185 PVBOXWDDMDISP_CONTEXT pContext = RTListNodeGetFirst(&pSession->CtxList, VBOXWDDMDISP_CONTEXT, ListNode); 186 if (pContext) 187 { 188 PVBOXWDDMDISP_DEVICE pDevice = pContext->pDevice; 189 DdiEscape.hDevice = pDevice->hDevice; 190 DdiEscape.hContext = pContext->ContextInfo.hContext; 191 Assert (DdiEscape.hContext); 192 Assert (DdiEscape.hDevice); 193 hr = pDevice->RtCallbacks.pfnEscapeCb(pDevice->pAdapter->hAdapter, &DdiEscape); 194 LeaveCriticalSection(&pSession->CritSect); 195 Assert(hr == S_OK); 196 if (hr == S_OK) 197 { 198 if (!pCmd->Hdr.cbCmdsReturned && !pCmd->Hdr.cbRemainingFirstCmd) 199 break; /* <- break to enter a new wait cycle */ 200 } 201 } 202 else 203 { 204 LeaveCriticalSection(&pSession->CritSect); 205 pCmd->Hdr.cbCmdsReturned = 0; 206 pCmd->Hdr.cbRemainingCmds = 0; 207 pCmd->Hdr.cbRemainingFirstCmd = 0; 208 } 209 210 return hr; 194 211 } 195 else212 case WAIT_TIMEOUT: 196 213 { 197 LeaveCriticalSection(&pSession->CritSect);198 214 pCmd->Hdr.cbCmdsReturned = 0; 199 215 pCmd->Hdr.cbRemainingCmds = 0; 200 216 pCmd->Hdr.cbRemainingFirstCmd = 0; 217 return WAIT_TIMEOUT; 201 218 } 202 203 return hr; 219 default: 220 AssertBreakpoint(); 221 return E_FAIL; 204 222 } 205 case WAIT_TIMEOUT: 206 { 207 pCmd->Hdr.cbCmdsReturned = 0; 208 pCmd->Hdr.cbRemainingCmds = 0; 209 pCmd->Hdr.cbRemainingFirstCmd = 0; 210 return S_OK; 211 } 212 default: 213 AssertBreakpoint(); 214 return E_FAIL; 215 } 223 } while (1); 216 224 } 217 225 -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
r30462 r30483 23 23 #include "VBoxDispD3DCmn.h" 24 24 #include "VBoxDispD3D.h" 25 26 #ifdef VBOXDISPMP_TEST 27 HRESULT vboxDispMpTstStart(); 28 HRESULT vboxDispMpTstStop(); 29 #endif 25 30 26 31 #ifdef VBOXWDDMDISP_DEBUG … … 1095 1100 HRESULT hr = vboxDispCmInit(); 1096 1101 Assert(hr == S_OK); 1102 #ifdef VBOXDISPMP_TEST 1103 if (hr == S_OK) 1104 { 1105 hr = vboxDispMpTstStart(); 1106 Assert(hr == S_OK); 1107 } 1108 #endif 1097 1109 if (hr == S_OK) 1098 1110 vboxVDbgPrint(("VBoxDispD3D: DLL loaded.\n")); … … 1106 1118 case DLL_PROCESS_DETACH: 1107 1119 { 1108 HRESULT hr = vboxDispCmTerm(); 1120 HRESULT hr; 1121 #ifdef VBOXDISPMP_TEST 1122 hr = vboxDispMpTstStop(); 1109 1123 Assert(hr == S_OK); 1110 1124 if (hr == S_OK) 1111 vboxVDbgPrint(("VBoxDispD3D: DLL unloaded.\n")); 1112 else 1113 bOk = FALSE; 1125 #endif 1126 { 1127 hr = vboxDispCmTerm(); 1128 Assert(hr == S_OK); 1129 if (hr == S_OK) 1130 vboxVDbgPrint(("VBoxDispD3D: DLL unloaded.\n")); 1131 else 1132 bOk = FALSE; 1133 } 1114 1134 // VbglR3Term(); 1115 1135 /// @todo RTR3Term(); -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.def
r28800 r30483 19 19 EXPORTS 20 20 OpenAdapter 21 VBoxDispMpGetCallbacks 21 22 -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D64.def
r28800 r30483 19 19 EXPORTS 20 20 OpenAdapter 21 VBoxDispMpGetCallbacks 21 22 -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispMp.cpp
r30464 r30483 56 56 static VBOXDISPMP g_VBoxDispMp; 57 57 58 HRESULT vboxDispMpEnable()58 DECLCALLBACK(HRESULT) vboxDispMpEnableEvents() 59 59 { 60 60 g_VBoxDispMp.pEscapeCmd = NULL; … … 65 65 66 66 67 HRESULT vboxDispMpDisable()67 DECLCALLBACK(HRESULT) vboxDispMpDisableEvents() 68 68 { 69 69 if (g_VBoxDispMp.pEscapeCmd) … … 76 76 #define VBOXDISPMP_BUF_MAXSIZE ((4096*4096)-96) 77 77 78 HRESULTvboxDispMpGetRegions(PVBOXDISPMP_REGIONS pRegions, DWORD dwMilliseconds)78 DECLCALLBACK(HRESULT) vboxDispMpGetRegions(PVBOXDISPMP_REGIONS pRegions, DWORD dwMilliseconds) 79 79 { 80 80 HRESULT hr = S_OK; … … 106 106 break; 107 107 } 108 else if (g_VBoxDispMp.pEscapeCmd->Hdr.cbRemainingCmds)108 else 109 109 { 110 Assert(g_VBoxDispMp.pEscapeCmd->Hdr.cbRemainingCmds); 111 Assert(g_VBoxDispMp.pEscapeCmd->Hdr.cbRemainingFirstCmd); 110 112 RTMemFree(g_VBoxDispMp.pEscapeCmd); 111 113 uint32_t newSize = RT_MAX(g_VBoxDispMp.cbEscapeCmd + VBOXDISPMP_BUF_INCREASE, g_VBoxDispMp.pEscapeCmd->Hdr.cbRemainingFirstCmd); 112 114 if (newSize < VBOXDISPMP_BUF_MAXSIZE) 113 115 newSize = RT_MAX(newSize, RT_MIN(g_VBoxDispMp.pEscapeCmd->Hdr.cbRemainingCmds, VBOXDISPMP_BUF_MAXSIZE)); 116 Assert(g_VBoxDispMp.cbEscapeCmd < newSize); 114 117 g_VBoxDispMp.pEscapeCmd = (PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD)RTMemAlloc(newSize); 115 118 Assert(g_VBoxDispMp.pEscapeCmd); 116 119 if (g_VBoxDispMp.pEscapeCmd) 117 120 g_VBoxDispMp.cbEscapeCmd = newSize; 121 else 122 { 123 g_VBoxDispMp.pEscapeCmd = NULL; 124 g_VBoxDispMp.cbEscapeCmd = 0; 125 hr = E_OUTOFMEMORY; 126 break; 127 } 118 128 } 119 129 } … … 133 143 return hr; 134 144 } 145 146 VBOXDISPMP_DECL(HRESULT) VBoxDispMpGetCallbacks(uint32_t u32Version, PVBOXDISPMP_CALLBACKS pCallbacks) 147 { 148 Assert(u32Version == VBOXDISPMP_VERSION); 149 if (u32Version != VBOXDISPMP_VERSION) 150 return E_INVALIDARG; 151 152 pCallbacks->pfnEnableEvents = vboxDispMpEnableEvents; 153 pCallbacks->pfnDisableEvents = vboxDispMpDisableEvents; 154 pCallbacks->pfnGetRegions = vboxDispMpGetRegions; 155 return S_OK; 156 } -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispMp.h
r30464 r30483 22 22 #include "../../Miniport/wddm/VBoxVideoIf.h" 23 23 24 HRESULT vboxDispMpEnable();25 HRESULT vboxDispMpDisable();26 27 24 typedef struct VBOXDISPMP_REGIONS 28 25 { … … 31 28 } VBOXDISPMP_REGIONS, *PVBOXDISPMP_REGIONS; 32 29 33 /* 34 * the VBOXDISPMP_REGIONS::pRegions returned is valid until the next vboxDispMpGetRegions call or vboxDispMpDisable call 30 typedef DECLCALLBACK(HRESULT) FNVBOXDISPMP_ENABLEEVENTS(); 31 typedef FNVBOXDISPMP_ENABLEEVENTS *PFNVBOXDISPMP_ENABLEEVENTS; 32 33 typedef DECLCALLBACK(HRESULT) FNVBOXDISPMP_DISABLEEVENTS(); 34 typedef FNVBOXDISPMP_DISABLEEVENTS *PFNVBOXDISPMP_DISABLEEVENTS; 35 36 typedef DECLCALLBACK(HRESULT) FNVBOXDISPMP_DISABLEEVENTS(); 37 typedef FNVBOXDISPMP_DISABLEEVENTS *PFNVBOXDISPMP_DISABLEEVENTS; 38 39 typedef DECLCALLBACK(HRESULT) FNVBOXDISPMP_GETREGIONS(PVBOXDISPMP_REGIONS pRegions, DWORD dwMilliseconds); 40 typedef FNVBOXDISPMP_GETREGIONS *PFNVBOXDISPMP_GETREGIONS; 41 42 typedef struct VBOXDISPMP_CALLBACKS 43 { 44 PFNVBOXDISPMP_ENABLEEVENTS pfnEnableEvents; 45 PFNVBOXDISPMP_DISABLEEVENTS pfnDisableEvents; 46 /** 47 * if events are enabled - blocks until dirty region is available or timeout occurs 48 * in the former case S_OK is returned on event, in the latter case WAIT_TIMEOUT is returned 49 * if events are disabled - returns S_FALSE 50 */ 51 PFNVBOXDISPMP_GETREGIONS pfnGetRegions; 52 } VBOXDISPMP_CALLBACKS, *PVBOXDISPMP_CALLBACKS; 53 54 /** @def VBOXNETCFGWIN_DECL 55 * The usual declaration wrapper. 35 56 */ 36 HRESULT vboxDispMpGetRegions(PVBOXDISPMP_REGIONS pRegions, DWORD dwMilliseconds); 57 58 /* enable this in case we include this in a dll*/ 59 # ifdef VBOXWDDMDISP 60 # define VBOXDISPMP_DECL(_type) DECLEXPORT(_type) 61 # else 62 # define VBOXDISPMP_DECL(_type) DECLIMPORT(_type) 63 # endif 64 65 #define VBOXDISPMP_IFVERSION 1 66 #define VBOXDISPMP_VERSION (VBOXVIDEOIF_VERSION | (VBOXDISPMP_IFVERSION < 16)) 67 /** 68 * VBoxDispMpGetCallbacks export 69 * 70 * @param u32Version - must be set to VBOXDISPMP_VERSION 71 * @param pCallbacks - callbacks structure 72 */ 73 typedef VBOXDISPMP_DECL(HRESULT) FNVBOXDISPMP_GETCALLBACKS(uint32_t u32Version, PVBOXDISPMP_CALLBACKS pCallbacks); 74 typedef FNVBOXDISPMP_GETCALLBACKS *PFNVBOXDISPMP_GETCALLBACKS; 37 75 38 76 #endif /* #ifndef ___VBoxDispMp_h___ */ -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispMpTst.cpp
r30464 r30483 20 20 21 21 static RTTHREAD g_VBoxDispMpTstThread; 22 static VBOXDISPMP_CALLBACKS g_VBoxDispMpTstCallbacks; 23 static HMODULE g_hVBoxDispMpModule; 24 static PFNVBOXDISPMP_GETCALLBACKS g_pfnVBoxDispMpGetCallbacks; 25 22 26 23 27 static void vboxDispMpTstLogRect(const char * pPrefix, RECT *pRect, const char * pSuffix) 24 28 { 25 vboxVDbg DoPrint("%s left(%d), top(%d), right(%d), bottom(%d) %s", pPrefix, pRect->left, pRect->top, pRect->right, pRect->bottom, pSuffix);29 vboxVDbgPrint(("%s left(%d), top(%d), right(%d), bottom(%d) %s", pPrefix, pRect->left, pRect->top, pRect->right, pRect->bottom, pSuffix)); 26 30 } 27 31 … … 30 34 VBOXDISPMP_REGIONS Regions; 31 35 32 HRESULT hr; 36 HRESULT hr = g_VBoxDispMpTstCallbacks.pfnEnableEvents(); 37 Assert(hr == S_OK); 38 if (hr != S_OK) 39 return VERR_GENERAL_FAILURE; 40 33 41 do 34 42 { 35 hr = vboxDispMpGetRegions(&Regions, INFINITE);43 hr = g_VBoxDispMpTstCallbacks.pfnGetRegions(&Regions, INFINITE); 36 44 Assert(hr == S_OK); 37 45 if (hr == S_OK) 38 46 { 39 vboxVDbg DoPrint("\n>>>\n");47 vboxVDbgPrint(("\n>>>\n")); 40 48 HWND hWnd = Regions.hWnd; 41 49 if (Regions.pRegions->fFlags.bAddVisibleRects) … … 48 56 --cVidibleRects; 49 57 50 vboxVDbg DoPrint("hWnd (0x%p), position and/or size changed: ", hWnd);58 vboxVDbgPrint(("hWnd (0x%p), position and/or size changed: ", hWnd)); 51 59 vboxDispMpTstLogRect("", Regions.pRegions->RectsInfo.aRects, "\n"); 52 60 } 53 61 54 vboxVDbg DoPrint("hWnd (0x%p), visibleRects: \n", hWnd);62 vboxVDbgPrint(("hWnd (0x%p), visibleRects: \n", hWnd)); 55 63 for (uint32_t i = iVisibleRects; i < cVidibleRects; ++i) 56 64 { … … 60 68 else if (Regions.pRegions->fFlags.bAddHiddenRects) 61 69 { 62 vboxVDbg DoPrint("hWnd (0x%p), hiddenRects: \n", hWnd);70 vboxVDbgPrint(("hWnd (0x%p), hiddenRects: \n", hWnd)); 63 71 for (uint32_t i = 0; i < Regions.pRegions->RectsInfo.cRects; ++i) 64 72 { … … 67 75 } 68 76 69 vboxVDbg DoPrint("\n<<<\n");77 vboxVDbgPrint(("\n<<<\n")); 70 78 } 71 79 } while (1); 80 81 hr = g_VBoxDispMpTstCallbacks.pfnDisableEvents(); 82 Assert(hr == S_OK); 83 72 84 return VINF_SUCCESS; 73 85 } … … 75 87 HRESULT vboxDispMpTstStart() 76 88 { 77 HRESULT hr = vboxDispMpEnable(); 78 Assert(hr == S_OK); 79 if (hr == S_OK) 89 HRESULT hr = E_FAIL; 90 g_hVBoxDispMpModule = GetModuleHandleW(L"VBoxDispD3D.dll"); 91 Assert(g_hVBoxDispMpModule); 92 93 if (g_hVBoxDispMpModule) 80 94 { 81 int rc = RTThreadCreate(&g_VBoxDispMpTstThread, vboxDispMpTstThreadProc, NULL, 0, 82 RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "VBoxDispMpTst"); 83 AssertRC(rc); 84 if (RT_SUCCESS(rc)) 85 return S_OK; 95 g_pfnVBoxDispMpGetCallbacks = (PFNVBOXDISPMP_GETCALLBACKS)GetProcAddress(g_hVBoxDispMpModule, "VBoxDispMpGetCallbacks"); 96 Assert(g_pfnVBoxDispMpGetCallbacks); 97 if (g_pfnVBoxDispMpGetCallbacks) 98 { 99 hr = g_pfnVBoxDispMpGetCallbacks(VBOXDISPMP_VERSION, &g_VBoxDispMpTstCallbacks); 100 Assert(hr == S_OK); 101 if (hr == S_OK) 102 { 103 int rc = RTThreadCreate(&g_VBoxDispMpTstThread, vboxDispMpTstThreadProc, NULL, 0, 104 RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "VBoxDispMpTst"); 105 AssertRC(rc); 106 if (RT_SUCCESS(rc)) 107 return S_OK; 86 108 87 hr = vboxDispMpDisable(); 88 Assert(hr == S_OK); 89 hr = E_FAIL; 109 hr = E_FAIL; 110 } 111 } 112 FreeLibrary(g_hVBoxDispMpModule); 90 113 } 114 91 115 return hr; 92 116 } … … 94 118 HRESULT vboxDispMpTstStop() 95 119 { 96 HRESULT hr = vboxDispMpDisable();120 HRESULT hr = g_VBoxDispMpTstCallbacks.pfnDisableEvents(); 97 121 Assert(hr == S_OK); 122 #if 0 98 123 if (hr == S_OK) 99 124 { 100 125 int rc = RTThreadWaitNoResume(g_VBoxDispMpTstThread, RT_INDEFINITE_WAIT, NULL); 101 126 AssertRC(rc); 127 if (RT_SUCCESS(rc)) 128 { 129 BOOL bResult = FreeLibrary(g_hVBoxDispMpModule); 130 Assert(bResult); 131 #ifdef DEBUG 132 if (!bResult) 133 { 134 DWORD winEr = GetLastError(); 135 hr = HRESULT_FROM_WIN32(winEr); 136 } 137 #endif 138 } 139 else 140 hr = E_FAIL; 102 141 } 142 #endif 103 143 return hr; 104 144 }
Note:
See TracChangeset
for help on using the changeset viewer.