File indexing completed on 2026-04-09 07:49:42
0001 #pragma once
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "ssys.h"
0014 #include "SOPTIX_OPT.h"
0015
0016 struct SOPTIX_Options
0017 {
0018 static constexpr const char* _LEVEL = "SOPTIX_Options__LEVEL" ;
0019 static int Level();
0020
0021 static constexpr const char* SOPTIX_Options_optLevel = "SOPTIX_Options_optLevel" ;
0022 static constexpr const char* SOPTIX_Options_debugLevel = "SOPTIX_Options_debugLevel" ;
0023 static constexpr const char* SOPTIX_Options_exceptionFlags = "SOPTIX_Options_exceptionFlags" ;
0024 static constexpr const char* SOPTIX_Options_link_debugLevel = "SOPTIX_Options_link_debugLevel" ;
0025
0026 const char* _optLevel ;
0027 const char* _debugLevel ;
0028 const char* _exceptionFlags ;
0029 const char* _link_debugLevel ;
0030
0031
0032 unsigned _numPayloadValues ;
0033 unsigned _numAttributeValues ;
0034
0035 static constexpr const char* SOPTIX_Options_maxTraceDepth = "SOPTIX_Options_maxTraceDepth" ;
0036 unsigned _maxTraceDepth ;
0037
0038 OptixModuleCompileOptions moduleCompileOptions = {};
0039 OptixPipelineCompileOptions pipelineCompileOptions = {};
0040 OptixProgramGroupOptions programGroupOptions = {};
0041 OptixPipelineLinkOptions pipelineLinkOptions = {};
0042
0043 std::string desc() const ;
0044
0045 SOPTIX_Options() ;
0046 void init();
0047
0048 void init_moduleCompileOptions();
0049 static std::string Desc_moduleCompileOptions(const OptixModuleCompileOptions& module_compile_options );
0050
0051 void init_pipelineCompileOptions();
0052 static std::string Desc_pipelineCompileOptions(const OptixPipelineCompileOptions& pipeline_compile_options );
0053
0054 void init_pipelineLinkOptions();
0055 static std::string Desc_pipelineLinkOptions(const OptixPipelineLinkOptions& pipeline_link_options );
0056
0057 };
0058
0059 inline int SOPTIX_Options::Level()
0060 {
0061 return ssys::getenvint(_LEVEL, 0);
0062 }
0063
0064
0065 inline std::string SOPTIX_Options::desc() const
0066 {
0067 std::stringstream ss ;
0068 ss << "[SOPTIX_Options::desc" << std::endl ;
0069 ss << " _LEVEL " << _LEVEL << std::endl ;
0070 ss << " Level " << Level() << std::endl ;
0071 ss << " _optLevel " << _optLevel << std::endl ;
0072 ss << " _debugLevel " << _debugLevel << std::endl ;
0073 ss << " _exceptionFlags " << _exceptionFlags << std::endl ;
0074 ss << " _link_debugLevel " << _link_debugLevel << std::endl ;
0075 ss << Desc_moduleCompileOptions(moduleCompileOptions) ;
0076 ss << Desc_pipelineCompileOptions(pipelineCompileOptions) ;
0077 ss << Desc_pipelineLinkOptions(pipelineLinkOptions) ;
0078 ss << "]SOPTIX_Options::desc" << std::endl ;
0079 std::string str = ss.str() ;
0080 return str ;
0081 }
0082
0083 inline SOPTIX_Options::SOPTIX_Options()
0084 :
0085 _optLevel( ssys::getenvvar(SOPTIX_Options_optLevel, "DEFAULT" ) ),
0086 _debugLevel( ssys::getenvvar(SOPTIX_Options_debugLevel, "DEFAULT" ) ),
0087 _exceptionFlags( ssys::getenvvar(SOPTIX_Options_exceptionFlags, "STACK_OVERFLOW" ) ),
0088 _link_debugLevel( ssys::getenvvar(SOPTIX_Options_link_debugLevel, "DEFAULT" )),
0089 _numPayloadValues(2),
0090 _numAttributeValues(2),
0091 _maxTraceDepth(ssys::getenvunsigned(SOPTIX_Options_maxTraceDepth, 2))
0092 {
0093 init();
0094 }
0095
0096 inline void SOPTIX_Options::init()
0097 {
0098 init_moduleCompileOptions();
0099 init_pipelineCompileOptions();
0100 init_pipelineLinkOptions();
0101 }
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112 inline void SOPTIX_Options::init_moduleCompileOptions()
0113 {
0114 OptixCompileOptimizationLevel optLevel = SOPTIX_OPT::OptimizationLevel(_optLevel) ;
0115 OptixCompileDebugLevel debugLevel = SOPTIX_OPT::DebugLevel(_debugLevel) ;
0116
0117 const OptixModuleCompileBoundValueEntry* boundValues = nullptr ;
0118 unsigned numBoundValues = 0 ;
0119 unsigned numPayloadTypes = 0 ;
0120 OptixPayloadType* payloadTypes = nullptr ;
0121
0122 moduleCompileOptions.maxRegisterCount = OPTIX_COMPILE_DEFAULT_MAX_REGISTER_COUNT ;
0123 moduleCompileOptions.optLevel = optLevel ;
0124 moduleCompileOptions.debugLevel = debugLevel ;
0125 moduleCompileOptions.boundValues = boundValues ;
0126 moduleCompileOptions.numBoundValues = numBoundValues ;
0127 moduleCompileOptions.numPayloadTypes = numPayloadTypes ;
0128 moduleCompileOptions.payloadTypes = payloadTypes ;
0129 }
0130
0131 inline std::string SOPTIX_Options::Desc_moduleCompileOptions(const OptixModuleCompileOptions& module_compile_options )
0132 {
0133 std::stringstream ss ;
0134 ss
0135 << "[SOPTIX_Options::Desc_moduleCompileOptions" << std::endl
0136 << " module_compile_options.maxRegisterCount " << module_compile_options.maxRegisterCount
0137 << " OPTIX_COMPILE_DEFAULT_MAX_REGISTER_COUNT " << OPTIX_COMPILE_DEFAULT_MAX_REGISTER_COUNT
0138 << std::endl
0139 << " module_compile_options.optLevel " << module_compile_options.optLevel
0140 << " " << SOPTIX_OPT::OptimizationLevel_( module_compile_options.optLevel )
0141 << std::endl
0142 << " module_compile_options.debugLevel " << module_compile_options.debugLevel
0143 << " " << SOPTIX_OPT::DebugLevel_( module_compile_options.debugLevel )
0144 << std::endl
0145 << "]SOPTIX_Options::Desc_moduleCompileOptions"
0146 << std::endl
0147 ;
0148 std::string str = ss.str() ;
0149 return str ;
0150 }
0151
0152 inline void SOPTIX_Options::init_pipelineCompileOptions()
0153 {
0154 int usesMotionBlur = 0 ;
0155
0156 OptixTraversableGraphFlags traversableGraphFlags = OPTIX_TRAVERSABLE_GRAPH_FLAG_ALLOW_ANY ;
0157
0158
0159
0160
0161 unsigned numPayloadValues = _numPayloadValues ;
0162 unsigned numAttributeValues = _numAttributeValues ;
0163 unsigned exceptionFlags = SOPTIX_OPT::ExceptionFlags( _exceptionFlags ) ;
0164 const char* pipelineLaunchParamsVariableName = "params";
0165
0166 unsigned usesPrimitiveTypeFlags = OPTIX_PRIMITIVE_TYPE_FLAGS_TRIANGLE ;
0167
0168 pipelineCompileOptions.usesMotionBlur = usesMotionBlur ;
0169 pipelineCompileOptions.traversableGraphFlags = traversableGraphFlags ;
0170 pipelineCompileOptions.numPayloadValues = numPayloadValues ;
0171 pipelineCompileOptions.numAttributeValues = numAttributeValues ;
0172 pipelineCompileOptions.exceptionFlags = exceptionFlags ;
0173 pipelineCompileOptions.pipelineLaunchParamsVariableName = pipelineLaunchParamsVariableName ;
0174 pipelineCompileOptions.usesPrimitiveTypeFlags = usesPrimitiveTypeFlags ;
0175 }
0176
0177 inline std::string SOPTIX_Options::Desc_pipelineCompileOptions(const OptixPipelineCompileOptions& pipeline_compile_options )
0178 {
0179 std::stringstream ss ;
0180 ss
0181 << "[SOPTIX_Options::Desc_pipelineCompileOptions" << std::endl
0182 << " pipeline_compile_options.numPayloadValues " << pipeline_compile_options.numPayloadValues << std::endl
0183 << " pipeline_compile_options.numAttributeValues " << pipeline_compile_options.numAttributeValues << std::endl
0184 << " pipeline_compile_options.exceptionFlags " << pipeline_compile_options.exceptionFlags
0185 << SOPTIX_OPT::Desc_ExceptionFlags( pipeline_compile_options.exceptionFlags )
0186 << std::endl
0187 << "]SOPTIX_Options::Desc_pipelineCompileOptions" << std::endl
0188 ;
0189 std::string str = ss.str() ;
0190 return str ;
0191 }
0192
0193
0194
0195 inline void SOPTIX_Options::init_pipelineLinkOptions()
0196 {
0197 OptixPayloadType* payloadType = nullptr ;
0198 programGroupOptions.payloadType = payloadType ;
0199
0200 #if OPTIX_VERSION <= 70600
0201 OptixCompileDebugLevel debugLevel = SOPTIX_OPT::DebugLevel(_link_debugLevel) ;
0202 pipelineLinkOptions.debugLevel = debugLevel ;
0203 #endif
0204 pipelineLinkOptions.maxTraceDepth = _maxTraceDepth ;
0205 }
0206
0207 inline std::string SOPTIX_Options::Desc_pipelineLinkOptions(const OptixPipelineLinkOptions& pipeline_link_options )
0208 {
0209 std::stringstream ss ;
0210 ss
0211 << "[SOPTIX_Options::Desc_pipelineLinkOptions" << std::endl
0212 << " pipeline_link_options.maxTraceDepth " << pipeline_link_options.maxTraceDepth << std::endl
0213 << std::endl
0214 #if OPTIX_VERSION <= 70600
0215 << " pipeline_link_options.debugLevel " << pipeline_link_options.debugLevel
0216 << " " << SOPTIX_OPT::DebugLevel_( pipeline_link_options.debugLevel )
0217 #endif
0218 << "]SOPTIX_Options::Desc_pipelineLinkOptions" << std::endl
0219 ;
0220 std::string str = ss.str() ;
0221 return str ;
0222 }
0223
0224