Changeset 32962 in vbox for trunk/src/VBox/Additions/WINNT/Graphics
- Timestamp:
- Oct 6, 2010 11:12:33 PM (14 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
r32930 r32962 29 29 #ifdef VBOX_WDDMDISP_WITH_PROFILE 30 30 #include "VBoxDispProfile.h" 31 32 /* uncomment to enable particular logging */ 33 #define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_ENABLE 34 //#define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_ENABLE 35 36 #ifdef VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_ENABLE 31 37 static VBoxDispProfileSet g_VBoxDispProfileDDI("D3D_DDI"); 32 //static BOOL g_VBoxDispPrifileDDIDumpAndReset = FALSE; 33 #define VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE() VBOXDISPPROFILE_FUNCTION_PROLOGUE(g_VBoxDispProfileDDI) 38 #define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_PROLOGUE() VBOXDISPPROFILE_FUNCTION_LOGGER_DEFINE(g_VBoxDispProfileDDI) 39 #define VBOXDDIROFILE_FUNCTION_LOGGER_DUMP() do {\ 40 g_VBoxDispProfileDDI.dump(_pDev); \ 41 } while (0) 42 #define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_RESET() do {\ 43 g_VBoxDispProfileDDI.resetEntries();\ 44 } while (0) 45 #define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DISABLE_CURRENT() do {\ 46 VBOXDISPPROFILE_FUNCTION_LOGGER_DISABLE_CURRENT();\ 47 } while (0) 48 49 50 #else 51 #define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_PROLOGUE() do {} while(0) 52 #define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DUMP() do {} while(0) 53 #define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_RESET() do {} while(0) 54 #define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DISABLE_CURRENT() do {} while (0) 55 #endif 56 57 #ifdef VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_ENABLE 58 static VBoxDispProfileFpsCounter g_VBoxDispFpsDDI(64); 59 #define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_PROLOGUE() VBOXDISPPROFILE_STATISTIC_LOGGER_DEFINE(&g_VBoxDispFpsDDI) 60 #define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_DISABLE_CURRENT() do {\ 61 VBOXDISPPROFILE_STATISTIC_LOGGER_DISABLE_CURRENT();\ 62 } while (0) 63 #define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_REPORT_FRAME(_pDev) do { \ 64 VBOXDISPPROFILE_STATISTIC_LOGGER_LOG_AND_DISABLE_CURRENT(); \ 65 g_VBoxDispFpsDDI.ReportFrame(); \ 66 if(!(g_VBoxDispFpsDDI.GetNumFrames() % 31)) \ 67 { \ 68 double fps = g_VBoxDispFpsDDI.GetFps(); \ 69 double cps = g_VBoxDispFpsDDI.GetCps(); \ 70 double tup = g_VBoxDispFpsDDI.GetTimeProcPercent(); \ 71 VBOXDISPPROFILE_DUMP((_pDev, "fps: %f, cps: %.1f, host %.1f%%\n", fps, cps, tup)); \ 72 } \ 73 } while (0) 74 #else 75 #define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_PROLOGUE() do {} while(0) 76 #define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_DISABLE_CURRENT() do {} while (0) 77 #define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_REPORT_FRAME(_pDev) do {} while (0) 78 #endif 79 80 #define VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE() \ 81 VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_PROLOGUE(); \ 82 VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_PROLOGUE(); 34 83 35 84 #define VBOXDISPPROFILE_DDI_DUMPRESET(_pDev) do {\ 36 AssertRelease(0); \ 37 g_VBoxDispProfileDDI.dump(_pDev);\ 38 g_VBoxDispProfileDDI.resetEntries();\ 39 VBOXDISPPROFILE_FUNCTION_LOGGER_DISABLE_CURRENT();\ 85 VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DUMP(); \ 86 VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_RESET(); \ 87 VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DISABLE_CURRENT();\ 88 } while (0) 89 90 #define VBOXDISPPROFILE_DDI_REPORT_FRAME(_pDev) do {\ 91 VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_REPORT_FRAME(_pDev); \ 40 92 } while (0) 41 93 … … 44 96 #define VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE() do {} while (0) 45 97 #define VBOXDISPPROFILE_DDI_DUMPRESET(_pDev) do {} while (0) 98 #define VBOXDISPPROFILE_DDI_REPORT_FRAME(_pDev) do {} while (0) 46 99 #endif 47 100 … … 5495 5548 Assert(hr == S_OK); 5496 5549 } 5550 5551 VBOXDISPPROFILE_DDI_REPORT_FRAME(pDevice); 5552 5497 5553 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); 5498 5554 return hr; -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispProfile.h
r32739 r32962 114 114 }; 115 115 116 class VBoxDispProfileScopeLogger117 { 118 public: 119 VBoxDispProfileScopeLogger( VBoxDispProfileEntry*pEntry) :116 template<typename T> class VBoxDispProfileScopeLogger 117 { 118 public: 119 VBoxDispProfileScopeLogger(T *pEntry) : 120 120 m_pEntry(pEntry), 121 121 m_bDisable(FALSE) … … 128 128 if (!m_bDisable) 129 129 { 130 uint64_t cNewTime = VBOXDISPPROFILE_GET_TIME_NANO(); 131 m_pEntry->step(cNewTime - m_cTime); 130 logStep(); 132 131 } 133 132 } … … 137 136 m_bDisable = TRUE; 138 137 } 139 private: 140 VBoxDispProfileEntry *m_pEntry; 138 139 void logAndDisable() 140 { 141 logStep(); 142 disable(); 143 } 144 145 private: 146 void logStep() 147 { 148 uint64_t cNewTime = VBOXDISPPROFILE_GET_TIME_NANO(); 149 m_pEntry->step(cNewTime - m_cTime); 150 } 151 T *m_pEntry; 141 152 uint64_t m_cTime; 142 153 BOOL m_bDisable; 143 154 }; 144 155 156 157 class VBoxDispProfileFpsCounter 158 { 159 public: 160 VBoxDispProfileFpsCounter(uint32_t cPeriods) 161 { 162 memset(&m_Data, 0, sizeof (m_Data)); 163 m_Data.mcPeriods = cPeriods; 164 m_Data.mpaPeriods = (uint64_t *)RTMemAllocZ(sizeof (m_Data.mpaPeriods[0]) * cPeriods); 165 m_Data.mpaCalls = (uint32_t *)RTMemAllocZ(sizeof (m_Data.mpaCalls[0]) * cPeriods); 166 m_Data.mpaTimes = (uint64_t *)RTMemAllocZ(sizeof (m_Data.mpaTimes[0]) * cPeriods); 167 } 168 169 ~VBoxDispProfileFpsCounter() 170 { 171 RTMemFree(m_Data.mpaPeriods); 172 RTMemFree(m_Data.mpaCalls); 173 RTMemFree(m_Data.mpaTimes); 174 } 175 176 void ReportFrame() 177 { 178 uint64_t cur = VBOXDISPPROFILE_GET_TIME_NANO(); 179 180 if(m_Data.mPrevTime) 181 { 182 uint64_t curPeriod = cur - m_Data.mPrevTime; 183 184 m_Data.mPeriodSum += curPeriod - m_Data.mpaPeriods[m_Data.miPeriod]; 185 m_Data.mpaPeriods[m_Data.miPeriod] = curPeriod; 186 187 m_Data.mCallsSum += m_Data.mCurCalls - m_Data.mpaCalls[m_Data.miPeriod]; 188 m_Data.mpaCalls[m_Data.miPeriod] = m_Data.mCurCalls; 189 190 m_Data.mTimeUsedSum += m_Data.mCurTimeUsed - m_Data.mpaTimes[m_Data.miPeriod]; 191 m_Data.mpaTimes[m_Data.miPeriod] = m_Data.mCurTimeUsed; 192 193 ++m_Data.miPeriod; 194 m_Data.miPeriod %= m_Data.mcPeriods; 195 } 196 m_Data.mPrevTime = cur; 197 ++m_Data.mcFrames; 198 199 m_Data.mCurTimeUsed = 0; 200 m_Data.mCurCalls = 0; 201 } 202 203 void step(uint64_t Time) 204 { 205 m_Data.mCurTimeUsed += Time; 206 ++m_Data.mCurCalls; 207 } 208 209 uint64_t GetEveragePeriod() 210 { 211 return m_Data.mPeriodSum / m_Data.mcPeriods; 212 } 213 214 double GetFps() 215 { 216 return ((double)1000000000.0) / GetEveragePeriod(); 217 } 218 219 double GetCps() 220 { 221 return GetFps() * m_Data.mCallsSum / m_Data.mcPeriods; 222 } 223 224 double GetTimeProcPercent() 225 { 226 return 100.0*m_Data.mTimeUsedSum/m_Data.mPeriodSum; 227 } 228 229 uint64_t GetNumFrames() 230 { 231 return m_Data.mcFrames; 232 } 233 private: 234 struct 235 { 236 uint64_t mPeriodSum; 237 uint64_t *mpaPeriods; 238 uint64_t mPrevTime; 239 uint64_t mcFrames; 240 uint32_t mcPeriods; 241 uint32_t miPeriod; 242 243 uint64_t mCallsSum; 244 uint32_t *mpaCalls; 245 246 uint64_t mTimeUsedSum; 247 uint64_t *mpaTimes; 248 249 uint64_t mCurTimeUsed; 250 uint64_t mCurCalls; 251 } m_Data; 252 }; 253 145 254 #define VBOXDISPPROFILE_FUNCTION_LOGGER_DISABLE_CURRENT() do { \ 146 __vboxDispProfileLogger.disable();\ 255 __vboxDispProfileFunctionLogger.disable();\ 256 } while (0) 257 258 #define VBOXDISPPROFILE_FUNCTION_LOGGER_LOG_AND_DISABLE_CURRENT() do { \ 259 __vboxDispProfileFunctionLogger.logAndDisable();\ 147 260 } while (0) 148 261 … … 150 263 static VBoxDispProfileEntry * __pVBoxDispProfileEntry = NULL; \ 151 264 if (!__pVBoxDispProfileEntry) { __pVBoxDispProfileEntry = _p.alloc(__FUNCTION__); } \ 152 VBoxDispProfileScopeLogger __vboxDispProfileLogger(__pVBoxDispProfileEntry); 153 154 155 #define VBOXDISPPROFILE_FUNCTION_PROLOGUE(_p) \ 156 VBOXDISPPROFILE_FUNCTION_LOGGER_DEFINE(_p) 157 265 VBoxDispProfileScopeLogger<VBoxDispProfileEntry> __vboxDispProfileFunctionLogger(__pVBoxDispProfileEntry); 266 267 #define VBOXDISPPROFILE_STATISTIC_LOGGER_DISABLE_CURRENT() do { \ 268 __vboxDispProfileStatisticLogger.disable();\ 269 } while (0) 270 271 #define VBOXDISPPROFILE_STATISTIC_LOGGER_LOG_AND_DISABLE_CURRENT() do { \ 272 __vboxDispProfileStatisticLogger.logAndDisable();\ 273 } while (0) 274 275 276 #define VBOXDISPPROFILE_STATISTIC_LOGGER_DEFINE(_p) \ 277 VBoxDispProfileScopeLogger<VBoxDispProfileFpsCounter> __vboxDispProfileStatisticLogger(_p); 278 279 //#define VBOXDISPPROFILE_FUNCTION_PROLOGUE(_p) \ 280 // VBOXDISPPROFILE_FUNCTION_LOGGER_DEFINE(_p) 158 281 159 282 #endif /* #ifndef ___VBoxDispProfile_h__ */ -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/context.c
r32699 r32962 1980 1980 #endif 1981 1981 1982 #ifdef VBOX_WITH_WDDM 1983 while (device->numContexts) 1984 { 1985 context_destroy(device, device->contexts[0]); 1986 } 1987 #endif 1988 1982 1989 /* Create a new context for the thread */ 1983 1990 return swapchain_create_context_for_thread(swapchain);
Note:
See TracChangeset
for help on using the changeset viewer.