[GRASS-dev] [GRASS GIS] #104: saving display to tiff or ppm garbled when NVIZ is not top window

Maris Nartiss wrote:

I'm still have not finished my morning coffee and thus was not able to
understand what and how I must test.
Glynn, if You want to get a lot of feedback from various users, could
You, please, provide step-by-step instructions what to test and how to
get all reportable information.

For the SVN trunk version:

  xdpyinfo
  glxinfo
  export -n GRASS_NO_GLX_PIXMAPS
  export -n GRASS_NO_GLX_PBUFFERS
  nviz elevation.dem
  File -> Save Image As -> Max. Resolution PPM
  File -> Quit
  export GRASS_NO_GLX_PBUFFERS=1
  nviz elevation.dem
  File -> Save Image As -> Max. Resolution PPM
  File -> Quit

For the 6.3 release branch (including 6.3.0RC*):

  xdpyinfo
  glxinfo
  export GRASS_GLX_PIXMAPS=1
  export GRASS_GLX_PBUFFERS=1
  nviz elevation.dem
  File -> Save Image As -> Max. Resolution PPM
  File -> Quit
  export -n GRASS_GLX_PBUFFERS
  nviz elevation.dem
  File -> Save Image As -> Max. Resolution PPM
  File -> Quit

Post all of the output (xdpyinfo, glxinfo, nviz).

--
Glynn Clements <glynn@gclements.plus.com>

#104: saving display to tiff or ppm garbled when NVIZ is not top window
----------------------+-----------------------------------------------------
  Reporter: dylan | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords: NVIZ openGL
----------------------+-----------------------------------------------------
Comment (by glynn):

Replying to [comment:6 msieczka]:

> On my system unless I export GRASS_NO_GLX_PIXMAPS=TRUE, NVIZ crashes at
saving image as maximum resolution PPM, with the following error:

I've made some more changes so that it will (hopefully) fall-back to using
the window if using a GLXPixmap fails. You'll still get the X error
message, but it shouldn't be fatal.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:13&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

#104: saving display to tiff or ppm garbled when NVIZ is not top window
----------------------+-----------------------------------------------------
  Reporter: dylan | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords: NVIZ openGL
----------------------+-----------------------------------------------------
Comment (by msieczka):

Replying to [comment:13 glynn]:

> I've made some more changes so that it will (hopefully) fall-back to
using the window if using
> a GLXPixmap fails. You'll still get the X error message, but it
shouldn't be fatal.

Still after this change same crash, and still GRASS_NO_GLX_PIXMAPS=TRUE
prevents it.

More folks please test. Anybody using radeon driver out there?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:14&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

GRASS GIS wrote:

#104: saving display to tiff or ppm garbled when NVIZ is not top window

Comment (by msieczka):

Replying to [comment:13 glynn]:

> I've made some more changes so that it will (hopefully) fall-back to
using the window if using
> a GLXPixmap fails. You'll still get the X error message, but it
shouldn't be fatal.

Still after this change same crash, and still GRASS_NO_GLX_PIXMAPS=TRUE
prevents it.

Oh, so it creates the GLXPixmap okay, but if you try to select it for
rendering it simply terminates the program (rather than just returning
False). IOW, there's no way to test whether or not the feature can be
used.

Well, there's not much that we can do about that, other than simply
not using it.

--
Glynn Clements <glynn@gclements.plus.com>

On Mar 29, 2008, at 3:52 AM, Glynn Clements wrote:

Post all of the output (xdpyinfo, glxinfo, nviz).

(I figured I should also drag the NVIZ window partially offscreen for the test)

OSX 10.5.2, Core 2 Duo, Intel integrated GMA950 graphics
OpenGL 1.2, so I could only test pixmap
X11R7
GRASS SVN trunk

(attachments)

xdpy_glx.txt (6.38 KB)

William Kyngesburye wrote:

On Mar 29, 2008, at 3:52 AM, Glynn Clements wrote:

> Post all of the output (xdpyinfo, glxinfo, nviz).
>
(I figured I should also drag the NVIZ window partially offscreen for
the test)

The window shouldn't matter if you're using a Pixmap or pBuffer
(that's largely the point of using them).

Destroy Pixmap
glXSwapBuffers: no context for this drawable

Does this actually cause any problems for subsequent use of NVIZ?

When the zoom code completes, there shouldn't be a current context or
current drawable; the window's expose handler should re-instate them
each time.

If this causes a problem, we could probably restore them.

--
Glynn Clements <glynn@gclements.plus.com>

On Mar 31, 2008, at 7:03 AM, Glynn Clements wrote:

Destroy Pixmap
glXSwapBuffers: no context for this drawable

Does this actually cause any problems for subsequent use of NVIZ?

When the zoom code completes, there shouldn't be a current context or
current drawable; the window's expose handler should re-instate them
each time.

If this causes a problem, we could probably restore them.

NVIZ still works after the save. (tried zoom, resize window, add vector)

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"History is an illusion caused by the passage of time, and time is an illusion caused by the passage of history."

- Hitchhiker's Guide to the Galaxy

#104: saving display to tiff or ppm garbled when NVIZ is not top window
----------------------+-----------------------------------------------------
  Reporter: dylan | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords: NVIZ openGL
----------------------+-----------------------------------------------------
Comment (by glynn):

Replying to [comment:14 msieczka]:

> Still after this change same crash, and still GRASS_NO_GLX_PIXMAPS=TRUE
prevents it.

Can you try the [http://trac.osgeo.org/grass/attachment/ticket/104/
do_zoom-error.diff patch]. It installs an error handler which (hopefully)
prevents the error from terminating the program.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:15&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

#104: saving display to tiff or ppm garbled when NVIZ is not top window
----------------------+-----------------------------------------------------
  Reporter: dylan | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords: NVIZ openGL
----------------------+-----------------------------------------------------
Comment (by msieczka):

Replying to [comment:15 glynn]:

> Can you try the [http://trac.osgeo.org/grass/attachment/ticket/104/
do_zoom-error.diff patch]. It
> installs an error handler which (hopefully) prevents the error from
terminating the program.

I'm sorry but it does not improve anything for me. Oh well, maybe it is
just something about my setup.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:16&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

#104: saving display to tiff or ppm garbled when NVIZ is not top window
----------------------+-----------------------------------------------------
  Reporter: dylan | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords: NVIZ openGL
----------------------+-----------------------------------------------------
Comment (by glynn):

Replying to [comment:16 msieczka]:

> > Can you try the patch.
>
> I'm sorry but it does not improve anything for me.

Right; I had the error base and major opcode confused. Can you try this
one instead?

attachment:ticket:104:do_zoom-error.2.diff

If that doesn't work, try:

> Tk_CreateErrorHandler(dpy, -1, -1, -1, Error_Handler, NULL);

to (try to) install a catch-all handler.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:17&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

GRASS GIS wrote:

#104: saving display to tiff or ppm garbled when NVIZ is not top window

Comment (by msieczka):

Replying to [comment:15 glynn]:

> Can you try the [http://trac.osgeo.org/grass/attachment/ticket/104/
> do_zoom-error.diff patch]. It installs an error handler which
> (hopefully) prevents the error from terminating the program.

I'm sorry but it does not improve anything for me.

I've submitted an updated patch. If it doesn't work, can you try to
debug it? Specifically, does the error handler get invoked?

[BTW, a note about patching NVIZ: running "make" in the
visualisation/nviz/src directory doesn't install the updated
executable; you have to run "make" in visualisation/nviz.]

The fact that the program terminates is apparently down to the default
error handler. It should be possible to prevent this from terminating
the program; most X applications don't terminate upon error, nor
(AFAICT) does Tk terminate for X errors which it understands.

Oh well, maybe it is just something about my setup.

I asked on the X.org list, and apparently all DRI-based drivers will
behave this way, regardless of whether or not DRI is actually used. It
doesn't affect the "nv" driver or Cygwin's XWin.exe as those only have
software OpenGL rendering, and the "nvidia" driver has its own
hardware rendering mechanism via nVidia's libGL.

Essentially, the current DRI-based drivers cannot render to a
GLXPixmap, but you can use a GLXPixmap with the
GLX_EXT_texture_from_pixmap extension (which is essentially the sole
reason why glXCreateGLXPixmap() doesn't just fail).

IOW, if we want to be able to test whether we can use a GLXPixmap
(without killing the program if we can't), we have to prevent the
GLXBadContext error from terminating the program.

I'm rather limited in my ability to test this as I don't have any
hardware which uses DRI-based drivers (it's all either software-only
or nVidia's non-DRI-based hardware driver).

--
Glynn Clements <glynn@gclements.plus.com>

#104: saving display to tiff or ppm garbled when NVIZ is not top window
----------------------+-----------------------------------------------------
  Reporter: dylan | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords: NVIZ openGL
----------------------+-----------------------------------------------------
Comment (by msieczka):

Replying to [comment:17 glynn]:
> Can you try this one instead?
>
> attachment:ticket:104:do_zoom-error.2.diff

Allright! Same "X Error" crops out but no crash this time and the full-res
ppm output completes.

> If that doesn't work, try:
>
> > Tk_CreateErrorHandler(dpy, -1, -1, -1, Error_Handler, NULL);

I didn't bother as the first option worked. Do you want me to anyway?
Could it be any better this way?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:18&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

GRASS GIS wrote:

#104: saving display to tiff or ppm garbled when NVIZ is not top window
----------------------+-----------------------------------------------------
  Reporter: dylan | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords: NVIZ openGL
----------------------+-----------------------------------------------------
Comment (by msieczka):

Replying to [comment:17 glynn]:
> Can you try this one instead?
>
> attachment:ticket:104:do_zoom-error.2.diff

Allright! Same "X Error" crops out but no crash this time and the full-res
ppm output completes.

Good. I'll commit that.

> If that doesn't work, try:
>
> > Tk_CreateErrorHandler(dpy, -1, -1, -1, Error_Handler, NULL);

I didn't bother as the first option worked. Do you want me to anyway?
Could it be any better this way?

No, the first option is better, as the error handler will only be
called in response to GLX requests. I don't want to interfere with
Tk's error handling any more than is necessary.

--
Glynn Clements <glynn@gclements.plus.com>

#104: saving display to tiff or ppm garbled when NVIZ is not top window
----------------------+-----------------------------------------------------
  Reporter: dylan | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: closed
  Priority: minor | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: fixed | Keywords: NVIZ openGL
----------------------+-----------------------------------------------------
Changes (by glynn):

  * status: new => closed
  * resolution: => fixed

Comment:

Replying to [comment:18 msieczka]:
> Replying to [comment:17 glynn]:
> > Can you try this one instead?
> >
> > attachment:ticket:104:do_zoom-error.2.diff
>
> Allright! Same "X Error" crops out but no crash this time and the full-
res ppm output completes.

I'm marking this as resolved.

The original problem (with using the window for rendering when creating
PPM files) is essentially a "cantfix".

With the fixes to the code which uses GLX Pixmaps and pBuffers, you should
only need to use the window on systems where no other option is available
(and in that case, there is simply no solution; you just have to manually
ensure that nothing occludes the window during rendering).

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:19&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/