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:
2019-09-12 14:46:47 +02:00
committed by Brecht Van Lommel
parent 7eb293a37b
commit 53932f1f06
10 changed files with 828 additions and 200 deletions

View File

@@ -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);