Cycles: Tweak inline policy for some functions
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 14 Jan 2016 09:53:05 +0000 (14:53 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 14 Jan 2016 09:53:05 +0000 (14:53 +0500)
The goal is to make Experimental kernel closer in performance to the
official kernel, avoiding spills and such.

There should not be big impact on official kernel, own tests showed
few percent performance drop on laptop's GPU. CPU was always the
same speed on AVX, AVX2 and SSE4.1 CPUs i've been testing here.

This seems to be the last essential step before we can get rid of
Experimental kernel and enable SSS officially on GPU without causing
some major performance issues.

Surely some more tweaks are possibly required, but that we can do
for until cows go home anyway.

intern/cycles/kernel/kernel_light.h
intern/cycles/kernel/kernel_path.h
intern/cycles/kernel/kernel_shader.h
intern/cycles/kernel/kernel_shadow.h
intern/cycles/kernel/svm/svm_mix.h
intern/cycles/kernel/svm/svm_tex_coord.h

index 7590ec2d706ec7efa2e7a522219e86582df27b75..ef098aeb050b41ce1c3771ae039fecd4fd47cd80 100644 (file)
@@ -845,7 +845,14 @@ ccl_device bool light_select_reached_max_bounces(KernelGlobals *kg, int index, i
        return (bounce > __float_as_int(data4.x));
 }
 
-ccl_device void light_sample(KernelGlobals *kg, float randt, float randu, float randv, float time, float3 P, int bounce, LightSample *ls)
+ccl_device_noinline void light_sample(KernelGlobals *kg,
+                                      float randt,
+                                      float randu,
+                                      float randv,
+                                      float time,
+                                      float3 P,
+                                      int bounce,
+                                      LightSample *ls)
 {
        /* sample index */
        int index = light_distribution_sample(kg, randt);
index fc32201596fbb47bcfe8f72c94c85eedbcf95236..650e3b047f0b48935df258b719d79323a28cddfc 100644 (file)
@@ -391,7 +391,12 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
        }
 }
 
-ccl_device void kernel_path_ao(KernelGlobals *kg, ShaderData *sd, PathRadiance *L, PathState *state, RNG *rng, float3 throughput)
+ccl_device_noinline void kernel_path_ao(KernelGlobals *kg,
+                                        ShaderData *sd,
+                                        PathRadiance *L,
+                                        PathState *state,
+                                        RNG *rng,
+                                        float3 throughput)
 {
        /* todo: solve correlation */
        float bsdf_u, bsdf_v;
@@ -586,7 +591,11 @@ ccl_device void kernel_path_subsurface_setup_indirect(
 
 #endif  /* __SUBSURFACE__ */
 
-ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer)
+ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
+                                               RNG *rng,
+                                               int sample,
+                                               Ray ray,
+                                               ccl_global float *buffer)
 {
        /* initialize */
        PathRadiance L;
index 63e5ace8f9410b7f91e9ab7ff809941680554b8a..9a4d237207585252938503f1df6e03ae79264787 100644 (file)
@@ -48,8 +48,10 @@ ccl_device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd
 }
 #endif
 
-ccl_device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
-       const Intersection *isect, const Ray *ray)
+ccl_device_noinline void shader_setup_from_ray(KernelGlobals *kg,
+                                               ShaderData *sd,
+                                               const Intersection *isect,
+                                               const Ray *ray)
 {
 #ifdef __INSTANCING__
        ccl_fetch(sd, object) = (isect->object == PRIM_NONE)? kernel_tex_fetch(__prim_object, isect->prim): isect->object;
index cb5fcf813f331159fc5465daa843e7a6aee95224..e86051095a50cb0e3b93c95172f378a2c0e70131 100644 (file)
@@ -183,11 +183,14 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
  * potentially transparent, and only in that case start marching. this gives
  * one extra ray cast for the cases were we do want transparency. */
 
-ccl_device_inline bool shadow_blocked(KernelGlobals *kg, ccl_addr_space PathState *state, ccl_addr_space Ray *ray_input, float3 *shadow
+ccl_device_noinline bool shadow_blocked(KernelGlobals *kg,
+                                        ccl_addr_space PathState *state,
+                                        ccl_addr_space Ray *ray_input,
+                                        float3 *shadow
 #ifdef __SPLIT_KERNEL__
-                                      , ShaderData *sd_mem, Intersection *isect_mem
+                                        , ShaderData *sd_mem, Intersection *isect_mem
 #endif
-                                      )
+                                       )
 {
        *shadow = make_float3(1.0f, 1.0f, 1.0f);
 
index 6111214acba97ed4c078fa1b0d8bc23d9acf47ea..7cbda111d81f82b52541cd64da267ceda71225e4 100644 (file)
@@ -261,7 +261,7 @@ ccl_device float3 svm_mix_clamp(float3 col)
        return outcol;
 }
 
-ccl_device float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2)
+ccl_device_noinline float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2)
 {
        float t = saturate(fac);
 
index eebd9bee420449d1ad7ad68d72b9f0a1a91e9084..27fed89fdf79e99da0731f29d50d24365610168f 100644 (file)
@@ -99,12 +99,12 @@ ccl_device void svm_node_tex_coord(KernelGlobals *kg,
        stack_store_float3(stack, out_offset, data);
 }
 
-ccl_device void svm_node_tex_coord_bump_dx(KernelGlobals *kg,
-                                           ShaderData *sd,
-                                           int path_flag,
-                                           float *stack,
-                                           uint4 node,
-                                           int *offset)
+ccl_device_inline void svm_node_tex_coord_bump_dx(KernelGlobals *kg,
+                                                  ShaderData *sd,
+                                                  int path_flag,
+                                                  float *stack,
+                                                  uint4 node,
+                                                  int *offset)
 {
 #ifdef __RAY_DIFFERENTIALS__
        float3 data;
@@ -184,12 +184,12 @@ ccl_device void svm_node_tex_coord_bump_dx(KernelGlobals *kg,
 #endif
 }
 
-ccl_device void svm_node_tex_coord_bump_dy(KernelGlobals *kg,
-                                           ShaderData *sd,
-                                           int path_flag,
-                                           float *stack,
-                                           uint4 node,
-                                           int *offset)
+ccl_device_inline void svm_node_tex_coord_bump_dy(KernelGlobals *kg,
+                                                  ShaderData *sd,
+                                                  int path_flag,
+                                                  float *stack,
+                                                  uint4 node,
+                                                  int *offset)
 {
 #ifdef __RAY_DIFFERENTIALS__
        float3 data;