VirtualBox

Ignore:
Timestamp:
Sep 5, 2014 7:14:21 PM (10 years ago)
Author:
vboxsync
Message:

Mac OS X host: 3D: offline rendering check: fix atomic variables mess.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/OpenGLTest/OpenGLTestDarwin.cpp

    r52622 r52623  
    5151       on startup. */
    5252
    53     static bool volatile fState = false;
    54     if (!ASMAtomicCmpXchgBool(&fState, true, false))
     53#define VBOX_OGL_CHECK_UNINITIALIZED    (0)
     54#define VBOX_OGL_CHECK_INITIALIZING     (1)
     55#define VBOX_OGL_CHECK_INITIALIZED      (2)
     56
     57    /* Transition VBOX_OGL_CHECK_UNINITIALIZED -> VBOX_OGL_CHECK_INITIALIZING means the current thread
     58       is the first one who entered the routine. In this case, it should detect number of GPUs, cache result
     59       and return it. If it's not TRUE, then fInitialized is VBOX_OGL_CHECK_INITIALIZING (another thread is performing
     60       the check; current thread should wait till result will be cached and return it) or VBOX_OGL_CHECK_INITIALIZED
     61       (result is already cached; just return it.) */
     62
     63    static uint8_t volatile fInitialized = VBOX_OGL_CHECK_UNINITIALIZED;
     64    if (!ASMAtomicCmpXchgU8(&fInitialized, VBOX_OGL_CHECK_INITIALIZING, VBOX_OGL_CHECK_UNINITIALIZED))
    5565    {
    56         while (ASMAtomicReadBool(&fState) != true)
     66        while (ASMAtomicReadU8(&fInitialized) != VBOX_OGL_CHECK_INITIALIZED)
    5767            RTThreadSleep(5);
    5868
     
    94104
    95105    LogRel(("OpenGL: Offline rendering support is %s (PID=%d)\n", fAppropriate ? "ON" : "OFF", (int)getpid()));
     106
     107    ASMAtomicWriteU8(&fInitialized, VBOX_OGL_CHECK_INITIALIZED);
    96108
    97109    return fAppropriate;
Note: See TracChangeset for help on using the changeset viewer.

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