繁体   English   中英

在Ubuntu 12.4上缓慢的OpenGL上下文访问

[英]Slow OpenGL context access on Ubuntu 12.4

我有一个访问OpenGL上下文的应用程序,我在2个OS上运行它:

1.库本图13.4

2,Ubuntu 12.4

我遇到了以下问题:在OS 1上大约需要60毫秒来设置上下文,而在OS 2上则需要10倍以上的时间。两个OS都使用驱动程序版本为319的Nvidia GPU。 OS 2的常规设置。上下文不在屏幕上。当前我不知道是什么原因造成的。我的问题是这种开销的可能来源是什么?X11设置?或者可能是操作系统级别的东西?

另一个区别是OS 1使用Nvidia GTX680,而OS2使用Nvidia GRID K1卡.OS2也驻留在服务器上,并且延迟测试在该计算机上本地运行。

更新:

这是导致大部分开销的部分:

typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
typedef Bool (*glXMakeContextCurrentARBProc)(Display*, GLXDrawable, GLXDrawable, GLXContext);
static glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0;
static glXMakeContextCurrentARBProc glXMakeContextCurrentARB = 0;

int main(int argc, const char* argv[]){
    static int visual_attribs[] = {
            None
    };
    int context_attribs[] = {
            GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
            GLX_CONTEXT_MINOR_VERSION_ARB, 0,
            None
    };

    Display* dpy = XOpenDisplay(0);
    int fbcount = 0;
    GLXFBConfig* fbc = NULL;
    GLXContext ctx;
    GLXPbuffer pbuf;

    /* open display */
    if ( ! (dpy = XOpenDisplay(0)) ){
            fprintf(stderr, "Failed to open display\n");
            exit(1);
    }

    /* get framebuffer configs, any is usable (might want to add proper attribs) */
    if ( !(fbc = glXChooseFBConfig(dpy, DefaultScreen(dpy), visual_attribs, &fbcount) ) ){
            fprintf(stderr, "Failed to get FBConfig\n");
            exit(1);
    }

    /* get the required extensions */
    glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB");
    glXMakeContextCurrentARB = (glXMakeContextCurrentARBProc)glXGetProcAddressARB( (const GLubyte *) "glXMakeContextCurrent");
    if ( !(glXCreateContextAttribsARB && glXMakeContextCurrentARB) ){
            fprintf(stderr, "missing support for GLX_ARB_create_context\n");
            XFree(fbc);
            exit(1);
    }

    /* create a context using glXCreateContextAttribsARB */
    if ( !( ctx = glXCreateContextAttribsARB(dpy, fbc[0], 0, True, context_attribs)) ){
            fprintf(stderr, "Failed to create opengl context\n");
            XFree(fbc);
            exit(1);
    }

    /* create temporary pbuffer */
    int pbuffer_attribs[] = {
            GLX_PBUFFER_WIDTH, 800,
            GLX_PBUFFER_HEIGHT, 600,
            None
    };
    pbuf = glXCreatePbuffer(dpy, fbc[0], pbuffer_attribs);

    XFree(fbc);
    XSync(dpy, False);

    /* try to make it the current context */
    if ( !glXMakeContextCurrent(dpy, pbuf, pbuf, ctx) ){
            /* some drivers does not support context without default framebuffer, so fallback on
             * using the default window.
             */
            if ( !glXMakeContextCurrent(dpy, DefaultRootWindow(dpy), DefaultRootWindow(dpy), ctx) ){
                    fprintf(stderr, "failed to make current\n");
                    exit(1);
            }
    }

    /* try it out */
    printf("vendor: %s\n", (const char*)glGetString(GL_VENDOR));

    return 0;
}

具体来说,该行:

pbuf = glXCreatePbuffer(dpy, fbc[0], pbuffer_attribs);

创建伪pbuffer的位置最慢。如果其余函数调用平均花费2-4 ms,则此调用在OS 1上花费40 ms。现在,在OS2上(这很慢),pbuffer创建需要700ms! 我希望现在我的问题看起来更加清楚。

绝对确定“ OS2”已正确设置驱动程序并且不会退回到SW OpenGL(Mesa)渲染上吗? glxgears在每个系统上报告什么帧速率?

我注意到Ubuntu 12.4是在2012年4月发布的,而我相信NVidia的“ GRID”技术直到2012年5月GTC才宣布,我认为显卡要到2013年才会出现(请参阅相关的Nvidia新闻稿 )。 因此,Ubuntu 12.4随附的Nvidia驱动程序似乎不太可能支持网格卡(除非您已努力使用Nvidia的最新驱动程序版本进行升级?)。

您可以在/usr/share/doc/nvidia-glx/README.txt.gz的附录A“支持的NVIDIA GPU产品”中查看受支持的硬件列表(至少在我的Debian上存在着这些有用的信息)机)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM