Mesh data

In the Optix 7 examples, when

HitGroupData* rt_data = (HitGroupData*)optixGetSbtDataPointer();

is called, in the closest hit program, does rt_data point to all the meshes, or the specific mesh in which intersection happened?

Inside the SDK example HitGroupData* points to the specific hit mesh geometry data and its material information stored per shader binding table (SBT) hit record entry.

More generally the optixGetSbtDataPointer() returns the pointer to the data field in the SBT entry you defined for each of the SBT record entries (not only hit records).

Means you control what is in there. For SBT hit records you normally put the data of the indices and attributes of the hit mesh and some additional information about the material in there.

Inside the OptiX 7 examples it’s this data:

struct HitGroupData
    GeometryData geometry_data;
    MaterialData material_data;

template <typename T>
struct Record
    T data;  // optixGetSbtDataPointer() returns a pointer to this data.

typedef Record<RayGenData>   RayGenRecord;
typedef Record<MissData>     MissRecord;
typedef Record<HitGroupData> HitGroupRecord; // This is how the structure for hit records is defined. 

// Search the code for "hitgroupRecordBase" and you'll see how it's built per example and what data is entered.

Thanks for the clarification. Can OptiX only access data passed through the SBT or can it access other data passed using cudaMemcpy?

Please read the whole OptiX 7 Programming Guide and work through some examples.

You can access any data passed via the SBT records or via the pipeline launch parameters.

Also see this post as well: