diff options
author | Michael Jones <michael_jones> | 2021-11-16 16:41:29 +0300 |
---|---|---|
committer | Michael Jones <michael_p_jones@apple.com> | 2021-11-16 16:42:23 +0300 |
commit | 64003fa4b0b1699998a5b048d980eb775d547d8d (patch) | |
tree | 0cc713ee41879893f0c41a0f559bd650b9a74285 /intern/cycles/kernel/integrator | |
parent | 85ac9b8584ca99648616f25146412009f05f1278 (diff) |
Cycles: Adapt volumetric lambda functions to work on MSL
This patch adapts the existing volumetric read/write lambda functions for Metal. Lambda expressions are not supported on MSL, so two new macros `VOLUME_READ_LAMBDA` and `VOLUME_WRITE_LAMBDA` have been defined with a default implementation which, on Metal, is overridden to use inline function objects.
This patch also removes the last remaining mention of the now-unused `ccl_addr_space`.
Ref T92212
Reviewed By: leesonw
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D13234
Diffstat (limited to 'intern/cycles/kernel/integrator')
-rw-r--r-- | intern/cycles/kernel/integrator/shade_shadow.h | 4 | ||||
-rw-r--r-- | intern/cycles/kernel/integrator/shade_volume.h | 14 | ||||
-rw-r--r-- | intern/cycles/kernel/integrator/volume_stack.h | 28 |
3 files changed, 22 insertions, 24 deletions
diff --git a/intern/cycles/kernel/integrator/shade_shadow.h b/intern/cycles/kernel/integrator/shade_shadow.h index 1de890aae29..a68fcaa7a64 100644 --- a/intern/cycles/kernel/integrator/shade_shadow.h +++ b/intern/cycles/kernel/integrator/shade_shadow.h @@ -95,8 +95,8 @@ ccl_device_inline void integrate_transparent_volume_shadow(KernelGlobals kg, shader_setup_from_volume(kg, shadow_sd, &ray); - const float step_size = volume_stack_step_size( - kg, [=](const int i) { return integrator_state_read_shadow_volume_stack(state, i); }); + VOLUME_READ_LAMBDA(integrator_state_read_shadow_volume_stack(state, i)); + const float step_size = volume_stack_step_size(kg, volume_read_lambda_pass); volume_shadow_heterogeneous(kg, state, &ray, shadow_sd, throughput, step_size); } diff --git a/intern/cycles/kernel/integrator/shade_volume.h b/intern/cycles/kernel/integrator/shade_volume.h index f42614cc87f..c5a80eb336f 100644 --- a/intern/cycles/kernel/integrator/shade_volume.h +++ b/intern/cycles/kernel/integrator/shade_volume.h @@ -78,9 +78,8 @@ ccl_device_inline bool shadow_volume_shader_sample(KernelGlobals kg, ccl_private ShaderData *ccl_restrict sd, ccl_private float3 *ccl_restrict extinction) { - shader_eval_volume<true>(kg, state, sd, PATH_RAY_SHADOW, [=](const int i) { - return integrator_state_read_shadow_volume_stack(state, i); - }); + VOLUME_READ_LAMBDA(integrator_state_read_shadow_volume_stack(state, i)) + shader_eval_volume<true>(kg, state, sd, PATH_RAY_SHADOW, volume_read_lambda_pass); if (!(sd->flag & SD_EXTINCTION)) { return false; @@ -98,9 +97,8 @@ ccl_device_inline bool volume_shader_sample(KernelGlobals kg, ccl_private VolumeShaderCoefficients *coeff) { const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag); - shader_eval_volume<false>(kg, state, sd, path_flag, [=](const int i) { - return integrator_state_read_volume_stack(state, i); - }); + VOLUME_READ_LAMBDA(integrator_state_read_volume_stack(state, i)) + shader_eval_volume<false>(kg, state, sd, path_flag, volume_read_lambda_pass); if (!(sd->flag & (SD_EXTINCTION | SD_SCATTER | SD_EMISSION))) { return false; @@ -921,8 +919,8 @@ ccl_device VolumeIntegrateEvent volume_integrate(KernelGlobals kg, VOLUME_SAMPLE_DISTANCE; /* Step through volume. */ - const float step_size = volume_stack_step_size( - kg, [=](const int i) { return integrator_state_read_volume_stack(state, i); }); + VOLUME_READ_LAMBDA(integrator_state_read_volume_stack(state, i)) + const float step_size = volume_stack_step_size(kg, volume_read_lambda_pass); /* TODO: expensive to zero closures? */ VolumeIntegrateResult result = {}; diff --git a/intern/cycles/kernel/integrator/volume_stack.h b/intern/cycles/kernel/integrator/volume_stack.h index cf69826ffff..ea3fa901e2d 100644 --- a/intern/cycles/kernel/integrator/volume_stack.h +++ b/intern/cycles/kernel/integrator/volume_stack.h @@ -18,6 +18,14 @@ CCL_NAMESPACE_BEGIN +/* Volumetric read/write lambda functions - default implementations */ +#ifndef VOLUME_READ_LAMBDA +# define VOLUME_READ_LAMBDA(function_call) \ + auto volume_read_lambda_pass = [=](const int i) { return function_call; }; +# define VOLUME_WRITE_LAMBDA(function_call) \ + auto volume_write_lambda_pass = [=](const int i, VolumeStack entry) { function_call; }; +#endif + /* Volume Stack * * This is an array of object/shared ID's that the current segment of the path @@ -88,26 +96,18 @@ ccl_device void volume_stack_enter_exit(KernelGlobals kg, IntegratorState state, ccl_private const ShaderData *sd) { - volume_stack_enter_exit( - kg, - sd, - [=](const int i) { return integrator_state_read_volume_stack(state, i); }, - [=](const int i, const VolumeStack entry) { - integrator_state_write_volume_stack(state, i, entry); - }); + VOLUME_READ_LAMBDA(integrator_state_read_volume_stack(state, i)) + VOLUME_WRITE_LAMBDA(integrator_state_write_volume_stack(state, i, entry)) + volume_stack_enter_exit(kg, sd, volume_read_lambda_pass, volume_write_lambda_pass); } ccl_device void shadow_volume_stack_enter_exit(KernelGlobals kg, IntegratorShadowState state, ccl_private const ShaderData *sd) { - volume_stack_enter_exit( - kg, - sd, - [=](const int i) { return integrator_state_read_shadow_volume_stack(state, i); }, - [=](const int i, const VolumeStack entry) { - integrator_state_write_shadow_volume_stack(state, i, entry); - }); + VOLUME_READ_LAMBDA(integrator_state_read_shadow_volume_stack(state, i)) + VOLUME_WRITE_LAMBDA(integrator_state_write_shadow_volume_stack(state, i, entry)) + volume_stack_enter_exit(kg, sd, volume_read_lambda_pass, volume_write_lambda_pass); } /* Clean stack after the last bounce. |