Yes, avoiding memory accesses is crucial for performance.
The conversions are not actually happening, That is is just a matter of reinterpreting a 32-bit register for the compiler.
Mind that the payload registers are defined as 32-bit unsigned int in OptiX, so the correct conversions are float_as_uint()
and uint_as_float()
or when only used in device code, the built-in versions __float_as_uint()
and __uint_as_float()
directly.
Looks like the OptiX SDK examples have consistently ignored that. I’ll have that fixed.