Porting APP from Optix 3.8 (32 bit) to Optix 6.5 (64 bit) : Need some help, please


Originally the check was outside the block (rtPotentialIntersection / rtReportIntersection), I had to move it inside due to an Optix error on the use of attribute “geometry normal” outside rtPotentialIntersection / rtReportIntersection calls

So I can roll back to old version using “n” in place of “geometric_normal”

Thanks, now I’m stuck in the _rtContextLaunch2D error… :-(

P.S. My compliments for your analysis and advice given

P.S. My compliments for your analysis and advice given

Thanks. Call it experience.

(Unknown error (Details: Function “_rtContextLaunch2D” caught exception: Assertion failed: “Unconditional assertion failure: CanonicalState still used in function: directcallable__bounds_selector_ptx0xc3db3bb81df72d16”))

Sorry, I have no idea what is going in your code.
Since OptiX 6 doesn’t handle selectors anymore, what is that directcallable__bounds_selector doing?
When and how is it called?
The “direct” implies it’s a bindless callable program, but what is bounds_selector meaning?
(Avoid bound callable programs if you can, use bindless.)

I’d need a minimal and complete reproducer to be able to look at this or file bug reports.

My program is written in Delphi (Object Pascal) and uses rtSelectors.

I searched everywere and there is no trace of the word “bounds_selector” in my source code

This is the selector program

item_selector.cu (2.4 KB)

item_selector.m64.ptx (7.8 KB)

So in Optix 6 I have to eliminate the concept of Selector?
I used them to “show” or “hide” entire objects (each object was composed of mesh). You can find an example of use in “item_selector.cu” that I attached above.
Can you point me to a thread or document that explains how to “eliminate” the selector without damaging my program?

From documentation: Note: Selector nodes are deprecated in RTX mode (default with OptiX 6.0).

How can I disable “RTX mode” ?
Maybe this is the problem…

EDIT: I have a RTX 3060 but if I call “rtGlobalGetAttribute(RT_GLOBAL_ATTRIBUTE_ENABLE_RTX, sizeof(int32_t), &RTXEnabled);” I obtain “RTXEnabled=0” (???)

Yes, that would be the problem.
There is no support for Selectors in OptiX 6 with the RTX execution strategy and the legacy mega-kernel execution model has now been completely removed from current drivers.
Please see this thread for explanations:

I have a RTX 3060 but if I call “rtGlobalGetAttribute(RT_GLOBAL_ATTRIBUTE_ENABLE_RTX, sizeof(int32_t), &RTXEnabled);” I obtain “RTXEnabled=0”

RTX is disabled on my card

It’s driver version dependent. The RTX mode is the only supported mode in currently released display drivers.
The RT_GLOBAL_ATTRIBUTE_ENABLE_RTX is meaningless now.

But if I ask to Optix, Optix says “disabled”, I’m confused

Please read the forum thread I linked above and compare your display driver version number to that. Selectors are gone.


See it as a chance to make your renderer a lot faster.

Since your visit program works on a per “item” base, the case if( (item_options & OPTIX_ITEM_ENABLED)!=0 ) could be converted to a rebuild of the top-level acceleration structure with only the enabled objects contained in the scene.
Assuming you only have one top-level Group node and many GeometryGroups holding the GeometryInstances.
Rebuilding the top-level AS is pretty fast.

Then the remaining item_options in that visit code can be handled with ray visibility flags.
There is an 8-bit mask available which should be sufficient to handle the three options you’re checking.
Actually all four checks in your visit program can be handled with ray visibility masks.

Note that the OptiX 6 API is not receiving any updates. That will only happen in OptiX 7. In the long term you should consider porting to that explicit and more modern OptiX 7 API which will always be faster than the old OptiX API used in versions 1 - 6. There have been quite some threads on this forum discussing the necessary changes.

Thanks, I wanted to explain something about my program. It’s an interior design program written in Delphi (32 bit) and uses OpenGL.
Many years ago I integrated Optix into it (you can see some tests here and here).
When the 32 bit Optix support stopped I stopped developing the Optix part.
Recently I’m porting the Delphi part to 64 bit (I also use a set of external 32 bit DLL of which I don’t own the source so I have to find some substitutes)
I attach to this post the image of the Optix tree structure of my program, those called as “TGLItem” are the single furniture. in the image below some furnitures and their sub parts (TGLMesh and TGLFaceGroup that contain the relations between geometry and materials inside the TGLMesh).
A room is a collection of furniture (TGLItem) the walls are also TGLItems.
The program shows and hides (in realtime) the furniture according to the wall on which they rest, so each frame can have a different configuration / visibility (see an example in OpenGL editing mode here). The Selector and the relative program was very good because I can enable or disable a piece of furniture at every frame without rebuilding the acceleration structures every time (it would be too slow).
Thanks anyway for the help.

P.S. In my program I used Optix also in “offline mode” to pre-calculate the Ambient Occlusion and the GI to use later in OpenGL via GLSL

See an example o calculus HERE


My Youtube Channel (OpenGL and Optix test HERE)

I took it a step further by replacing the “selector” with a “group”.
However, I am now stuck with another problem.
The part of the program that calculates the shadows receives exceptions (see below) only when the pixel is not in shadow (miss).
If I don’t calculate the shadows or if I calculate the shadows BUT the pixel is in shadow everything works perfectly.
Reflections work, only with shadows I have problems.
For the “SHADOW_RAY_TYPE” I don’t define any program except “rtMaterialSetAnyHitProgram” and I never had problems (Optix 3.8.0). Should something be corrected/added for Optix 6?

Should I also define the “rtMaterialSetClosestHitProgram” for shadows rays ?

I attach an example image. The points in red are the ones that receive the exception.
Thank you very much

Unknown error (Details: Function “_rtContextLaunch2D” caught exception: Encountered a CUDA error: cudaDriver().CuEventSynchronize( m_event ) returned (700): Illegal address, file: , line: 0


OPTIX 6 Render

OPTIX 6 Render (no Shadows)

One more Info…

If I define this “rtMaterialSetAnyHitProgram” program, I get all pixel red,

RT_PROGRAM void any_hit_shadow()
  rtIgnoreIntersection(); // Continue the search

If I define this “rtMaterialSetAnyHitProgram” program, I get the image below,

RT_PROGRAM void any_hit_shadow()
  // This material is tatally opaque, so it fully attenuates all shadow rays
  ShadowRayData.Shadowed = true;
  ShadowRayData.ShadowColor = optix::make_float3(0.0f); 
  rtTerminateRay(); // Occlusion found

The part of the program that calculates the shadows receives exceptions (see below) only when the pixel is not in shadow (miss).

If you receive exceptions from OptiX, you should implement an exception program which captures these to find out exactly what the exceptions are about.
Exception programs in OptiX 6 are per launch entry point. Means you need to have as many as you have raygeneration programs in your shader pipeline.
Here is an exception program example:
and how to enable it:

If the exceptions you’re seeing are stack overflows, then that is most likely due to a missing change to the new API which is not using the old stack size in bytes anymore but is automatically calculated from a maximum number of recursions you must set since OptiX 6.0.0.
Please read this OptiX 6.5.0 Programming Guide section:
and these API references:

When changing OptiX SDK versions please read all SDK Release Notes of the versions you have skipped as well to find the important changes.

The exception I get is this

Unknown error (Details: Function “_rtContextLaunch2D” caught exception: Encountered a CUDA error: cudaDriver().CuEventSynchronize( m_event ) returned (700): Illegal address, file: , line: 0

It was not a stack overflow, those are displayed in fucsia, red color, in my program, means “generic exception”.

This is the exception callback

RT_PROGRAM void exception()
  const unsigned int ExceptionCode = rtGetExceptionCode();
  rtPrintf( "Caught exception 0x%X at launch index (%d,%d)\n", ExceptionCode, launch_index.x, launch_index.y );
    output_buffer[launch_index] = make_color( GlobalSettings[0].BadColor1 );
    output_buffer[launch_index] = make_color( GlobalSettings[0].BadColor2 );

Encountered a CUDA error: cudaDriver().CuEventSynchronize( m_event ) returned (700): Illegal address, file: , line: 0

Yes, that is a crash in CUDA which can happen for many reasons, including errors in your shader code, and cannot be analyzed by looking at images.

You should still set the maximum number of recursions correctly first and implement an exception program for debugging things.

Please always provide the following system configuration information when asking about OptiX issues:
OS version, installed GPU(s), VRAM amount, display driver version, OptiX (major.minor.micro) version, CUDA toolkit version (major.minor) used to generate the input PTX, host compiler version.

Do the OptiX SDK 6.5.0 examples run on your system?

Should I also define the “rtMaterialSetClosestHitProgram” for shadows rays?

If the shadow rays only test visibility, you don’t need a closest hit program for them. The anyhit program is all you need.
When you do not use cutout opacity in your scene, then a faster method is to use only a miss program and the RTrayflags RT_RAY_FLAG_DISABLE_ANYHIT | RT_RAY_FLAG_DISABLE_CLOSESTHIT | RT_RAY_FLAG_TERMINATE_ON_FIRST_HIT
Explained here with OptiX 7 terms: https://forums.developer.nvidia.com/t/anyhit-program-as-shadow-ray-with-optix-7-2/181312/2

Note again that your use case of selectors can be replaced with ray visibility masks alone and you should be able to convert your program to OptiX 6 or better OptiX 7 without loss of features.