Normalize entire buffer

Is there any easy way to normalize float values in a buffer? Currently, I’m implementing a cuda program to scan my output buffer for the min/max values and then scale each element. I feel like this might be something that may have a simpler solution.

Essentially i want to autogain the image.

You might consider using the new CUDA interop feature of OptiX 3.0 with some algorithms from Thrust (Google Code Archive - Long-term storage for Google Code Project Hosting.). Thrust includes code for doing parallel reduction and scan.

OptiX doesn’t directly support reduction and scan from within a ray generation program without using atomics (note there is only support for atomicAdd for float).