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

#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
Keywords: NVIZ openGL |
-------------------------+--------------------------------------------------
With a recent version of NVIZ garbled images are created when saving
either tiff or ppm files, when NVIZ is not:

1. the top-most window
or
2. not completely on-screen (moved such that part of the window is off-
screen)

This is on Linux x86. Not sure if this is an OpenGL bug, or what...

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104&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):

It's not an OpenGL bug, but a limitation. If you render to a window, the
rendering is clipped to the visible portion (the part that's on-screen and
not obscured by another window). If you read the rendered image (with
glReadPixels()), the clipped portions will contain garbage.

The only reliable way to generate image files using OpenGL is to render to
an off-screen target such as a pBuffer or GLXPixmap. But those require
support from the driver, and we haven't had much luck with either approach
(of course, there might be bugs in the code which creates the pBuffer or
GLXPixmap).

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:1&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 hamish):

see RT bug # 3041:

   "NVIZ max PPM dump fails to construct image"
   http://intevation.de/rt/webrt?serial_num=3041

Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:2&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:1 glynn]:

> The only reliable way to generate image files using OpenGL is to render
to an off-screen target such as a pBuffer or GLXPixmap. But those require
support from the driver, and we haven't had much luck with either approach

Actually, using a GLXPixmap works fine for me with both Cygwin's XWin.exe
and X.org with the "nv" driver (that's the FOSS driver with no DRI/DRM
support; I haven't tried the proprietary "nvidia" driver yet).

Neither of those X servers support GLX 1.3, so I haven't tested pBuffers
yet.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:3&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

BTW, I've just fixed a bug in that code which caused the pnmcat stage
to fail if the smallest monitor dimension was a power of two (e.g.
1280x1024).

Essentially, the code always added one to the number of rows and
columns (rather than rounding up), so if the image size was an exact
multiple of the tile size, you would get an extra zero-width column
and a zero-width row, which pnmcat complained about.

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

GRASS GIS wrote:

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

> The only reliable way to generate image files using OpenGL is to render
to an off-screen target such as a pBuffer or GLXPixmap. But those require
support from the driver, and we haven't had much luck with either approach

Actually, using a GLXPixmap works fine for me with both Cygwin's XWin.exe
and X.org with the "nv" driver (that's the FOSS driver with no DRI/DRM
support; I haven't tried the proprietary "nvidia" driver yet).

In light of this, I suggest re-considering whether a GLX Pixmap should
be used by default for 6.3.0. Currently, a GLX Pixmap has to be
specifically enabled by setting GRASS_GLX_PIXMAPS (whereas the trunk
requires it to be specifically disabled by setting
GRASS_NO_GLX_PIXMAPS).

If it turns out that GLX Pixmaps work on a significant proportion of
systems, they should probably be used by default, as they don't suffer
from the inherent problems of trying to read a window's contents
(clipping, occlusion, the window receiving events in the middle of
rendering, etc).

I say "a significant proportion" rather than "the majority", because
the situation is likely to get better (rather than worse) over time.

--
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 dylan):

Some updates (2008-03-26 SVN) & "nvidia" driver with DRI/GLX enabled.

1. export to full-res PPM, no error messages but results in black image.
------------------------------------------
Creating PBuffer Using GLX 1.3
Final Assembled Image will be 3185 x 4096
Writing Tile 1 of 16
Writing Tile 2 of 16
Writing Tile 3 of 16
Writing Tile 4 of 16
Writing Tile 5 of 16
Writing Tile 6 of 16
Writing Tile 7 of 16
Writing Tile 8 of 16
Writing Tile 9 of 16
Writing Tile 10 of 16
Writing Tile 11 of 16
Writing Tile 12 of 16
Writing Tile 13 of 16
Writing Tile 14 of 16
Writing Tile 15 of 16
Writing Tile 16 of 16
Assembling Tiles
Destroy pbuffer
------------------------------------------

2. set env. variables:
export GRASS_NO_GLX_PIXMAPS=TRUE
export GRASS_NO_GLX_PBUFFERS=TRUE

export to full-res PPM, resulting image is at the coarse grid resolution.
After setting the coarse resolution to 1 and the fine resolution to 1 the
output file appears to be correct.
------------------------------------------
Final Assembled Image will be 3909 x 4096
Writing Tile 1 of 49
Writing Tile 2 of 49
Writing Tile 3 of 49
Writing Tile 4 of 49
Writing Tile 5 of 49
Writing Tile 6 of 49
Writing Tile 7 of 49
Writing Tile 8 of 49
Writing Tile 9 of 49
Writing Tile 10 of 49
Writing Tile 11 of 49
Writing Tile 12 of 49
Writing Tile 13 of 49
Writing Tile 14 of 49
Writing Tile 15 of 49
Writing Tile 16 of 49
Writing Tile 17 of 49
Writing Tile 18 of 49
Writing Tile 19 of 49
Writing Tile 20 of 49
Writing Tile 21 of 49
Writing Tile 22 of 49
Writing Tile 23 of 49
Writing Tile 24 of 49
Writing Tile 25 of 49
Writing Tile 26 of 49
Writing Tile 27 of 49
Writing Tile 28 of 49
Writing Tile 29 of 49
Writing Tile 30 of 49
Writing Tile 31 of 49
Writing Tile 32 of 49
Writing Tile 33 of 49
Writing Tile 34 of 49
Writing Tile 35 of 49
Writing Tile 36 of 49
Writing Tile 37 of 49
Writing Tile 38 of 49
Writing Tile 39 of 49
Writing Tile 40 of 49
Writing Tile 41 of 49
Writing Tile 42 of 49
Writing Tile 43 of 49
Writing Tile 44 of 49
Writing Tile 45 of 49
Writing Tile 46 of 49
Writing Tile 47 of 49
Writing Tile 48 of 49
Writing Tile 49 of 49
Assembling Tiles
------------------------------------------

It seems like Glynn's recent changes + setting environmental variables is
the trick to getting things to work using the "nvidia" driver.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:4&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 dylan):

Some updates (2008-03-26 SVN) & "nvidia" driver with DRI/GLX enabled.

1. export to full-res PPM, no error messages but results in black image.
------------------------------------------
Creating PBuffer Using GLX 1.3
Final Assembled Image will be 3185 x 4096

Destroy pbuffer
------------------------------------------

Okay; I'll try to get the nvidia driver up and running so that I can
look into this.

2. set env. variables:
export GRASS_NO_GLX_PIXMAPS=TRUE
export GRASS_NO_GLX_PBUFFERS=TRUE

Can you try the GLX Pixmap case, i.e.

  export GRASS_NO_GLX_PBUFFERS=TRUE
  export -n GRASS_NO_GLX_PIXMAPS
?

That's the case that's looking like it might be the most reliable.

export to full-res PPM, resulting image is at the coarse grid resolution.
After setting the coarse resolution to 1 and the fine resolution to 1 the
output file appears to be correct.

The coarse resolution is probably a coincidence.

Certainly, the do_zoom.c code doesn't touch the grid resolution,
regardless of which rendering target is used.

It may be timing related. AFAICT, the UI code switches to coarse
resolution when certain events occur (e.g. drag), then switches back
to fine resolution once the UI is considered "idle".

------------------------------------------
Final Assembled Image will be 3909 x 4096
------------------------------------------

It seems like Glynn's recent changes + setting environmental variables is
the trick to getting things to work using the "nvidia" driver.

If both environment variables are set, it renders into the window then
reads the data from the screen. That method is the most compatible (it
doesn't require any OpenGL or GLX features beyond those which are
already required for interactive display), but it's also the most
error-prone.

In this sense, bug #104 is a "cantfix".

Using the view window for rendering image files will always have the
risk of some other application putting something (dialog, tooltip,
menu, etc) over the view window in the middle of the rendering
process.

The only reason why we support this method is that the other methods
all require specific GLX features which the X server and/or OpenGL
library might not provide (or, worse still, they may "provide" a
version which doesn't work; we handle the case where the feature isn't
available, we can't handle the case where it's available but doesn't
actually work).

--
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:4 dylan]:

> Some updates (2008-03-26 SVN) & "nvidia" driver with DRI/GLX enabled.

