Cycles: add Optix support in the kernel
This adds all the kernel side changes for the Optix backend. Ref D5363
This commit is contained in:
@@ -326,13 +326,19 @@ ccl_device_forceinline bool kernel_path_shader_apply(KernelGlobals *kg,
|
||||
return true;
|
||||
}
|
||||
|
||||
ccl_device_noinline void kernel_path_ao(KernelGlobals *kg,
|
||||
ShaderData *sd,
|
||||
ShaderData *emission_sd,
|
||||
PathRadiance *L,
|
||||
ccl_addr_space PathState *state,
|
||||
float3 throughput,
|
||||
float3 ao_alpha)
|
||||
#ifdef __KERNEL_OPTIX__
|
||||
ccl_device_inline /* inline trace calls */
|
||||
#else
|
||||
ccl_device_noinline
|
||||
#endif
|
||||
void
|
||||
kernel_path_ao(KernelGlobals *kg,
|
||||
ShaderData *sd,
|
||||
ShaderData *emission_sd,
|
||||
PathRadiance *L,
|
||||
ccl_addr_space PathState *state,
|
||||
float3 throughput,
|
||||
float3 ao_alpha)
|
||||
{
|
||||
PROFILING_INIT(kg, PROFILING_AO);
|
||||
|
||||
@@ -655,9 +661,11 @@ ccl_device void kernel_path_trace(
|
||||
|
||||
kernel_path_trace_setup(kg, sample, x, y, &rng_hash, &ray);
|
||||
|
||||
# ifndef __KERNEL_OPTIX__
|
||||
if (ray.t == 0.0f) {
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Initialize state. */
|
||||
float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
|
||||
@@ -671,6 +679,13 @@ ccl_device void kernel_path_trace(
|
||||
PathState state;
|
||||
path_state_init(kg, emission_sd, &state, rng_hash, sample, &ray);
|
||||
|
||||
# ifdef __KERNEL_OPTIX__
|
||||
/* Force struct into local memory to avoid costly spilling on trace calls. */
|
||||
if (pass_stride < 0) /* This is never executed and just prevents the compiler from doing SROA. */
|
||||
for (int i = 0; i < sizeof(L); ++i)
|
||||
reinterpret_cast<unsigned char *>(&L)[-pass_stride + i] = 0;
|
||||
# endif
|
||||
|
||||
/* Integrate. */
|
||||
kernel_path_integrate(kg, &state, throughput, &ray, &L, buffer, emission_sd);
|
||||
|
||||
|
Reference in New Issue
Block a user