Cycles: Cleanup, indentation and braces

This commit is contained in:
Sergey Sharybin
2016-02-03 15:00:55 +01:00
parent 87cbcd697b
commit 3aa74828ab
19 changed files with 141 additions and 115 deletions

View File

@@ -212,8 +212,8 @@ void BlenderSync::sync_background_light(bool use_portal)
ObjectKey key(b_world, 0, b_world);
if(light_map.sync(&light, b_world, b_world, key) ||
world_recalc ||
b_world.ptr.data != world_map)
world_recalc ||
b_world.ptr.data != world_map)
{
light->type = LIGHT_BACKGROUND;
light->map_resolution = get_int(cworld, "sample_map_resolution");

View File

@@ -142,32 +142,32 @@ static void set_default_value(ShaderInput *input,
{
/* copy values for non linked inputs */
switch(input->type) {
case SHADER_SOCKET_FLOAT: {
input->set(get_float(b_sock.ptr, "default_value"));
break;
}
case SHADER_SOCKET_INT: {
input->set((float)get_int(b_sock.ptr, "default_value"));
break;
}
case SHADER_SOCKET_COLOR: {
input->set(float4_to_float3(get_float4(b_sock.ptr, "default_value")));
break;
}
case SHADER_SOCKET_NORMAL:
case SHADER_SOCKET_POINT:
case SHADER_SOCKET_VECTOR: {
input->set(get_float3(b_sock.ptr, "default_value"));
break;
}
case SHADER_SOCKET_STRING: {
input->set((ustring)blender_absolute_path(b_data, b_id, get_string(b_sock.ptr, "default_value")));
break;
}
case SHADER_SOCKET_CLOSURE:
case SHADER_SOCKET_UNDEFINED:
break;
case SHADER_SOCKET_FLOAT: {
input->set(get_float(b_sock.ptr, "default_value"));
break;
}
case SHADER_SOCKET_INT: {
input->set((float)get_int(b_sock.ptr, "default_value"));
break;
}
case SHADER_SOCKET_COLOR: {
input->set(float4_to_float3(get_float4(b_sock.ptr, "default_value")));
break;
}
case SHADER_SOCKET_NORMAL:
case SHADER_SOCKET_POINT:
case SHADER_SOCKET_VECTOR: {
input->set(get_float3(b_sock.ptr, "default_value"));
break;
}
case SHADER_SOCKET_STRING: {
input->set((ustring)blender_absolute_path(b_data, b_id, get_string(b_sock.ptr, "default_value")));
break;
}
case SHADER_SOCKET_CLOSURE:
case SHADER_SOCKET_UNDEFINED:
break;
}
}
@@ -399,12 +399,12 @@ static ShaderNode *add_node(Scene *scene,
SubsurfaceScatteringNode *subsurface = new SubsurfaceScatteringNode();
switch(b_subsurface_node.falloff()) {
case BL::ShaderNodeSubsurfaceScattering::falloff_CUBIC:
subsurface->closure = CLOSURE_BSSRDF_CUBIC_ID;
break;
case BL::ShaderNodeSubsurfaceScattering::falloff_GAUSSIAN:
subsurface->closure = CLOSURE_BSSRDF_GAUSSIAN_ID;
break;
case BL::ShaderNodeSubsurfaceScattering::falloff_CUBIC:
subsurface->closure = CLOSURE_BSSRDF_CUBIC_ID;
break;
case BL::ShaderNodeSubsurfaceScattering::falloff_GAUSSIAN:
subsurface->closure = CLOSURE_BSSRDF_GAUSSIAN_ID;
break;
}
node = subsurface;
@@ -414,18 +414,18 @@ static ShaderNode *add_node(Scene *scene,
GlossyBsdfNode *glossy = new GlossyBsdfNode();
switch(b_glossy_node.distribution()) {
case BL::ShaderNodeBsdfGlossy::distribution_SHARP:
glossy->distribution = ustring("Sharp");
break;
case BL::ShaderNodeBsdfGlossy::distribution_BECKMANN:
glossy->distribution = ustring("Beckmann");
break;
case BL::ShaderNodeBsdfGlossy::distribution_GGX:
glossy->distribution = ustring("GGX");
break;
case BL::ShaderNodeBsdfGlossy::distribution_ASHIKHMIN_SHIRLEY:
glossy->distribution = ustring("Ashikhmin-Shirley");
break;
case BL::ShaderNodeBsdfGlossy::distribution_SHARP:
glossy->distribution = ustring("Sharp");
break;
case BL::ShaderNodeBsdfGlossy::distribution_BECKMANN:
glossy->distribution = ustring("Beckmann");
break;
case BL::ShaderNodeBsdfGlossy::distribution_GGX:
glossy->distribution = ustring("GGX");
break;
case BL::ShaderNodeBsdfGlossy::distribution_ASHIKHMIN_SHIRLEY:
glossy->distribution = ustring("Ashikhmin-Shirley");
break;
}
node = glossy;
}
@@ -433,15 +433,15 @@ static ShaderNode *add_node(Scene *scene,
BL::ShaderNodeBsdfGlass b_glass_node(b_node);
GlassBsdfNode *glass = new GlassBsdfNode();
switch(b_glass_node.distribution()) {
case BL::ShaderNodeBsdfGlass::distribution_SHARP:
glass->distribution = ustring("Sharp");
break;
case BL::ShaderNodeBsdfGlass::distribution_BECKMANN:
glass->distribution = ustring("Beckmann");
break;
case BL::ShaderNodeBsdfGlass::distribution_GGX:
glass->distribution = ustring("GGX");
break;
case BL::ShaderNodeBsdfGlass::distribution_SHARP:
glass->distribution = ustring("Sharp");
break;
case BL::ShaderNodeBsdfGlass::distribution_BECKMANN:
glass->distribution = ustring("Beckmann");
break;
case BL::ShaderNodeBsdfGlass::distribution_GGX:
glass->distribution = ustring("GGX");
break;
}
node = glass;
}

View File

@@ -657,14 +657,14 @@ public:
/* pass in parameters */
void *args[] = {&d_buffer,
&d_rng_state,
&sample,
&rtile.x,
&rtile.y,
&rtile.w,
&rtile.h,
&rtile.offset,
&rtile.stride};
&d_rng_state,
&sample,
&rtile.x,
&rtile.y,
&rtile.w,
&rtile.h,
&rtile.offset,
&rtile.stride};
/* launch kernel */
int threads_per_block;
@@ -684,9 +684,9 @@ public:
cuda_assert(cuFuncSetCacheConfig(cuPathTrace, CU_FUNC_CACHE_PREFER_L1));
cuda_assert(cuLaunchKernel(cuPathTrace,
xblocks , yblocks, 1, /* blocks */
xthreads, ythreads, 1, /* threads */
0, 0, args, 0));
xblocks , yblocks, 1, /* blocks */
xthreads, ythreads, 1, /* threads */
0, 0, args, 0));
cuda_assert(cuCtxSynchronize());
@@ -717,14 +717,14 @@ public:
/* pass in parameters */
void *args[] = {&d_rgba,
&d_buffer,
&sample_scale,
&task.x,
&task.y,
&task.w,
&task.h,
&task.offset,
&task.stride};
&d_buffer,
&sample_scale,
&task.x,
&task.y,
&task.w,
&task.h,
&task.offset,
&task.stride};
/* launch kernel */
int threads_per_block;
@@ -738,9 +738,9 @@ public:
cuda_assert(cuFuncSetCacheConfig(cuFilmConvert, CU_FUNC_CACHE_PREFER_L1));
cuda_assert(cuLaunchKernel(cuFilmConvert,
xblocks , yblocks, 1, /* blocks */
xthreads, ythreads, 1, /* threads */
0, 0, args, 0));
xblocks , yblocks, 1, /* blocks */
xthreads, ythreads, 1, /* threads */
0, 0, args, 0));
unmap_pixels((rgba_byte)? rgba_byte: rgba_half);
@@ -803,9 +803,9 @@ public:
cuda_assert(cuFuncSetCacheConfig(cuShader, CU_FUNC_CACHE_PREFER_L1));
cuda_assert(cuLaunchKernel(cuShader,
xblocks , 1, 1, /* blocks */
threads_per_block, 1, 1, /* threads */
0, 0, args, 0));
xblocks , 1, 1, /* blocks */
threads_per_block, 1, 1, /* threads */
0, 0, args, 0));
cuda_assert(cuCtxSynchronize());

View File

@@ -994,7 +994,8 @@ public:
if(path_exists(clbin) && load_binary(kernel_path,
clbin,
build_flags,
&cpProgram)) {
&cpProgram))
{
/* Kernel loaded from binary, nothing to do. */
VLOG(2) << "Loaded kernel from " << clbin << ".";
}
@@ -1672,7 +1673,8 @@ public:
clbin,
custom_kernel_build_options,
&path_trace_program,
debug_src)) {
debug_src))
{
/* Kernel loaded from binary, nothing to do. */
}
else {
@@ -2080,7 +2082,8 @@ public:
clbin,
custom_kernel_build_options,
program,
debug_src)) {
debug_src))
{
/* Kernel loaded from binary. */
}
else {

View File

@@ -216,8 +216,13 @@ CCL_NAMESPACE_BEGIN
#undef BVH_NAME_EVAL
#undef BVH_FUNCTION_FULL_NAME
ccl_device_intersect bool scene_intersect(KernelGlobals *kg, const Ray *ray, const uint visibility, Intersection *isect,
uint *lcg_state, float difl, float extmax)
ccl_device_intersect bool scene_intersect(KernelGlobals *kg,
const Ray *ray,
const uint visibility,
Intersection *isect,
uint *lcg_state,
float difl,
float extmax)
{
#ifdef __OBJECT_MOTION__
if(kernel_data.bvh.have_motion) {

View File

@@ -693,8 +693,10 @@ bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D, float t, L
return false;
if(!ray_aligned_disk_intersect(P, D, t,
lightP, radius, &ls->P, &ls->t))
lightP, radius, &ls->P, &ls->t))
{
return false;
}
ls->Ng = -D;
ls->D = D;
@@ -736,8 +738,10 @@ bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D, float t, L
float3 light_P = make_float3(data0.y, data0.z, data0.w);
if(!ray_quad_intersect(P, D, t,
light_P, axisu, axisv, &ls->P, &ls->t))
light_P, axisu, axisv, &ls->P, &ls->t))
{
return false;
}
ls->D = D;
ls->Ng = Ng;

