gInteractiveOptix: Using OpenGL textures

Hello,

I am building some code for volume rendering for scientific visualization and considering to use gvdb; my code uses Optix as rendering backend and currently support particles and polygonal meshes, the idea is add support to streamlines and 3D volumes.

A good starting point for volume rendering in Optix is gInteractiveOptix, however I am getting the next error at the end of the initialization step:

terminate called after throwing an instance of ‘optix::Exception’
what(): Invalid value (Details: Function “RTresult _rtTextureSamplerCreateFromGLImage(RTcontext, unsigned int, RTgltarget, RTtexturesampler_api**)” detected error: Not a valid OpenGL texture)
Aborted (core dumped)

Next is the full log:

~$ ./gInteractiveOptix
Starting here
Got here
Sys Exe Path : .
DPY : 0x1c3c440 .
GLX Config Sample Buffers : 0.
GLX Config Samples : 0.
GLX Config Sample Buffers : 0.
GLX Config Samples : 0.
GLX Config Sample Buffers : 0.
GLX Config Samples : 0.
GLX Config Sample Buffers : 0.
GLX Config Samples : 0.
GLX Config Sample Buffers : 1.
GLX Config Samples : 2.
GLX Config Sample Buffers : 1.
GLX Config Samples : 2.
GLX Config Sample Buffers : 1.
GLX Config Samples : 2.
GLX Config Sample Buffers : 1.
GLX Config Samples : 2.
GLX Config Sample Buffers : 1.
GLX Config Samples : 4.
GLX Config Sample Buffers : 1.
GLX Config Samples : 4.
GLX Config Sample Buffers : 1.
GLX Config Samples : 4.
GLX Config Sample Buffers : 1.
GLX Config Samples : 4.
GLX Config Sample Buffers : 1.
GLX Config Samples : 8.
GLX Config Sample Buffers : 1.
GLX Config Samples : 8.
GLX Config Sample Buffers : 1.
GLX Config Samples : 8.
GLX Config Sample Buffers : 1.
GLX Config Samples : 8.
GLX Config Sample Buffers : 1.
GLX Config Samples : 16.
GLX Config Sample Buffers : 1.
GLX Config Samples : 16.
GLX Config Sample Buffers : 1.
GLX Config Samples : 16.
GLX Config Sample Buffers : 1.
GLX Config Samples : 16.
Creating Window.
Width : 1024 Height : 768.
Window : 73400322.
Window Created.
Creating OptiX context.
Creating OptiX output buffer.
Setting Ray Generation program.
Loading: optix_trace_primary.ptx, trace_primary
Loading: optix_trace_primary.ptx, exception
Setting Miss program.
Loading: optix_trace_miss.ptx, miss
Creating random number buffer.
Creating Mesh intersection programs.
Loading: optix_mesh_intersect.ptx, mesh_intersect
Loading: optix_mesh_intersect.ptx, mesh_bounds
Creating Volume intersection programs.
Loading: optix_vol_intersect.ptx, vol_intersect
Loading: optix_vol_intersect.ptx, vol_levelset
Loading: optix_vol_intersect.ptx, vol_deep
Loading: optix_vol_intersect.ptx, vol_bounds
Creating OptiX Main Group and BVH.
Device List:
0. GeForce GTX TITAN Z, Runtime Ver: 3.5

  1. GeForce GTX TITAN Z, Runtime Ver: 3.5
    Driver Device: 1
    Runtime Device: 1
    CUDA Total Mem: 6082.31 MB
    CUDA Free Mem: 5643.06 MB
    Loading polygon model.
    Loading and parsing model ‘lucy.obj’…
    (*) Stride: 24, Offsets: v 0, m 0, o 0, n 12 t 0
    Model reading completed successfully! (25002 verts, 50000 tris)
    Loading VDB. …/explosion.vbx
    LoadVBX: …/explosion.vbx
    Sizes: char 1, int 4, u64 8, float 4
    EXTENTS:
    Volume Res: 208 x 280 x 232
    Volume Max: 208 x 280 x 232
    Bound Min: 0.000000 x 0.000000 x 0.000000
    Bound Max: 208.000000 x 280.000000 x 232.000000
    Voxelsize: 1.000000 x 1.000000 x 1.000000
    VDB CONFIG: <5, 5, 5, 4, 3>:
    # Nodes / # Pool Max Node Ave Child Max Child
    Level 0: 10284 10284 10284 0 0
    Level 1: 12 12 12 857 4096
    Level 2: 1 1 1 12 32768
    Level 3: 1 0 1 0 0
    Level 4: 1 0 1 0 0
    Ratio Interior/Total: 0.15%
    ATLAS STORAGE
    Atlas Res: 160 x 160 x 410 LeafCnt: 16 x 16 x 41 LeafDim: 8^3
    Vol Extents: 26390 bricks, 13.51 million voxels
    Atlas Storage: 10284 bricks, 5.27 million voxels
    Atlas Active: 10284 bricks, 5.27 million voxels
    Occupancy: 38.97%
    MEMORY USAGE:
    Topology Nodes: 0.63 MB ( 0.63 MB active)
    Topology Bitmasks: 0.02 MB ( 0.02 MB active)
    Topology Pointers: 1.12 MB ( 0.62 MB active)
    Topology Total: 1.77 MB ( 1.27 MB active)
    Atlas:
    Channel 0: 40.04 MB (4 bytes/vox)
    Atlas Total: 40.04 MB (Dense: 51.54 MB)
    Volume Total: 41.81 MB
    Creating screen buffer. 1024 x 768
    Adding OptiX materials.
    Loading: optix_trace_surface.ptx, trace_surface
    Loading: optix_trace_surface.ptx, trace_shadow
    Loading: optix_trace_deep.ptx, trace_deep
    Loading: optix_trace_deep.ptx, trace_shadow
    Adding GVDB Volume to OptiX graph.
    atlas_glid 1
    atlas_glid 1
    terminate called after throwing an instance of ‘optix::Exception’
    what(): Invalid value (Details: Function “RTresult _rtTextureSamplerCreateFromGLImage(RTcontext, unsigned int, RTgltarget, RTtexturesampler_api**)” detected error: Not a valid OpenGL texture)
    Aborted (core dumped)

System Specs:

Geforce GTX Titan Z (Kepler)
Nvidia Driver 375.39
gvdb 1.0
CUDA 8.0
Optix 4.0.2
Ubuntu 16

I tested gInteractiveGL and it worked, so not sure if there is something wrong with the parameters set for rtTextureSamplerCreateFromGLImage method. Debugging further seemed to me RTgltarget parameter was correct but not sure if the texId (2nd parameter) is being generated correctly. On the other hand why it is necessary Optix/OpenGL interop in gvdb when using Optix ?

Regards,

Benjamin

Hi Benjamin,

You need to be sure that you call gvdb.UseOpenGLAtlas().
See Programming Guide, p.53.
Optix currently requires that GVDB allocate data using GL interop.

Regards,
Rama

Thanks Rama,

It seems Optix might be the problem, I built myself a short program setting OGL-interop with a 2D and 3D texture using Optix 4.0.2 and 4.1.0 and it also fails with the same error.

I posted this problem in the Optix Forum (btw another user got a similar error with an Optix 3.9 example).

System:

Ubuntu 16
Titan Z (Kepler)
CUDA 8
Nvidia Driver 375

Regards,