Vertex Buffer and Index buffer stride

Hi everyone.
I declared my vertex buffer as a float3 buffer and my index buffer as an int3 buffer.
When setting index_buffer_stride and vertex_buffer_stride in the acceleration structures, what value should I put, 0 or 4, becouse I don’t know if CUDA pads float3 to 16 bytes?
I tried ti find out but couldn’t get sure on what is correct, and OptiX doesn’t give any inofrmation if the value I’m setting is correct.
Thanks in advance

I have used 0 for stride without any problems. That is the default.

If you look into the OptiX programming guide Table 3 Acceleration structure properties it explains that vertex_buffer_stride is the offset between two vertices in the vertex buffer, given in bytes.
That means the offset between two float3 vertices which are tightly packed is sizeof(optix::float3) or 3 * sizeof(float) == 12 bytes. Similar for index_vertex_stride.
The default value 0 means the vertices are tightly packed, so internally it’ll use a stride of 12 bytes.

If you interleave your vertex attribute data per vertex, then the stride would be the size of your vertex attribute structure.

These strides are only required for some acceleration structure builders which need to know the layout on the host, all others only use the bounding box program you provide in which you(!) specify the vertex and index access, which answers your padding question: CUDA cannot pad your user defined buffer or these programs would break.

Though there are performance differences for data vectors: float, float2 and float4 can be loaded with one instruction, float3 is loaded with three instructions using individual floats.
That’s also why there are different memory alignment requirements on these:
float: 4 bytes, float2: 8 bytes, float3: 4 bytes, float4: 16 bytes aligned.