Cycles: Cleanup, style

I wouldn't mind changing style to have space after keyword, but there was
no official code style change proposed.
This commit is contained in:
Sergey Sharybin 2018-08-24 14:36:18 +02:00
parent e92e90c30e
commit 658a9c6cf5
20 changed files with 50 additions and 53 deletions

@ -159,8 +159,7 @@ bool link_ptxas(CompilationSettings &settings)
" --gpu-name sm_" + std::to_string(settings.target_arch) +
" -m" + std::to_string(settings.bits);
if (settings.verbose)
{
if(settings.verbose) {
ptx += " --verbose";
printf("%s\n", ptx.c_str());
}

@ -1057,7 +1057,7 @@ static void add_nodes(Scene *scene,
for(b_node->internal_links.begin(b_link); b_link != b_node->internal_links.end(); ++b_link) {
BL::NodeSocket to_socket(b_link->to_socket());
SocketType::Type to_socket_type = convert_socket_type(to_socket);
if (to_socket_type == SocketType::UNDEFINED) {
if(to_socket_type == SocketType::UNDEFINED) {
continue;
}
@ -1084,7 +1084,7 @@ static void add_nodes(Scene *scene,
*/
for(b_node->inputs.begin(b_input); b_input != b_node->inputs.end(); ++b_input) {
SocketType::Type input_type = convert_socket_type(*b_input);
if (input_type == SocketType::UNDEFINED) {
if(input_type == SocketType::UNDEFINED) {
continue;
}
@ -1100,7 +1100,7 @@ static void add_nodes(Scene *scene,
}
for(b_node->outputs.begin(b_output); b_output != b_node->outputs.end(); ++b_output) {
SocketType::Type output_type = convert_socket_type(*b_output);
if (output_type == SocketType::UNDEFINED) {
if(output_type == SocketType::UNDEFINED) {
continue;
}

@ -1025,7 +1025,7 @@ void device_cpu_info(vector<DeviceInfo>& devices)
info.num = 0;
info.advanced_shading = true;
info.bvh_layout_mask = BVH_LAYOUT_BVH2;
if (system_cpu_support_sse2()) {
if(system_cpu_support_sse2()) {
info.bvh_layout_mask |= BVH_LAYOUT_BVH4;
}
info.has_volume_decoupled = true;

@ -1139,13 +1139,13 @@ string OpenCLInfo::get_readable_device_name(cl_device_id device_id)
/* Special exception for AMD Vega, need to be able to tell
* Vega 56 from 64 apart.
*/
if (name == "Radeon RX Vega") {
if(name == "Radeon RX Vega") {
cl_int max_compute_units = 0;
if (clGetDeviceInfo(device_id,
CL_DEVICE_MAX_COMPUTE_UNITS,
sizeof(max_compute_units),
&max_compute_units,
NULL) == CL_SUCCESS)
if(clGetDeviceInfo(device_id,
CL_DEVICE_MAX_COMPUTE_UNITS,
sizeof(max_compute_units),
&max_compute_units,
NULL) == CL_SUCCESS)
{
name += " " + to_string(max_compute_units);
}

@ -443,7 +443,7 @@ template<typename T>
void array_hash(const Node *node, const SocketType& socket, MD5Hash& md5)
{
const array<T>& a = *(const array<T>*)(((char*)node) + socket.struct_offset);
for (size_t i = 0; i < a.size(); i++) {
for(size_t i = 0; i < a.size(); i++) {
md5.append((uint8_t*)&a[i], sizeof(T));
}
}
@ -452,7 +452,7 @@ void float3_array_hash(const Node *node, const SocketType& socket, MD5Hash& md5)
{
/* Don't compare 4th element used for padding. */
const array<float3>& a = *(const array<float3>*)(((char*)node) + socket.struct_offset);
for (size_t i = 0; i < a.size(); i++) {
for(size_t i = 0; i < a.size(); i++) {
md5.append((uint8_t*)&a[i], sizeof(float) * 3);
}
}

@ -120,7 +120,7 @@ ccl_device_inline float bessel_I0(float x)
/* Logarithm of the Bessel function of the first kind. */
ccl_device_inline float log_bessel_I0(float x)
{
if (x > 12.0f) {
if(x > 12.0f) {
/* log(1/x) == -log(x) iff x > 0.
* This is only used with positive cosines */
return x + 0.5f * (1.f / (8.0f * x) - M_LN_2PI_F - logf(x));

@ -170,7 +170,7 @@ ccl_device_inline bool path_state_volume_next(KernelGlobals *kg, ccl_addr_space
/* For volume bounding meshes we pass through without counting transparent
* bounces, only sanity check in case self intersection gets us stuck. */
state->volume_bounds_bounce++;
if (state->volume_bounds_bounce > VOLUME_BOUNDS_MAX) {
if(state->volume_bounds_bounce > VOLUME_BOUNDS_MAX) {
return false;
}

@ -1010,7 +1010,7 @@ ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
DiffuseBsdf *bsdf = (DiffuseBsdf*)bsdf_alloc(sd,
sizeof(DiffuseBsdf),
make_float3(0.8f, 0.8f, 0.8f));
if (bsdf != NULL) {
if(bsdf != NULL) {
bsdf->N = sd->N;
sd->flag |= bsdf_diffuse_setup(bsdf);
}

@ -69,22 +69,22 @@ public:
void setup(ShaderData *sd, int path_flag, float3 weight)
{
if (method == u_cubic) {
if(method == u_cubic) {
alloc(sd, path_flag, weight, CLOSURE_BSSRDF_CUBIC_ID);
}
else if (method == u_gaussian) {
else if(method == u_gaussian) {
alloc(sd, path_flag, weight, CLOSURE_BSSRDF_GAUSSIAN_ID);
}
else if (method == u_burley) {
else if(method == u_burley) {
alloc(sd, path_flag, weight, CLOSURE_BSSRDF_BURLEY_ID);
}
else if (method == u_principled) {
else if(method == u_principled) {
alloc(sd, path_flag, weight, CLOSURE_BSSRDF_PRINCIPLED_ID);
}
else if (method == u_random_walk) {
else if(method == u_random_walk) {
alloc(sd, path_flag, weight, CLOSURE_BSSRDF_RANDOM_WALK_ID);
}
else if (method == u_principled_random_walk) {
else if(method == u_principled_random_walk) {
alloc(sd, path_flag, weight, CLOSURE_BSSRDF_PRINCIPLED_RANDOM_WALK_ID);
}
}

@ -200,11 +200,9 @@ public:
void setup(ShaderData *sd, int path_flag, float3 weight)
{
if(!skip(sd, path_flag, LABEL_GLOSSY))
{
if(!skip(sd, path_flag, LABEL_GLOSSY)) {
PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*)alloc(sd, path_flag, weight);
if (!bsdf)
{
if(!bsdf) {
return;
}

@ -98,11 +98,11 @@ ccl_device void svm_node_ao(KernelGlobals *kg,
float3 normal = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): sd->N;
float ao = svm_ao(kg, sd, normal, state, dist, samples, flags);
if (stack_valid(out_ao_offset)) {
if(stack_valid(out_ao_offset)) {
stack_store_float(stack, out_ao_offset, ao);
}
if (stack_valid(out_color_offset)) {
if(stack_valid(out_color_offset)) {
float3 color = stack_load_float3(stack, color_offset);
stack_store_float3(stack, out_color_offset, ao * color);
}

@ -148,11 +148,11 @@ ccl_device_noinline float3 svm_bevel(
int prim = kernel_tex_fetch(__prim_index, isect.hits[hit].prim);
int shader = kernel_tex_fetch(__tri_shader, prim);
if (shader & SHADER_SMOOTH_NORMAL) {
if(shader & SHADER_SMOOTH_NORMAL) {
float u = isect.hits[hit].u;
float v = isect.hits[hit].v;
if (sd->type & PRIMITIVE_TRIANGLE) {
if(sd->type & PRIMITIVE_TRIANGLE) {
N = triangle_smooth_normal(kg, N, prim, u, v);
}
#ifdef __OBJECT_MOTION__

@ -757,7 +757,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
const AttributeDescriptor attr_descr_random = find_attribute(kg, sd, data_node4.y);
float random = 0.0f;
if (attr_descr_random.offset != ATTR_STD_NOT_FOUND) {
if(attr_descr_random.offset != ATTR_STD_NOT_FOUND) {
random = primitive_attribute_float(kg, sd, attr_descr_random, NULL, NULL);
}
else {
@ -769,7 +769,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
if(bsdf) {
PrincipledHairExtra *extra = (PrincipledHairExtra*)closure_alloc_extra(sd, sizeof(PrincipledHairExtra));
if (!extra)
if(!extra)
break;
/* Random factors range: [-randomization/2, +randomization/2]. */

@ -94,13 +94,13 @@ ccl_device float svm_math(NodeMath type, float Fac1, float Fac2)
Fac = fabsf(Fac1);
else if(type == NODE_MATH_ARCTAN2)
Fac = atan2f(Fac1, Fac2);
else if (type == NODE_MATH_FLOOR)
else if(type == NODE_MATH_FLOOR)
Fac = floorf(Fac1);
else if (type == NODE_MATH_CEIL)
else if(type == NODE_MATH_CEIL)
Fac = ceilf(Fac1);
else if (type == NODE_MATH_FRACT)
else if(type == NODE_MATH_FRACT)
Fac = Fac1 - floorf(Fac1);
else if (type == NODE_MATH_SQRT)
else if(type == NODE_MATH_SQRT)
Fac = safe_sqrtf(Fac1);
else if(type == NODE_MATH_CLAMP)
Fac = saturate(Fac1);

@ -70,7 +70,7 @@ ccl_device void voronoi_neighbors(float3 p, NodeVoronoiDistanceMetric distance,
}
/* To keep the shortest four distances and associated points we have to keep them in sorted order. */
if (d < da[0]) {
if(d < da[0]) {
da[3] = da[2];
da[2] = da[1];
da[1] = da[0];
@ -81,7 +81,7 @@ ccl_device void voronoi_neighbors(float3 p, NodeVoronoiDistanceMetric distance,
pa[1] = pa[0];
pa[0] = vp;
}
else if (d < da[1]) {
else if(d < da[1]) {
da[3] = da[2];
da[2] = da[1];
da[1] = d;
@ -90,14 +90,14 @@ ccl_device void voronoi_neighbors(float3 p, NodeVoronoiDistanceMetric distance,
pa[2] = pa[1];
pa[1] = vp;
}
else if (d < da[2]) {
else if(d < da[2]) {
da[3] = da[2];
da[2] = d;
pa[3] = pa[2];
pa[2] = vp;
}
else if (d < da[3]) {
else if(d < da[3]) {
da[3] = d;
pa[3] = vp;
}

@ -245,7 +245,7 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to)
ShaderNode *convert;
ShaderInput *convert_in;
if (to->type() == SocketType::CLOSURE) {
if(to->type() == SocketType::CLOSURE) {
EmissionNode *emission = new EmissionNode();
emission->color = make_float3(1.0f, 1.0f, 1.0f);
emission->strength = 1.0f;

@ -548,7 +548,7 @@ void LightManager::device_update_background(Device *device,
/* get the resolution from the light's size (we stuff it in there) */
int2 res = make_int2(background_light->map_resolution, background_light->map_resolution/2);
/* If the resolution isn't set manually, try to find an environment texture. */
if (res.x == 0) {
if(res.x == 0) {
Shader *shader = (scene->background->shader) ? scene->background->shader : scene->default_background;
foreach(ShaderNode *node, shader->graph->nodes) {
if(node->type == EnvironmentTextureNode::node_type) {
@ -560,12 +560,12 @@ void LightManager::device_update_background(Device *device,
}
}
}
if (res.x > 0 && res.y > 0) {
if(res.x > 0 && res.y > 0) {
VLOG(2) << "Automatically set World MIS resolution to " << res.x << " by " << res.y << "\n";
}
}
/* If it's still unknown, just use the default. */
if (res.x == 0 || res.y == 0) {
if(res.x == 0 || res.y == 0) {
res = make_int2(1024, 512);
VLOG(2) << "Setting World MIS resolution to default\n";
}

@ -951,9 +951,9 @@ void VoronoiTextureNode::compile(SVMCompiler& compiler)
ShaderOutput *color_out = output("Color");
ShaderOutput *fac_out = output("Fac");
if (vector_in->link) compiler.stack_assign(vector_in);
if (scale_in->link) compiler.stack_assign(scale_in);
if (exponent_in->link) compiler.stack_assign(exponent_in);
if(vector_in->link) compiler.stack_assign(vector_in);
if(scale_in->link) compiler.stack_assign(scale_in);
if(exponent_in->link) compiler.stack_assign(exponent_in);
int vector_offset = tex_mapping.compile_begin(compiler, vector_in);
@ -2856,7 +2856,7 @@ void AmbientOcclusionNode::compile(SVMCompiler& compiler)
int flags = (inside? NODE_AO_INSIDE : 0) | (only_local? NODE_AO_ONLY_LOCAL : 0);
if (!distance_in->link && distance == 0.0f) {
if(!distance_in->link && distance == 0.0f) {
flags |= NODE_AO_GLOBAL_RADIUS;
}

@ -136,10 +136,10 @@ ccl_device_forceinline bool ray_triangle_intersect(
#if defined(__KERNEL_SSE2__) && defined (__KERNEL_SSE__)
int uvw_sign = movemask(UVWW) & 0x7;
if (uvw_sign != 0)
{
if (uvw_sign != 0x7)
if(uvw_sign != 0) {
if(uvw_sign != 0x7) {
return false;
}
}
#else
const float minUVW = min(U, min(V, W));

@ -300,7 +300,7 @@ size_t system_physical_ram()
#elif defined(__APPLE__)
uint64_t ram = 0;
size_t len = sizeof(ram);
if (sysctlbyname("hw.memsize", &ram, &len, NULL, 0) == 0) {
if(sysctlbyname("hw.memsize", &ram, &len, NULL, 0) == 0) {
return ram;
}
return 0;