Ray pump with Optix Prime

I regularly put a “ray pump” in my ray generator kernels, to simulate non-linear propagation. It looks like the following:

myPRD prd;
prd.origin = ...;
prd.direction = ...;
optix::Ray ray;
    prd.relaunch = false;

    // setup ray origin and direction based on prd

    // trace
    rtTrace(top_object, ray, prd);
while (true == prd.relaunch);
prd.relaunch, prd.origin and prd.direction

are set in any/closest-hit programs, which allows me to simulate ray deflection

Now I thought I could gain performance using Optix Prime, but Prime seems very simple and only compute ray/triangle intersections (no extra, I like this)

Is there a way to have a ray-pump like this with Optix Prime ? Or should I stick to Optix to have a ray-pump ?

With OptiX Prime that’s all your responsibility to implement.
It’s a low-level ray intersection API, not a high-level ray casting API like OptiX.

Generating rays would be a separate kernel which feeds new rays into the query buffer.
You would do this once for the primary rays and then as long as needed for each hit result and depending on the shading calculations you are also responsible for.

How you do that and from where you pick new rays is completely your choice.
You can pool that work however you like and define the most suitable query size as needed.

When having different path length it’s beneficial to use multiple smaller (where small is >64k rays!) query and hit buffers and fill them asynchronously so that you always have the GPU working on intersection calculations.

Have a look at OptiX Prime SDK examples (the ones with “prime” in the name) which do this in the more advanced versions.

I see what you mean. Thank you for your answer !