Changeset 84664 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Video
- Timestamp:
- Jun 3, 2020 1:30:21 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/gallium/test/d3d9main.cpp
r84321 r84664 18 18 #include "d3d9render.h" 19 19 20 #include <stdio.h> 21 20 22 #define D3D9TEST_MAX_DEVICES 2 21 23 … … 39 41 40 42 int miRenderId; 41 int miRenderStep; 43 enum 44 { 45 RenderModeStep = 0, 46 RenderModeContinuous = 1, 47 RenderModeFPS = 2 48 } miRenderMode; 42 49 HWND mHwnd; 43 50 IDirect3D9Ex *mpD3D9; … … 56 63 mpRender(0), 57 64 miRenderId(3), 58 miRender Step(1)65 miRenderMode(RenderModeStep) 59 66 { 60 67 memset(&mpaDevices, 0, sizeof(mpaDevices)); … … 243 250 return; 244 251 245 /* Second number is the step mode. */ 246 miRenderStep = atoi(p); 252 /* Second number is the render/step mode. */ 253 int i = atoi(p); 254 switch (i) 255 { 256 default: 257 case 0: miRenderMode = RenderModeStep; break; 258 case 1: miRenderMode = RenderModeContinuous; break; 259 case 2: miRenderMode = RenderModeFPS; break; 260 } 247 261 } 248 262 … … 283 297 bool fFirst = true; 284 298 MSG msg; 299 300 LARGE_INTEGER PerfFreq; 301 QueryPerformanceFrequency(&PerfFreq); 302 float const PerfPeriod = 1.0f / PerfFreq.QuadPart; /* Period in seconds. */ 303 304 LARGE_INTEGER PrevTS; 305 QueryPerformanceCounter(&PrevTS); 306 307 int cFrames = 0; 308 float elapsed = 0; 309 285 310 do 286 311 { 287 312 BOOL fGotMessage; 288 if (miRender Step)313 if (miRenderMode == RenderModeStep) 289 314 { 290 315 fGotMessage = GetMessageA(&msg, 0, 0, 0); … … 301 326 } 302 327 303 float dt = 0.0f; /* Time in seconds since last render step. @todo Measure. */304 305 328 BOOL fDoRender = FALSE; 306 if (miRender Step)329 if (miRenderMode == RenderModeStep) 307 330 { 308 331 if (msg.message == WM_CHAR) … … 321 344 if (fDoRender) 322 345 { 323 dt = fFirst ? 0.0f : 0.1f; /* 0.1 second increment per step. */ 346 LARGE_INTEGER CurrTS; 347 QueryPerformanceCounter(&CurrTS); 348 349 /* Time in seconds since the previous render step. */ 350 float dt = fFirst ? 0.0f : (CurrTS.QuadPart - PrevTS.QuadPart) * PerfPeriod; 324 351 if (mpRender) 325 352 { … … 328 355 fFirst = false; 329 356 } 357 358 if (miRenderMode == RenderModeFPS) 359 { 360 ++cFrames; 361 elapsed += dt; 362 if (elapsed > 1.0f) 363 { 364 float msPerFrame = elapsed * 1000.0f / cFrames; 365 char sz[256]; 366 _snprintf(sz, sizeof(sz), "D3D9 Test FPS %d Frame Time %fms", cFrames, msPerFrame); 367 SetWindowTextA(mHwnd, sz); 368 369 cFrames = 0; 370 elapsed = 0.0f; 371 } 372 } 373 374 PrevTS = CurrTS; 330 375 } 331 376 } while (msg.message != WM_QUIT);
Note:
See TracChangeset
for help on using the changeset viewer.