Multiple entry points

I’m working on an application with that uses two ray generation programs. I want to launch one, then use the output from it as input to the second one. However, since there are some inputs to the second ray generation program that I don’t know to begin with, I’d like to leave some of the objects used only by the second program uninitialized to begin with (such as output buffers and acceleration structures), since I don’t know their sizes yet.

However, when I run the first ray generation program, I get this error:

OptiX Error: Invalid value (Details: Function "_rtContextLaunch2D" caught exception: Initalization of non-primitive type output_buffer: Buffer object, [1769646])

This is referring to the RTbuffer used only by the second ray generation program.

I can assign junk data to the buffers and acceleration structures to make the program run, but is there a better way? Is there an equivalent of NULL for an RTobject that I could assign temporarily while the first ray generation program runs?

No, an empty buffer and a dummy object would be required or OptiX’ validation steps fails.

You can assign an empty buffer (unless it’s an interop buffer, then it must have a size).
If you get it filled later on, you would just set its data and size.

For the RTobject, if that is the root of the second launch, you would need to attach at least an empty Group. I’m not sure if OptiX handles an empty scene today, it wasn’t supporting that in the past. In that case add a dummy object like a single triangle. Group -> GeometryInstance (with NoAccel) -> Geometry (one triangle).

Exchanging RTobjects and building a new acceleration structure between launches will be slow. If that is a streaming approach, make sure to use a fast builder. The Lbvh builder is the fastest, but renders slower than the others.