How to use Optix Selector?

Hello, I’m trying to implement a basic procedure to show/hide geometry within the rendered scene. I use a Selector for this. I couldn’t find any examples on Selector use, so I might use it incorrectly and that’s why the program crashes. Below is a simple implementation example:

//--------cuda file
#include <optix.h>

rtDeclareVariable(int, vis, , );

RT_PROGRAM void vis_prog()
{
rtIntersectChild(0);
}

//----------program

optix::Selector selector = context->createSelector();

//create program from ptx

optix::Program selection_program;
//–

selector->setVisitProgram(selection_program);

selector->addChild(group_to_hide_or_show);

//---------------------------
The scene contains other groups, but I’m not adding them to selector.

All steps are passed successfully (generation of PTX, creating selector, scene and etc.), but after launch I receive the following error:

Uses:
%6 = call float* @_ZN4cort11AABB_getPtrEPNS_14CanonicalStateE(%“struct.cort::C
anonicalState.4”* %0) #1
%7 = call i32 @_ZN4cort24Traversal_getCurrentNodeEPNS_14CanonicalStateE(%“stru
ct.cort::CanonicalState.4”* %0) #1
%8 = call i32 @_ZN4cort33GraphNode_convertToSelectorHandleEPNS_14CanonicalStat
eEj(%“struct.cort::CanonicalState.4”* %0, i32 %7) #1
%9 = call i32 @_ZN4cort20Selector_getChildrenEPNS_14CanonicalStateEj(%“struct.
cort::CanonicalState.4”* %0, i32 %8) #1
call void @_ZN4cort33Runtime_computeGraphNodeGeneralBBEPNS_14CanonicalStateEjP
NS_9GeneralBBE(%“struct.cort::CanonicalState.4”* %0, i32 %25, %“struct.cort::Gen
eralBB”* %childbb) #1

Are there any suggestions what I do wrong or maybe there are more detailed examples on how to use Selectors in Optix?

Thank you very much in advance,
Evgeniya
//-------------------
Device info:
OptiX 6.0.0
Number of Devices = 1

Device 0: Quadro P4000
Compute Support: 6.1
Total Memory: 8589934592
Clock Rate: 1480000 kHz
Max. Threads per Block: 1024
Streaming Multiprocessor Count: 14
Execution Timeout Enabled: 1
Max. Hardware Texture Count: 1048576
TCC Driver enabled: 0
CUDA Device Ordinal: 0

Hi @emalikova,

Selectors in OptiX 6 are only enabled with RTX mode disabled. See rtGlobalSetAttribute() with the RT_GLOBAL_ATTRIBUTE_ENABLE_RTX parameter. RTX mode is enabled by default, so you do need to take action to opt-out.

Note that with RTX mode disabled, your program won’t be able to take advantage of Turing architecture acceleration. Selectors are being phased out of OptiX in favor of visibility masks, which are more limited but have hardware support. Take a look at visibility masks, let us know if they appear too limited for your needs. Depending on what you need, there are some recipes we could suggest with or without visibility masks to emulate selector node behavior.


David.

Thank you very for your reply. Visibility masks seem to be exactly what I need. But I’m using Optix 6.0 with Windows 7 and it seems that I receive the same problem, like in https://devtalk.nvidia.com/default/topic/1049565/optix/how-to-properly-use-visibility-masks-/ . Is this bug fixed in Optix 7?

Thank you very much in advance,
Best regards,
Evgeniya

The bug in that thread should already been fixed in currently shipping drivers.
Which display driver version are you using?

Please try the new OptiX 6.5 version: [url]OptiX 6.5 Release - OptiX - NVIDIA Developer Forums

OptiX 7 is a very different host API and the pre-release SDK and drivers should also not show this issue: [url]https://devtalk.nvidia.com/default/topic/1058310/optix/optix-7-0-release/[/url]

I would highly recommend to use OptiX 7 for new developments. While it’s more explicit and needs knowledge of the CUDA runtime or driver API to implement an application, it’s much more flexible and faster. (“With great power comes great responsibility!”)
[url]Porting to OptiX 7 - OptiX - NVIDIA Developer Forums

Hi @emalikova,

I momentarily thought I had reproduced the problem using visibility masks with OptiX 6 on a non-RTX GPU, but it turns out that I forgot one detail about them: they are only used when setting visibility masks on geometry groups that are part of Group nodes. If you create a geometry group and assign it as the top object to trace, the visibility mask will be ignored.

Please check to see if that’s the problem you ran into. When I modified the optixMeshViewer sample to toggle the visibility mask, it didn’t work on my Maxwell based laptop, because the geometry group is assigned to the top object, but when I modified the optixGeometryTriangles sample to do the same thing, the visibility masks started working because the geometry object is a child of a group node.

It seems with latest drivers the visibility masks are working fine, so if my advice here doesn’t help, please let us know how to reproduce so we can fix the problem.


David.