Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#50 transport plugin can't successfully set fconfig.readback

General issue
closed-fixed
DRC
VirtualGL (43)
5
2014-04-28
2012-07-31
A. Steinmetz
No

Due to the following sequence in rr/pbwin.cpp a transport plugin can't successfully modify fconfig.readback:

void pbwin::sendplugin(GLint drawbuf, bool spoillast, bool sync,
bool dostereo, int stereomode)
{
rrframe f; bool usepbo=(fconfig.readback==RRREAD_PBO);
<snip>
if(!_plugin)
{
_plugin=new rrplugin(_dpy, _drawable, fconfig.transport);
_plugin->connect(strlen(fconfig.client)>0?
fconfig.client:DisplayString(_dpy), fconfig.port);
}

The above sequence must be modified the following way:

void pbwin::sendplugin(GLint drawbuf, bool spoillast, bool sync,
bool dostereo, int stereomode)
{
rrframe f; bool usepbo;
<snip>
if(!_plugin)
{
_plugin=new rrplugin(_dpy, _drawable, fconfig.transport);
_plugin->connect(strlen(fconfig.client)>0?
fconfig.client:DisplayString(_dpy), fconfig.port);
}
usepbo=(fconfig.readback==RRREAD_PBO);

If an application itself uses PBOs and VGL_READBACK=pbo is set, VirtualGL dies. A transport plugin that tries to remedy this by modifying fconfig.readback apart form doing transport stuff will fail, too, as at least once PBO mode is tried due to the above code sequence and this will fail. The usepbo flag must be set after mapping and initializing the plugin to solve this problem.

For demo code exposing the PBO problem see http://www.songho.ca/opengl/files/pboPack.zip

Discussion

  • DRC
    DRC
    2012-07-31

    I'll take a look. I definitely want to fix the issue with PBO-enabled apps dying as well as this issue.

     
  • DRC
    DRC
    2012-08-02

    • status: open --> closed-fixed
     
  • DRC
    DRC
    2012-08-02

    OK, so the first issue (pboPack dying when VGL_READBACK=pbo) is due to an error in pboPack. In getInfo(), it is modifying the GL_EXTENSIONS string during the call to this->extensions.push_back(tok). After that call, the extensions string is tokenized, so when VirtualGL subsequently tries to read it, it only sees the first value and thus believes that the PBO extension isn't available.

    Easiest way around is to just use strdup() to make a copy of the extensions string:

    // get all extensions as a string
    str = (const char *)strdup((const char *)glGetString(GL_EXTENSIONS));

    // split extensions
    if(str)
    {
    tok = strtok((char*)str, " ");
    while(tok)
    {
    this->extensions.push_back(tok); // put a extension into struct
    tok = strtok(0, " "); // next token
    }
    free((void *)str);
    }

    Then VirtualGL is happy again. I also checked your patch into SVN trunk, so plugins should now be able to override VGL_READBACK.

    Let me know if you encounter any further issues.