Can I not enter the miss shader?

I have designed a custom intersection shader. Some calculation tasks are performed in the intersection shader and the results are directly wrote to the device memory. I do not need to trigger the anyhit, closesthit and miss shader. At present, I can do this without triggering anyhit and closesthit shader, that is, do not call optimxReportIntersection in the intersection shader, but always enter the miss shader. I think getting into the miss shader will cause some overhead. Is there any way to prevent program execution from entering the miss shader?

Thanks in advance.

I’m assuming you’re implementing some algorithm which gathers all intersections along a ray.
In that case, please also read the forum posts from this search result:

If you’re using a custom intersection program for that, you will not be able to benefit from built-in geometric primitives in OptiX 7 that way, which is especially important for performance when using triangles.

Mind that the intersection program is the most often called program in the ray tracing pipeline and is called in BVH traversal order not in ray direction order.

That said, if you never call optixReportIntersection (which would invoke the anyhit and potentially closesthit programs when the anyhit doesn’t call optixIgnoreIntersection) all rays will effectively miss all geometry.
There is no way around that in that case.

Never use an empty miss program! If you don’t need a miss program for a ray type, the fastest miss program is the NULL program.

Meaning if you build your OptixProgramGroupDesc structures for your pipeline, add an entry for kind = OPTIX_PROGRAM_GROUP_KIND_MISS which has nullptr for the miss.module and miss.entryFunctionName fields like this:

  pgd = &programGroupDescriptions[PROGRAM_ID_MISS_SHADOW];
  pgd->miss.module            = nullptr; // Redundant after the memset() above, for code clarity.
  pgd->miss.entryFunctionName = nullptr; // No miss program for shadow rays.

Demonstrated in this example:

Yeah,I use custom primitive.

Got it.

Thank you very much!