OptiX6.0 in Unity3D

I am facing a very strange problem now.

I made my OptiX program into a DLL, and when I put it in the C # console program, everything worked fine. Putting it in Unity3D to call the ray tracing calculation gave me an error and the program crashed.
After debugging, it is found that there is no error when the Unity program runs to the
“const char* testPtx = getPtxString(“draw_color.cu”);” API, but when it runs to the
“Program ray_gen_program1 = context1->createProgramFromPTXString(testPtx, “draw_solid_color”);” API, it crashes and freezes. But after this time, I called the optixHello program in the SDK through the same DLL to run normally when the Check function was removed, but the window popped up by OpenGL did not display any color.

In addition, I found that when compiling PTX code in Unity programs, no matter the path of the .cu file is correct, no matter whether the code in the file is correct, it passes in the SDK API like this(rtProgramCreateFromPTXString(context, ptx, “draw_solid_color”, &ray_gen_program);), but in the end, it does not output correctly in OpenGL. Result (a picture with a custom color).

So can the DLL made by Optix be called by Unity to calculate?

Sounds like something is going wrong with your PTX files or loading of them. Any further analysis would require much more information.

I would generally not recommend using the OptiX SDK examples’ sutil library in applications outside the OptiX SDK example environment because that is using hard-coded paths to resources.
https://devtalk.nvidia.com/default/topic/1047922/optix/sdk-samples-sutil-getptxstring-file-path-/post/5317954

Very right, I did not use the getPtx function in the sutil library, because there is a parameter in this function about the folder path, which is very inconvenient and almost impossible to use.
After much debugging, I can prove:
1.Unity3D game development engine can use DLL, and I have correctly used and calculated CUDA packaged DLL.
2. I have successfully packaged my OptiX program and the Hello program in the official SDK as a DLL. I called this external module through the C # console program under the VS2017 platform, and it has been successful.
3. At this time I started using this DLL module in Unity, and I found that Unity3d’s next line of code for getPtx crashed directly, while another API worked but had no results.
The crashing code is: (Program ray_gen_program1 = context1-> createProgramFromPTXString (testPtx, “draw_solid_color”);)
But it works: (rtProgramCreateFromPTXString (context, ptx, “draw_solid_color”, & ray_gen_program);)
Ignore the variable names here, for example. Here my console program call in C # runs successfully and is calculated correctly.

@qrb195217 Did you ever manage to solve this problem?

I’m having a very similar problem with my C# wrapper of the GVDB library which utilizes 2 .ptx files. When I run my wrapper in a C# console app, with the .ptx files next to the executable everything runs fine. As soon as I put the same files in a unity project, my .dll works, but apparently the .ptx files fail to load, Unity crashes immediately and I get the following error in the crash dump:

GVDB CUDA ERROR:
Launch status: file not found
Kernel status: no error
Caller: VolumeGVDB::LoadFunction
Call:   cuModuleLoad
Args:   cuda_gvdb_module.ptx