I use OptiX to make some computation, and I need to get back some data. For this I use an output buffer, like this:
optix::Buffer outBuffer; outBuffer=context->createBuffer(RT_BUFFER_OUTPUT, RT_FORMAT_USER, N*N); outBuffer->setElementSize(sizeof(outData)); context["outBuffer"]->set(outBuffer);
My problem is, between two Optix runs, this buffer is not cleared, this mean, data from the first run are still present after the second run.
I achieved to clear the buffer with the code below, but I had to set the buffer as “RT_BUFFER_INPUT_OUTPUT”, which is not really correct.
optix::Buffer outBuffer; outData* pointerOutData; outBuffer=context["outBuffer"]->getBuffer(); pointerOutData = (outData*)outBuffer->map(0, RT_BUFFER_MAP_WRITE_DISCARD); memset(pointerOutData, 0, N*N*sizeof(outData)); outBuffer->unmap();
Is there a way to clear an output buffer, without mapping it on the host and doing a “memset” on it?