Context launch timing


I’m writing an interactive renderer that updates the mesh geometry every frame (i.e. the vertice position and possibly connectivity change). I find that context->launch takes 600+ms every time after I change the scene and takes only 15ms afterward.

My guess is that after each change OptiX may recompile the magekernel which takes time. However, I’m not sure about this. The geometry is typically quite simple (50K tri faces) and I just want a 24FPS rendering of a “geometry sequence”.

I couldn’t find such an example that demonstrates how this can be achieved. Is there any way to avoid the long launch time?

Thanks in advance.

Based on , I tried to avoid any changes to the scene (adding program, modify scene graph structure etc.), but updating the attribute and indice buffers only instead.

However, I still find that I get this 1-second pause from time to time. Could you provide some insight how to avoid this?


If you only change data in geometry attribute and index buffers, there should be no recompile of the kernel.
But there will be a rebuild of the acceleration structure and depending on the acceleration structure builder you’re using (Trbvh recommended for build performance), the underlying GPU, and the data that would take some time. What’s your system configuration?

It’s unclear what else is happening in your program to result in a one second hiccup.
Declaring new variables between launches for example is always invoking a kernel recompile.
You should be able to determine if that happens by adding a usage report callback.

The OptiX Introduction example 10 in the OptiX Advanced Samples shows how to do that.
Links here:
Search for “setUsageReportCallback” in Application.cpp.

If you’re using triangle geometry and the Trbvh (or Sbvh, don’t for animated geometry) then make sure to set the acceleration properties to invoke the specialized faster splitting triangle builder.
The same Application.cpp code contains a function “setAccelerationProperties” showing how to do that.
There are multiple threads on this forum explaining that in more detail.

Hi Detlef,

Thank you so much for your timely reply! I added setUsageReportCallback and found that the hiccup happens every 32 created buffer. I fixed the problem by not creating a new buffer but reuse it every time.