Raw pointer buffer access detected

I have a warning saying “Raw pointer buffer access detected”. What does this mean and how can I resolve it?

Am I correct in guessing that this refers to the documentation section that states “Taking the address of a variable on the device is not supported”? Will this still apply when my method is marked inline?

No, that just means you’ve done something like this:

rtBuffer<type, dimension> buffer;
type* t = &buffer[index];
// or 
type& t = buffer[index];

Note that only operator allows to access a single buffer element of whatever type, including user defined structs. Pointer arithmetic to access another buffer element is not allowed.

The warning indicates that you took a pointer to a buffer element which OptiX cannot optimize as well as if you copied the whole thing and which would then allow optimizers to strip away all individual loads of fields which aren’t actually used.

Try if either method is faster and use what suits your case better.

Find more information and links in this thread of exactly the same title:

(The forum has a search function at the top right next to your name.
Type something into the search field, hit return, and then click on the “Show” button in the results page to refine your search to the OptiX forum.)

I recommend to use forceinline on any function which is not RT_PROGRAM or RT_CALLABLE_PROGRAM.
inline is just a hint and depending on the number of arguments and size of the function body, the CUDA compiler might decide to not inline the function. In older OptiX versions the resulting call instructions were not handled at all. I’m using this RT_FUNCTION define for consistent looks: