RT_CALLABLE_PROGRAM and rtTrace()

Hi all,

Is it possible to call rtTrace inside a RT_CALLABLE_PROGRAM ?
I’m trying to do it but it seems like when I put a rtTrace call into the code of my RT_CALLABLE_PROGRAM, the RT_CALLABLE_PROGRAM is not executed.

More precisely, for this very simple example of Ray Launch program and RT_CALLABLE_PROGRAM :

RT_CALLABLE_PROGRAM void propagate(float3 origin, float3 direction, Mode mode, unsigned material)
{
	rtPrintf("Propagating : %f, %f, %f\n", direction.x, direction.y, direction.z);
	Ray ray = make_Ray(origin, direction, 0, RAY_EPSILON, RT_DEFAULT_MAX);
	Payload pld;
	rtTrace(mesh_geometry, ray, pld);
}
rtCallableProgram(void, propagate, (float3 origin, float3 direction, Mode mode, unsigned material));

RT_PROGRAM void launch()
{
	float3 direction = directions[launch_index];
	propagate(origin, direction, mode, init_material_id);
}

I get no output. It looks like the code from propagate is not executed at all.

When I remove the call to rtTrace, I get the following output :

Propagating : 0.153765, 0.351678, 0.923406
Propagating : 0.800347, 0.218985, 0.558114
Propagating : 0.462844, 0.099148, 0.880878
Propagating : 0.487298, 0.144910, 0.861128
Propagating : 0.767564, 0.500614, 0.400288
Propagating : 0.069481, 0.656887, 0.750781
Propagating : 0.704419, 0.300434, 0.643066
Propagating : 0.644998, 0.763750, 0.025765
Propagating : 0.583844, 0.474976, 0.658426
Propagating : 0.340727, 0.312259, 0.886792

Which is exactly what I would want to see. What am I doing wrong ? Should I find another way than using rtTrace inside a RT_CALLABLE_PROGRAM ?

Thanks,
Hamza

From the OptiX 3.5.1 Programming Guide, Chapter 4.10.5:
“RT_CALLABLE_PROGRAMs have many of the same privileges that normal RT_PROGRAMs do. They can have OptiX variables of their own, and they can invoke OptiX functions such as rtTrace or read or write attribute variables.”

Does it work without the rtPrintf()? (That would require some output of the ray generation program to be read on the host.)
Which OptiX version are you using?
What are the installed GPU(s)?

It’s faster to call with const references to vector types than with values, e.g. const float3& origin, etc. in your case.
I wouldn’t name the callable program variable the same as the program you’re putting into it.

For what do you want to use that callable program in the future? The given case wouldn’t require it.
(I have a full path tracer implementation based on callable programs and none of the rtTrace() calls in the whole renderer needs to be inside a callable program.)

Thanks for your answer.
Indeed, I read your quote from the programming guide just after sending the message !

  • Taking out the rtPrintf calls does seem to change anything.
  • I’m on OptiX 3.5.1.
  • I have a Quadro K2000 and a GeForce GTX Titan.

I guess I could take out these rtTrace calls inside callable programs, but it seems more convenient for what I’m doing and since such calls are supposed to work, I guess the problem is elsewhere.

EDIT : And the problem was elsewhere indeed, and pretty dumb. I was calling rtReportIntersection with an unset value.

Many thanks for your help !