Cycles: fixes for building kernel without certain features

Ref D5363
This commit is contained in:
Patrick Mours
2019-08-21 12:04:40 +02:00
committed by Brecht Van Lommel
parent 7a15b938bd
commit b05e7ea719
11 changed files with 37 additions and 13 deletions

View File

@@ -39,7 +39,9 @@ ccl_device_forceinline int bvh_aligned_node_intersect(KernelGlobals *kg,
{ {
/* fetch node data */ /* fetch node data */
# ifdef __VISIBILITY_FLAG__
float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0); float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
# endif
float4 node0 = kernel_tex_fetch(__bvh_nodes, node_addr + 1); float4 node0 = kernel_tex_fetch(__bvh_nodes, node_addr + 1);
float4 node1 = kernel_tex_fetch(__bvh_nodes, node_addr + 2); float4 node1 = kernel_tex_fetch(__bvh_nodes, node_addr + 2);
float4 node2 = kernel_tex_fetch(__bvh_nodes, node_addr + 3); float4 node2 = kernel_tex_fetch(__bvh_nodes, node_addr + 3);
@@ -111,7 +113,9 @@ ccl_device_forceinline int bvh_unaligned_node_intersect(KernelGlobals *kg,
float dist[2]) float dist[2])
{ {
int mask = 0; int mask = 0;
# ifdef __VISIBILITY_FLAG__
float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0); float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
# endif
if (bvh_unaligned_node_intersect_child(kg, P, dir, t, node_addr, 0, &dist[0])) { if (bvh_unaligned_node_intersect_child(kg, P, dir, t, node_addr, 0, &dist[0])) {
# ifdef __VISIBILITY_FLAG__ # ifdef __VISIBILITY_FLAG__
if ((__float_as_uint(cnodes.x) & visibility)) if ((__float_as_uint(cnodes.x) & visibility))

View File

@@ -319,10 +319,12 @@ ccl_device_inline void path_radiance_accum_ao(PathRadiance *L,
float3 bsdf, float3 bsdf,
float3 ao) float3 ao)
{ {
#ifdef __PASSES__
/* Store AO pass. */ /* Store AO pass. */
if (L->use_light_pass && state->bounce == 0) { if (L->use_light_pass && state->bounce == 0) {
L->ao += alpha * throughput * ao; L->ao += alpha * throughput * ao;
} }
#endif
#ifdef __SHADOW_TRICKS__ #ifdef __SHADOW_TRICKS__
/* For shadow catcher, accumulate ratio. */ /* For shadow catcher, accumulate ratio. */

View File

@@ -237,7 +237,9 @@ ccl_device void camera_sample_orthographic(KernelGlobals *kg,
/* Panorama Camera */ /* Panorama Camera */
ccl_device_inline void camera_sample_panorama(ccl_constant KernelCamera *cam, ccl_device_inline void camera_sample_panorama(ccl_constant KernelCamera *cam,
#ifdef __CAMERA_MOTION__
const ccl_global DecomposedTransform *cam_motion, const ccl_global DecomposedTransform *cam_motion,
#endif
float raster_x, float raster_x,
float raster_y, float raster_y,
float lens_u, float lens_u,
@@ -413,8 +415,12 @@ ccl_device_inline void camera_sample(KernelGlobals *kg,
camera_sample_orthographic(kg, raster_x, raster_y, lens_u, lens_v, ray); camera_sample_orthographic(kg, raster_x, raster_y, lens_u, lens_v, ray);
} }
else { else {
#ifdef __CAMERA_MOTION__
const ccl_global DecomposedTransform *cam_motion = kernel_tex_array(__camera_motion); const ccl_global DecomposedTransform *cam_motion = kernel_tex_array(__camera_motion);
camera_sample_panorama(&kernel_data.cam, cam_motion, raster_x, raster_y, lens_u, lens_v, ray); camera_sample_panorama(&kernel_data.cam, cam_motion, raster_x, raster_y, lens_u, lens_v, ray);
#else
camera_sample_panorama(&kernel_data.cam, raster_x, raster_y, lens_u, lens_v, ray);
#endif
} }
} }

View File

@@ -114,14 +114,12 @@ ccl_device_inline void kernel_write_denoising_shadow(KernelGlobals *kg,
float value = path_total_shaded / max(path_total, 1e-7f); float value = path_total_shaded / max(path_total, 1e-7f);
kernel_write_pass_float(buffer + 2, value * value); kernel_write_pass_float(buffer + 2, value * value);
} }
#endif /* __DENOISING_FEATURES__ */
ccl_device_inline void kernel_update_denoising_features(KernelGlobals *kg, ccl_device_inline void kernel_update_denoising_features(KernelGlobals *kg,
ShaderData *sd, ShaderData *sd,
ccl_addr_space PathState *state, ccl_addr_space PathState *state,
PathRadiance *L) PathRadiance *L)
{ {
#ifdef __DENOISING_FEATURES__
if (state->denoising_feature_weight == 0.0f) { if (state->denoising_feature_weight == 0.0f) {
return; return;
} }
@@ -162,13 +160,8 @@ ccl_device_inline void kernel_update_denoising_features(KernelGlobals *kg,
state->denoising_feature_weight = 0.0f; state->denoising_feature_weight = 0.0f;
} }
#else
(void)kg;
(void)sd;
(void)state;
(void)L;
#endif /* __DENOISING_FEATURES__ */
} }
#endif /* __DENOISING_FEATURES__ */
#ifdef __KERNEL_DEBUG__ #ifdef __KERNEL_DEBUG__
ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg, ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,

View File

@@ -590,7 +590,9 @@ ccl_device_forceinline void kernel_path_integrate(KernelGlobals *kg,
throughput /= probability; throughput /= probability;
} }
# ifdef __DENOISING_FEATURES__
kernel_update_denoising_features(kg, &sd, state, L); kernel_update_denoising_features(kg, &sd, state, L);
# endif
# ifdef __AO__ # ifdef __AO__
/* ambient occlusion */ /* ambient occlusion */
@@ -610,8 +612,10 @@ ccl_device_forceinline void kernel_path_integrate(KernelGlobals *kg,
} }
# endif /* __SUBSURFACE__ */ # endif /* __SUBSURFACE__ */
# ifdef __EMISSION__
/* direct lighting */ /* direct lighting */
kernel_path_surface_connect_light(kg, &sd, emission_sd, throughput, state, L); kernel_path_surface_connect_light(kg, &sd, emission_sd, throughput, state, L);
# endif /* __EMISSION__ */
# ifdef __VOLUME__ # ifdef __VOLUME__
} }

