SDK Samples: sutil :: getPtxString? file path?

That is one of my pet peeves in the OptiX SDK examples and also in the OptiX Advanced Samples on github.

They both hardcode the locations of the sample’s directory and location of the *.ptx files into the compiled samples, which means they only run where you actually built them, unless you set the two environment values OPTIX_SAMPLES_DIR and OPTIX_SAMPLES_PTX_DIR.
Search for these in the code to find how the folder names for SAMPLES_DIR and SAMPLES_PTX_DIR are generated.

In my own OptiX application frameworks, I store all *.ptx files in an application specific folder relative to the executable, e.g. my_app.exe loads the raygeneration code from “./my_app_ptx/raygeneration.ptx”. I also do that for runtime generated material shaders using NVRTC.
Works anywhere when copied around!
Looks like that inside the code then:

m_mapOfPrograms["raygeneration"] = m_context->createProgramFromPTXFile("./my_app_ptx/raygeneration.ptx", "raygeneration");

Additionally the *.cu to *.ptx CUDA compilation rule bloats the name of the generated *.ptx file to uniquely identify it per application and *.cu file because they are all stored in a single folder of the SDK and some of the programs in the OptiX SDK 6.0.0\SDK\cuda folder are shared among multiple examples.
In the precompiled examples those resulting *.ptx files are all in OptiX SDK 6.0.0\SDK-precompiled-samples\ptx including your optixTutorial ones.

I’m not using any of that sutil functionality but only link against OptiX. With separate folders for the *.ptx files per application a raygen.cu is simply compiled to raygen.ptx.

If you’re starting with OptiX, please have a look at the OptiX Introduction presentation video and open source samples from the GTC 2018.
All links here: https://devtalk.nvidia.com/default/topic/998546/optix/optix-advanced-samples-on-github/
That code also contains a comment about those hardcoded paths.
https://github.com/nvpro-samples/optix_advanced_samples/blob/master/src/optixIntroduction/optixIntro_07/src/Application.cpp#L55

1 Like