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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With