12# define __KERNEL_OPTIX__
19OptiXDeviceQueue::OptiXDeviceQueue(OptiXDevice *device) : CUDADeviceQueue(device) {}
21void OptiXDeviceQueue::init_execution()
23 CUDADeviceQueue::init_execution();
26static bool is_optix_specific_kernel(
DeviceKernel kernel,
bool use_osl)
44 OptiXDevice *
const optix_device =
static_cast<OptiXDevice *
>(cuda_device_);
47 const bool use_osl =
static_cast<OSLGlobals *
>(optix_device->get_cpu_osl_memory())->use;
49 const bool use_osl =
false;
52 if (!is_optix_specific_kernel(kernel, use_osl)) {
53 return CUDADeviceQueue::enqueue(kernel,
work_size, args);
56 if (cuda_device_->have_error()) {
62 const CUDAContextScope scope(cuda_device_);
64 const device_ptr sbt_data_ptr = optix_device->sbt_data.device_pointer;
65 const device_ptr launch_params_ptr = optix_device->launch_params.device_pointer;
86 cuda_device_assert(cuda_device_,
93 cuda_device_assert(cuda_device_, cuStreamSynchronize(cuda_stream_));
95 OptixPipeline pipeline =
nullptr;
96 OptixShaderBindingTable sbt_params = {};
100 pipeline = optix_device->pipelines[PIP_SHADE];
101 sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_BACKGROUND *
sizeof(SbtRecord);
104 pipeline = optix_device->pipelines[PIP_SHADE];
105 sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_LIGHT *
sizeof(SbtRecord);
108 pipeline = optix_device->pipelines[PIP_SHADE];
109 sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_SURFACE *
sizeof(SbtRecord);
112 pipeline = optix_device->pipelines[PIP_SHADE];
113 sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_SURFACE_RAYTRACE *
sizeof(SbtRecord);
116 pipeline = optix_device->pipelines[PIP_SHADE];
117 sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_SURFACE_MNEE *
sizeof(SbtRecord);
120 pipeline = optix_device->pipelines[PIP_SHADE];
121 sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_VOLUME *
sizeof(SbtRecord);
124 pipeline = optix_device->pipelines[PIP_SHADE];
125 sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_SHADOW *
sizeof(SbtRecord);
128 pipeline = optix_device->pipelines[PIP_SHADE];
129 sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_SHADE_DEDICATED_LIGHT *
sizeof(SbtRecord);
133 pipeline = optix_device->pipelines[PIP_INTERSECT];
134 sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_INTERSECT_CLOSEST *
sizeof(SbtRecord);
137 pipeline = optix_device->pipelines[PIP_INTERSECT];
138 sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_INTERSECT_SHADOW *
sizeof(SbtRecord);
141 pipeline = optix_device->pipelines[PIP_INTERSECT];
142 sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_INTERSECT_SUBSURFACE *
sizeof(SbtRecord);
145 pipeline = optix_device->pipelines[PIP_INTERSECT];
146 sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_INTERSECT_VOLUME_STACK *
sizeof(SbtRecord);
149 pipeline = optix_device->pipelines[PIP_INTERSECT];
150 sbt_params.raygenRecord = sbt_data_ptr +
151 PG_RGEN_INTERSECT_DEDICATED_LIGHT *
sizeof(SbtRecord);
155 pipeline = optix_device->pipelines[PIP_SHADE];
156 sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_EVAL_DISPLACE *
sizeof(SbtRecord);
159 pipeline = optix_device->pipelines[PIP_SHADE];
160 sbt_params.raygenRecord = sbt_data_ptr + PG_RGEN_EVAL_BACKGROUND *
sizeof(SbtRecord);
163 pipeline = optix_device->pipelines[PIP_SHADE];
164 sbt_params.raygenRecord = sbt_data_ptr +
165 PG_RGEN_EVAL_CURVE_SHADOW_TRANSPARENCY *
sizeof(SbtRecord);
170 <<
" is attempted to be enqueued.";
174 sbt_params.missRecordBase = sbt_data_ptr + MISS_PROGRAM_GROUP_OFFSET *
sizeof(SbtRecord);
175 sbt_params.missRecordStrideInBytes =
sizeof(SbtRecord);
176 sbt_params.missRecordCount = NUM_MISS_PROGRAM_GROUPS;
177 sbt_params.hitgroupRecordBase = sbt_data_ptr + HIT_PROGAM_GROUP_OFFSET *
sizeof(SbtRecord);
178 sbt_params.hitgroupRecordStrideInBytes =
sizeof(SbtRecord);
179 sbt_params.hitgroupRecordCount = NUM_HIT_PROGRAM_GROUPS;
180 sbt_params.callablesRecordBase = sbt_data_ptr + CALLABLE_PROGRAM_GROUPS_BASE *
sizeof(SbtRecord);
181 sbt_params.callablesRecordCount = NUM_CALLABLE_PROGRAM_GROUPS;
182 sbt_params.callablesRecordStrideInBytes =
sizeof(SbtRecord);
186 sbt_params.callablesRecordCount +=
static_cast<unsigned int>(optix_device->osl_groups.size());
191 optix_device_assert(optix_device,
192 optixLaunch(pipeline,
195 optix_device->launch_params.data_elements,
203 return !(optix_device->have_error());
#define CCL_NAMESPACE_END
CCL_NAMESPACE_BEGIN bool device_kernel_has_shading(DeviceKernel kernel)
bool device_kernel_has_intersection(DeviceKernel kernel)
const char * device_kernel_as_string(DeviceKernel kernel)
ccl_gpu_kernel_postfix ccl_global const int * path_index_array
ccl_gpu_kernel_postfix ccl_global const int ccl_global float const int work_size
ccl_gpu_kernel_postfix ccl_global KernelWorkTile const int ccl_global float * render_buffer
@ DEVICE_KERNEL_INTEGRATOR_SHADE_LIGHT
@ DEVICE_KERNEL_INTEGRATOR_SHADE_DEDICATED_LIGHT
@ DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE
@ DEVICE_KERNEL_SHADER_EVAL_DISPLACE
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_SUBSURFACE
@ DEVICE_KERNEL_INTEGRATOR_SHADE_SHADOW
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_VOLUME_STACK
@ DEVICE_KERNEL_SHADER_EVAL_BACKGROUND
@ DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_DEDICATED_LIGHT
@ DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_MNEE
@ DEVICE_KERNEL_SHADER_EVAL_CURVE_SHADOW_TRANSPARENCY
@ DEVICE_KERNEL_INTEGRATOR_SHADE_VOLUME
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_SHADOW
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST
@ DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND