I am trying to get CUDA OptiX interop working.
I plan on allocating memory on CUDA and make OptiX Buffer use it.
My code is as follows:
Buffer vertex_buffer = m_context->createBufferForCUDA(RT_BUFFER_INPUT, RT_FORMAT_FLOAT3, nverts); float3 *d_ptr; cudaMalloc((void **)&d_ptr, sizeof(float3)*nverts); cudaMemcpy( d_ptr, verts, sizeof(float3)*nverts, cudaMemcpyHostToDevice); vertex_buffer->setDevicePointer(0, (CUdeviceptr)d_ptr);
I got an uncaught exception at setDevicePointer(). The error message is as follows:
First-chance exception at 0x000007fefd92cacd in sample.exe: Microsoft C++ exception: cudaError at memory location 0x001fdb20..
I have two cards on my machine. One is low-end NVS 300 and the other is GTX 670.
Since the major compute capability of those two cards doesn’t match, only GTX 670 should be used by OptiX. Even if I force device to be used by Buffer::setDevices(), it still doesn’t work.
Could the device memory address converting between Driver and Runtime API and issue?
I tried (CUdeviceptr)(uintptr_t) to cast on d_ptr, but still with no luck.
Any one have any idea on what might go wrong?