19 OptixDeviceContext SLOptix::context = {};
20 CUstream SLOptix::stream = {};
21 bool SLOptix::available =
false;
22 string SLOptix::exePath;
25 void context_log_cb(
unsigned int level,
30 std::cerr <<
"[" << std::setw(2) << level <<
"][" << std::setw(12) << tag <<
"]: "
42 void SLOptix::createStreamAndContext()
46 createStreamAndContextOrThrow();
48 catch (std::exception& e)
50 SLOptix::available =
false;
51 SL_LOG(
"**** OptiX is not available on this machine ****");
53 SL_LOG(
"The OptiX menu entries stay disabled. The usual causes are a");
54 SL_LOG(
"display driver too old for the OptiX ABI of the headers in");
55 SL_LOG(
"externals/lib-optix, or no NVIDIA GPU at all.");
60 void SLOptix::createStreamAndContextOrThrow()
64 CUDA_CHECK(cuInit(0));
65 CUDA_CHECK(cuMemFree(0));
72 #if CUDA_VERSION >= 13000
73 CUDA_CHECK(cuCtxCreate(&cu_ctx,
nullptr, 0, 0));
75 CUDA_CHECK(cuCtxCreate(&cu_ctx, 0, 0));
77 CUDA_CHECK(cuStreamCreate(&SLOptix::stream,
81 OPTIX_CHECK(optixInit());
82 OptixDeviceContextOptions options = {};
83 options.logCallbackFunction = &context_log_cb;
84 options.logCallbackLevel = 4;
85 OPTIX_CHECK(optixDeviceContextCreate(cu_ctx,
89 SLOptix::available =
true;
#define SL_LOG(...)
Some debugging and error handling macros.
Error checking macros and helpers for the OptiX ray tracer.