I have a RT_PROGRAM which I launch several times with only slight changes in the algorithm for each step.
It looks like this:
RT_PROGRAM void trace()
{
// common part for each step
// ...
// varying part
if(step==0)
{
// ...
}
else if(step==1)
{
// ...
}
// common part for each step
// ...
}
I could use a rtVariable to define the step prior to launching.
However, I would like to exploit compiler optimization.
So what I did is:
template <int step>
__forceinline__ __device__
void trace_generic()
{
// common part for each step
// ...
// varying part
if(step==0)
{
// ...
}
else if(step==1)
{
// ...
}
// common part for each step
// ...
}
RT_PROGRAM void trace_0()
{
trace_generic<0>();
}
RT_PROGRAM void trace_1()
{
trace_generic<1>();
}
But could I template the RT_PROGRAM itself? If yes, how would I tell OptiX the template parameters?