Twinklebear/ChameleonRT

Do I need to change "render_optix_ptx" if I change the render_optix.cu file when use optix backend

caihuanrose311 opened this issue · 3 comments

Hi, I find that in the nvidia optix 7.0 samples, they use *.cu file to create ptx string.

   const std::string ptx = sutil::getPtxString( OPTIX_SAMPLE_NAME, "geometry.cu" );
    OPTIX_CHECK_LOG( optixModuleCreateFromPTX(
        state.context,
        &module_compile_options,
        &state.pipeline_compile_options,
        ptx.c_str(),
        ptx.size(),
        log,
        &sizeof_log,
        &state.geometry_module ) );

But in ChameleonRT, the ptx file is "render_optix_ptx". Is it created from render_optix.cu? If I changed the code of render_optix.cu, do I need to change render_optix_ptx?

optix::Module module(device,
render_optix_ptx,
sizeof(render_optix_ptx),
optix::DEFAULT_MODULE_COMPILE_OPTIONS,
pipeline_opts);

I known that render_optix_ptx is compiled from *.cu file now

Exactly, there's two options for getting the compiled PTX: you can compile it from a .cu file at runtime (like the optix samples), or build it ahead of time and embed the PTX in the program or read it from some file. ChameleonRT does the second, and embeds the compiled PTX in a generated header file "render_optix_embedded_ptx.h". The compilation step is done here in CMake: https://github.com/Twinklebear/ChameleonRT/blob/master/optix/CMakeLists.txt#L13-L21