1
\$\begingroup\$

enter image description here

My Visual Studio 2019, 64-bit version of Tetris using OpenGL runs significantly faster, 3X, in Debug mode than in Release mode.

The image above shows the board. Each cycle of the rendering or game loop redraws everything, viz., the light blue background, the grid, the individual game pieces (one shown) with the latest one added moving every 300 ms, and the text score display. I have moved all the repetitive code out of the loop, e.g., that which sets the location in shaders for uniform constants.

The Release mode loop cycle time ranges from 0.05 to 1390.0 ms while that of the Debug mode ranges from 0.05 to 350.0 ms.

Any thoughts on what I might investigate?

Thanks.

\$\endgroup\$
3
  • 4
    \$\begingroup\$ What does your profiler tell you about where your code is spending the bulk of its time on the long loops? \$\endgroup\$ – DMGregory Feb 14 at 14:27
  • \$\begingroup\$ Always start with a profiler. Always always. \$\endgroup\$ – Almo Feb 14 at 22:49
  • \$\begingroup\$ I have little experience using the VS profiler. However, I have implemented the technique discussed in Intro to Profiling | Game Engine series wherein Cherno makes the point that profiling is very IDE dependent. I am still working with the Cherno method to see if I can find the issue. I am not opposed to using the VS profiler. Might you know of profiling tutorials, or other guiding information which you have found useful? \$\endgroup\$ – user34299 Feb 18 at 15:23
0
\$\begingroup\$

I ran timing analysis on 4 sections of the rendering (game) loop to see if I could find a recurring problem. The 4 sections were drawing the background and grid, the game piece(s), and the score. All of them were mostly low time, on the order of 0.001 to 0.01 milliseconds, except for an occasional 35 to 400 millisecond spike.

The Windows 10, x64 computer I used has 2 video graphic cards. They are Intel UHD Graphics 620 and NVIDIA 2GB GeForce MX130. The former is used for everything on the system by default while the latter has to be specifically assigned for any given executable.

I assigned the Tetris release executable to the NVIDIA card and the problem disappeared. The times for the 4 drawing sections were also far more consistent, i.e., had a lower standard deviation.

I suspect that the Windows system was demanding the periodic use of the Intel graphics system relegating my application to a lower status during that demand.

This does raise the interesting question of what happens when my Tetris is deployed to a system with a single graphics card. I do not know if the game can be made a priority so it does not do herky-jerky movements.

\$\endgroup\$
4
  • \$\begingroup\$ "what happens when my Tetris is deployed to a system with a single graphics card." If the system has no dedicated NVIDIA GPU, you may run into frame rate issue. If the GPU is a dedicated one, you'll likely have no issue. If the target system has a similar setup has you have, you'll probably need to tell the NVIDIA driver to handle your .exe with the NVIDIA GPU during the installation process. \$\endgroup\$ – Vaillancourt Feb 21 at 15:19
  • \$\begingroup\$ I agree with all. Do you agree with my suspicion that the problem on my system was the load that Windows 10 was putting on the Intel UHD Graphics 620 system? \$\endgroup\$ – user34299 Feb 26 at 13:37
  • \$\begingroup\$ "the problem" is probably that Windows does not know which processor to use when running a "random" app. I'm not clear about why it would run your debug build on the right processor, but on the release build, but Windows/NVIDIA not knowing to run an in-development graphics app on the dedicated GPU rather than on the CPU is a common issue. \$\endgroup\$ – Vaillancourt Feb 26 at 14:57
  • \$\begingroup\$ If a Tetris app is having framerate issues on Intel graphics then I'd suggest that you're doing something very wrong somewhere. Intel graphics may be slow, but they're not that slow - an Intel 620 can easily benchmark Quake at better than 500fps/2mspf, for example. \$\endgroup\$ – Maximus Minimus Mar 23 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.