Dear OptiX team,
we realized the other day that code generation in our project places some recursive ray tracing calls into direct callables (this is done to find intersection information without recursive shading, so the stack growth is limited).
We were surprised in retrospect that this works, and that OptiX even accepts such programs, since the documentation seems quite explicit that ray tracing is forbidden in direct callables.
Turning all of our our project’s direct callables to continuation callables to anticipate such a potential case seems undesirable as they are apparently quite a bit slower. While looking into this, we also found it curious that other ray tracing APIs (e.g. DXR) don’t have a distinction between direct and continuation callables.
Basically my question boils down to the following:
Is the distinction between direct and continuation callables a relic needed to support some older hardware? (in the sense that we could ignore it when imposing some minimum hardware version). Is there any set of conditions in which we could safely trace rays from direct callables?
Hi @wenzel.jakob, sharp eye!
You’ve discovered some recent internal changes we’ve made in support of the upcoming Shader Execution Reordering API. We’re not yet prepared to cover the new requirements and limitations publicly. We will be providing new guidance that should answer this questions and clarify with the next version of OptiX.
The guidance in the Programming Guide still applies, and generally speaking it’s still best to stick to it for today’s callables. One reason your test happened to work is you didn’t use recursive shading, but (for the benefit of others reading this) continuation callables are still the only way to support recursive trace with recursive shading in a callable, the distinction is still relevant on current hardware. Note especially that even if it’s working, we don’t yet sanction tracing from direct callables. That might continue to work, or it might get broken for unforseen reasons. We have to be conservative and careful with which guarantees we make so you don’t get surprised.
Excellent, thank you for the clarification. We will try to get our hands on one of the next-gen GPUs to be able to play with this once the new version of OptiX is released.