5

Is there any way to declare a dynamically sized array payload in optix? I've googled and read the Optix documentation, only to find that Optix doesn't allow the use of malloc. Is there any way I could do something like the following?

struct PerRayData_radiance
{
 float3 result;
 float  importance;
 int depth;
 float stuff[N];
};

Were I size the array stuff to size N depending on some user parameters.

I tried searching the NVIDIA forums for past questions but it seems like it has been shut down due to some security issues.

Robert Crovella
  • 143,785
  • 11
  • 213
  • 257
icebreeze
  • 113
  • 5

1 Answers1

4

You can't. I asked exactly this question on the NVIDIA OptiX forums when they were around as I wanted to do this for my application (wish I could give you an http pointer). Unfortunately, one constraint of the ptx generated files used by OptiX is you can't have this kind of dynamic allocation in the radiance rays you're passing around.

For our application we have to instead use an array with a maximum size and an uint specifying the length for the current run. It's memory wasteful, I know, but I don't see any way around it.

You'll want to play around with maximum sizes for your application and hardware because the stack size will likely be pushed in this situation.

Stephen Johnson
  • 467
  • 3
  • 8
  • Thanks, I had a feeling that was going to be the case. – icebreeze Sep 10 '12 at 16:24
  • 2
    Incidentally, we're now working around this now by using the CUDA context sharing capability in 3.0. Basically, we've found a way to let OptiX do the ray tracing and CUDA do the calculations requiring dynamic allocation with more flexibility and not such a constrained stack. YMMV, of course. – Stephen Johnson Nov 20 '12 at 13:39