Opened 17 years ago
Closed 17 years ago
#104 closed defect (fixed)
saving display to tiff or ppm garbled when NVIZ is not top window
Reported by: | dylan | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 6.4.0 |
Component: | Default | Version: | svn-trunk |
Keywords: | NVIZ openGL | Cc: | |
CPU: | Unspecified | Platform: | Unspecified |
Description
With a recent version of NVIZ garbled images are created when saving either tiff or ppm files, when NVIZ is not:
- the top-most window
or
- 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...
Attachments (2)
Change History (21)
follow-up: 3 comment:1 by , 17 years ago
comment:2 by , 17 years ago
see RT bug # 3041:
"NVIZ max PPM dump fails to construct image" http://intevation.de/rt/webrt?serial_num=3041
Hamish
comment:3 by , 17 years ago
Replying to 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.
follow-up: 5 comment:4 by , 17 years ago
Some updates (2008-03-26 SVN) & "nvidia" driver with DRI/GLX enabled.
- 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
- 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.
follow-up: 6 comment:5 by , 17 years ago
Replying to dylan:
Some updates (2008-03-26 SVN) & "nvidia" driver with DRI/GLX enabled.
- 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).
follow-up: 13 comment:6 by , 17 years ago
Replying to 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.
comment:7 by , 17 years ago
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> 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.
follow-up: 9 comment:8 by , 17 years ago
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
comment:9 by , 17 years ago
Replying to 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?
follow-up: 11 comment:10 by , 17 years ago
Replying to 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.
follow-up: 12 comment:11 by , 17 years ago
Replying to 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
comment:12 by , 17 years ago
Replying to glynn:
Oh, another thing to check: export LIBGL_ALWAYS_INDIRECT=1
Still crashes. Same debug output.
follow-up: 14 comment:13 by , 17 years ago
Replying to 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.
follow-up: 15 comment:14 by , 17 years ago
Replying to 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?
follow-up: 16 comment:15 by , 17 years ago
follow-up: 17 comment:16 by , 17 years ago
follow-up: 18 comment:17 by , 17 years ago
Replying to 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.
follow-up: 19 comment:18 by , 17 years ago
Replying to glynn:
Can you try this one instead?
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?
comment:19 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Replying to msieczka:
Replying to glynn:
Can you try this one instead?
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).
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).