Page MenuHome

Cycles: Rework OptiX visibility flags handling
ClosedPublic

Authored by Patrick Mours (pmoursnv) on Sep 22 2021, 9:01 PM.

Details

Summary

Before the visibility test against the visibility flags was performed in an any-hit program in OptiX
(called __anyhit__kernel_optix_visibility_test), which was using the __prim_visibility array.
This is not entirely correct however, since __prim_visibility is filled with the merged visibility
flags of all objects that reference that primitive, so if one object uses different visibility flags
than another object, but they both are instances of the same geometry, they would appear the same
way. The reason that the any-hit program was used rather than the OptiX instance visibility mask is
that the latter is currently limited to 8 bits only, which is not sufficient to contain all Cycles
visibility flags (12 bits).

To mostly fix the problem with multiple instances and different visibility flags, I changed things to
use the OptiX instance visibility mask for a subset of the Cycles visibility flags (PATH_RAY_CAMERA
to PATH_RAY_VOLUME_SCATTER, which fit into 8 bits) and only fall back to the visibility test any-hit
program if that isn't enough (e.g. the ray visibility mask exceeds 8 bits or when using the built-in
curves from OptiX, since the any-hit program is then also used to skip the curve endcaps).

This may also improve performance in some cases, since by default OptiX can now perform the normal
scene intersection trace calls entirely on RT cores without having to jump back to the SM on every
hit to execute the any-hit program.

Fixes T89801

Diff Detail

Repository
rB Blender

Event Timeline

Patrick Mours (pmoursnv) requested review of this revision.Sep 22 2021, 9:01 PM
Patrick Mours (pmoursnv) created this revision.

Benchmark shows differences that are in the noise (changes with each run and had times were it was slower and times were it was faster in all scenes):

This revision is now accepted and ready to land.Sep 27 2021, 3:45 PM