View File

@@ -445,7 +445,9 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg,
} }
} }
# ifdef __DENOISING_FEATURES__
kernel_update_denoising_features(kg, &sd, &state, L); kernel_update_denoising_features(kg, &sd, &state, L);
# endif
# ifdef __AO__ # ifdef __AO__
/* ambient occlusion */ /* ambient occlusion */

View File

@@ -115,7 +115,6 @@ CCL_NAMESPACE_BEGIN
# define __LAMP_MIS__ # define __LAMP_MIS__
# define __CAMERA_MOTION__ # define __CAMERA_MOTION__
# define __OBJECT_MOTION__ # define __OBJECT_MOTION__
# define __HAIR__
# define __BAKING__ # define __BAKING__
# define __PRINCIPLED__ # define __PRINCIPLED__
# define __SUBSURFACE__ # define __SUBSURFACE__

View File

@@ -132,10 +132,12 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(
} }
} }
#ifdef __DENOISING_FEATURES__
if (IS_STATE(ray_state, ray_index, RAY_ACTIVE)) { if (IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
PathRadiance *L = &kernel_split_state.path_radiance[ray_index]; PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
kernel_update_denoising_features(kg, sd, state, L); kernel_update_denoising_features(kg, sd, state, L);
} }
#endif
} }
#ifdef __AO__ #ifdef __AO__

View File

@@ -16,6 +16,8 @@
CCL_NAMESPACE_BEGIN CCL_NAMESPACE_BEGIN
#ifdef __SHADER_RAYTRACE__
ccl_device_noinline float svm_ao(KernelGlobals *kg, ccl_device_noinline float svm_ao(KernelGlobals *kg,
ShaderData *sd, ShaderData *sd,
float3 N, float3 N,
@@ -102,4 +104,6 @@ ccl_device void svm_node_ao(
} }
} }
#endif /* __SHADER_RAYTRACE__ */
CCL_NAMESPACE_END CCL_NAMESPACE_END

View File

@@ -16,6 +16,8 @@
CCL_NAMESPACE_BEGIN CCL_NAMESPACE_BEGIN
#ifdef __SHADER_RAYTRACE__
/* Bevel shader averaging normals from nearby surfaces. /* Bevel shader averaging normals from nearby surfaces.
* *
* Sampling strategy from: BSSRDF Importance Sampling, SIGGRAPH 2013 * Sampling strategy from: BSSRDF Importance Sampling, SIGGRAPH 2013
@@ -214,4 +216,6 @@ ccl_device void svm_node_bevel(
stack_store_float3(stack, out_offset, bevel_N); stack_store_float3(stack, out_offset, bevel_N);
} }
#endif /* __SHADER_RAYTRACE__ */
CCL_NAMESPACE_END CCL_NAMESPACE_END

View File

@@ -16,6 +16,8 @@
CCL_NAMESPACE_BEGIN CCL_NAMESPACE_BEGIN
#ifdef __TEXTURES__
ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint flags) ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint flags)
{ {
float4 r = kernel_tex_image_interp(kg, id, x, y); float4 r = kernel_tex_image_interp(kg, id, x, y);
@@ -199,4 +201,6 @@ ccl_device void svm_node_tex_environment(KernelGlobals *kg,
stack_store_float(stack, alpha_offset, f.w); stack_store_float(stack, alpha_offset, f.w);
} }
#endif /* __TEXTURES__ */
CCL_NAMESPACE_END CCL_NAMESPACE_END