Cycles: Tweak inline policy for some functions

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.
This commit is contained in:
Sergey Sharybin 2016-01-14 14:53:05 +05:00
parent 5af103fe00
commit 1f273cec00
6 changed files with 42 additions and 21 deletions

@ -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);

@ -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;

@ -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;

@ -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);

@ -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);

@ -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;