Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top