Hi all,
I have crashes at launch after resizing buffers. I have several buffers that I have to resize from time to time. For example, I have this buffer I have created as
optix::Buffer b = context->createBuffer(RT_BUFFER_OUTPUT, RT_FORMAT_USER, receivers, transmitters);
b->setElementSize(sizeof(ReceptionInfo));
context["receptionInfoBuffer"]->set(b);
receptionInfoBuffer=b;
I also have a buffer of buffers, created as
optix::Buffer internalRaysBuffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_BUFFER_ID, receivers);
int* buffers = static_cast<int*>(internalRaysBuffer->map());
for (size_t i = 0; i < receivers; i++)
{
optix::Buffer aux = context->createBuffer(RT_BUFFER_INPUT_OUTPUT | RT_BUFFER_GPU_LOCAL, RT_FORMAT_INT, raySphere.elevationSteps, raySphere.azimuthSteps, transmitters);
buffers[i] = aux->getId();
}
internalRaysBuffer->unmap();
context["internalRaysBuffer"]->set(internalRaysBuffer);
I can launch and everything goes well. Then I have to resize. According to the documentation, if I am not missing anything, I could resize the buffer simply as
receptionInfoBuffer->setSize(newReceivers, 1u);
for instance.
And for the buffer of buffers I do
internalRaysBuffer->setSize(newReceivers);
int* buffers = static_cast<int*>(internalRaysBuffer->map());
for (unsigned int i = oldReceivers; i < newReceivers; i++)
{
optix::Buffer aux = context->createBuffer(RT_BUFFER_INPUT_OUTPUT | RT_BUFFER_GPU_LOCAL, RT_FORMAT_INT, raySphere.elevationSteps, raySphere.azimuthSteps, 1u);
buffers[i] = aux->getId();
}
internalRaysBuffer->unmap();
But then if I launch again I have a crash with message error code -1 and message Unknown error (Details: Function “_rtContextLaunch3D” caught exception: Encountered a CUDA error: cudaDriver().CuMemcpyDtoHAsync( dstHost, srcDevice, byteCount, hStream.get() ) returned (719): Launch failed)
I have tried setting again the element size, setting the buffer in the context again and all of this result in the same crashes.
However, if I just destroy() the buffers and create them again, everything works well.
How should I resize the buffers? It is more efficient to resize them or can I just destroy and recreate them?
Thanks a lot.