28# define __KERNEL_OPTIX__
33static void execute_optix_task(
TaskPool &pool, OptixTask task, OptixResult &failure_reason)
35 OptixTask additional_tasks[16];
36 unsigned int num_additional_tasks = 0;
38 const OptixResult
result = optixTaskExecute(task, additional_tasks, 16, &num_additional_tasks);
39 if (result == OPTIX_SUCCESS) {
40 for (
unsigned int i = 0; i < num_additional_tasks; ++i) {
41 pool.
push([&pool, additional_task = additional_tasks[i], &failure_reason] {
42 execute_optix_task(pool, additional_task, failure_reason);
52 : CUDADevice(info, stats, profiler, headless),
57 launch_params(this,
"kernel_params",
false)
64 const CUDAContextScope scope(
this);
67 OptixDeviceContextOptions
options = {};
69 options.logCallbackFunction = [](
unsigned int level,
const char *,
const char *message,
void *) {
88 LOG_INFO <<
"Using OptiX debug mode.";
89 options.validationMode = OPTIX_DEVICE_CONTEXT_VALIDATION_MODE_ALL;
91 optix_assert(optixDeviceContextCreate(cuContext, &
options, &context));
92 optix_assert(optixDeviceContextSetLogCallback(
95 unsigned int rtcore_version = 0;
96 optix_assert(optixDeviceContextGetProperty(
97 context, OPTIX_DEVICE_PROPERTY_RTCORE_VERSION, &rtcore_version,
sizeof(rtcore_version)));
104 launch_params.alloc_to_device(1);
107OptiXDevice::~OptiXDevice()
110 const CUDAContextScope scope(
this);
112 free_bvh_memory_delayed();
116 launch_params.free();
119 if (optix_module !=
nullptr) {
120 optixModuleDestroy(optix_module);
122 if (mnee_module !=
nullptr) {
123 optixModuleDestroy(mnee_module);
125 if (shader_raytrace_module !=
nullptr) {
126 optixModuleDestroy(shader_raytrace_module);
128 for (
int i = 0; i < 2; ++i) {
129 if (builtin_modules[i] !=
nullptr) {
130 optixModuleDestroy(builtin_modules[i]);
133 for (
int i = 0; i < NUM_PIPELINES; ++i) {
134 if (pipelines[i] !=
nullptr) {
135 optixPipelineDestroy(pipelines[i]);
138 for (
int i = 0; i < NUM_PROGRAM_GROUPS; ++i) {
139 if (groups[i] !=
nullptr) {
140 optixProgramGroupDestroy(groups[i]);
145 if (osl_camera_module !=
nullptr) {
146 optixModuleDestroy(osl_camera_module);
148 if (osl_shadow_module !=
nullptr) {
149 optixModuleDestroy(osl_shadow_module);
151 if (osl_shadow_curve_module !=
nullptr) {
152 optixModuleDestroy(osl_shadow_curve_module);
154 if (osl_volume_module !=
nullptr) {
155 optixModuleDestroy(osl_volume_module);
157 for (
const OptixModule &
module : osl_modules) {
159 optixModuleDestroy(
module);
162 for (
const OptixProgramGroup &group : osl_groups) {
163 if (group !=
nullptr) {
164 optixProgramGroupDestroy(group);
167 osl_colorsystem.free();
170 optixDeviceContextDestroy(context);
175 return make_unique<OptiXDeviceQueue>(
this);
184static string get_optix_include_dir()
186 const char *env_dir = getenv(
"OPTIX_ROOT_DIR");
187 const char *default_dir = CYCLES_RUNTIME_OPTIX_ROOT_DIR;
189 if (env_dir && env_dir[0]) {
190 const string env_include_dir =
path_join(env_dir,
"include");
191 return env_include_dir;
193 if (default_dir[0]) {
194 const string default_include_dir =
path_join(default_dir,
"include");
195 return default_include_dir;
201string OptiXDevice::compile_kernel_get_common_cflags(
const uint64_t kernel_features)
203 string common_cflags = CUDADevice::compile_kernel_get_common_cflags(kernel_features);
206 common_cflags +=
string_printf(
" -I\"%s\"", get_optix_include_dir().c_str());
210 common_cflags +=
" --keep-device-functions";
213 return common_cflags;
216void OptiXDevice::create_optix_module(
TaskPool &pool,
217 OptixModuleCompileOptions &module_options,
222 OptixTask task =
nullptr;
223 result = optixModuleCreateWithTasks(context,
232 if (result == OPTIX_SUCCESS) {
233 pool.
push([&pool, task, &result] { execute_optix_task(pool, task, result); });
239static void add_hit_miss_program_groups(
const OptixProgramGroup *groups,
242 if (groups[PG_MISS] !=
nullptr) {
243 pipeline_groups.push_back(groups[PG_MISS]);
246 for (
int i = HIT_PROGAM_GROUP_OFFSET; i < HIT_PROGAM_GROUP_OFFSET + NUM_HIT_PROGRAM_GROUPS; i++)
248 if (groups[i] !=
nullptr) {
249 pipeline_groups.push_back(groups[i]);
256static unsigned int hit_program_continuation_stack_size(
const OptixStackSizes *stack_size)
258 unsigned int trace_css = 0;
259 for (
int i = HIT_PROGAM_GROUP_OFFSET; i < HIT_PROGAM_GROUP_OFFSET + NUM_HIT_PROGRAM_GROUPS; i++)
261 trace_css = std::max(trace_css, stack_size[i].cssCH);
262 trace_css = std::max(trace_css, stack_size[i].cssIS + stack_size[i].cssAH);
267bool OptiXDevice::load_kernels(
const uint64_t kernel_features)
279 const bool use_osl_shading =
false;
280 const bool use_osl_camera =
false;
286 const bool need_optix_kernels = (kernel_features &
292 string suffix = use_osl_shading ?
"_osl" :
"";
294 if (need_optix_kernels) {
295 ptx_filename =
path_get(
"lib/kernel_optix" + suffix +
".ptx.zst");
296 if (use_adaptive_compilation() ||
path_file_size(ptx_filename) == -1) {
297 std::string optix_include_dir = get_optix_include_dir();
298 if (optix_include_dir.empty()) {
300 "Unable to compile OptiX kernels at runtime. Set OPTIX_ROOT_DIR environment variable "
301 "to a directory containing the OptiX SDK.");
306 "OptiX headers not found at %s, unable to compile OptiX kernels at runtime. Install "
307 "OptiX SDK in the specified location, or set OPTIX_ROOT_DIR environment variable to a "
308 "directory containing the OptiX SDK.",
309 optix_include_dir.c_str()));
316 if (!CUDADevice::load_kernels(kernel_features)) {
320 if (!need_optix_kernels) {
324 const CUDAContextScope scope(
this);
327 if (optix_module !=
nullptr) {
328 optixModuleDestroy(optix_module);
329 optix_module =
nullptr;
331 if (mnee_module !=
nullptr) {
332 optixModuleDestroy(mnee_module);
333 mnee_module =
nullptr;
335 if (shader_raytrace_module !=
nullptr) {
336 optixModuleDestroy(shader_raytrace_module);
337 shader_raytrace_module =
nullptr;
339 for (
int i = 0; i < 2; ++i) {
340 if (builtin_modules[i] !=
nullptr) {
341 optixModuleDestroy(builtin_modules[i]);
342 builtin_modules[i] =
nullptr;
345 for (
int i = 0; i < NUM_PIPELINES; ++i) {
346 if (pipelines[i] !=
nullptr) {
347 optixPipelineDestroy(pipelines[i]);
348 pipelines[i] =
nullptr;
351 for (
int i = 0; i < NUM_PROGRAM_GROUPS; ++i) {
352 if (groups[i] !=
nullptr) {
353 optixProgramGroupDestroy(groups[i]);
359 if (osl_camera_module !=
nullptr) {
360 optixModuleDestroy(osl_camera_module);
361 osl_camera_module =
nullptr;
363 if (osl_shadow_module !=
nullptr) {
364 optixModuleDestroy(osl_shadow_module);
365 osl_shadow_module =
nullptr;
367 if (osl_shadow_curve_module !=
nullptr) {
368 optixModuleDestroy(osl_shadow_curve_module);
369 osl_shadow_curve_module =
nullptr;
371 if (osl_volume_module !=
nullptr) {
372 optixModuleDestroy(osl_volume_module);
373 osl_volume_module =
nullptr;
377 for (
const OptixModule &
module : osl_modules) {
379 optixModuleDestroy(
module);
384 for (
const OptixProgramGroup &group : osl_groups) {
385 if (group !=
nullptr) {
386 optixProgramGroupDestroy(group);
392 OptixModuleCompileOptions module_options = {};
393 module_options.maxRegisterCount = 0;
396 module_options.optLevel = OPTIX_COMPILE_OPTIMIZATION_LEVEL_0;
397 module_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_FULL;
400 module_options.optLevel = OPTIX_COMPILE_OPTIMIZATION_LEVEL_3;
401 module_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_NONE;
404 module_options.boundValues =
nullptr;
405 module_options.numBoundValues = 0;
406 module_options.payloadTypes =
nullptr;
407 module_options.numPayloadTypes = 0;
410 pipeline_options.usesMotionBlur =
false;
411 pipeline_options.traversableGraphFlags =
412 OPTIX_TRAVERSABLE_GRAPH_FLAG_ALLOW_SINGLE_LEVEL_INSTANCING;
413 pipeline_options.numPayloadValues = 8;
414 pipeline_options.numAttributeValues = 2;
415 pipeline_options.exceptionFlags = OPTIX_EXCEPTION_FLAG_NONE;
416 pipeline_options.pipelineLaunchParamsVariableName =
"kernel_params";
418 pipeline_options.usesPrimitiveTypeFlags = OPTIX_PRIMITIVE_TYPE_FLAGS_TRIANGLE;
420 pipeline_options.usesPrimitiveTypeFlags |= OPTIX_PRIMITIVE_TYPE_FLAGS_ROUND_LINEAR |
421 OPTIX_PRIMITIVE_TYPE_FLAGS_ROUND_CATMULLROM;
424 pipeline_options.usesPrimitiveTypeFlags |= OPTIX_PRIMITIVE_TYPE_FLAGS_CUSTOM;
431 pipeline_options.usesMotionBlur =
true;
434 pipeline_options.traversableGraphFlags = OPTIX_TRAVERSABLE_GRAPH_FLAG_ALLOW_ANY;
439 string base_ptx_data;
440 if (use_adaptive_compilation() ||
path_file_size(ptx_filename) == -1) {
441 string cflags = compile_kernel_get_common_cflags(kernel_features);
442 ptx_filename = compile_kernel(cflags, (
"kernel" + suffix).c_str(),
true);
444 LOG_INFO <<
"OptiX: Loading module from " << ptx_filename;
446 set_error(
string_printf(
"Failed to load OptiX kernel from '%s'", ptx_filename.c_str()));
450 auto load_optional_module = [
this, &kernel_features](
const string &name,
451 string &ptx_data) ->
bool {
453 if (use_adaptive_compilation() ||
path_file_size(filename) == -1) {
455 const char *suffix =
"_optix";
456 string source_name = name;
457 const size_t optix_pos = source_name.find(suffix);
458 if (optix_pos != string::npos) {
459 source_name.erase(optix_pos, strlen(suffix));
463 const string cflags = compile_kernel_get_common_cflags(kernel_features);
464 filename = compile_kernel(cflags, source_name.c_str(),
true);
474 string mnee_ptx_data;
476 !load_optional_module(use_osl_shading ?
"kernel_optix_osl_mnee" :
"kernel_optix_mnee",
481 string shader_raytrace_ptx_data;
482 if (use_shader_raytrace &&
483 !load_optional_module(use_osl_shading ?
"kernel_optix_osl_shader_raytrace" :
484 "kernel_optix_shader_raytrace",
485 shader_raytrace_ptx_data))
490 string osl_camera_ptx_data;
491 if (use_osl_camera && !load_optional_module(
"kernel_optix_osl_camera", osl_camera_ptx_data)) {
494 string osl_shadow_ptx_data;
495 if (use_osl_shading && !load_optional_module(
"kernel_optix_osl_shadow", osl_shadow_ptx_data)) {
498 string osl_shadow_curve_ptx_data;
499 if (use_osl_shading &&
500 !load_optional_module(
"kernel_optix_osl_shadow_curve", osl_shadow_curve_ptx_data))
504 string osl_volume_ptx_data;
505 if (use_osl_volume && !load_optional_module(
"kernel_optix_osl_volume", osl_volume_ptx_data)) {
511 OptixResult base_result = OPTIX_SUCCESS;
512 OptixResult mnee_result = OPTIX_SUCCESS;
513 OptixResult shader_raytrace_result = OPTIX_SUCCESS;
515 OptixResult osl_camera_result = OPTIX_SUCCESS;
516 OptixResult osl_shadow_result = OPTIX_SUCCESS;
517 OptixResult osl_shadow_curve_result = OPTIX_SUCCESS;
518 OptixResult osl_volume_result = OPTIX_SUCCESS;
522 LOG_INFO <<
"OptiX: Creating modules.";
523 create_optix_module(pool, module_options, base_ptx_data, optix_module, base_result);
525 create_optix_module(pool, module_options, mnee_ptx_data, mnee_module, mnee_result);
527 if (use_shader_raytrace) {
528 create_optix_module(pool,
530 shader_raytrace_ptx_data,
531 shader_raytrace_module,
532 shader_raytrace_result);
535 if (use_osl_shading) {
537 pool, module_options, osl_shadow_ptx_data, osl_shadow_module, osl_shadow_result);
538 create_optix_module(pool,
540 osl_shadow_curve_ptx_data,
541 osl_shadow_curve_module,
542 osl_shadow_curve_result);
544 if (use_osl_camera) {
546 pool, module_options, osl_camera_ptx_data, osl_camera_module, osl_camera_result);
548 if (use_osl_volume) {
550 pool, module_options, osl_volume_ptx_data, osl_volume_module, osl_volume_result);
554 LOG_INFO <<
"OptiX: modules created in " << load_module_timer.
get_time() <<
" seconds.";
556 if (base_result != OPTIX_SUCCESS) {
557 set_error(
string_printf(
"Failed to load OptiX kernel from '%s' (%s)",
558 ptx_filename.c_str(),
559 optixGetErrorName(base_result)));
562 if (mnee_result != OPTIX_SUCCESS) {
564 string_printf(
"Failed to load OptiX MNEE kernel (%s)", optixGetErrorName(mnee_result)));
567 if (shader_raytrace_result != OPTIX_SUCCESS) {
568 set_error(
string_printf(
"Failed to load OptiX shader ray-tracing kernel (%s)",
569 optixGetErrorName(shader_raytrace_result)));
573 if (osl_camera_result != OPTIX_SUCCESS) {
574 set_error(
string_printf(
"Failed to load OptiX OSL camera kernel (%s)",
575 optixGetErrorName(osl_camera_result)));
578 if (osl_shadow_result != OPTIX_SUCCESS) {
579 set_error(
string_printf(
"Failed to load OptiX OSL shadow kernel (%s)",
580 optixGetErrorName(osl_shadow_result)));
583 if (osl_shadow_curve_result != OPTIX_SUCCESS) {
584 set_error(
string_printf(
"Failed to load OptiX OSL shadow curve kernel (%s)",
585 optixGetErrorName(osl_shadow_curve_result)));
588 if (osl_volume_result != OPTIX_SUCCESS) {
589 set_error(
string_printf(
"Failed to load OptiX OSL volume kernel (%s)",
590 optixGetErrorName(osl_volume_result)));
597 OptixProgramGroupDesc group_descs[NUM_PROGRAM_GROUPS] = {};
598 OptixProgramGroupOptions group_options = {};
599 group_descs[PG_RGEN_INTERSECT_CLOSEST].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
600 group_descs[PG_RGEN_INTERSECT_CLOSEST].raygen.module = optix_module;
601 group_descs[PG_RGEN_INTERSECT_CLOSEST].raygen.entryFunctionName =
602 "__raygen__kernel_optix_integrator_intersect_closest";
603 group_descs[PG_RGEN_INTERSECT_SHADOW].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
604 group_descs[PG_RGEN_INTERSECT_SHADOW].raygen.module = optix_module;
605 group_descs[PG_RGEN_INTERSECT_SHADOW].raygen.entryFunctionName =
606 "__raygen__kernel_optix_integrator_intersect_shadow";
607 group_descs[PG_RGEN_INTERSECT_SUBSURFACE].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
608 group_descs[PG_RGEN_INTERSECT_SUBSURFACE].raygen.module = optix_module;
609 group_descs[PG_RGEN_INTERSECT_SUBSURFACE].raygen.entryFunctionName =
610 "__raygen__kernel_optix_integrator_intersect_subsurface";
611 group_descs[PG_RGEN_INTERSECT_VOLUME_STACK].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
612 group_descs[PG_RGEN_INTERSECT_VOLUME_STACK].raygen.module = optix_module;
613 group_descs[PG_RGEN_INTERSECT_VOLUME_STACK].raygen.entryFunctionName =
614 "__raygen__kernel_optix_integrator_intersect_volume_stack";
615 group_descs[PG_RGEN_INTERSECT_DEDICATED_LIGHT].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
616 group_descs[PG_RGEN_INTERSECT_DEDICATED_LIGHT].raygen.module = optix_module;
617 group_descs[PG_RGEN_INTERSECT_DEDICATED_LIGHT].raygen.entryFunctionName =
618 "__raygen__kernel_optix_integrator_intersect_dedicated_light";
619 group_descs[PG_MISS].kind = OPTIX_PROGRAM_GROUP_KIND_MISS;
620 group_descs[PG_MISS].miss.module = optix_module;
621 group_descs[PG_MISS].miss.entryFunctionName =
"__miss__kernel_optix_miss";
622 group_descs[PG_HITD].kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
623 group_descs[PG_HITD].hitgroup.moduleCH = optix_module;
624 group_descs[PG_HITD].hitgroup.entryFunctionNameCH =
"__closesthit__kernel_optix_hit";
625 group_descs[PG_HITD].hitgroup.moduleAH = optix_module;
626 group_descs[PG_HITD].hitgroup.entryFunctionNameAH =
"__anyhit__kernel_optix_visibility_test";
627 group_descs[PG_HITS].kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
628 group_descs[PG_HITS].hitgroup.moduleAH = optix_module;
629 group_descs[PG_HITS].hitgroup.entryFunctionNameAH =
"__anyhit__kernel_optix_shadow_all_hit";
630 group_descs[PG_HITV].kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
631 group_descs[PG_HITV].hitgroup.moduleCH = optix_module;
632 group_descs[PG_HITV].hitgroup.entryFunctionNameCH =
"__closesthit__kernel_optix_hit";
633 group_descs[PG_HITV].hitgroup.moduleAH = optix_module;
634 group_descs[PG_HITV].hitgroup.entryFunctionNameAH =
"__anyhit__kernel_optix_volume_test";
636 OptixProgramGroupDesc ignore_desc = {};
637 ignore_desc.kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
638 ignore_desc.hitgroup.moduleCH = optix_module;
639 ignore_desc.hitgroup.entryFunctionNameCH =
"__closesthit__kernel_optix_ignore";
640 ignore_desc.hitgroup.moduleAH = optix_module;
641 ignore_desc.hitgroup.entryFunctionNameAH =
"__anyhit__kernel_optix_ignore";
645 OptixBuiltinISOptions builtin_options = {};
646 builtin_options.builtinISModuleType = OPTIX_PRIMITIVE_TYPE_ROUND_CATMULLROM;
647 builtin_options.buildFlags = OPTIX_BUILD_FLAG_PREFER_FAST_TRACE |
648 OPTIX_BUILD_FLAG_ALLOW_COMPACTION | OPTIX_BUILD_FLAG_ALLOW_UPDATE;
649 builtin_options.curveEndcapFlags = OPTIX_CURVE_ENDCAP_DEFAULT;
650 builtin_options.usesMotionBlur =
false;
652 optix_assert(optixBuiltinISModuleGet(
653 context, &module_options, &pipeline_options, &builtin_options, &builtin_modules[0]));
655 group_descs[PG_HITD].hitgroup.moduleIS = builtin_modules[0];
656 group_descs[PG_HITD].hitgroup.entryFunctionNameIS =
nullptr;
657 group_descs[PG_HITS].hitgroup.moduleIS = builtin_modules[0];
658 group_descs[PG_HITS].hitgroup.entryFunctionNameIS =
nullptr;
660 if (pipeline_options.usesMotionBlur) {
661 builtin_options.usesMotionBlur =
true;
663 optix_assert(optixBuiltinISModuleGet(
664 context, &module_options, &pipeline_options, &builtin_options, &builtin_modules[1]));
666 group_descs[PG_HITD_MOTION] = group_descs[PG_HITD];
667 group_descs[PG_HITD_MOTION].hitgroup.moduleIS = builtin_modules[1];
668 group_descs[PG_HITS_MOTION] = group_descs[PG_HITS];
669 group_descs[PG_HITS_MOTION].hitgroup.moduleIS = builtin_modules[1];
672 builtin_options.builtinISModuleType = OPTIX_PRIMITIVE_TYPE_ROUND_LINEAR;
673 builtin_options.usesMotionBlur =
false;
675 optix_assert(optixBuiltinISModuleGet(
676 context, &module_options, &pipeline_options, &builtin_options, &builtin_modules[2]));
678 group_descs[PG_HITD_CURVE_LINEAR] = group_descs[PG_HITD];
679 group_descs[PG_HITD_CURVE_LINEAR].hitgroup.moduleIS = builtin_modules[2];
680 group_descs[PG_HITS_CURVE_LINEAR] = group_descs[PG_HITS];
681 group_descs[PG_HITS_CURVE_LINEAR].hitgroup.moduleIS = builtin_modules[2];
682 group_descs[PG_HITV_CURVE_LINEAR] = ignore_desc;
683 group_descs[PG_HITL_CURVE_LINEAR] = ignore_desc;
685 if (pipeline_options.usesMotionBlur) {
686 builtin_options.usesMotionBlur =
true;
688 optix_assert(optixBuiltinISModuleGet(
689 context, &module_options, &pipeline_options, &builtin_options, &builtin_modules[3]));
691 group_descs[PG_HITD_CURVE_LINEAR_MOTION] = group_descs[PG_HITD_CURVE_LINEAR];
692 group_descs[PG_HITD_CURVE_LINEAR_MOTION].hitgroup.moduleIS = builtin_modules[3];
693 group_descs[PG_HITS_CURVE_LINEAR_MOTION] = group_descs[PG_HITS_CURVE_LINEAR];
694 group_descs[PG_HITS_CURVE_LINEAR_MOTION].hitgroup.moduleIS = builtin_modules[3];
695 group_descs[PG_HITV_CURVE_LINEAR_MOTION] = ignore_desc;
696 group_descs[PG_HITL_CURVE_LINEAR_MOTION] = ignore_desc;
701 group_descs[PG_HITD_CURVE_RIBBON] = group_descs[PG_HITD];
702 group_descs[PG_HITD_CURVE_RIBBON].kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
703 group_descs[PG_HITD_CURVE_RIBBON].hitgroup.moduleIS = optix_module;
704 group_descs[PG_HITD_CURVE_RIBBON].hitgroup.entryFunctionNameIS =
705 "__intersection__curve_ribbon";
706 group_descs[PG_HITS_CURVE_RIBBON] = group_descs[PG_HITS];
707 group_descs[PG_HITS_CURVE_RIBBON].kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
708 group_descs[PG_HITS_CURVE_RIBBON].hitgroup.moduleIS = optix_module;
709 group_descs[PG_HITS_CURVE_RIBBON].hitgroup.entryFunctionNameIS =
710 "__intersection__curve_ribbon";
711 group_descs[PG_HITV_CURVE_RIBBON] = ignore_desc;
712 group_descs[PG_HITL_CURVE_RIBBON] = ignore_desc;
716 group_descs[PG_HITD_POINTCLOUD] = group_descs[PG_HITD];
717 group_descs[PG_HITD_POINTCLOUD].kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
718 group_descs[PG_HITD_POINTCLOUD].hitgroup.moduleIS = optix_module;
719 group_descs[PG_HITD_POINTCLOUD].hitgroup.entryFunctionNameIS =
"__intersection__point";
720 group_descs[PG_HITS_POINTCLOUD] = group_descs[PG_HITS];
721 group_descs[PG_HITS_POINTCLOUD].kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
722 group_descs[PG_HITS_POINTCLOUD].hitgroup.moduleIS = optix_module;
723 group_descs[PG_HITS_POINTCLOUD].hitgroup.entryFunctionNameIS =
"__intersection__point";
724 group_descs[PG_HITV_POINTCLOUD] = ignore_desc;
725 group_descs[PG_HITL_POINTCLOUD] = ignore_desc;
730 group_descs[PG_HITL].kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
731 group_descs[PG_HITL].hitgroup.moduleAH = optix_module;
732 group_descs[PG_HITL].hitgroup.entryFunctionNameAH =
"__anyhit__kernel_optix_local_hit";
736 if (use_shader_raytrace) {
737 group_descs[PG_RGEN_SHADE_SURFACE_RAYTRACE].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
738 group_descs[PG_RGEN_SHADE_SURFACE_RAYTRACE].raygen.module = shader_raytrace_module;
739 group_descs[PG_RGEN_SHADE_SURFACE_RAYTRACE].raygen.entryFunctionName =
740 "__raygen__kernel_optix_integrator_shade_surface_raytrace";
744 if (!use_osl_shading) {
745 group_descs[PG_CALL_SVM_AO].kind = OPTIX_PROGRAM_GROUP_KIND_CALLABLES;
746 group_descs[PG_CALL_SVM_AO].callables.moduleDC = shader_raytrace_module;
747 group_descs[PG_CALL_SVM_AO].callables.entryFunctionNameDC =
"__direct_callable__svm_node_ao";
748 group_descs[PG_CALL_SVM_BEVEL].kind = OPTIX_PROGRAM_GROUP_KIND_CALLABLES;
749 group_descs[PG_CALL_SVM_BEVEL].callables.moduleDC = shader_raytrace_module;
750 group_descs[PG_CALL_SVM_BEVEL].callables.entryFunctionNameDC =
751 "__direct_callable__svm_node_bevel";
756 group_descs[PG_RGEN_INTERSECT_MNEE].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
757 group_descs[PG_RGEN_INTERSECT_MNEE].raygen.module = mnee_module;
758 group_descs[PG_RGEN_INTERSECT_MNEE].raygen.entryFunctionName =
759 "__raygen__kernel_optix_integrator_intersect_mnee";
764 if (use_osl_shading) {
765 group_descs[PG_RGEN_SHADE_BACKGROUND].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
766 group_descs[PG_RGEN_SHADE_BACKGROUND].raygen.module = optix_module;
767 group_descs[PG_RGEN_SHADE_BACKGROUND].raygen.entryFunctionName =
768 "__raygen__kernel_optix_integrator_shade_background";
769 group_descs[PG_RGEN_SHADE_LIGHT_NEE].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
770 group_descs[PG_RGEN_SHADE_LIGHT_NEE].raygen.module = optix_module;
771 group_descs[PG_RGEN_SHADE_LIGHT_NEE].raygen.entryFunctionName =
772 "__raygen__kernel_optix_integrator_shade_light_nee";
773 group_descs[PG_RGEN_SHADE_LIGHT_FORWARD].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
774 group_descs[PG_RGEN_SHADE_LIGHT_FORWARD].raygen.module = optix_module;
775 group_descs[PG_RGEN_SHADE_LIGHT_FORWARD].raygen.entryFunctionName =
776 "__raygen__kernel_optix_integrator_shade_light_forward";
777 group_descs[PG_RGEN_SHADE_SURFACE].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
778 group_descs[PG_RGEN_SHADE_SURFACE].raygen.module = optix_module;
779 group_descs[PG_RGEN_SHADE_SURFACE].raygen.entryFunctionName =
780 "__raygen__kernel_optix_integrator_shade_surface";
781 if (use_osl_volume) {
782 group_descs[PG_RGEN_SHADE_VOLUME].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
783 group_descs[PG_RGEN_SHADE_VOLUME].raygen.module = osl_volume_module;
784 group_descs[PG_RGEN_SHADE_VOLUME].raygen.entryFunctionName =
785 "__raygen__kernel_optix_integrator_shade_volume";
786 group_descs[PG_RGEN_SHADE_VOLUME_RAY_MARCHING].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
787 group_descs[PG_RGEN_SHADE_VOLUME_RAY_MARCHING].raygen.module = osl_volume_module;
788 group_descs[PG_RGEN_SHADE_VOLUME_RAY_MARCHING].raygen.entryFunctionName =
789 "__raygen__kernel_optix_integrator_shade_volume_ray_marching";
791 group_descs[PG_RGEN_SHADE_SHADOW].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
792 group_descs[PG_RGEN_SHADE_SHADOW].raygen.module = osl_shadow_module;
793 group_descs[PG_RGEN_SHADE_SHADOW].raygen.entryFunctionName =
794 "__raygen__kernel_optix_integrator_shade_shadow";
795 group_descs[PG_RGEN_SHADE_DEDICATED_LIGHT].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
796 group_descs[PG_RGEN_SHADE_DEDICATED_LIGHT].raygen.module = optix_module;
797 group_descs[PG_RGEN_SHADE_DEDICATED_LIGHT].raygen.entryFunctionName =
798 "__raygen__kernel_optix_integrator_shade_dedicated_light";
799 group_descs[PG_RGEN_EVAL_DISPLACE].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
800 group_descs[PG_RGEN_EVAL_DISPLACE].raygen.module = optix_module;
801 group_descs[PG_RGEN_EVAL_DISPLACE].raygen.entryFunctionName =
802 "__raygen__kernel_optix_shader_eval_displace";
803 group_descs[PG_RGEN_EVAL_BACKGROUND].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
804 group_descs[PG_RGEN_EVAL_BACKGROUND].raygen.module = optix_module;
805 group_descs[PG_RGEN_EVAL_BACKGROUND].raygen.entryFunctionName =
806 "__raygen__kernel_optix_shader_eval_background";
807 group_descs[PG_RGEN_EVAL_CURVE_SHADOW_TRANSPARENCY].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
808 group_descs[PG_RGEN_EVAL_CURVE_SHADOW_TRANSPARENCY].raygen.module = osl_shadow_curve_module;
809 group_descs[PG_RGEN_EVAL_CURVE_SHADOW_TRANSPARENCY].raygen.entryFunctionName =
810 "__raygen__kernel_optix_shader_eval_curve_shadow_transparency";
811 group_descs[PG_RGEN_EVAL_VOLUME_DENSITY].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
812 group_descs[PG_RGEN_EVAL_VOLUME_DENSITY].raygen.module = optix_module;
813 group_descs[PG_RGEN_EVAL_VOLUME_DENSITY].raygen.entryFunctionName =
814 "__raygen__kernel_optix_shader_eval_volume_density";
818 if (use_osl_camera) {
819 group_descs[PG_RGEN_INIT_FROM_CAMERA].kind = OPTIX_PROGRAM_GROUP_KIND_RAYGEN;
820 group_descs[PG_RGEN_INIT_FROM_CAMERA].raygen.module = osl_camera_module;
821 group_descs[PG_RGEN_INIT_FROM_CAMERA].raygen.entryFunctionName =
822 "__raygen__kernel_optix_integrator_init_from_camera";
826 optix_assert(optixProgramGroupCreate(
827 context, group_descs, NUM_PROGRAM_GROUPS, &group_options,
nullptr,
nullptr, groups));
830 auto get_pipeline_stack_size = [&](OptixPipeline
pipeline,
832 unsigned int &trace_css) {
834 for (
int i = 0; i < NUM_PROGRAM_GROUPS; ++i) {
836 if (groups[i] !=
nullptr &&
837 std::find(pipeline_groups.begin(), pipeline_groups.end(), groups[i]) !=
838 pipeline_groups.end())
840 optix_assert(optixProgramGroupGetStackSize(groups[i], &stack_size[i], pipeline));
845 trace_css = hit_program_continuation_stack_size(stack_size.data());
851 sbt_data.alloc(NUM_PROGRAM_GROUPS);
852 memset(sbt_data.host_pointer, 0,
sizeof(SbtRecord) * NUM_PROGRAM_GROUPS);
853 for (
int i = 0; i < NUM_PROGRAM_GROUPS; ++i) {
854 if (groups[i] !=
nullptr) {
855 optix_assert(optixSbtRecordPackHeader(groups[i], &sbt_data[i]));
858 sbt_data.copy_to_device();
860 OptixPipelineLinkOptions link_options = {};
861 link_options.maxTraceDepth = 1;
863 if (use_osl_shading || use_osl_camera) {
866 else if (use_shader_raytrace || use_mnee) {
869 pipeline_groups.reserve(NUM_PROGRAM_GROUPS);
870 if (use_shader_raytrace) {
871 pipeline_groups.push_back(groups[PG_RGEN_SHADE_SURFACE_RAYTRACE]);
872 pipeline_groups.push_back(groups[PG_CALL_SVM_AO]);
873 pipeline_groups.push_back(groups[PG_CALL_SVM_BEVEL]);
876 pipeline_groups.push_back(groups[PG_RGEN_INTERSECT_MNEE]);
878 add_hit_miss_program_groups(groups, pipeline_groups);
880 optix_assert(optixPipelineCreate(context,
883 pipeline_groups.data(),
884 pipeline_groups.size(),
887 &pipelines[PIP_SHADE]));
889 unsigned int trace_css;
891 pipelines[PIP_SHADE], pipeline_groups, trace_css);
894 const unsigned int css = std::max(stack_size[PG_RGEN_SHADE_SURFACE_RAYTRACE].cssRG,
895 stack_size[PG_RGEN_INTERSECT_MNEE].cssRG) +
896 link_options.maxTraceDepth * trace_css;
897 const unsigned int dss = std::max(stack_size[PG_CALL_SVM_AO].dssDC,
898 stack_size[PG_CALL_SVM_BEVEL].dssDC);
901 optix_assert(optixPipelineSetStackSize(
902 pipelines[PIP_SHADE], 0, dss, css, pipeline_options.usesMotionBlur ? 3 : 2));
907 pipeline_groups.reserve(NUM_PROGRAM_GROUPS);
908 pipeline_groups.push_back(groups[PG_RGEN_INTERSECT_CLOSEST]);
909 pipeline_groups.push_back(groups[PG_RGEN_INTERSECT_SHADOW]);
910 pipeline_groups.push_back(groups[PG_RGEN_INTERSECT_SUBSURFACE]);
911 pipeline_groups.push_back(groups[PG_RGEN_INTERSECT_VOLUME_STACK]);
912 pipeline_groups.push_back(groups[PG_RGEN_INTERSECT_DEDICATED_LIGHT]);
913 pipeline_groups.push_back(groups[PG_MISS]);
914 pipeline_groups.push_back(groups[PG_HITD]);
915 pipeline_groups.push_back(groups[PG_HITS]);
916 pipeline_groups.push_back(groups[PG_HITL]);
917 pipeline_groups.push_back(groups[PG_HITV]);
918 if (pipeline_options.usesMotionBlur) {
919 pipeline_groups.push_back(groups[PG_HITD_MOTION]);
920 pipeline_groups.push_back(groups[PG_HITS_MOTION]);
923 pipeline_groups.push_back(groups[PG_HITD_CURVE_LINEAR]);
924 pipeline_groups.push_back(groups[PG_HITS_CURVE_LINEAR]);
925 if (pipeline_options.usesMotionBlur) {
926 pipeline_groups.push_back(groups[PG_HITD_CURVE_LINEAR_MOTION]);
927 pipeline_groups.push_back(groups[PG_HITS_CURVE_LINEAR_MOTION]);
931 pipeline_groups.push_back(groups[PG_HITD_CURVE_RIBBON]);
932 pipeline_groups.push_back(groups[PG_HITS_CURVE_RIBBON]);
935 pipeline_groups.push_back(groups[PG_HITD_POINTCLOUD]);
936 pipeline_groups.push_back(groups[PG_HITS_POINTCLOUD]);
939 optix_assert(optixPipelineCreate(context,
942 pipeline_groups.data(),
943 pipeline_groups.size(),
946 &pipelines[PIP_INTERSECT]));
948 unsigned int trace_css;
950 pipelines[PIP_INTERSECT], pipeline_groups, trace_css);
953 const unsigned int css =
954 std::max(stack_size[PG_RGEN_INTERSECT_CLOSEST].cssRG,
955 std::max(stack_size[PG_RGEN_INTERSECT_SHADOW].cssRG,
956 std::max(stack_size[PG_RGEN_INTERSECT_SUBSURFACE].cssRG,
957 stack_size[PG_RGEN_INTERSECT_VOLUME_STACK].cssRG))) +
958 link_options.maxTraceDepth * trace_css;
960 optix_assert(optixPipelineSetStackSize(
961 pipelines[PIP_INTERSECT], 0, 0, css, pipeline_options.usesMotionBlur ? 3 : 2));
964 return !have_error();
967bool OptiXDevice::load_osl_kernels()
979 auto get_osl_kernel = [&](
const OSL::ShaderGroupRef &group) {
985 osl_globals.ss->getattribute(group.get(),
"num_layers", num_layers);
986 if (num_layers == 0) {
993 osl_globals.ss->getattribute(group.get(),
"group_fused_name", fused_name);
994 osl_globals.ss->getattribute(
995 group.get(),
"ptx_compiled_version", OSL::TypeDesc::PTR, &osl_ptx);
997 int groupdata_size = 0;
998 osl_globals.ss->getattribute(group.get(),
"llvm_groupdata_size", groupdata_size);
999 if (groupdata_size == 0) {
1001 osl_globals.ss->getattribute(group.get(),
"groupdata_size", groupdata_size);
1003 if (groupdata_size > 2048) {
1005 string_printf(
"Requested OSL group data size (%d) is greater than the maximum "
1006 "supported with OptiX (2048)",
1011 return OSLKernel{std::move(osl_ptx), std::move(fused_name)};
1017 osl_kernels.emplace_back(get_osl_kernel(osl_globals.camera_state));
1018 for (
const OSL::ShaderGroupRef &group : osl_globals.surface_state) {
1019 osl_kernels.emplace_back(get_osl_kernel(group));
1021 for (
const OSL::ShaderGroupRef &group : osl_globals.volume_state) {
1022 osl_kernels.emplace_back(get_osl_kernel(group));
1024 for (
const OSL::ShaderGroupRef &group : osl_globals.displacement_state) {
1025 osl_kernels.emplace_back(get_osl_kernel(group));
1027 for (
const OSL::ShaderGroupRef &group : osl_globals.bump_state) {
1028 osl_kernels.emplace_back(get_osl_kernel(group));
1035 const CUDAContextScope scope(
this);
1037 if (pipelines[PIP_SHADE]) {
1038 optixPipelineDestroy(pipelines[PIP_SHADE]);
1041 for (OptixModule &
module : osl_modules) {
1043 optixModuleDestroy(
module);
1047 for (OptixProgramGroup &group : osl_groups) {
1048 if (group !=
nullptr) {
1049 optixProgramGroupDestroy(group);
1056 if (osl_kernels.size() == 1 && osl_kernels[0].ptx.empty()) {
1060 OptixProgramGroupOptions group_options = {};
1061 OptixModuleCompileOptions module_options = {};
1062 module_options.optLevel = OPTIX_COMPILE_OPTIMIZATION_LEVEL_3;
1063 module_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_NONE;
1067 size_t id_osl_services = osl_kernels.size();
1068 size_t id_osl_shadeops = osl_kernels.size() + 1;
1069 osl_groups.resize(osl_kernels.size() + 2);
1070 osl_modules.resize(osl_kernels.size() + 2);
1073 string osl_services_ptx, ptx_filename =
path_get(
"lib/kernel_optix_osl_services.ptx.zst");
1075 set_error(
string_printf(
"Failed to load OptiX OSL services kernel from '%s'",
1076 ptx_filename.c_str()));
1080 const char *shadeops_ptx_ptr =
nullptr;
1081 osl_globals.ss->getattribute(
"shadeops_cuda_ptx", OSL::TypeDesc::PTR, &shadeops_ptx_ptr);
1082 int shadeops_ptx_size = 0;
1083 osl_globals.ss->getattribute(
"shadeops_cuda_ptx_size", OSL::TypeDesc::INT, &shadeops_ptx_size);
1084 string shadeops_ptx(shadeops_ptx_ptr, shadeops_ptx_size);
1087 OptixResult services_result, shadeops_result;
1090 LOG_INFO <<
"OptiX: Creating OSL services and shaderops modules.";
1091 create_optix_module(
1092 pool, module_options, osl_services_ptx, osl_modules[id_osl_services], services_result);
1093 create_optix_module(
1094 pool, module_options, shadeops_ptx, osl_modules[id_osl_shadeops], shadeops_result);
1096 LOG_INFO <<
"OptiX: OSL services and shaderops modules created in " << timer.
get_time()
1101 if (services_result != OPTIX_SUCCESS) {
1102 set_error(
string_printf(
"Failed to load OptiX OSL services kernel from '%s' (%s)",
1103 ptx_filename.c_str(),
1104 optixGetErrorName(services_result)));
1107 OptixProgramGroupDesc group_desc = {};
1108 group_desc.kind = OPTIX_PROGRAM_GROUP_KIND_CALLABLES;
1109 group_desc.callables.entryFunctionNameDC =
"__direct_callable__dummy_services";
1110 group_desc.callables.moduleDC = osl_modules[id_osl_services];
1112 optix_assert(optixProgramGroupCreate(context,
1118 &osl_groups[id_osl_services]));
1122 if (shadeops_result != OPTIX_SUCCESS) {
1123 set_error(
string_printf(
"Failed to load OptiX OSL shadeops kernel (%s)",
1124 optixGetErrorName(shadeops_result)));
1127 OptixProgramGroupDesc group_desc = {};
1128 group_desc.kind = OPTIX_PROGRAM_GROUP_KIND_CALLABLES;
1129 group_desc.callables.entryFunctionNameDC =
"__direct_callable__dummy_shadeops";
1130 group_desc.callables.moduleDC = osl_modules[id_osl_shadeops];
1132 optix_assert(optixProgramGroupCreate(context,
1138 &osl_groups[id_osl_shadeops]));
1147 LOG_INFO <<
"OptiX: Creating OSL kernel modules.";
1148 for (
size_t i = 0; i < osl_kernels.size(); ++i) {
1149 if (osl_kernels[i].ptx.empty()) {
1152 create_optix_module(pool, module_options, osl_kernels[i].ptx, osl_modules[i], results[i]);
1155 LOG_INFO <<
"OptiX: OSL kernel modules created in " << timer.
get_time() <<
" seconds.";
1158 for (
size_t i = 0; i < osl_kernels.size(); ++i) {
1159 if (osl_kernels[i].ptx.empty()) {
1163 if (results[i] != OPTIX_SUCCESS) {
1164 set_error(
string_printf(
"Failed to load OptiX OSL kernel for %s (%s)",
1165 osl_kernels[i].fused_entry.c_str(),
1166 optixGetErrorName(results[i])));
1170 OptixProgramGroupDesc group_desc = {};
1171 group_desc.kind = OPTIX_PROGRAM_GROUP_KIND_CALLABLES;
1172 group_desc.callables.entryFunctionNameDC = osl_kernels[i].fused_entry.c_str();
1173 group_desc.callables.moduleDC = osl_modules[i];
1175 optix_assert(optixProgramGroupCreate(
1176 context, &group_desc, 1, &group_options,
nullptr,
nullptr, &osl_groups[i]));
1180 sbt_data.alloc(NUM_PROGRAM_GROUPS + osl_groups.size());
1181 for (
int i = 0; i < NUM_PROGRAM_GROUPS; ++i) {
1182 if (groups[i] !=
nullptr) {
1183 optix_assert(optixSbtRecordPackHeader(groups[i], &sbt_data[i]));
1186 for (
size_t i = 0; i < osl_groups.size(); ++i) {
1187 if (osl_groups[i] !=
nullptr) {
1188 optix_assert(optixSbtRecordPackHeader(osl_groups[i], &sbt_data[NUM_PROGRAM_GROUPS + i]));
1193 optix_assert(optixSbtRecordPackHeader(osl_groups[id_osl_services],
1194 &sbt_data[NUM_PROGRAM_GROUPS + i]));
1197 sbt_data.copy_to_device();
1199 OptixPipelineLinkOptions link_options = {};
1200 link_options.maxTraceDepth = 0;
1204 pipeline_groups.reserve(NUM_PROGRAM_GROUPS);
1205 pipeline_groups.push_back(groups[PG_RGEN_SHADE_BACKGROUND]);
1206 pipeline_groups.push_back(groups[PG_RGEN_SHADE_LIGHT_NEE]);
1207 pipeline_groups.push_back(groups[PG_RGEN_SHADE_LIGHT_FORWARD]);
1208 pipeline_groups.push_back(groups[PG_RGEN_SHADE_SURFACE]);
1209 if (groups[PG_RGEN_SHADE_SURFACE_RAYTRACE] !=
nullptr) {
1210 pipeline_groups.push_back(groups[PG_RGEN_SHADE_SURFACE_RAYTRACE]);
1212 if (groups[PG_CALL_SVM_AO] !=
nullptr) {
1213 pipeline_groups.push_back(groups[PG_CALL_SVM_AO]);
1215 if (groups[PG_CALL_SVM_BEVEL] !=
nullptr) {
1216 pipeline_groups.push_back(groups[PG_CALL_SVM_BEVEL]);
1218 if (groups[PG_RGEN_INTERSECT_MNEE] !=
nullptr) {
1219 pipeline_groups.push_back(groups[PG_RGEN_INTERSECT_MNEE]);
1221 if (groups[PG_RGEN_SHADE_VOLUME] !=
nullptr) {
1222 pipeline_groups.push_back(groups[PG_RGEN_SHADE_VOLUME]);
1224 pipeline_groups.push_back(groups[PG_RGEN_SHADE_SHADOW]);
1225 pipeline_groups.push_back(groups[PG_RGEN_SHADE_DEDICATED_LIGHT]);
1226 pipeline_groups.push_back(groups[PG_RGEN_EVAL_DISPLACE]);
1227 pipeline_groups.push_back(groups[PG_RGEN_EVAL_BACKGROUND]);
1228 pipeline_groups.push_back(groups[PG_RGEN_EVAL_CURVE_SHADOW_TRANSPARENCY]);
1229 pipeline_groups.push_back(groups[PG_RGEN_INIT_FROM_CAMERA]);
1230 pipeline_groups.push_back(groups[PG_RGEN_EVAL_VOLUME_DENSITY]);
1233 if (groups[PG_RGEN_SHADE_SURFACE_RAYTRACE] !=
nullptr ||
1234 groups[PG_RGEN_INTERSECT_MNEE] !=
nullptr)
1236 link_options.maxTraceDepth = 1;
1237 add_hit_miss_program_groups(groups, pipeline_groups);
1240 for (
const OptixProgramGroup &group : osl_groups) {
1241 if (group !=
nullptr) {
1242 pipeline_groups.push_back(group);
1246 optix_assert(optixPipelineCreate(context,
1249 pipeline_groups.data(),
1250 pipeline_groups.size(),
1253 &pipelines[PIP_SHADE]));
1256 OptixStackSizes stack_size[NUM_PROGRAM_GROUPS] = {};
1259 for (
int i = 0; i < NUM_PROGRAM_GROUPS; ++i) {
1260 if (groups[i] !=
nullptr) {
1262 optixProgramGroupGetStackSize(groups[i], &stack_size[i], pipelines[PIP_SHADE]));
1265 for (
size_t i = 0; i < osl_groups.size(); ++i) {
1266 if (osl_groups[i] !=
nullptr) {
1267 optix_assert(optixProgramGroupGetStackSize(
1268 osl_groups[i], &osl_stack_size[i], pipelines[PIP_SHADE]));
1272 const unsigned int trace_css = hit_program_continuation_stack_size(stack_size);
1273 const unsigned int css = std::max(stack_size[PG_RGEN_SHADE_SURFACE_RAYTRACE].cssRG,
1274 stack_size[PG_RGEN_INTERSECT_MNEE].cssRG) +
1275 link_options.maxTraceDepth * trace_css;
1276 unsigned int dss = std::max(stack_size[PG_CALL_SVM_AO].dssDC,
1277 stack_size[PG_CALL_SVM_BEVEL].dssDC);
1278 for (
unsigned int i = 0; i < osl_stack_size.size(); ++i) {
1279 dss = std::max(dss, osl_stack_size[i].dssDC);
1282 optix_assert(optixPipelineSetStackSize(
1283 pipelines[PIP_SHADE], 0, dss, css, pipeline_options.usesMotionBlur ? 3 : 2));
1295 size_t cpu_data_sizes[2] = {0, 0};
1296 osl_globals.ss->getattribute(
"colorsystem", OSL::TypeDesc::PTR, &cpu_data);
1297 osl_globals.ss->getattribute(
1298 "colorsystem:sizes", TypeDesc(TypeDesc::LONGLONG, 2), (
void *)cpu_data_sizes);
1300 size_t cpu_full_size = cpu_data_sizes[0];
1301 size_t num_strings = cpu_data_sizes[1];
1302 size_t fixed_data_size = cpu_full_size -
sizeof(ustringhash) * num_strings;
1305 uint8_t *gpu_data = osl_colorsystem.alloc(fixed_data_size +
sizeof(
size_t) * num_strings);
1308 memcpy(gpu_data, cpu_data, fixed_data_size);
1311 ustringhash *cpu_strings =
reinterpret_cast<ustringhash *
>(cpu_data + fixed_data_size);
1312 size_t *gpu_strings =
reinterpret_cast<size_t *
>(gpu_data + fixed_data_size);
1313 for (
int i = 0; i < num_strings; i++) {
1314 gpu_strings[i] = cpu_strings[i].hash();
1318 osl_colorsystem.copy_to_device();
1321 &osl_colorsystem.device_pointer,
1325 return !have_error();
1331OSLGlobals *OptiXDevice::get_cpu_osl_memory()
1334 return &osl_globals;
1340bool OptiXDevice::build_optix_bvh(BVHOptiX *bvh,
1341 OptixBuildOperation operation,
1342 const OptixBuildInput &build_input,
1343 const uint16_t num_motion_steps)
1352 const CUDAContextScope scope(
this);
1357 OptixAccelBufferSizes sizes = {};
1358 OptixAccelBuildOptions
options = {};
1359 options.operation = operation;
1360 if (build_input.type == OPTIX_BUILD_INPUT_TYPE_CURVES) {
1363 options.buildFlags = OPTIX_BUILD_FLAG_PREFER_FAST_TRACE | OPTIX_BUILD_FLAG_ALLOW_COMPACTION |
1364 OPTIX_BUILD_FLAG_ALLOW_UPDATE;
1365 use_fast_trace_bvh =
true;
1367 else if (use_fast_trace_bvh) {
1368 LOG_INFO <<
"Using fast to trace OptiX BVH";
1369 options.buildFlags = OPTIX_BUILD_FLAG_PREFER_FAST_TRACE | OPTIX_BUILD_FLAG_ALLOW_COMPACTION;
1372 LOG_INFO <<
"Using fast to update OptiX BVH";
1373 options.buildFlags = OPTIX_BUILD_FLAG_PREFER_FAST_BUILD | OPTIX_BUILD_FLAG_ALLOW_UPDATE;
1376 options.motionOptions.numKeys = num_motion_steps;
1377 options.motionOptions.flags = OPTIX_MOTION_FLAG_START_VANISH | OPTIX_MOTION_FLAG_END_VANISH;
1378 options.motionOptions.timeBegin = 0.0f;
1379 options.motionOptions.timeEnd = 1.0f;
1381 optix_assert(optixAccelComputeMemoryUsage(context, &
options, &build_input, 1, &sizes));
1385 temp_mem.alloc_to_device(
align_up(sizes.tempSizeInBytes, 8) + 8);
1386 if (!temp_mem.device_pointer) {
1393 if (operation == OPTIX_BUILD_OPERATION_BUILD) {
1405 OptixAccelEmitDesc compacted_size_prop = {};
1406 compacted_size_prop.
type = OPTIX_PROPERTY_TYPE_COMPACTED_SIZE;
1409 compacted_size_prop.result =
align_up(temp_mem.device_pointer + sizes.tempSizeInBytes, 8);
1411 OptixTraversableHandle out_handle = 0;
1412 optix_assert(optixAccelBuild(context,
1417 temp_mem.device_pointer,
1418 sizes.tempSizeInBytes,
1420 sizes.outputSizeInBytes,
1422 use_fast_trace_bvh ? &compacted_size_prop :
nullptr,
1423 use_fast_trace_bvh ? 1 : 0));
1424 bvh->traversable_handle =
static_cast<uint64_t>(out_handle);
1427 cuda_assert(cuStreamSynchronize(
nullptr));
1431 if (use_fast_trace_bvh) {
1432 uint64_t compacted_size = sizes.outputSizeInBytes;
1433 cuda_assert(cuMemcpyDtoH(&compacted_size, compacted_size_prop.result,
sizeof(compacted_size)));
1439 if (compacted_size < sizes.outputSizeInBytes) {
1441 compacted_data.alloc_to_device(compacted_size);
1442 if (!compacted_data.device_pointer) {
1445 return !have_error();
1448 optix_assert(optixAccelCompact(context,
1451 compacted_data.device_pointer,
1454 bvh->traversable_handle =
static_cast<uint64_t>(out_handle);
1457 cuda_assert(cuStreamSynchronize(
nullptr));
1459 std::swap(out_data.
device_size, compacted_data.device_size);
1460 std::swap(out_data.
device_pointer, compacted_data.device_pointer);
1466 return !have_error();
1473 free_bvh_memory_delayed();
1475 BVHOptiX *
const bvh_optix =
static_cast<BVHOptiX *
>(bvh);
1477 progress.
set_substatus(
"Building OptiX acceleration structure");
1484 OptixBuildOperation operation = OPTIX_BUILD_OPERATION_BUILD;
1485 if (
refit && !use_fast_trace_bvh) {
1486 assert(bvh_optix->traversable_handle != 0);
1487 operation = OPTIX_BUILD_OPERATION_UPDATE;
1490 bvh_optix->as_data->free();
1491 bvh_optix->traversable_handle = 0;
1498 Hair *
const hair =
static_cast<Hair *const
>(geom);
1505 size_t num_motion_steps = 1;
1508 if (pipeline_options.usesMotionBlur && hair->get_use_motion_blur() && attr_P->
has_motion()) {
1509 num_motion_steps = hair->get_motion_steps();
1516 size_t num_vertices = num_segments * 4;
1519 index_data.alloc(num_segments);
1520 vertex_data.alloc(num_vertices * num_motion_steps);
1524 index_data.alloc(num_segments);
1525 vertex_data.alloc(num_vertices * num_motion_steps);
1528 aabb_data.alloc(num_segments * num_motion_steps);
1532 for (
size_t step = 0;
step < num_motion_steps; ++
step) {
1538 for (
size_t curve_index = 0, segment_index = 0, vertex_index =
step * num_vertices;
1545 const int first_key_index = curve.
first_key;
1549 index_data[segment_index++] = vertex_index;
1552 curve_radius_step[first_key_index + k]);
1555 const int last_key_index = first_key_index + curve.
num_keys - 1;
1557 curve_radius_step[last_key_index]);
1560 const int first_key_index = curve.
first_key;
1562 curve_radius_step[first_key_index]);
1566 index_data[segment_index++] = vertex_index - 1;
1569 curve_radius_step[first_key_index + k]);
1572 const int last_key_index = first_key_index + curve.
num_keys - 1;
1574 curve_radius_step[last_key_index]);
1576 curve_radius_step[last_key_index]);
1581 for (
size_t curve_index = 0, i = 0; curve_index < hair->
num_curves(); ++curve_index) {
1588 const size_t index =
step * num_segments + i;
1601 aabb_data.copy_to_device();
1602 index_data.copy_to_device();
1603 vertex_data.copy_to_device();
1606 aabb_ptrs.reserve(num_motion_steps);
1609 width_ptrs.reserve(num_motion_steps);
1610 vertex_ptrs.reserve(num_motion_steps);
1611 for (
size_t step = 0;
step < num_motion_steps; ++
step) {
1612 aabb_ptrs.push_back(aabb_data.device_pointer +
step * num_segments *
sizeof(OptixAabb));
1613 const device_ptr base_ptr = vertex_data.device_pointer +
1615 width_ptrs.push_back(base_ptr + 3 *
sizeof(
float));
1616 vertex_ptrs.push_back(base_ptr);
1620 unsigned int build_flags = OPTIX_GEOMETRY_FLAG_REQUIRE_SINGLE_ANYHIT_CALL;
1621 OptixBuildInput build_input = {};
1623 build_input.type = OPTIX_BUILD_INPUT_TYPE_CURVES;
1625 build_input.curveArray.curveType = OPTIX_PRIMITIVE_TYPE_ROUND_LINEAR;
1628 build_input.curveArray.curveType = OPTIX_PRIMITIVE_TYPE_ROUND_CATMULLROM;
1630 build_input.curveArray.numPrimitives = num_segments;
1631 build_input.curveArray.vertexBuffers = (CUdeviceptr *)vertex_ptrs.data();
1632 build_input.curveArray.numVertices = num_vertices;
1633 build_input.curveArray.vertexStrideInBytes =
sizeof(
float4);
1634 build_input.curveArray.widthBuffers = (CUdeviceptr *)width_ptrs.data();
1635 build_input.curveArray.widthStrideInBytes =
sizeof(
float4);
1636 build_input.curveArray.indexBuffer = (CUdeviceptr)index_data.device_pointer;
1637 build_input.curveArray.indexStrideInBytes =
sizeof(int);
1638 build_input.curveArray.flag = build_flags;
1644 build_flags |= OPTIX_GEOMETRY_FLAG_DISABLE_ANYHIT;
1646 build_input.type = OPTIX_BUILD_INPUT_TYPE_CUSTOM_PRIMITIVES;
1647 build_input.customPrimitiveArray.aabbBuffers = (CUdeviceptr *)aabb_ptrs.data();
1648 build_input.customPrimitiveArray.numPrimitives = num_segments;
1649 build_input.customPrimitiveArray.strideInBytes =
sizeof(OptixAabb);
1650 build_input.customPrimitiveArray.flags = &build_flags;
1651 build_input.customPrimitiveArray.numSbtRecords = 1;
1655 if (!build_optix_bvh(bvh_optix, operation, build_input, num_motion_steps)) {
1656 progress.
set_error(
"Failed to build OptiX acceleration structure");
1661 Mesh *
const mesh =
static_cast<Mesh *const
>(geom);
1666 const size_t num_verts = mesh->
num_verts();
1668 size_t num_motion_steps = 1;
1670 if (pipeline_options.usesMotionBlur && mesh->get_use_motion_blur() && attr_P->
has_motion()) {
1671 num_motion_steps = mesh->get_motion_steps();
1675 index_data.alloc(mesh->get_triangles().size());
1676 memcpy(index_data.data(),
1677 mesh->get_triangles().data(),
1678 mesh->get_triangles().size() *
sizeof(
int));
1680 vertex_data.alloc(num_verts * num_motion_steps);
1682 for (
size_t step = 0;
step < num_motion_steps; ++
step) {
1685 std::copy_n(verts, num_verts, vertex_data.data() + num_verts *
step);
1689 index_data.copy_to_device();
1690 vertex_data.copy_to_device();
1693 vertex_ptrs.reserve(num_motion_steps);
1694 for (
size_t step = 0;
step < num_motion_steps; ++
step) {
1695 vertex_ptrs.push_back(vertex_data.device_pointer +
1700 unsigned int build_flags = OPTIX_GEOMETRY_FLAG_REQUIRE_SINGLE_ANYHIT_CALL;
1701 OptixBuildInput build_input = {};
1702 build_input.type = OPTIX_BUILD_INPUT_TYPE_TRIANGLES;
1703 build_input.triangleArray.vertexBuffers = (CUdeviceptr *)vertex_ptrs.data();
1704 build_input.triangleArray.numVertices = num_verts;
1705 build_input.triangleArray.vertexFormat = OPTIX_VERTEX_FORMAT_FLOAT3;
1706 build_input.triangleArray.vertexStrideInBytes =
sizeof(
packed_float3);
1707 build_input.triangleArray.indexBuffer = index_data.device_pointer;
1708 build_input.triangleArray.numIndexTriplets = mesh->
num_triangles();
1709 build_input.triangleArray.indexFormat = OPTIX_INDICES_FORMAT_UNSIGNED_INT3;
1710 build_input.triangleArray.indexStrideInBytes = 3 *
sizeof(int);
1711 build_input.triangleArray.flags = &build_flags;
1715 build_input.triangleArray.numSbtRecords = 1;
1716 build_input.triangleArray.primitiveIndexOffset = mesh->
prim_offset;
1718 if (!build_optix_bvh(bvh_optix, operation, build_input, num_motion_steps)) {
1719 progress.
set_error(
"Failed to build OptiX acceleration structure");
1725 const size_t num_points = pointcloud->
num_points();
1726 if (num_points == 0) {
1730 size_t num_motion_steps = 1;
1733 if (pipeline_options.usesMotionBlur && pointcloud->get_use_motion_blur() &&
1736 num_motion_steps = pointcloud->get_motion_steps();
1740 aabb_data.alloc(num_points * num_motion_steps);
1743 for (
size_t step = 0;
step < num_motion_steps; ++
step) {
1748 for (
size_t i = 0; i < num_points; ++i) {
1753 const size_t index =
step * num_points + i;
1764 aabb_data.copy_to_device();
1767 aabb_ptrs.reserve(num_motion_steps);
1768 for (
size_t step = 0;
step < num_motion_steps; ++
step) {
1769 aabb_ptrs.push_back(aabb_data.device_pointer +
step * num_points *
sizeof(OptixAabb));
1775 unsigned int build_flags = OPTIX_GEOMETRY_FLAG_DISABLE_ANYHIT |
1776 OPTIX_GEOMETRY_FLAG_REQUIRE_SINGLE_ANYHIT_CALL;
1777 OptixBuildInput build_input = {};
1778 build_input.type = OPTIX_BUILD_INPUT_TYPE_CUSTOM_PRIMITIVES;
1779 build_input.customPrimitiveArray.aabbBuffers = (CUdeviceptr *)aabb_ptrs.data();
1780 build_input.customPrimitiveArray.numPrimitives = num_points;
1781 build_input.customPrimitiveArray.strideInBytes =
sizeof(OptixAabb);
1782 build_input.customPrimitiveArray.flags = &build_flags;
1783 build_input.customPrimitiveArray.numSbtRecords = 1;
1784 build_input.customPrimitiveArray.primitiveIndexOffset = pointcloud->
prim_offset;
1786 if (!build_optix_bvh(bvh_optix, operation, build_input, num_motion_steps)) {
1787 progress.
set_error(
"Failed to build OptiX acceleration structure");
1792 unsigned int num_instances = 0;
1793 unsigned int max_num_instances = 0xFFFFFFFF;
1795 bvh_optix->as_data->free();
1796 bvh_optix->traversable_handle = 0;
1797 bvh_optix->motion_transform_data->free();
1799 optixDeviceContextGetProperty(context,
1800 OPTIX_DEVICE_PROPERTY_LIMIT_MAX_INSTANCE_ID,
1802 sizeof(max_num_instances));
1804 max_num_instances >>= 1;
1805 if (bvh->
objects.size() > max_num_instances) {
1807 "Failed to build OptiX acceleration structure because there are too many instances");
1813 instances.alloc(bvh->
objects.size());
1816 size_t motion_transform_offset = 0;
1817 if (pipeline_options.usesMotionBlur) {
1818 size_t total_motion_transform_size = 0;
1821 total_motion_transform_size =
align_up(total_motion_transform_size,
1822 OPTIX_TRANSFORM_BYTE_ALIGNMENT);
1823 const size_t motion_keys =
max(ob->get_motion().size(), (
size_t)2) - 2;
1824 total_motion_transform_size = total_motion_transform_size +
1825 sizeof(OptixSRTMotionTransform) +
1826 motion_keys *
sizeof(OptixSRTData);
1830 assert(bvh_optix->motion_transform_data->device ==
this);
1831 bvh_optix->motion_transform_data->alloc_to_device(total_motion_transform_size);
1840 BVHOptiX *
const blas =
static_cast<BVHOptiX *
>(ob->get_geometry()->bvh.get());
1841 OptixTraversableHandle handle = blas->traversable_handle;
1846 OptixInstance &instance = instances[num_instances++];
1847 memset(&instance, 0,
sizeof(instance));
1850 instance.transform[0] = 1.0f;
1851 instance.transform[5] = 1.0f;
1852 instance.transform[10] = 1.0f;
1865 if (0 == instance.visibilityMask) {
1866 instance.visibilityMask = 0xFF;
1869 if (ob->get_geometry()->is_hair()) {
1870 const Hair *hair =
static_cast<const Hair *
>(ob->get_geometry());
1872 instance.sbtOffset = PG_HITD_CURVE_RIBBON - PG_HITD;
1875 instance.visibilityMask |= 4;
1878 instance.sbtOffset = PG_HITD_CURVE_LINEAR - PG_HITD;
1880 instance.sbtOffset = PG_HITD_CURVE_LINEAR_MOTION - PG_HITD;
1886 instance.sbtOffset = PG_HITD_MOTION - PG_HITD;
1890 else if (ob->get_geometry()->is_pointcloud()) {
1892 instance.sbtOffset = PG_HITD_POINTCLOUD - PG_HITD;
1895 instance.visibilityMask |= 4;
1904 instance.flags = OPTIX_INSTANCE_FLAG_DISABLE_ANYHIT;
1908 if (pipeline_options.usesMotionBlur && ob->
use_motion()) {
1909 size_t motion_keys =
max(ob->get_motion().size(), (
size_t)2) - 2;
1910 size_t motion_transform_size =
sizeof(OptixSRTMotionTransform) +
1911 motion_keys *
sizeof(OptixSRTData);
1913 const CUDAContextScope scope(
this);
1915 motion_transform_offset =
align_up(motion_transform_offset,
1916 OPTIX_TRANSFORM_BYTE_ALIGNMENT);
1917 CUdeviceptr motion_transform_gpu = bvh_optix->motion_transform_data->device_pointer +
1918 motion_transform_offset;
1919 motion_transform_offset += motion_transform_size;
1923 OptixSRTMotionTransform *motion_transform =
reinterpret_cast<OptixSRTMotionTransform *
>(
1924 motion_transform_storage.data());
1925 motion_transform->child = handle;
1926 motion_transform->motionOptions.numKeys = ob->get_motion().size();
1927 motion_transform->motionOptions.flags = OPTIX_MOTION_FLAG_NONE;
1928 motion_transform->motionOptions.timeBegin = 0.0f;
1929 motion_transform->motionOptions.timeEnd = 1.0f;
1931 OptixSRTData *
const srt_data = motion_transform->srtData;
1934 decomp.data(), ob->get_motion().data(), ob->get_motion().size());
1936 for (
size_t i = 0; i < ob->get_motion().
size(); ++i) {
1938 srt_data[i].sx = decomp[i].y.w;
1939 srt_data[i].sy = decomp[i].z.w;
1940 srt_data[i].sz = decomp[i].w.w;
1943 srt_data[i].a = decomp[i].z.x;
1944 srt_data[i].b = decomp[i].z.y;
1945 srt_data[i].c = decomp[i].w.x;
1946 assert(decomp[i].
z.z == 0.0f);
1947 assert(decomp[i].
w.y == 0.0f);
1948 assert(decomp[i].
w.z == 0.0f);
1951 srt_data[i].pvx = 0.0f;
1952 srt_data[i].pvy = 0.0f;
1953 srt_data[i].pvz = 0.0f;
1956 srt_data[i].qx = decomp[i].x.x;
1957 srt_data[i].qy = decomp[i].x.y;
1958 srt_data[i].qz = decomp[i].x.z;
1959 srt_data[i].qw = decomp[i].x.w;
1962 srt_data[i].tx = decomp[i].y.x;
1963 srt_data[i].ty = decomp[i].y.y;
1964 srt_data[i].tz = decomp[i].y.z;
1968 cuMemcpyHtoD(motion_transform_gpu, motion_transform, motion_transform_size);
1969 motion_transform =
nullptr;
1970 motion_transform_storage.clear();
1973 optixConvertPointerToTraversableHandle(context,
1974 motion_transform_gpu,
1975 OPTIX_TRAVERSABLE_TYPE_SRT_MOTION_TRANSFORM,
1976 &instance.traversableHandle);
1979 instance.traversableHandle = handle;
1981 if (ob->get_geometry()->is_instanced()) {
1983 memcpy(instance.transform, &ob->get_tfm(),
sizeof(instance.transform));
1989 instances.resize(num_instances);
1990 instances.copy_to_device();
1993 OptixBuildInput build_input = {};
1994 build_input.type = OPTIX_BUILD_INPUT_TYPE_INSTANCES;
1995 build_input.instanceArray.instances = instances.device_pointer;
1996 build_input.instanceArray.numInstances = num_instances;
1998 if (!build_optix_bvh(bvh_optix, OPTIX_BUILD_OPERATION_BUILD, build_input, 0)) {
1999 progress.
set_error(
"Failed to build OptiX acceleration structure");
2001 tlas_handle = bvh_optix->traversable_handle;
2005void OptiXDevice::release_bvh(
BVH *bvh)
2010 BVHOptiX *
const bvh_optix =
static_cast<BVHOptiX *
>(bvh);
2012 delayed_free_bvh_memory.emplace_back(std::move(bvh_optix->as_data));
2013 delayed_free_bvh_memory.emplace_back(std::move(bvh_optix->motion_transform_data));
2014 bvh_optix->traversable_handle = 0;
2017void OptiXDevice::free_bvh_memory_delayed()
2020 delayed_free_bvh_memory.free_memory();
2023void OptiXDevice::const_copy_to(
const char *name,
void *host,
const size_t size)
2026 CUDADevice::const_copy_to(name, host,
size);
2028 if (strcmp(name,
"data") == 0) {
2032 KernelData *
const data = (KernelData *)host;
2033 *(OptixTraversableHandle *)&
data->device_bvh = tlas_handle;
2040# define KERNEL_DATA_ARRAY(data_type, data_name) \
2041 if (strcmp(name, #data_name) == 0) { \
2042 update_launch_params(offsetof(KernelParamsOptiX, data_name), host, size); \
2046# include "kernel/data_arrays.h"
2047# undef KERNEL_DATA_ARRAY
2050void OptiXDevice::update_launch_params(
const size_t offset,
void *data,
const size_t data_size)
2052 const CUDAContextScope scope(
this);
2054 cuda_assert(cuMemcpyHtoD(launch_params.device_pointer + offset, data, data_size));
unsigned long long int uint64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
void refit(btStridingMeshInterface *triangles, const btVector3 &aabbMin, const btVector3 &aabbMax)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Attribute * find(ustring name) const
const T * data_at_time_step(const int step, const int num_time_steps) const
vector< Geometry * > geometry
vector< Object * > objects
bool use_hardware_raytracing
bool is_pointcloud() const
virtual bool has_motion_blur() const
Curve get_curve(const size_t i) const
size_t curve_segment_offset
size_t num_curves() const
size_t num_segments() const
CurveShapeType curve_shape
NODE_DECLARE size_t num_verts() const
size_t num_triangles() const
int get_device_index() const
bool is_traceable() const
uint visibility_for_tracing() const
Point get_point(const int i) const
size_t num_points() const
void set_substatus(const string &substatus_)
void set_error(const string &error_message_)
void push(TaskRunFunction &&task)
void wait_work(Summary *stats=nullptr)
device_ptr device_pointer
void alloc_to_device(const size_t num, bool shrink_to_fit=true)
CCL_NAMESPACE_BEGIN struct Options options
#define KERNEL_DATA_ARRAY(type, name)
#define KERNEL_FEATURE_VOLUME
#define KERNEL_FEATURE_HAIR_RIBBON
#define KERNEL_FEATURE_OBJECT_MOTION
#define KERNEL_FEATURE_OSL_SHADING
#define KERNEL_FEATURE_SUBSURFACE
#define KERNEL_FEATURE_HAIR_THICK
#define KERNEL_FEATURE_PATH_TRACING
#define KERNEL_FEATURE_OSL_CAMERA
#define KERNEL_FEATURE_NODE_RAYTRACE
#define KERNEL_FEATURE_BAKING
#define KERNEL_FEATURE_MNEE
#define KERNEL_FEATURE_POINTCLOUD
#define CCL_NAMESPACE_END
#define assert(assertion)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
Segment< FEdge *, Vec3r > segment
std::string filename(const std::string_view &str, size_t pos)
constexpr StringRefNull radius
BMesh const char void * data
PipelineGraphic pipeline(vert_main, frag_main)
size_t path_file_size(const string &path)
bool path_is_directory(const string &path)
string path_get(const string &sub)
string path_join(const string &dir, const string &file)
bool path_read_compressed_text(const string &path, string &text)
static struct PyModuleDef module
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
void bounds_grow(const int k, const packed_float3 *curve_keys, const float *curve_radius, BoundBox &bounds) const
void bounds_grow(const packed_float3 *points, const float *radius, BoundBox &bounds) const
std::unique_lock< std::mutex > thread_scoped_lock
ccl_device_inline size_t align_up(const size_t offset, const size_t alignment)