Set empty output buffer

Hi,
is there a way how to set empty output buffer?
If I have in shader program

rtBuffer<float4, 2> output_buffer;

then I must set it from program, because otherwise I got an error when optix validate.

Calling program[“output_buffer”]->setBuffer(NULL); causes program crash.

I need multiple output buffers, but no everytime, something like:

if (isColor)
   color_buffer[index] = color;
if (isNormal)
   normal_buffer[index] = normal;
...

I found some solution with callable programs. So I create callable program for each output buffer and set this buffer into it.
However this solution have two problems:

  • I must have callable program for each buffer (is there a way how to copy optix::Buffer to avoid compile it for each buffer?)
  • When I don’t need this buffer and I remove it, I must remove also this callable program.

Is there other way how to do this?