Optimization for geometry created on demand


My application creates the scene objects on demand. That is, there are AABBs and if a ray intersects one, the geometry of the object is created. It takes much time. Sometimes it requires more than a minute to render a frame. I wonder if there are some ways to optimize it. Does OptiX have something for it? Maybe it is impossible? I thought about allocation of memory for an array and storing the polygons there. But it seems to be slower than the procedural generation if the hardware is not used. Also, there is a question how to free the allocated memory for an object if no ray hits it. Thank you in advance.

Alexander Temnyakov

Hi Alexander!

There is an open-source library in OptiX 7 called Demand Loading. With it, you can launch an OptiX kernel, gather a list of missing resource requests, then fill the requests after the launch, and re-launch the kernel with a new larger set of resources. It is meant to do exactly what you’re describing, by loading assets on-demand only as needed. But, the examples are all based on texture loading currently. In theory it should be usable for on-demand geometry loading as well. Have a look at the SDK samples called optixDemandLoadSimple and optixDemandTexture. You can find the demand loading library code in the SDK/lib/DemandLoading folder.

This library does not yet handle freeing resources when no rays hit them, also called eviction. The demand loading team is currently working on eviction support, so you might expect to see that in a future version of OptiX. However, there is no reason that you couldn’t track all the hit and un-hit resources yourself for each launch, and implement your own eviction.


1 Like

It’s clear. Thank you for your answer!

1 Like

You are welcome. I forgot to mention that Mark Leone has given several presentations about the Demand Loading Library, so it might be worth checking them out before diving into the code to get a good sense of how it works.

Here’s the presentation from OptiX 7.2, GTC Fall '20.

There is also a newer version for OptiX 7.3 that looks like it is not available yet on the On-Demand site, but if you happened to register for this year’s spring GTC '21, you can watch via this link (Mark’s talk starts at 32:33) :



1 Like