Optix 7 : SBT vs global params

Hi all,

(Sorry for my english) I’m quite new in Optix. I want to use it for physics computation.
I want to share a large array (1 000 to 10 000) of uint32_t (triangle id) with unknown size at compile time to __raygen_rg().
Is it better to:
- copy data on classic global GPU memory and send the device pointer and size by global params
- copy data on classic global GPU memory and send the device pointer and size by a STB for raygen
- copy data directly in a STB for raygen. (Is it possible for an array of unknown size at compile time) ?

With love

I would use method one. Just put the CUdeviceptr to the data and the size information into the the launch parameters.
That way you could access it anywhere inside the OptiX device programs since they are global.
You need the launch parameter buffer anyway and with this method you wouldn’t need any SBT data on the ray generation record.

Something like this for example where the CUdeviceptr outputBuffer in line 51 and the int2 resolution in line 65 work together to define the buffer independently of the launch dimensions.

ok ! Thank you !
For my knowleage : what is adventages to STB is we can share data by global parms ?

Having SBT data at the ray generation SBT record isn’t really necessary since there can only be one inside an SBT. At least I haven’t needed it so far.
It becomes a lot more important for the SBT hit records, where you can/must provide different data like the vertex attributes and indices and material parameters which control the behaviour of the resp. anyhit and closesthit programs.

What’s in the SBT record is fully under the developer’s control. The SBT is pretty flexible. The crucial thing to learn is how the SBT index is calculated, see chapter 7.3 here:

In my example applications I only use SBT records with an additional data field inside the hit records, all others only need the program itself and parts of the launch parameters.
I have one hit record per instance inside the SBT because each instance represents one geometry acceleration structure (GAS) with one SBT record each.
That way I can provide the pointers to the vertex attributes and indices as well as the material index per instance as SBT data directly.

1 Like