[Mesa-dev] Performance glxSwapBuffers 32 bit vs. 64 bit

Theiss, Ingo ingo.theiss at i-matrixx.de
Fri Nov 11 12:25:19 PST 2011


 
Am Freitag, 11. November 2011 14:53 CET, Brian Paul <brian.e.paul at gmail.com> schrieb: 
 
> 2011/11/11 Michel Dänzer <michel at daenzer.net>:
> 
> > Anyway, I guess there's room for optimization in glReadPixels...
> 
> Ingo, if you could find out what the format/type parameters to
> glReadPixels are, we could look into some optimization in the state
> tracker.  I wouldn't be surprised if there's some channel swizzling or
> format conversion going on.
> 
> -Brina
> 
 
Hi Brian,

I have digged around in the VirtualGL source code and hope I have found what you requested. Don´t blame me if I am wrong as I have very limited knowledge in C programming :-(

Here is the (overwritten?) glReadPixels function from VirtualGL:

void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
        GLenum format, GLenum type, GLvoid *pixels)
{
        TRY();
        if(format==GL_COLOR_INDEX && !ctxh.overlaycurrent() && type!=GL_BITMAP)
        {
                format=GL_RED;
                if(type==GL_BYTE || type==GL_UNSIGNED_BYTE) type=GL_UNSIGNED_BYTE;
                else
                {
                        int rowlen=-1, align=-1;  GLubyte *buf=NULL;
                        _glGetIntegerv(GL_PACK_ALIGNMENT, &align);
                        _glGetIntegerv(GL_PACK_ROW_LENGTH, &rowlen);
                        newcheck(buf=new unsigned char[width*height])
                        if(type==GL_SHORT) type=GL_UNSIGNED_SHORT;
                        if(type==GL_INT) type=GL_UNSIGNED_INT;
                        glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
                        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
                        glPixelStorei(GL_UNPACK_ROW_LENGTH, 1);
                        _glReadPixels(x, y, width, height, format, GL_UNSIGNED_BYTE, buf);
                        glPopClientAttrib();
                        _rpixelconvert(unsigned short, GL_UNSIGNED_SHORT, 2)
                        _rpixelconvert(unsigned int, GL_UNSIGNED_INT, 4)
                        _rpixelconvert(float, GL_FLOAT, 4)
                        delete [] buf;
                        return;
                }
        }
        _glReadPixels(x, y, width, height, format, type, pixels);
        CATCH();
}

One more noob question regarding this code: Is the glReadPixels function with the underscore the call to the "parent" glReadPixels function of libGL.so? I have not found the _glReadPixels function inside the VirtualGL code so this seems the only explanation to me.

Regards,

Ingo


More information about the mesa-dev mailing list