Changing the size of an Optix::Buffer

What is the appropriate way of changing the size of a buffer after a context has been created (between trace calls).

Example workflow:

Buffer eyeHitBuffer = _context->createBuffer(RT_BUFFER_OUTPUT);
eyeHitBuffer->setFormat(RT_FORMAT_USER);
eyeHitBuffer->setElementSize(sizeof(HitRecord));
eyeHitBuffer->setSize(WIDTH, HEIGHT);
_context[ “eyeHitBuffer” ]->set(eyeHitBuffer);

trace()

eyeHitBuffer->setSize(NEW_WIDTH, NEW_HEIGHT);

Is this sufficient or is it also necessary to use _context[ “eyeHitBuffer” ]->set(eyeHitBuffer) again?

Thanks!
Josh

You can take a look at most of the resize function for the windowing in the Optix SDK:

_context[“eyeHitBuffer”]->getBuffer()->setSize(NEW_WIDTH, NEW_HEIGHT);

mdkoa1 is correct. You don’t need to reattach it to the context again. Just set the new size. Note that this will invalidate all the data associated with the buffer.