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

@ -39,7 +39,9 @@ ccl_device_forceinline int bvh_aligned_node_intersect(KernelGlobals *kg,
{
/* fetch node data */
# ifdef __VISIBILITY_FLAG__
float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
# endif
float4 node0 = kernel_tex_fetch(__bvh_nodes, node_addr + 1);
float4 node1 = kernel_tex_fetch(__bvh_nodes, node_addr + 2);
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])
{
int mask = 0;
# ifdef __VISIBILITY_FLAG__
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])) {
# ifdef __VISIBILITY_FLAG__
if ((__float_as_uint(cnodes.x) & visibility))

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

@ -237,7 +237,9 @@ ccl_device void camera_sample_orthographic(KernelGlobals *kg,
/* Panorama Camera */
ccl_device_inline void camera_sample_panorama(ccl_constant KernelCamera *cam,
#ifdef __CAMERA_MOTION__
const ccl_global DecomposedTransform *cam_motion,
#endif
float raster_x,
float raster_y,
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);
}
else {
#ifdef __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);
#else
camera_sample_panorama(&kernel_data.cam, raster_x, raster_y, lens_u, lens_v, ray);
#endif
}
}

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

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

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

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

@ -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)) {
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
kernel_update_denoising_features(kg, sd, state, L);
}
#endif
}
#ifdef __AO__

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

@ -16,6 +16,8 @@
CCL_NAMESPACE_BEGIN
#ifdef __SHADER_RAYTRACE__
/* Bevel shader averaging normals from nearby surfaces.
*
* Sampling strategy from: BSSRDF Importance Sampling, SIGGRAPH 2013
@ -120,14 +122,14 @@ ccl_device_noinline float3 svm_bevel(KernelGlobals *kg,
if (sd->type & PRIMITIVE_TRIANGLE) {
hit_P = triangle_refine_local(kg, sd, &isect.hits[hit], ray);
}
#ifdef __OBJECT_MOTION__
# ifdef __OBJECT_MOTION__
else if (sd->type & PRIMITIVE_MOTION_TRIANGLE) {
float3 verts[3];
motion_triangle_vertices(
kg, sd->object, kernel_tex_fetch(__prim_index, isect.hits[hit].prim), sd->time, verts);
hit_P = motion_triangle_refine_local(kg, sd, &isect.hits[hit], ray, verts);
}
#endif /* __OBJECT_MOTION__ */
# endif /* __OBJECT_MOTION__ */
/* Get geometric normal. */
float3 hit_Ng = isect.Ng[hit];
@ -151,11 +153,11 @@ ccl_device_noinline float3 svm_bevel(KernelGlobals *kg,
if (sd->type & PRIMITIVE_TRIANGLE) {
N = triangle_smooth_normal(kg, N, prim, u, v);
}
#ifdef __OBJECT_MOTION__
# ifdef __OBJECT_MOTION__
else if (sd->type & PRIMITIVE_MOTION_TRIANGLE) {
N = motion_triangle_smooth_normal(kg, N, sd->object, prim, u, v, sd->time);
}
#endif /* __OBJECT_MOTION__ */
# endif /* __OBJECT_MOTION__ */
}
/* Transform normals to world space. */
@ -214,4 +216,6 @@ ccl_device void svm_node_bevel(
stack_store_float3(stack, out_offset, bevel_N);
}
#endif /* __SHADER_RAYTRACE__ */
CCL_NAMESPACE_END

@ -16,6 +16,8 @@
CCL_NAMESPACE_BEGIN
#ifdef __TEXTURES__
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);
@ -199,4 +201,6 @@ ccl_device void svm_node_tex_environment(KernelGlobals *kg,
stack_store_float(stack, alpha_offset, f.w);
}
#endif /* __TEXTURES__ */
CCL_NAMESPACE_END