Populate optix buffer with text

For debugging purposes, I would like to populate an optix buffer with something (like text). Is this possible?

You can put whatever you want in an OptiX buffer as long as you handle the data as you intend it to be used. If you’re looking for an easy debugging option to print out something take a look at the rtPrintf function

When I implement rtPrintf, I only get text output to my console and the message : “PRINT BUFFER 0 OVERFLOW”. I am trying to display an optix buffer in Qt using openGL. For now, I want to check if I am able to write anything into the buffer and display it on screen.

I allocate memory for an openGL buffer and attach it to optix using:

buffer = m_context->createBufferFromGLBO(RT_BUFFER_OUTPUT, vbo);

I do not get output when I try to write the vbo to the openGL context. So now I want to load something into the buffer (like text or color etc) and display it using openGL. By doing so, I can determine where my mistake is.

First of all, have you enabled it with rtContextSetPrintEnabled ? If yes, try to increase the stack memory with rtContextSetPrintBufferSize or selectively choosing which threads the result will be printed with rtContextSetPrintLaunchIndex

I don’t think rtPrintf will do exactly what you want since it doesn’t allow writing into arbitrary buffers. You can take a look at how we copy the data into buffers inside of include/internal/optix_internal.h. Basically we have to determine the size of output (rt_print_strlen) plus the size of the arguments, allocate space for them in a buffer, then copy the values in.

One thing to note when looking at the implementation of rtPrintf, there are a few special functions that get rewritten later when we know where the print buffer is and whether printing has been enabled or not.