VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispMpTst.cpp@ 32889

Last change on this file since 32889 was 32889, checked in by vboxsync, 14 years ago

wddm/3d: chromium over hgsmi transport fixing & perf measurement

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 KB
Line 
1/** @file
2 *
3 * VBoxVideo Display D3D User mode dll
4 *
5 * Copyright (C) 2010 Oracle Corporation
6 *
7 * This file is part of VirtualBox Open Source Edition (OSE), as
8 * available from http://www.virtualbox.org. This file is free software;
9 * you can redistribute it and/or modify it under the terms of the GNU
10 * General Public License (GPL) as published by the Free Software
11 * Foundation, in version 2 as it comes in the "COPYING" file of the
12 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14 */
15#include "VBoxDispMp.h"
16
17#include <iprt/thread.h>
18#include <iprt/err.h>
19
20#include "VBoxDispD3DCmn.h"
21
22#include "VBoxDispProfile.h"
23
24static RTTHREAD g_VBoxDispMpTstThread;
25static VBOXDISPMP_CALLBACKS g_VBoxDispMpTstCallbacks;
26static HMODULE g_hVBoxDispMpModule;
27static PFNVBOXDISPMP_GETCALLBACKS g_pfnVBoxDispMpGetCallbacks;
28
29
30static void vboxDispMpTstLogRect(const char * pPrefix, RECT *pRect, const char * pSuffix)
31{
32 vboxVDbgPrint(("%s left(%d), top(%d), right(%d), bottom(%d) %s", pPrefix, pRect->left, pRect->top, pRect->right, pRect->bottom, pSuffix));
33}
34
35static DECLCALLBACK(int) vboxDispMpTstThreadProc(RTTHREAD ThreadSelf, void *pvUser)
36{
37 VBOXDISPMP_REGIONS Regions;
38
39 HRESULT hr = g_VBoxDispMpTstCallbacks.pfnEnableEvents();
40 Assert(hr == S_OK);
41 if (hr != S_OK)
42 return VERR_GENERAL_FAILURE;
43
44 do
45 {
46 hr = g_VBoxDispMpTstCallbacks.pfnGetRegions(&Regions, INFINITE);
47 Assert(hr == S_OK);
48 if (hr == S_OK)
49 {
50 vboxVDbgPrint(("\n>>>\n"));
51 HWND hWnd = Regions.hWnd;
52 if (Regions.pRegions->fFlags.bSetVisibleRects)
53 {
54 uint32_t iVisibleRects = 0;
55 uint32_t cVisibleRects = Regions.pRegions->RectsInfo.cRects;
56 if (Regions.pRegions->fFlags.bSetViewRect)
57 {
58 iVisibleRects = 1;
59
60 vboxVDbgPrint(("hWnd (0x%p), position and/or size changed: ", hWnd));
61 vboxDispMpTstLogRect("", Regions.pRegions->RectsInfo.aRects, "\n");
62 }
63
64 vboxVDbgPrint(("hWnd (0x%p), visibleRects: \n", hWnd));
65 for (uint32_t i = iVisibleRects; i < cVisibleRects; ++i)
66 {
67 vboxDispMpTstLogRect("", &Regions.pRegions->RectsInfo.aRects[i], "");
68 }
69 }
70 else if (Regions.pRegions->fFlags.bAddHiddenRects)
71 {
72 vboxVDbgPrint(("hWnd (0x%p), hiddenRects: \n", hWnd));
73 for (uint32_t i = 0; i < Regions.pRegions->RectsInfo.cRects; ++i)
74 {
75 vboxDispMpTstLogRect("", &Regions.pRegions->RectsInfo.aRects[i], "");
76 }
77 }
78
79 vboxVDbgPrint(("\n<<<\n"));
80 }
81 } while (1);
82
83 hr = g_VBoxDispMpTstCallbacks.pfnDisableEvents();
84 Assert(hr == S_OK);
85
86 return VINF_SUCCESS;
87}
88
89HRESULT vboxDispMpTstStart()
90{
91 HRESULT hr = E_FAIL;
92 g_hVBoxDispMpModule = GetModuleHandleW(L"VBoxDispD3D.dll");
93 Assert(g_hVBoxDispMpModule);
94
95 if (g_hVBoxDispMpModule)
96 {
97 g_pfnVBoxDispMpGetCallbacks = (PFNVBOXDISPMP_GETCALLBACKS)GetProcAddress(g_hVBoxDispMpModule, "VBoxDispMpGetCallbacks");
98 Assert(g_pfnVBoxDispMpGetCallbacks);
99 if (g_pfnVBoxDispMpGetCallbacks)
100 {
101 hr = g_pfnVBoxDispMpGetCallbacks(VBOXDISPMP_VERSION, &g_VBoxDispMpTstCallbacks);
102 Assert(hr == S_OK);
103 if (hr == S_OK)
104 {
105 int rc = RTThreadCreate(&g_VBoxDispMpTstThread, vboxDispMpTstThreadProc, NULL, 0,
106 RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "VBoxDispMpTst");
107 AssertRC(rc);
108 if (RT_SUCCESS(rc))
109 return S_OK;
110
111 hr = E_FAIL;
112 }
113 }
114 FreeLibrary(g_hVBoxDispMpModule);
115 }
116
117 return hr;
118}
119
120HRESULT vboxDispMpTstStop()
121{
122 HRESULT hr = g_VBoxDispMpTstCallbacks.pfnDisableEvents();
123 Assert(hr == S_OK);
124#if 0
125 if (hr == S_OK)
126 {
127 int rc = RTThreadWaitNoResume(g_VBoxDispMpTstThread, RT_INDEFINITE_WAIT, NULL);
128 AssertRC(rc);
129 if (RT_SUCCESS(rc))
130 {
131 BOOL bResult = FreeLibrary(g_hVBoxDispMpModule);
132 Assert(bResult);
133#ifdef DEBUG
134 if (!bResult)
135 {
136 DWORD winEr = GetLastError();
137 hr = HRESULT_FROM_WIN32(winEr);
138 }
139#endif
140 }
141 else
142 hr = E_FAIL;
143 }
144#endif
145 return hr;
146}
147
148int vboxUhgsmiTst(PVBOXUHGSMI pUhgsmi, uint32_t cbBuf, uint32_t cNumCals, uint64_t * pTimeMs)
149{
150 PVBOXUHGSMI_BUFFER pBuf;
151 int rc = pUhgsmi->pfnBufferCreate(pUhgsmi, cbBuf, VBOXUHGSMI_SYNCHOBJECT_TYPE_EVENT, NULL, &pBuf);
152 AssertRC(rc);
153 if (RT_SUCCESS(rc))
154 {
155 uint64_t TimeMs = VBOXDISPPROFILE_GET_TIME_MILLI();
156 do
157 {
158 VBOXUHGSMI_BUFFER_LOCK_FLAGS fFlags;
159 fFlags.Value = 0;
160 fFlags.bLockEntire = 1;
161 fFlags.bDiscard = 1;
162
163 void *pvLock;
164 rc = pBuf->pfnLock(pBuf, 0, cbBuf, fFlags, &pvLock);
165 AssertRC(rc);
166 if (!RT_SUCCESS(rc))
167 break;
168
169 rc = pBuf->pfnUnlock(pBuf);
170 AssertRC(rc);
171 if (!RT_SUCCESS(rc))
172 break;
173
174 VBOXUHGSMI_BUFFER_SUBMIT SubmitData;
175 SubmitData.pBuf = pBuf;
176 SubmitData.fFlags.Value = 0;
177 SubmitData.fFlags.bDoNotRetire = 1;
178 SubmitData.fFlags.bEntireBuffer = 1;
179
180 rc = pUhgsmi->pfnBufferSubmitAsynch(pUhgsmi, &SubmitData, 1);
181 AssertRC(rc);
182 if (!RT_SUCCESS(rc))
183 break;
184
185 DWORD dw = WaitForSingleObject(pBuf->hSynch, INFINITE);
186 Assert(dw == WAIT_OBJECT_0);
187 if (dw)
188 break;
189 } while (--cNumCals);
190
191 TimeMs = VBOXDISPPROFILE_GET_TIME_MILLI() - TimeMs;
192 *pTimeMs = TimeMs;
193
194 pBuf->pfnDestroy(pBuf);
195 }
196 return rc;
197}
Note: See TracBrowser for help on using the repository browser.

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