diff options
author | Brecht Van Lommel <brecht> | 2021-10-17 17:10:10 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-10-18 20:02:10 +0300 |
commit | 1df3b51988852fa8ee6b530a64aa23346db9acd4 (patch) | |
tree | dd79dba4c8ff8bb8474cc399e9d1b308d845e0cb /intern/cycles/kernel/kernel_passes.h | |
parent | 44c3bb729be42d6d67eaf8918d7cbcb2ff0b315d (diff) |
Cycles: replace integrator state argument macros
* Rename struct KernelGlobals to struct KernelGlobalsCPU
* Add KernelGlobals, IntegratorState and ConstIntegratorState typedefs
that every device can define in its own way.
* Remove INTEGRATOR_STATE_ARGS and INTEGRATOR_STATE_PASS macros and
replace with these new typedefs.
* Add explicit state argument to INTEGRATOR_STATE and similar macros
In preparation for decoupling main and shadow paths.
Differential Revision: https://developer.blender.org/D12888
Diffstat (limited to 'intern/cycles/kernel/kernel_passes.h')
-rw-r--r-- | intern/cycles/kernel/kernel_passes.h | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h index b981e750dda..4d05b63bfbd 100644 --- a/intern/cycles/kernel/kernel_passes.h +++ b/intern/cycles/kernel/kernel_passes.h @@ -25,9 +25,9 @@ CCL_NAMESPACE_BEGIN /* Get pointer to pixel in render buffer. */ ccl_device_forceinline ccl_global float *kernel_pass_pixel_render_buffer( - INTEGRATOR_STATE_CONST_ARGS, ccl_global float *ccl_restrict render_buffer) + KernelGlobals kg, ConstIntegratorState state, ccl_global float *ccl_restrict render_buffer) { - const uint32_t render_pixel_index = INTEGRATOR_STATE(path, render_pixel_index); + const uint32_t render_pixel_index = INTEGRATOR_STATE(state, path, render_pixel_index); const uint64_t render_buffer_offset = (uint64_t)render_pixel_index * kernel_data.film.pass_stride; return render_buffer + render_buffer_offset; @@ -36,11 +36,12 @@ ccl_device_forceinline ccl_global float *kernel_pass_pixel_render_buffer( #ifdef __DENOISING_FEATURES__ ccl_device_forceinline void kernel_write_denoising_features_surface( - INTEGRATOR_STATE_ARGS, + KernelGlobals kg, + IntegratorState state, ccl_private const ShaderData *sd, ccl_global float *ccl_restrict render_buffer) { - if (!(INTEGRATOR_STATE(path, flag) & PATH_RAY_DENOISING_FEATURES)) { + if (!(INTEGRATOR_STATE(state, path, flag) & PATH_RAY_DENOISING_FEATURES)) { return; } @@ -49,7 +50,7 @@ ccl_device_forceinline void kernel_write_denoising_features_surface( return; } - ccl_global float *buffer = kernel_pass_pixel_render_buffer(INTEGRATOR_STATE_PASS, render_buffer); + ccl_global float *buffer = kernel_pass_pixel_render_buffer(kg, state, render_buffer); float3 normal = zero_float3(); float3 diffuse_albedo = zero_float3(); @@ -109,32 +110,34 @@ ccl_device_forceinline void kernel_write_denoising_features_surface( } if (kernel_data.film.pass_denoising_albedo != PASS_UNUSED) { - const float3 denoising_feature_throughput = INTEGRATOR_STATE(path, - denoising_feature_throughput); + const float3 denoising_feature_throughput = INTEGRATOR_STATE( + state, path, denoising_feature_throughput); const float3 denoising_albedo = ensure_finite3(denoising_feature_throughput * diffuse_albedo); kernel_write_pass_float3(buffer + kernel_data.film.pass_denoising_albedo, denoising_albedo); } - INTEGRATOR_STATE_WRITE(path, flag) &= ~PATH_RAY_DENOISING_FEATURES; + INTEGRATOR_STATE_WRITE(state, path, flag) &= ~PATH_RAY_DENOISING_FEATURES; } else { - INTEGRATOR_STATE_WRITE(path, denoising_feature_throughput) *= specular_albedo; + INTEGRATOR_STATE_WRITE(state, path, denoising_feature_throughput) *= specular_albedo; } } -ccl_device_forceinline void kernel_write_denoising_features_volume(INTEGRATOR_STATE_ARGS, +ccl_device_forceinline void kernel_write_denoising_features_volume(KernelGlobals kg, + IntegratorState state, const float3 albedo, const bool scatter, ccl_global float *ccl_restrict render_buffer) { - ccl_global float *buffer = kernel_pass_pixel_render_buffer(INTEGRATOR_STATE_PASS, render_buffer); - const float3 denoising_feature_throughput = INTEGRATOR_STATE(path, denoising_feature_throughput); + ccl_global float *buffer = kernel_pass_pixel_render_buffer(kg, state, render_buffer); + const float3 denoising_feature_throughput = INTEGRATOR_STATE( + state, path, denoising_feature_throughput); if (scatter && kernel_data.film.pass_denoising_normal != PASS_UNUSED) { /* Assume scatter is sufficiently diffuse to stop writing denoising features. */ - INTEGRATOR_STATE_WRITE(path, flag) &= ~PATH_RAY_DENOISING_FEATURES; + INTEGRATOR_STATE_WRITE(state, path, flag) &= ~PATH_RAY_DENOISING_FEATURES; /* Write view direction as normal. */ const float3 denoising_normal = make_float3(0.0f, 0.0f, -1.0f); @@ -153,7 +156,8 @@ ccl_device_forceinline void kernel_write_denoising_features_volume(INTEGRATOR_ST /* Write shadow catcher passes on a bounce from the shadow catcher object. */ ccl_device_forceinline void kernel_write_shadow_catcher_bounce_data( - INTEGRATOR_STATE_ARGS, + KernelGlobals kg, + IntegratorState state, ccl_private const ShaderData *sd, ccl_global float *ccl_restrict render_buffer) { @@ -164,18 +168,18 @@ ccl_device_forceinline void kernel_write_shadow_catcher_bounce_data( kernel_assert(kernel_data.film.pass_shadow_catcher_sample_count != PASS_UNUSED); kernel_assert(kernel_data.film.pass_shadow_catcher_matte != PASS_UNUSED); - if (!kernel_shadow_catcher_is_path_split_bounce(INTEGRATOR_STATE_PASS, sd->object_flag)) { + if (!kernel_shadow_catcher_is_path_split_bounce(kg, state, sd->object_flag)) { return; } - ccl_global float *buffer = kernel_pass_pixel_render_buffer(INTEGRATOR_STATE_PASS, render_buffer); + ccl_global float *buffer = kernel_pass_pixel_render_buffer(kg, state, render_buffer); /* Count sample for the shadow catcher object. */ kernel_write_pass_float(buffer + kernel_data.film.pass_shadow_catcher_sample_count, 1.0f); /* Since the split is done, the sample does not contribute to the matte, so accumulate it as * transparency to the matte. */ - const float3 throughput = INTEGRATOR_STATE(path, throughput); + const float3 throughput = INTEGRATOR_STATE(state, path, throughput); kernel_write_pass_float(buffer + kernel_data.film.pass_shadow_catcher_matte + 3, average(throughput)); } @@ -191,12 +195,13 @@ ccl_device_inline size_t kernel_write_id_pass(ccl_global float *ccl_restrict buf return depth * 4; } -ccl_device_inline void kernel_write_data_passes(INTEGRATOR_STATE_ARGS, +ccl_device_inline void kernel_write_data_passes(KernelGlobals kg, + IntegratorState state, ccl_private const ShaderData *sd, ccl_global float *ccl_restrict render_buffer) { #ifdef __PASSES__ - const int path_flag = INTEGRATOR_STATE(path, flag); + const int path_flag = INTEGRATOR_STATE(state, path, flag); if (!(path_flag & PATH_RAY_CAMERA)) { return; @@ -208,12 +213,12 @@ ccl_device_inline void kernel_write_data_passes(INTEGRATOR_STATE_ARGS, return; } - ccl_global float *buffer = kernel_pass_pixel_render_buffer(INTEGRATOR_STATE_PASS, render_buffer); + ccl_global float *buffer = kernel_pass_pixel_render_buffer(kg, state, render_buffer); if (!(path_flag & PATH_RAY_SINGLE_PASS_DONE)) { if (!(sd->flag & SD_TRANSPARENT) || kernel_data.film.pass_alpha_threshold == 0.0f || average(shader_bsdf_alpha(kg, sd)) >= kernel_data.film.pass_alpha_threshold) { - if (INTEGRATOR_STATE(path, sample) == 0) { + if (INTEGRATOR_STATE(state, path, sample) == 0) { if (flag & PASSMASK(DEPTH)) { const float depth = camera_z_depth(kg, sd->P); kernel_write_pass_float(buffer + kernel_data.film.pass_depth, depth); @@ -250,12 +255,12 @@ ccl_device_inline void kernel_write_data_passes(INTEGRATOR_STATE_ARGS, kernel_write_pass_float(buffer + kernel_data.film.pass_motion_weight, 1.0f); } - INTEGRATOR_STATE_WRITE(path, flag) |= PATH_RAY_SINGLE_PASS_DONE; + INTEGRATOR_STATE_WRITE(state, path, flag) |= PATH_RAY_SINGLE_PASS_DONE; } } if (kernel_data.film.cryptomatte_passes) { - const float3 throughput = INTEGRATOR_STATE(path, throughput); + const float3 throughput = INTEGRATOR_STATE(state, path, throughput); const float matte_weight = average(throughput) * (1.0f - average(shader_bsdf_transparency(kg, sd))); if (matte_weight > 0.0f) { @@ -279,17 +284,17 @@ ccl_device_inline void kernel_write_data_passes(INTEGRATOR_STATE_ARGS, } if (flag & PASSMASK(DIFFUSE_COLOR)) { - const float3 throughput = INTEGRATOR_STATE(path, throughput); + const float3 throughput = INTEGRATOR_STATE(state, path, throughput); kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_color, shader_bsdf_diffuse(kg, sd) * throughput); } if (flag & PASSMASK(GLOSSY_COLOR)) { - const float3 throughput = INTEGRATOR_STATE(path, throughput); + const float3 throughput = INTEGRATOR_STATE(state, path, throughput); kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_color, shader_bsdf_glossy(kg, sd) * throughput); } if (flag & PASSMASK(TRANSMISSION_COLOR)) { - const float3 throughput = INTEGRATOR_STATE(path, throughput); + const float3 throughput = INTEGRATOR_STATE(state, path, throughput); kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_color, shader_bsdf_transmission(kg, sd) * throughput); } @@ -314,7 +319,7 @@ ccl_device_inline void kernel_write_data_passes(INTEGRATOR_STATE_ARGS, mist = powf(mist, mist_falloff); /* Modulate by transparency */ - const float3 throughput = INTEGRATOR_STATE(path, throughput); + const float3 throughput = INTEGRATOR_STATE(state, path, throughput); const float3 alpha = shader_bsdf_alpha(kg, sd); const float mist_output = (1.0f - mist) * average(throughput * alpha); |