Hi, I’m new into the OptiX world and it would be great if someone can help me with the following:
The problem I’m facing is the same asked by OmSp in his second question here: https://devtalk.nvidia.com/default/topic/1013672/optix/using-texture-memory/
In my implementation, I have two buffers, the first one is used to do some calculations (using cufft) and the second one is a copy of the first to be used in a TextureSampler (I get an error if I try to use the same buffer for the fft and TextureSampler). My problem comes when I need to update de TextureSampler’s data with the result of the fft. I get it to work by copying data to host and then back to gpu, doing something like this:
fftBuffer = context->createBuffer(RT_BUFFER_INPUT_OUTPUT, RT_FORMAT_FLOAT, fftSize, fftSize); samplerBuffer = context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_FLOAT, fftSize, fftSize); (...) // Copying data from one buffer to the other float* dataOrigin = reinterpret_cast<float*>(fftBuffer->map()); float* dataDestination = reinterpret_cast<float*>(samplerBuffer->map()); memcpy(dataDestination , dataOrigin , sizeof(float)*fftSize*fftSize); fftBuffer->unmap(); samplerBuffer->unmap();
But this is really inefficient due to the device-host and host-device data transfers. I suppose it wolud be much better if I could do a device2device copy, so I tried this:
cudaError_t lastError = cudaMemcpy(dataDestination, dataOrigin, sizeof(float)*fftSize*fftSize, cudaMemcpyDeviceToDevice);
This code throws “cudaErrorInvalidValue(11)”. Can you give me any hint about what I’m doing wrong or which is the right way to update the TextureSampler buffer efficiently?
Thanks a lot for your time!
- Visual Studio Community 2017
- CUDA 9.1
- OptiX 5.1
- Nvidia GTX 750Ti