> 1. export to full-res PPM, no error messages but results in black image.

> Creating PBuffer Using GLX 1.3

I think I've fixed this; at least, it works on my system.

The main change was to create a new context rather than using the existing
context.

I've also changed the glXChooseFBConfig() call so that it only reports
FBConfigs which are likely to actually work (e.g. those which are
compatible with pBuffers and have a depth buffer).

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:5&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:5 glynn]:

> I think I've fixed this; at least, it works on my system.

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

{{{
Create PixMap Using GLX 1.1
X Error of failed request: GLXBadContext
   Major opcode of failed request: 143 (GLX)
   Minor opcode of failed request: 5 (X_GLXMakeCurrent)
   Serial number of failed request: 5128
   Current serial number in output stream: 5128
}}}

After exporting GRASS_NO_GLX_PIXMAPS=TRUE all is OK.

Debian testing x86, X.Org 7.2, Mesa 7.0.3 rc2, "radeon" driver 6.6.3, Ati
Radeon Mobility X700, GRASS SVN r30759.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:6&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:5 glynn]:

> I think I've fixed this; at least, it works on my system.

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

{{{
Create PixMap Using GLX 1.1
X Error of failed request: GLXBadContext
   Major opcode of failed request: 143 (GLX)
   Minor opcode of failed request: 5 (X_GLXMakeCurrent)
   Serial number of failed request: 5128
   Current serial number in output stream: 5128
}}}

Odd. The glXMakeCurrent manpage says:

       GLXBadContext is generated if ctx is not a valid GLX context.

But there don't appear to be any errors regarding the
glXCreateContext() call, and both are created using the same
XVisualInfo structure.

After exporting GRASS_NO_GLX_PIXMAPS=TRUE all is OK.

Could you debug this?

Once NVIZ is running, get its PID, then:

  $ gdb $GISBASE/etc/nviz2.2/nviz
  > attach <pid>
  > break Create_OS_Ctx
  > cont

Selecting the menu option will re-enter the debugger. Single-step
through the function (with "next"), printing out the values of any
variables as they are assigned.

--
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):

Glynn wrote:

> Could you debug this?

Here's debug output:

{{{
GRASS 6.3.svn (spearfish60):~ > g.region rast=elevation.10m -a
GRASS 6.3.svn (spearfish60):~ > nviz elev=elevation.10m&
[1] 12698
Loading Data
Loading Data
translating colors from fp
recalculating normals...
Row 100

GRASS 6.3.svn (spearfish60):~ > gdb $GISBASE/etc/nviz2.2/nviz
GNU gdb 6.7.1-debian
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
Using host libthread_db library "/lib/i686/cmov/libthread_db.so.1".

(gdb) attach 12698
Attaching to program: /usr/local/grass-6.3.svn/etc/nviz2.2/nviz, process
12698
Reading symbols from /usr/local/grass-6.3.svn/lib/libgrass_ogsf.so...done.
Loaded symbols for /usr/local/grass-6.3.svn/lib/libgrass_ogsf.so
Reading symbols from
/usr/local/grass-6.3.svn/lib/libgrass_bitmap.so...done.
Loaded symbols for /usr/local/grass-6.3.svn/lib/libgrass_bitmap.so
Reading symbols from
/usr/local/grass-6.3.svn/lib/libgrass_linkm.so...done.
Loaded symbols for /usr/local/grass-6.3.svn/lib/libgrass_linkm.so
Reading symbols from /usr/local/grass-6.3.svn/lib/libgrass_g3d.so...done.
Loaded symbols for /usr/local/grass-6.3.svn/lib/libgrass_g3d.so
Reading symbols from /usr/local/grass-6.3.svn/lib/libgrass_gis.so...done.
Loaded symbols for /usr/local/grass-6.3.svn/lib/libgrass_gis.so
Reading symbols from
/usr/local/grass-6.3.svn/lib/libgrass_datetime.so...done.
Loaded symbols for /usr/local/grass-6.3.svn/lib/libgrass_datetime.so
Reading symbols from /usr/lib/libz.so.1...done.
Loaded symbols for /usr/lib/libz.so.1
Reading symbols from
/usr/local/grass-6.3.svn/lib/libgrass_sites.so...done.
Loaded symbols for /usr/local/grass-6.3.svn/lib/libgrass_sites.so
Reading symbols from
/usr/local/grass-6.3.svn/lib/libgrass_dbmibase.so...done.
Loaded symbols for /usr/local/grass-6.3.svn/lib/libgrass_dbmibase.so
Reading symbols from
/usr/local/grass-6.3.svn/lib/libgrass_dbmiclient.so...done.
Loaded symbols for /usr/local/grass-6.3.svn/lib/libgrass_dbmiclient.so
Reading symbols from /usr/local/grass-6.3.svn/lib/libgrass_vect.so...done.
Loaded symbols for /usr/local/grass-6.3.svn/lib/libgrass_vect.so
Reading symbols from /usr/local/grass-6.3.svn/lib/libgrass_dgl.so...done.
Loaded symbols for /usr/local/grass-6.3.svn/lib/libgrass_dgl.so
Reading symbols from /usr/local/grass-6.3.svn/lib/libgrass_dig2.so...done.
Loaded symbols for /usr/local/grass-6.3.svn/lib/libgrass_dig2.so
Reading symbols from
/usr/local/grass-6.3.svn/lib/libgrass_rtree.so...done.
Loaded symbols for /usr/local/grass-6.3.svn/lib/libgrass_rtree.so
Reading symbols from /usr/local/lib/libgdal.so.1...done.
Loaded symbols for /usr/local/lib/libgdal.so.1
Reading symbols from /usr/local/grass-6.3.svn/lib/libgrass_form.so...done.
Loaded symbols for /usr/local/grass-6.3.svn/lib/libgrass_form.so
Reading symbols from /usr/lib/libtk8.4.so.0...done.
Loaded symbols for /usr/lib/libtk8.4.so.0
Reading symbols from /lib/i686/cmov/libm.so.6...done.
Loaded symbols for /lib/i686/cmov/libm.so.6
Reading symbols from /usr/lib/libtcl8.4.so.0...done.
Loaded symbols for /usr/lib/libtcl8.4.so.0
Reading symbols from /usr/lib/libGLU.so.1...done.
Loaded symbols for /usr/lib/libGLU.so.1
Reading symbols from /usr/lib/libGL.so.1...Reading symbols from
/usr/lib/debug/usr/lib/libGL.so.1.2...done.
done.
Loaded symbols for /usr/lib/libGL.so.1
Reading symbols from /usr/lib/libSM.so.6...done.
Loaded symbols for /usr/lib/libSM.so.6
Reading symbols from /usr/lib/libICE.so.6...done.
Loaded symbols for /usr/lib/libICE.so.6
Reading symbols from /usr/lib/libX11.so.6...done.
Loaded symbols for /usr/lib/libX11.so.6
Reading symbols from /usr/lib/libXmu.so.6...done.
Loaded symbols for /usr/lib/libXmu.so.6
Reading symbols from /usr/lib/libXext.so.6...done.
Loaded symbols for /usr/lib/libXext.so.6
Reading symbols from /usr/lib/libtiff.so.4...done.
Loaded symbols for /usr/lib/libtiff.so.4
Reading symbols from /lib/i686/cmov/libc.so.6...done.
Loaded symbols for /lib/i686/cmov/libc.so.6
Reading symbols from /usr/local/lib/libgeos_c.so.1...done.
Loaded symbols for /usr/local/lib/libgeos_c.so.1
Reading symbols from /usr/local/lib/libgeos-3.0.0.so...done.
Loaded symbols for /usr/local/lib/libgeos-3.0.0.so
Reading symbols from /usr/lib/libsqlite3.so.0...done.
Loaded symbols for /usr/lib/libsqlite3.so.0
Reading symbols from /usr/lib/libexpat.so.1...done.
Loaded symbols for /usr/lib/libexpat.so.1
Reading symbols from /usr/lib/libxerces-c.so.28...done.
Loaded symbols for /usr/lib/libxerces-c.so.28
Reading symbols from /lib/i686/cmov/libpthread.so.0...done.
[Thread debugging using libthread_db enabled]
[New Thread 0xb58cc6d0 (LWP 12698)]
[New Thread 0xb58cbb90 (LWP 12703)]
Loaded symbols for /lib/i686/cmov/libpthread.so.0
Reading symbols from /usr/lib/libpq.so.5...done.
Loaded symbols for /usr/lib/libpq.so.5
Reading symbols from /lib/i686/cmov/librt.so.1...done.
Loaded symbols for /lib/i686/cmov/librt.so.1
Reading symbols from /lib/i686/cmov/libdl.so.2...done.
Loaded symbols for /lib/i686/cmov/libdl.so.2
Reading symbols from /usr/lib/libcurl.so.4...done.
Loaded symbols for /usr/lib/libcurl.so.4
Reading symbols from /usr/lib/libidn.so.11...done.
Loaded symbols for /usr/lib/libidn.so.11
Reading symbols from /usr/lib/libssh2.so.1...done.
Loaded symbols for /usr/lib/libssh2.so.1
Reading symbols from /usr/lib/libldap_r-2.4.so.2...done.
Loaded symbols for /usr/lib/libldap_r-2.4.so.2
Reading symbols from /usr/lib/libkrb5.so.3...done.
Loaded symbols for /usr/lib/libkrb5.so.3
Reading symbols from /usr/lib/libk5crypto.so.3...done.
Loaded symbols for /usr/lib/libk5crypto.so.3
Reading symbols from /lib/libcom_err.so.2...done.
Loaded symbols for /lib/libcom_err.so.2
Reading symbols from /usr/lib/i686/cmov/libssl.so.0.9.8...done.
Loaded symbols for /usr/lib/i686/cmov/libssl.so.0.9.8
Reading symbols from /usr/lib/i686/cmov/libcrypto.so.0.9.8...done.
Loaded symbols for /usr/lib/i686/cmov/libcrypto.so.0.9.8
Reading symbols from /usr/lib/libgssapi_krb5.so.2...done.
Loaded symbols for /usr/lib/libgssapi_krb5.so.2
Reading symbols from /usr/lib/libstdc++.so.6...done.
Loaded symbols for /usr/lib/libstdc++.so.6
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /usr/lib/libXxf86vm.so.1...done.
Loaded symbols for /usr/lib/libXxf86vm.so.1
Reading symbols from /usr/lib/libXdamage.so.1...done.
Loaded symbols for /usr/lib/libXdamage.so.1
Reading symbols from /usr/lib/libXfixes.so.3...done.
Loaded symbols for /usr/lib/libXfixes.so.3
Reading symbols from /usr/lib/libdrm.so.2...done.
Loaded symbols for /usr/lib/libdrm.so.2
Reading symbols from /usr/lib/libXau.so.6...done.
Loaded symbols for /usr/lib/libXau.so.6
Reading symbols from /usr/lib/libXdmcp.so.6...done.
Loaded symbols for /usr/lib/libXdmcp.so.6
Reading symbols from /usr/lib/libXt.so.6...done.
Loaded symbols for /usr/lib/libXt.so.6
Reading symbols from /usr/lib/libjpeg.so.62...done.
Loaded symbols for /usr/lib/libjpeg.so.62
Reading symbols from /usr/lib/libicuuc.so.38...done.
Loaded symbols for /usr/lib/libicuuc.so.38
Reading symbols from /usr/lib/libicudata.so.38...warning: Lowest section
in /usr/lib/libicudata.so.38 is .hash at 000000b4
done.
Loaded symbols for /usr/lib/libicudata.so.38
Reading symbols from /lib/i686/cmov/libcrypt.so.1...done.
Loaded symbols for /lib/i686/cmov/libcrypt.so.1
Reading symbols from /usr/lib/libgcrypt.so.11...done.
Loaded symbols for /usr/lib/libgcrypt.so.11
Reading symbols from /usr/lib/libgpg-error.so.0...done.
Loaded symbols for /usr/lib/libgpg-error.so.0
Reading symbols from /lib/i686/cmov/libnsl.so.1...done.
Loaded symbols for /lib/i686/cmov/libnsl.so.1
Reading symbols from /usr/lib/liblber-2.4.so.2...done.
Loaded symbols for /usr/lib/liblber-2.4.so.2
Reading symbols from /lib/i686/cmov/libresolv.so.2...done.
Loaded symbols for /lib/i686/cmov/libresolv.so.2
Reading symbols from /usr/lib/libsasl2.so.2...done.
Loaded symbols for /usr/lib/libsasl2.so.2
Reading symbols from /usr/lib/libgnutls.so.26...done.
Loaded symbols for /usr/lib/libgnutls.so.26
Reading symbols from /usr/lib/libkrb5support.so.0...done.
Loaded symbols for /usr/lib/libkrb5support.so.0
Reading symbols from /lib/libkeyutils.so.1...done.
Loaded symbols for /lib/libkeyutils.so.1
Reading symbols from /usr/lib/libtasn1.so.3...done.
Loaded symbols for /usr/lib/libtasn1.so.3
Reading symbols from /usr/lib/libXcursor.so.1...done.
Loaded symbols for /usr/lib/libXcursor.so.1
Reading symbols from /usr/lib/libXrender.so.1...done.
Loaded symbols for /usr/lib/libXrender.so.1
Reading symbols from /usr/lib/dri/r300_dri.so...Reading symbols from
/usr/lib/debug/usr/lib/dri/r300_dri.so...done.
done.
Loaded symbols for /usr/lib/dri/r300_dri.so
Reading symbols from /usr/lib/gconv/ISO8859-2.so...done.
Loaded symbols for /usr/lib/gconv/ISO8859-2.so
0xffffe410 in __kernel_vsyscall ()

(gdb) break Create_OS_Ctx
Breakpoint 1 at 0x80625fe: file do_zoom.c, line 241.

(gdb) cont
Continuing.
[Switching to Thread 0xb58cc6d0 (LWP 12698)]

Breakpoint 1, Create_OS_Ctx (width=800, height=800) at do_zoom.c:241
241 dpy = togl_display();
(gdb) next
242 if (dpy == NULL) {
(gdb) next
246 scr = togl_screen_number();
(gdb) next
250 if (!getenv("GRASS_NO_GLX_PBUFFERS"))
(gdb) next
254 if (!ver_major)
(gdb) next
255 glXQueryVersion(dpy, &ver_major, &ver_minor);
(gdb) next
257 if (ver_minor >= 3)
(gdb) next
305 if (!pbuffer)
(gdb) next
307 if (!getenv("GRASS_NO_GLX_PIXMAPS"))
(gdb) next
316 };
(gdb) next
317 fprintf(stderr, "Create PixMap Using GLX 1.1\n");
(gdb) next
Create PixMap Using GLX 1.1
319 vi = glXChooseVisual(dpy, scr, att);
(gdb) next
320 if (vi == NULL) {
(gdb) next
325 ctx = glXCreateContext(dpy, vi, NULL, GL_FALSE);
(gdb) next
326 if (ctx == NULL) {
(gdb) next
331 pixmap =
(gdb) next
334 if (!pixmap) {
(gdb) next
338 glxpixmap = glXCreateGLXPixmap(dpy, vi, pixmap);
(gdb) next
339 if (!glxpixmap) {
(gdb) next
343 glXMakeCurrent(dpy, glxpixmap, ctx);
(gdb) next
X Error of failed request: GLXBadContext
   Major opcode of failed request: 143 (GLX)
   Minor opcode of failed request: 5 (X_GLXMakeCurrent)
   Serial number of failed request: 6067
   Current serial number in output stream: 6067

Program exited with code 01.
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:7&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):

Glynn wrote:

> Could you debug this?

Here's debug output:

Could you repeat this, printing the values of variables as they are
assigned, i.e.:

319 vi = glXChooseVisual(dpy, scr, att);
(gdb) next
320 if (vi == NULL) {

print *vi

(gdb) next
325 ctx = glXCreateContext(dpy, vi, NULL, GL_FALSE);
(gdb) next
326 if (ctx == NULL) {

print /x ctx

(gdb) next
331 pixmap =
(gdb) next
334 if (!pixmap) {

print /x pixmap

(gdb) next
338 glxpixmap = glXCreateGLXPixmap(dpy, vi, pixmap);
(gdb) next
339 if (!glxpixmap) {

print /x glxpixmap

The first one (*vi) is potentially the most significant.

--
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):

Glynn,

Here's more debug info you requested in your email:

{{{
320 if (vi == NULL) {
(gdb) print *vi
$1 = {visual = 0x809ed08, visualid = 40, screen = 0, depth = 24, class =
4, red_mask = 16711680, green_mask = 65280, blue_mask = 255, colormap_size
= 256, bits_per_rgb = 8}

326 if (ctx == NULL) {
(gdb) print /x ctx
$2 = 0x8aebc10

334 if (!pixmap) {
(gdb) print /x pixmap
$3 = 0x3200132

339 if (!glxpixmap) {
(gdb) print /x glxpixmap
$4 = 0x320014d
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:8&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:8 msieczka]:

Nothing out of the ordinary there.

The context, Pixmap and GLXPixmap are all being created with respect to
the same XVisualInfo* value.

The GLXPixmap case works fine on Cygwin's XWin.exe, X.org with "nv"
driver, and X.org with "nvidia" driver (the first two with X.org's libGL,
the last with nVidia's). This is with X.org 7.2 & server 1.3.0.0.

This is looking like an issue with the Radeon driver.

Note that we handle the case where the server fails to create the
GLXPixmap. The problem is that it creates the GLXPixmap then complains
when you try to use it.

One finale check: can you try "export LIBGL_DEBUG=verbose" before running
it, and see if that sheds any light?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:9&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:9 glynn]:

> One finale check: can you try "export LIBGL_DEBUG=verbose" before
running it, and see if
> that sheds any light?

It doesn't seem to. The only difference is that now, at NVIZ startup, it
prints additionaly:

{{{
libGL error:
Can't open configuration file /etc/drirc: No such file or directory.
libGL error:
Can't open configuration file /path/to/my/home/.drirc: No such file or
directory.
}}}

Does it matter?

I can't get vesa driver to work (X starts but terminates right away
without errors or significant warnigs in the log file). If time allows
I'll try fglrx and post the results then.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:10&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:10 msieczka]:

> > One finale check: can you try "export LIBGL_DEBUG=verbose" before
running it, and see if
> > that sheds any light?
>
> It doesn't seem to. The only difference is that now, at NVIZ startup, it
prints additionaly:

[snip]

> Does it matter?

I don't think so.

Oh, another thing to check: export LIBGL_ALWAYS_INDIRECT=1

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:11&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:11 glynn]:

> Oh, another thing to check: export LIBGL_ALWAYS_INDIRECT=1

Still crashes. Same debug output.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/104#comment:12&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:11 glynn]:

> Oh, another thing to check: export LIBGL_ALWAYS_INDIRECT=1

Still crashes. Same debug output.

I don't have any other suggestions at this point.

FWIW, I've back-ported the pBuffer fixes to the 6.3.0 branch.

It would be useful if we could get as many people as possible to try
using the GLXPixmap and/or pBuffer code, and reporting success or
failure, along with their platform details (OS, X version(s), video
hardware, preferably xdpyinfo and glxinfo output).

For 6.3.0, these have to be specifically enabled by setting
GRASS_GLX_PBUFFERS and/or GRASS_GLX_PIXMAPS (the value is irrelevant,
they just need to be set) before starting NVIZ.

In the trunk version, they are enabled by default, and can be disabled
by setting GRASS_NO_GLX_PBUFFERS and/or GRASS_NO_GLX_PIXMAPS (to
anything).

Note that the pBuffer code requires GLX 1.3, which (AFAICT) is only
available with nVidia's OpenGL driver. If you don't have GLX 1.3,
setting GRASS_GLX_PBUFFERS has no effect.

If both pBuffers and GLXPixmaps are enabled and functional, pBuffers
are used; you'll need to explicitly disable pBuffers to test the
GLXPixmap case.

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

Hi,
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.
Thanks!
Maris.