VirtualBox

Ignore:
Timestamp:
Feb 2, 2018 9:54:30 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
120671
Message:

HostServices/SharedOpenGL: turn CR_RENDER_FORCE_PRESENT_MAIN_THREAD conditional compilation into a runtime check based on an env variable, for both glx (where it defaults to 1) and wgl (where it defaults to 0).

Location:
trunk/src/VBox/HostServices/SharedOpenGL/render
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h

    r69474 r70851  
    247247    int sync;
    248248#endif
     249    int force_present_main_thread;
    249250    int render_to_app_window;
    250251    int render_to_crut_window;
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m

    r69500 r70851  
    116116 * Disable this to see how the output is without the FBO in the middle of the processing chain. */
    117117#define FBO 1
    118 /** @def CR_RENDER_FORCE_PRESENT_MAIN_THREAD
    119  * Force present schedule to main thread. */
    120118/** @def SHOW_WINDOW_BACKGROUND
    121119 * Define this to see the window background even if the window is clipped. */
     
    123121 * Define this to get some debug info about the messages flow. */
    124122#if 0 || defined(DOXYGEN_RUNNING)
    125 # define CR_RENDER_FORCE_PRESENT_MAIN_THREAD
    126123# define SHOW_WINDOW_BACKGROUND 1
    127124# define DEBUG_VERBOSE
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_config.c

    r69390 r70851  
    373373    render_spu->sync = 0;
    374374#endif
    375 }
    376 
     375
     376    /* Config of "render force present main thread" (currently implemented by glx and wgl). */
     377    const char *forcePresent = crGetenv("CR_RENDER_FORCE_PRESENT_MAIN_THREAD");
     378    if (forcePresent)
     379        render_spu->force_present_main_thread = crStrToInt(forcePresent) ? 1 : 0;
     380    else
     381    {
     382#if defined(GLX)
     383        /* Customer needed this for avoiding system 3D driver bugs. */
     384        render_spu->force_present_main_thread = 1;
     385#else
     386        render_spu->force_present_main_thread = 0;
     387#endif
     388    }
     389}
     390
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_glx.c

    r69390 r70851  
    19251925}
    19261926
    1927 #define CR_RENDER_FORCE_PRESENT_MAIN_THREAD
    1928 
    19291927void renderspu_SystemVBoxPresentComposition( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
    19301928{
    1931     /* the CR_RENDER_FORCE_PRESENT_MAIN_THREAD is actually inherited from cocoa backend impl,
    1932      * here it forces rendering in WinCmd thread rather than a Main thread.
    1933      * it is used for debugging only in any way actually.
    1934      * @todo: change to some more generic macro name */
    1935 #ifndef CR_RENDER_FORCE_PRESENT_MAIN_THREAD
    1936     const struct VBOXVR_SCR_COMPOSITOR *pCompositor;
    1937     /* we do not want to be blocked with the GUI thread here, so only draw her eif we are really able to do that w/o bllocking */
    1938     int rc = renderspuVBoxCompositorTryAcquire(window, &pCompositor);
    1939     if (RT_SUCCESS(rc))
    1940     {
    1941         renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry, 0, false);
    1942         renderspuVBoxCompositorRelease(window);
    1943     }
    1944     else if (rc == VERR_SEM_BUSY)
    1945 #endif
     1929    /* The !render_spu.force_present_main_thread code flow is actually inspired
     1930     * by cocoa backend impl, here it forces rendering in WinCmd thread rather
     1931     * than a Main thread.  It defaults to 1, because otherwise there were
     1932     * 3D driver incompatibilities on some systems. Elsewhere it causes flicker
     1933     * on NVidia GPUs. In principle would need root cause investigation. */
     1934    if (!render_spu.force_present_main_thread)
     1935    {
     1936        const struct VBOXVR_SCR_COMPOSITOR *pCompositor;
     1937        /* we do not want to be blocked with the GUI thread here, so only draw here if we are really able to do that w/o blocking */
     1938        int rc = renderspuVBoxCompositorTryAcquire(window, &pCompositor);
     1939        if (RT_SUCCESS(rc))
     1940        {
     1941            renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry, 0, false);
     1942            renderspuVBoxCompositorRelease(window);
     1943        }
     1944        else if (rc != VERR_SEM_BUSY)
     1945        {
     1946            /* this is somewhat we do not expect */
     1947            WARN(("renderspuVBoxCompositorTryAcquire failed rc %d", rc));
     1948            return;
     1949        }
     1950    }
     1951
    19461952    {
    19471953        Status status;
     
    19621968        XFlush(render_spu.pCommunicationDisplay);
    19631969    }
    1964 #ifndef CR_RENDER_FORCE_PRESENT_MAIN_THREAD
    1965     else
    1966     {
    1967         /* this is somewhat we do not expect */
    1968         WARN(("renderspuVBoxCompositorTryAcquire failed rc %d", rc));
    1969     }
    1970 #endif
    19711970}
    19721971
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c

    r70789 r70851  
    12871287void renderspu_SystemVBoxPresentComposition( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
    12881288{
    1289     /* the CR_RENDER_FORCE_PRESENT_MAIN_THREAD is actually inherited from cocoa backend impl,
    1290      * here it forces rendering in WinCmd thread rather than a Main thread.
    1291      * it is used for debugging only in any way actually.
    1292      * @todo: change to some more generic macro name */
    1293 #ifndef CR_RENDER_FORCE_PRESENT_MAIN_THREAD
    1294     const struct VBOXVR_SCR_COMPOSITOR *pCompositor;
    1295     /* we do not want to be blocked with the GUI thread here, so only draw her eif we are really able to do that w/o bllocking */
    1296     int rc = renderspuVBoxCompositorTryAcquire(window, &pCompositor);
    1297     if (RT_SUCCESS(rc))
    1298     {
    1299         renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry, 0, false);
    1300         renderspuVBoxCompositorRelease(window);
    1301     }
    1302     else if (rc == VERR_SEM_BUSY)
    1303 #endif
     1289    /* The !render_spu.force_present_main_thread code flow is actually inspired
     1290     * by cocoa backend impl, here it forces rendering in WndProc, i.e. main
     1291     * thread. It defaults to 0, because it is for debugging and working around
     1292     * bugs. In principle would need root cause investigation. */
     1293    if (!render_spu.force_present_main_thread)
     1294    {
     1295        const struct VBOXVR_SCR_COMPOSITOR *pCompositor;
     1296        /* we do not want to be blocked with the GUI thread here, so only draw here if we are really able to do that w/o blocking */
     1297        int rc = renderspuVBoxCompositorTryAcquire(window, &pCompositor);
     1298        if (RT_SUCCESS(rc))
     1299        {
     1300            renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry, 0, false);
     1301            renderspuVBoxCompositorRelease(window);
     1302        }
     1303        else if (rc != VERR_SEM_BUSY)
     1304        {
     1305            /* this is somewhat we do not expect */
     1306            crWarning("renderspuVBoxCompositorTryAcquire failed rc %d", rc);
     1307        }
     1308    }
     1309
    13041310    {
    13051311        render_spu.self.Flush();
     
    13071313        RedrawWindow(window->hWnd, NULL, NULL, RDW_INTERNALPAINT);
    13081314    }
    1309 #ifndef CR_RENDER_FORCE_PRESENT_MAIN_THREAD
    1310     else
    1311     {
    1312         /* this is somewhat we do not expect */
    1313         crWarning("renderspuVBoxCompositorTryAcquire failed rc %d", rc);
    1314     }
    1315 #endif
    13161315}
    13171316
Note: See TracChangeset for help on using the changeset viewer.

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