Hello all,
I apologize if this is too simple a question, but here goes. Is it possible to create a custom intersection program with OptiX 7 such that an integer parameter is passed to it? for example, I have a .cu file with the following CUDA code snippet:
extern "C" __global__ void __intersection__quad(int qIdx) { ... }
which is successfully compiled to PTX code, which for purposes of this question I will call is_ptx (a string). Later, in my main.cpp file I go to build an OptixModule from the PTX code as follows:
OptixPipelineCompileOptions pipeline_compile_options = {};
// Default options MUST be consistent for all modules used in a SINGLE pipeline
OptixModuleCompileOptions module_compile_options = {};
module_compile_options.maxRegisterCount = OPTIX_COMPILE_DEFAULT_MAX_REGISTER_COUNT;
module_compile_options.optLevel = OPTIX_COMPILE_OPTIMIZATION_DEFAULT;
module_compile_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_LINEINFO;
pipeline_compile_options.usesMotionBlur = false;
// This option is important to ensure we compile code which is optimal for
// out scene hierarchy. We use a SINGLE GAS - no instancing or multi-level
// hierarchies
pipeline_compile_options.traversableGraphFlags = OPTIX_TRAVERSABLE_GRAPH_FLAG_ALLOW_SINGLE_GAS;
// Our DEVICE code uses 2 payload registers
pipeline_compile_options.numPayloadValues = 2;
pipeline_compile_options.numAttributeValues = 2;
pipeline_compile_options.exceptionFlags = OPTIX_EXCEPTION_FLAG_STACK_OVERFLOW |
OPTIX_EXCEPTION_FLAG_TRACE_DEPTH |
OPTIX_EXCEPTION_FLAG_USER |
OPTIX_EXCEPTION_FLAG_DEBUG;
// This is the name of the launch parameter struct in our DEVICE code
// e.g. LaunchParameter params
pipeline_compile_options.pipelineLaunchParamsVariableName = "params";
OptixModule moduleIS = nullptr;
{
// Get PTX shader IntersectionReflectQuad - i.e. Intersection program
std::cout << "Reading PTX shader (Intersection) that was previously compiled ...\n";
std::string is_ptx;
getShaderString(optix7_ptx::IntersectReflectQuad, is_ptx);
std::cout << "Creating Intersection module ...\n";
// Create actual module from PTX
OPTIX_CHECK_LOG(optixModuleCreateFromPTX(context, &module_compile_options,
&pipeline_compile_options, is_ptx.c_str(),
is_ptx.size(), log, &sizeof_log, &moduleIS));
}
Where ‘context’ above is GPU DEVICE context, successfully set previously in file. However, when I try to run this I get a segmentation fault.
I am guessing that maybe there needs to be a special setting in compile/pipeline options - or maybe I am completely off the mark. Hopefully something very simple :)
Anyway, any hints/help would be greatly appreciated.
Thanks