protonscr

SetOverlayTexture is slow for new OpenGL textures

steamvropen
ValveSoftware/SteamVR-for-Linux#158 · opened 2018-11-26 by ChristophHaag · updated 2018-11-26 · 0 comments · github
CChristophHaag 2018-11-26 github

Submitted here instead at OpenVR because my guess is that this is a problem of the Linux specific OpenGL-Vulkan interop and that it's better with Vulkan textures and maybe on Windows though I have not tested it.

Here is a small example: https://gist.github.com/ChristophHaag/b144c5837ff6b90f38f391d761d68f38

First, this code creates a 32x32 RGBA OpenGL texture once and submits it 10 times with SetOverlayTexture(). This is slow the first time, subsequent calls to SetOverlayTexture are done in acceptable time.

Then, it creates the same 32x32RGBA OpenGL texture, but every loop it is a new OpenGL texture with a new handle that is submitted. This is slow every time.

The numbers for me:

Submit time: 74.2784ms
Submit time: 0.278253ms
Submit time: 0.267352ms
Submit time: 0.298611ms
Submit time: 0.285185ms
Submit time: 0.340229ms
Submit time: 0.259958ms
Submit time: 0.321785ms
Submit time: 0.26133ms
Submit time: 0.270648ms
Avg texture submit time when reusing GL textures : 7.68618
Submit time: 53.852ms
Submit time: 41.9922ms
Submit time: 30.0756ms
Submit time: 30.6021ms
Submit time: 32.7388ms
Submit time: 53.1882ms
Submit time: 36.8669ms
Submit time: 32.2948ms
Submit time: 58.8223ms
Submit time: 32.9572ms
Avg texture submit time when creating new GL textures every time : 40.339

Submitting a new 32x32 OpenGL texture on average takes longer than three 11ms frames on the Vive. If you leave it running for longer (see below), submitting a single texture can take more than 200ms.

But wait, there's more.
If you change the loops variable to something big and skip the texture reusing code by changing the lines like this,

    int loops = 10000;
    for (int createNewTextures = 1; createNewTextures <= 1; createNewTextures++) {

then it runs long enough to look into the HMD and see vrcompositor itself stuttering!

This stutter can also be seen in the frametime graph:
screenshot_20181126_145402

Nothing extracted yet.