What is "built-in" triangle?

Hello, I’m a beginner of OPTIX and I’m creating a module now.

I’ve found a pipeline compile option about primitive type flags.

I’m planning to use only triangle meshes.

So, I’ve added a line of code .
[ pipelineCompileOptions.usesPrimitiveTypeFlags = OPTIX_PRIMITIVE_TYPE_FLAGS_TRIANGLE; ]

However, it is written in the programming guide that OPTIX_PRIMITIVE_TYPE_FLAGS_TRIANGLE is used when the scene contains nothing but “built-in” triangles.

At this time, could you tell me what is the meaning of “built-in”?

First of all, OptiX supports any custom geometric primitive for which you, as the developer, can calculate the axis aligned bounding box (AABB) and calculate the ray-primitive intersection inside an intersections program you provide.

Now, to make use of the much faster hardware triangle intersection routines inside RTX GPUs, OptiX needs to know that the geometric primitives are triangles to use that special case. That’s why there is a specific acceleration structure (AS) build input type for triangles to let OptiX build the AABBs around the triangles and use the hardware ray-triangle intersection. This is meant with “built-in triangle primitives”.
(When running this on non-RTX boards, OptiX will also calculate the AABBs and use a fast intersection program internally.)

To complete that topic, since OptiX 7.1 there are also built-in curve primitives which have an additional AS build input type and will also build the AABBs internally and provide fast intersection programs for the three types (linear, quadratic, cubic B-splines) you need to query and add to the pipeline and use inside the hit record in the shader binding table (SBT).

This is explained inside the Acceleration Structures chapter of the OptiX Programming Guide.

Finally to your actual question: To allow for more pipeline optimizations you can tell OptiX up-front inside the OptixPipelineCompileOptions usesPrimitiveTypeFlags which kind of geometric primitives (custom, triangle, curves) need to be supported by a pipeline, so that OptiX can compile the code more optimally. By default (usesPrimitiveTypeFlags == 0) it supports custom and triangle primitives, but curves must be explicitly enabled there!

Means if you know that there are only built-in triangle primitives used, it’s perfectly fine to set the OptixPipelineCompileOptions usesPrimitiveTypeFlags field to OPTIX_PRIMITIVE_TYPE_FLAGS_TRIANGLE.
Setting it to triangle primitives only, means all your AS build inputs must be of type OptixBuildInputTriangleArray

Please keep reading through the OptiX 7.3 Programming Guide and API Reference and look at the various examples inside the OptiX SDK to see where these things are used. These fundamental things are explained in there.
More OptiX 7 examples can be found when following the sticky post with the OptiX 7.3 release announcement.

Thank you for your detailed reply and advice!

Now I understand exactly what “built-in” is.

I will keep reading through the programming guide and examples as you advised!