View File

@@ -39,7 +39,7 @@ ccl_device void kernel_branched_path_surface_connect_light(KernelGlobals *kg, RN
/* lamp sampling */
for(int i = 0; i < kernel_data.integrator.num_all_lights; i++) {
if(UNLIKELY(light_select_reached_max_bounces(kg, i, state->bounce)))
continue;
continue;
int num_samples = ceil_to_int(num_samples_adjust*light_select_num_samples(kg, i));
float num_samples_inv = num_samples_adjust/(num_samples*kernel_data.integrator.num_all_lights);

View File

@@ -225,9 +225,14 @@ ccl_device_inline void shader_setup_from_subsurface(KernelGlobals *kg, ShaderDat
/* ShaderData setup from position sampled on mesh */
ccl_device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
const float3 P, const float3 Ng, const float3 I,
int shader, int object, int prim, float u, float v, float t, float time)
ccl_device void shader_setup_from_sample(KernelGlobals *kg,
ShaderData *sd,
const float3 P,
const float3 Ng,
const float3 I,
int shader, int object, int prim,
float u, float v, float t,
float time)
{
/* vectors */
ccl_fetch(sd, P) = P;

View File

@@ -87,7 +87,7 @@ ccl_device char kernel_next_iteration_setup(
/* Path radiance update for AO/Direct_lighting's shadow blocked. */
if(IS_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL) ||
IS_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_AO))
{
{
state = &PathState_coop[ray_index];
L = &PathRadiance_coop[ray_index];
float3 _throughput = throughput_coop[ray_index];

View File

@@ -254,7 +254,8 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
case CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID: {
#ifdef __CAUSTICS_TRICKS__
if(!kernel_data.integrator.caustics_reflective &&
!kernel_data.integrator.caustics_refractive && (path_flag & PATH_RAY_DIFFUSE)) {
!kernel_data.integrator.caustics_refractive && (path_flag & PATH_RAY_DIFFUSE))
{
break;
}
#endif

View File

@@ -168,14 +168,16 @@ ccl_device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack
float3 f;
/* Compute Sky */
if(sky_model == 0)
if(sky_model == 0) {
f = sky_radiance_old(kg, dir, sunphi, suntheta,
radiance_x, radiance_y, radiance_z,
config_x, config_y, config_z);
else
}
else {
f = sky_radiance_new(kg, dir, sunphi, suntheta,
radiance_x, radiance_y, radiance_z,
config_x, config_y, config_z);
}
stack_store_float3(stack, out_offset, f);
}

View File

@@ -245,7 +245,7 @@ typedef enum NodeMath {
NODE_MATH_LESS_THAN,
NODE_MATH_GREATER_THAN,
NODE_MATH_MODULO,
NODE_MATH_ABSOLUTE,
NODE_MATH_ABSOLUTE,
NODE_MATH_CLAMP /* used for the clamp UI option */
} NodeMath;

View File

@@ -481,7 +481,8 @@ void ShaderGraph::remove_unneeded_nodes()
if(bg->outputs[0]->links.size()) {
/* Black color or zero strength, remove node */
if((!bg->inputs[0]->link && bg->inputs[0]->value == make_float3(0.0f, 0.0f, 0.0f)) ||
(!bg->inputs[1]->link && bg->inputs[1]->value.x == 0.0f)) {
(!bg->inputs[1]->link && bg->inputs[1]->value.x == 0.0f))
{
vector<ShaderInput*> inputs = bg->outputs[0]->links;
relink(bg->inputs, inputs, NULL);
@@ -496,7 +497,8 @@ void ShaderGraph::remove_unneeded_nodes()
if(em->outputs[0]->links.size()) {
/* Black color or zero strength, remove node */
if((!em->inputs[0]->link && em->inputs[0]->value == make_float3(0.0f, 0.0f, 0.0f)) ||
(!em->inputs[1]->link && em->inputs[1]->value.x == 0.0f)) {
(!em->inputs[1]->link && em->inputs[1]->value.x == 0.0f))
{
vector<ShaderInput*> inputs = em->outputs[0]->links;
relink(em->inputs, inputs, NULL);

View File

@@ -353,7 +353,8 @@ void ImageManager::remove_image(const string& filename,
filename,
builtin_data,
interpolation,
extension)) {
extension))
{
remove_image(slot);
break;
}
@@ -377,7 +378,8 @@ void ImageManager::tag_reload_image(const string& filename,
filename,
builtin_data,
interpolation,
extension)) {
extension))
{
images[slot]->need_load = true;
break;
}
@@ -390,7 +392,8 @@ void ImageManager::tag_reload_image(const string& filename,
filename,
builtin_data,
interpolation,
extension)) {
extension))
{
float_images[slot]->need_load = true;
break;
}

View File

@@ -4251,10 +4251,10 @@ bool VectorMathNode::constant_fold(ShaderOutput *socket, float3 *optimized_value
if(vector1_in->link == NULL && vector2_in->link == NULL) {
svm_vector_math(&value,
&vector,
(NodeVectorMath)type_enum[type],
vector1_in->value,
vector2_in->value);
&vector,
(NodeVectorMath)type_enum[type],
vector1_in->value,
vector2_in->value);
if(socket == output("Value")) {
optimized_value->x = value;

View File

@@ -165,7 +165,7 @@ static void ArHosekSkyModel_CookConfiguration(
10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[i+27] +
5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[i+36] +
pow(solar_elevation, 5.0) * elev_matrix[i+45]);
}
}
// alb 1 low turb
elev_matrix = dataset + (9*6*10 + 9*6*(int_turbidity-1));
@@ -301,7 +301,7 @@ double arhosekskymodel_radiance(ArHosekSkyModelState *state,
int low_wl = (int)((wavelength - 320.0) / 40.0);
if(low_wl < 0 || low_wl >= 11)
return 0.0f;
return 0.0f;
double interp = fmod((wavelength - 320.0 ) / 40.0, 1.0);
@@ -318,8 +318,8 @@ double arhosekskymodel_radiance(ArHosekSkyModelState *state,
double result = ( 1.0 - interp ) * val_low;
if(low_wl+1 < 11) {
result +=
if(low_wl+1 < 11) {
result +=
interp
* ArHosekSkyModel_GetRadianceInternal(
state->configs[low_wl+1],
@@ -347,7 +347,7 @@ ArHosekSkyModelState * arhosek_xyz_skymodelstate_alloc_init(
state->albedo = albedo;
state->elevation = elevation;
for(unsigned int channel = 0; channel < 3; ++channel) {
for(unsigned int channel = 0; channel < 3; ++channel) {
ArHosekSkyModel_CookConfiguration(
datasetsXYZ[channel],
state->configs[channel],

View File

@@ -204,9 +204,10 @@ void OpenSubdMesh::add_face(int *index, int num)
if(opposite && opposite->GetOpposite())
assert("A non-manifold edge incident to more than 2 faces was found\n");
if(origin->GetEdge(destination))
if(origin->GetEdge(destination)) {
assert("An edge connecting two vertices was specified more than once."
"It's likely that an incident face was flipped\n");
"It's likely that an incident face was flipped\n");
}
}
#endif

View File

@@ -141,7 +141,7 @@ void MD5Hash::process(const uint8_t *data /*[64]*/)
X = xbuf; /* (dynamic only) */
for(i = 0; i < 16; ++i, xp += 4)
xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
}
}

View File

@@ -558,7 +558,7 @@ ccl_device_inline const ssef shuffle_swap(const ssef& a, shuffle_swap_t shuf)
#ifdef __KERNEL_SSE41__
ccl_device_inline void gen_idirsplat_swap(const ssef &pn, const shuffle_swap_t &shuf_identity, const shuffle_swap_t &shuf_swap,
const float3& idir, ssef idirsplat[3], shuffle_swap_t shufflexyz[3])
const float3& idir, ssef idirsplat[3], shuffle_swap_t shufflexyz[3])
{
const __m128 idirsplat_raw[] = { _mm_set_ps1(idir.x), _mm_set_ps1(idir.y), _mm_set_ps1(idir.z) };
idirsplat[0] = _mm_xor_ps(idirsplat_raw[0], pn);
@@ -577,7 +577,7 @@ ccl_device_inline void gen_idirsplat_swap(const ssef &pn, const shuffle_swap_t &
#else
ccl_device_inline void gen_idirsplat_swap(const ssef &pn, const shuffle_swap_t &shuf_identity, const shuffle_swap_t &shuf_swap,
const float3& idir, ssef idirsplat[3], shuffle_swap_t shufflexyz[3])
const float3& idir, ssef idirsplat[3], shuffle_swap_t shufflexyz[3])
{
idirsplat[0] = ssef(idir.x) ^ pn;
idirsplat[1] = ssef(idir.y) ^ pn;