Re: [info-performer] depth buffer write is slow.

New Message Reply Date view Thread view Subject view Author view

From: Wayne Price (W.Price++at++miramar.demon.co.uk)
Date: 08/15/2002 06:36:19


> Must dependend on the driver and the memory bandwidth of the
> system, but on Dual-athlon with GeForce4 under Linux (latest driver),
> I don't get any speedup with tiling. The max is always with one
> glReadPixels call, with around 90Mpixels/sec. Or I have a bug
> im my code (GL_UNPACK_SKIP_PIXELS seems killing the perf,
> but otherwise you need a memcopy, no ?).
> I tried to swap the indices, or doing by block of rows, it's
> not better.
>
> #if 0
> glDrawPixels( width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels );
> #else
> block = 128;
> stepi = width / block;
> stepj = height / block;
>
> glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
> glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, height);
> glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
> glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
>
> for (j=0;j<stepj;j++)
> for (i=0;i<stepi;i++)
> {
> glRasterPos2i(i*block,j*block);
> glPixelStorei(GL_UNPACK_SKIP_PIXELS, i*block);
> glDrawPixels( block, block, GL_RGB, GL_UNSIGNED_BYTE,
> pixels + width*j*block*3);
> }
> #endif
>

I can't see anything obviously wrong with the code. Here's the code I use:

    int byteWidth = imageWidth * pixelSize;
    if (byteWidth & 1)
      glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    else if (byteWidth & 2)
      glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
    else
      glPixelStorei(GL_UNPACK_ALIGNMENT, 4);

    glPixelStorei(GL_UNPACK_ROW_LENGTH, imageWidth);

    const int TILE_SIZE = 7;
    int xtiles = (imageWidth + (1 << TILE_SIZE) - 1) >> TILE_SIZE;
    int ytiles = (imageHeight + (1 << TILE_SIZE) - 1) >> TILE_SIZE;
    for (int y = 0; y < ytiles; y++)
    {
      register int yo = y << TILE_SIZE;
      glPixelStorei(GL_UNPACK_SKIP_ROWS, yo);

      register int tileh = 1 << TILE_SIZE;
      if (yo + tileh > imageHeight)
        tileh = imageHeight - yo;

      for (int x = 0; x < xtiles; x++)
      {
        register int xo = x << TILE_SIZE;
        glPixelStorei(GL_UNPACK_SKIP_PIXELS, xo);

        register int tilew = 1 << TILE_SIZE;
        if (xo + tilew > imageWidth)
          tilew = imageWidth - xo;

        glRasterPos2i(xorigin + xo, yorigin + yo);
        glDrawPixels(tilew, tileh, GL_RGB, GL_UNSIGNED_BYTE, imageData);
      }
    }

    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);

The only obvious differences are the GL_UNPACK_SKIP_ROWS and
GL_UNPACK_ALIGNMENT stuff.

Wayne

-- 
___________________________________________________________________________
Wayne Price     W.Price++at++electronic-alchemy.co.uk     Electronic Alchemy Ltd
Mobile: +44 (0) 7770 376383                       Home: +44 (0) 1483 531235


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Thu Aug 15 2002 - 06:27:16 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.