Re: copy z-buffer with scaling on iR

New Message Reply Date view Thread view Subject view Author view

Hansong Zhang (zhangh++at++cs.unc.edu)
Tue, 21 Oct 1997 11:27:29 -0400 (EDT)


> > > Do you have latest iR gfx patches ? ( 1808 for Onyx, 2191 for Onyx2 )
> >
> > I don't know. Have to ask the facilities.
> >
>
> You can see with: versions | grep patch
>

I don't think we have the patches you mentioned:
versions | grep patch | grep 1808 shows nothing (the machine is Onyx
chasis with iR upgrade). Our largest-numbered patch is actually 1460.

> > > Does it work with no zoom ? ( or other values of zoom )
> >
> > Yes. 512x512 -> 512x512 copy is no problem.
> >
>
> So DEPTH_TEST enabled/disabled as you describe below has no effect ( ie always
> works ) if pixelzoom == 1.0 ?
>

That's right. When doing no-zoom copies DEPTH_TEST on/off has no effect.
The copy is fine either way.

> > DEPTH_TEST is off. Turns out this is the problem. So on iR if there's no
> > DEPTH_TEST, there's no depth write. Generally I think this is not quite
> > right - no DEPTH_TEST should mean writes without any condition
> > Anyway, the convention should at least be the same across machines.
>
> Well, man glEnable says:
> ...
> It doesn't say that if disabled then update depth buffer. Just so I'm clear, do
> you have DEPTH_TEST on while you draw, then turn it off to copypixels or is it
> always the same state ?
>

DEPTH_TEST is on when I draw geometry. Then I disable it to do tricks:-)
The zbuffer copy code happened to be after the depth test's disabled, and
before it's re-enabled for the next draw.

> Do you know if you actually had a multisampled visual, use glXGetConfig in code
> on your visual, or use the xwininfo command:
> use -tree option to get all windows then use the -id option on the window
> that's your main draw window, this will show which visual you use. You can look
> at the visual data then with findvis.
>

The visual is 0x5a:

0x5a, RGBA 12/12/12/12, db, Z 23, S 1

I guess S1 means no multisampling. And I see obviously zig-zag on polygon
edges.

Actually this is another problem: about a year ago when I was using
GLUT-3.1, multisampling is fine, but after upgrading to 3.2... etc, I lost
it - for the same code. But I'll ask Mark Kilgard about this.

> The simplest thing might be if you could send me the code you are using, sounds
> like we should get the story straight, especially if behaviour is different
> depending on pixelzoom. If your code is large then it might be a useful
> exercise to narrow it down to a small test case, that always helps in these
> cases.
>
Yes the program is big (with my own Performer-like data structure!)... but
the parts that causes the problem are simple, so here it is:

        glColorMask(0,0,0,GL_TRUE);
        glClear(GL_COLOR_BUFFER_BIT);
        glColor4f(1,1,1,1);

        glDisable(GL_DEPTH_TEST);
        .
        .
        .
            // The following call is key to the problem. Without it
            // copy with 0.5 zoom factor won't work (i.e. when
            // cam_w=cam_h=512, copy_w=copy_h=256)

            // glEnable(GL_DEPTH_TEST);
             
            //glDepthFunc(GL_ALWAYS);
            glDepthMask(GL_TRUE);
            CopyPixels(cam_w, cam_h, copy_w, copy_h,
                cam_x0, cam_y0, copy_x0, copy_y0, GL_DEPTH);
            glReadPixels(copy_x0, copy_y0, copy_w, copy_h,
                GL_DEPTH_COMPONENT, GL_FLOAT, zbuffer);
            glDepthMask(0);
            glDisable(GL_DEPTH_TEST);

            // The following always works.
            // Copy color buffer for debugging purposes only
            glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
            CopyPixels(cam_w, cam_h, copy_w, copy_h,
                cam_x0, cam_y0, copy_x0, copy_y0, GL_COLOR);
            glColorMask(0,0,0,GL_TRUE);

The CopyPixels() function called above is:

void CopyPixels(int fromWidth, int fromHeight, int toWidth, int toHeight,
                int fromX, int fromY, int toX, int toY,
                int type)
                /* type can be GL_COLOR, GL_DEPTH, GL_STENCIL */
{
   float oldxfactor, oldyfactor;
   float xfactor = (float) toWidth / (float) fromWidth;
   float yfactor = (float) toHeight / (float) fromHeight;
   int oldviewport[4];

   PushViewProjMat();
   glGetIntegerv(GL_VIEWPORT, oldviewport);
   Go2D_NoScissor(toX, toY, toWidth, toHeight);
   glRasterPos2i(0, 0);

   glViewport(oldviewport[0],oldviewport[1],oldviewport[2],oldviewport[3]);
   PopViewProjMat();
   glGetFloatv(GL_ZOOM_X, &oldxfactor);
   glGetFloatv(GL_ZOOM_Y, &oldyfactor);
   /* set zoom factor */
   glPixelZoom(xfactor, yfactor);

   glCopyPixels(fromX, fromY, fromWidth, fromHeight, type);
   GLenum error = glGetError();
   if (error != GL_NO_ERROR) {
       fprintf(stderr, "GL Error in CopyPixels: %d\n", error);
   }

   /* restore old zoom factors */
   glPixelZoom(oldxfactor, oldyfactor);
}

Enjoy,
Hansong

=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:56:06 PDT

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