diff options
-rw-r--r-- | intern/cycles/kernel/kernel_passes.h | 69 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path.h | 2 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_types.h | 76 | ||||
-rw-r--r-- | intern/cycles/render/film.cpp | 155 |
4 files changed, 150 insertions, 152 deletions
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h index 6bed73ad459..4236e2c5d4f 100644 --- a/intern/cycles/kernel/kernel_passes.h +++ b/intern/cycles/kernel/kernel_passes.h @@ -170,19 +170,19 @@ ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg, PathRadiance *L) { int flag = kernel_data.film.pass_flag; - if(flag & PASS_BVH_TRAVERSED_NODES) { + if(flag & PASSMASK(BVH_TRAVERSED_NODES)) { kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_nodes, L->debug_data.num_bvh_traversed_nodes); } - if(flag & PASS_BVH_TRAVERSED_INSTANCES) { + if(flag & PASSMASK(BVH_TRAVERSED_INSTANCES)) { kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_instances, L->debug_data.num_bvh_traversed_instances); } - if(flag & PASS_BVH_INTERSECTIONS) { + if(flag & PASSMASK(BVH_INTERSECTIONS)) { kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_intersections, L->debug_data.num_bvh_intersections); } - if(flag & PASS_RAY_BOUNCES) { + if(flag & PASSMASK(RAY_BOUNCES)) { kernel_write_pass_float(buffer + kernel_data.film.pass_ray_bounces, L->debug_data.num_ray_bounces); } @@ -199,8 +199,9 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl return; int flag = kernel_data.film.pass_flag; + int light_flag = kernel_data.film.light_pass_flag; - if(!(flag & PASS_ALL)) + if(!((flag | light_flag) & PASS_ANY)) return; if(!(path_flag & PATH_RAY_SINGLE_PASS_DONE)) { @@ -209,29 +210,29 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl average(shader_bsdf_alpha(kg, sd)) >= kernel_data.film.pass_alpha_threshold) { if(state->sample == 0) { - if(flag & PASS_DEPTH) { + if(flag & PASSMASK(DEPTH)) { float depth = camera_distance(kg, sd->P); kernel_write_pass_float(buffer + kernel_data.film.pass_depth, depth); } - if(flag & PASS_OBJECT_ID) { + if(flag & PASSMASK(OBJECT_ID)) { float id = object_pass_id(kg, sd->object); kernel_write_pass_float(buffer + kernel_data.film.pass_object_id, id); } - if(flag & PASS_MATERIAL_ID) { + if(flag & PASSMASK(MATERIAL_ID)) { float id = shader_pass_id(kg, sd); kernel_write_pass_float(buffer + kernel_data.film.pass_material_id, id); } } - if(flag & PASS_NORMAL) { + if(flag & PASSMASK(NORMAL)) { float3 normal = shader_bsdf_average_normal(kg, sd); kernel_write_pass_float3(buffer + kernel_data.film.pass_normal, normal); } - if(flag & PASS_UV) { + if(flag & PASSMASK(UV)) { float3 uv = primitive_uv(kg, sd); kernel_write_pass_float3(buffer + kernel_data.film.pass_uv, uv); } - if(flag & PASS_MOTION) { + if(flag & PASSMASK(MOTION)) { float4 speed = primitive_motion_vector(kg, sd); kernel_write_pass_float4(buffer + kernel_data.film.pass_motion, speed); kernel_write_pass_float(buffer + kernel_data.film.pass_motion_weight, 1.0f); @@ -241,16 +242,16 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl } } - if(flag & (PASS_DIFFUSE_INDIRECT|PASS_DIFFUSE_COLOR|PASS_DIFFUSE_DIRECT)) + if(light_flag & PASSMASK_COMPONENT(DIFFUSE)) L->color_diffuse += shader_bsdf_diffuse(kg, sd)*throughput; - if(flag & (PASS_GLOSSY_INDIRECT|PASS_GLOSSY_COLOR|PASS_GLOSSY_DIRECT)) + if(light_flag & PASSMASK_COMPONENT(GLOSSY)) L->color_glossy += shader_bsdf_glossy(kg, sd)*throughput; - if(flag & (PASS_TRANSMISSION_INDIRECT|PASS_TRANSMISSION_COLOR|PASS_TRANSMISSION_DIRECT)) + if(light_flag & PASSMASK_COMPONENT(TRANSMISSION)) L->color_transmission += shader_bsdf_transmission(kg, sd)*throughput; - if(flag & (PASS_SUBSURFACE_INDIRECT|PASS_SUBSURFACE_COLOR|PASS_SUBSURFACE_DIRECT)) + if(light_flag & PASSMASK_COMPONENT(SUBSURFACE)) L->color_subsurface += shader_bsdf_subsurface(kg, sd)*throughput; - if(flag & PASS_MIST) { + if(light_flag & PASSMASK(MIST)) { /* bring depth into 0..1 range */ float mist_start = kernel_data.film.mist_start; float mist_inv_depth = kernel_data.film.mist_inv_depth; @@ -280,49 +281,49 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl ccl_device_inline void kernel_write_light_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L) { #ifdef __PASSES__ - int flag = kernel_data.film.pass_flag; + int light_flag = kernel_data.film.light_pass_flag; if(!kernel_data.film.use_light_pass) return; - if(flag & PASS_DIFFUSE_INDIRECT) + if(light_flag & PASSMASK(DIFFUSE_INDIRECT)) kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_indirect, L->indirect_diffuse); - if(flag & PASS_GLOSSY_INDIRECT) + if(light_flag & PASSMASK(GLOSSY_INDIRECT)) kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_indirect, L->indirect_glossy); - if(flag & PASS_TRANSMISSION_INDIRECT) + if(light_flag & PASSMASK(TRANSMISSION_INDIRECT)) kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_indirect, L->indirect_transmission); - if(flag & PASS_SUBSURFACE_INDIRECT) + if(light_flag & PASSMASK(SUBSURFACE_INDIRECT)) kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_indirect, L->indirect_subsurface); - if(flag & PASS_DIFFUSE_DIRECT) + if(light_flag & PASSMASK(DIFFUSE_DIRECT)) kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_direct, L->direct_diffuse); - if(flag & PASS_GLOSSY_DIRECT) + if(light_flag & PASSMASK(GLOSSY_DIRECT)) kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_direct, L->direct_glossy); - if(flag & PASS_TRANSMISSION_DIRECT) + if(light_flag & PASSMASK(TRANSMISSION_DIRECT)) kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_direct, L->direct_transmission); - if(flag & PASS_SUBSURFACE_DIRECT) + if(light_flag & PASSMASK(SUBSURFACE_DIRECT)) kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_direct, L->direct_subsurface); - if(flag & PASS_EMISSION) + if(light_flag & PASSMASK(EMISSION)) kernel_write_pass_float3(buffer + kernel_data.film.pass_emission, L->emission); - if(flag & PASS_BACKGROUND) + if(light_flag & PASSMASK(BACKGROUND)) kernel_write_pass_float3(buffer + kernel_data.film.pass_background, L->background); - if(flag & PASS_AO) + if(light_flag & PASSMASK(AO)) kernel_write_pass_float3(buffer + kernel_data.film.pass_ao, L->ao); - if(flag & PASS_DIFFUSE_COLOR) + if(light_flag & PASSMASK(DIFFUSE_COLOR)) kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_color, L->color_diffuse); - if(flag & PASS_GLOSSY_COLOR) + if(light_flag & PASSMASK(GLOSSY_COLOR)) kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_color, L->color_glossy); - if(flag & PASS_TRANSMISSION_COLOR) + if(light_flag & PASSMASK(TRANSMISSION_COLOR)) kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_color, L->color_transmission); - if(flag & PASS_SUBSURFACE_COLOR) + if(light_flag & PASSMASK(SUBSURFACE_COLOR)) kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_color, L->color_subsurface); - if(flag & PASS_SHADOW) { + if(light_flag & PASSMASK(SHADOW)) { float4 shadow = L->shadow; shadow.w = kernel_data.film.pass_shadow_scale; kernel_write_pass_float4(buffer + kernel_data.film.pass_shadow, shadow); } - if(flag & PASS_MIST) + if(light_flag & PASSMASK(MIST)) kernel_write_pass_float(buffer + kernel_data.film.pass_mist, 1.0f - L->mist); #endif } diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 207ba741e6f..791c25c6553 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -140,7 +140,7 @@ ccl_device_forceinline void kernel_path_background( L->transparent += average(throughput); #ifdef __PASSES__ - if(!(kernel_data.film.pass_flag & PASS_BACKGROUND)) + if(!(kernel_data.film.light_pass_flag & PASSMASK(BACKGROUND))) #endif /* __PASSES__ */ return; } diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 5b8b760c48c..1761ab22bd6 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -368,43 +368,55 @@ typedef enum ClosureLabel { /* Render Passes */ +#define PASS_NAME_JOIN(a, b) a ## _ ## b +#define PASSMASK(pass) (1 << ((PASS_NAME_JOIN(PASS, pass)) % 32)) + +#define PASSMASK_COMPONENT(comp) (PASSMASK(PASS_NAME_JOIN(comp, DIRECT)) | \ + PASSMASK(PASS_NAME_JOIN(comp, INDIRECT)) | \ + PASSMASK(PASS_NAME_JOIN(comp, COLOR))) + typedef enum PassType { PASS_NONE = 0, - PASS_COMBINED = (1 << 0), - PASS_DEPTH = (1 << 1), - PASS_NORMAL = (1 << 2), - PASS_UV = (1 << 3), - PASS_OBJECT_ID = (1 << 4), - PASS_MATERIAL_ID = (1 << 5), - PASS_DIFFUSE_COLOR = (1 << 6), - PASS_GLOSSY_COLOR = (1 << 7), - PASS_TRANSMISSION_COLOR = (1 << 8), - PASS_DIFFUSE_INDIRECT = (1 << 9), - PASS_GLOSSY_INDIRECT = (1 << 10), - PASS_TRANSMISSION_INDIRECT = (1 << 11), - PASS_DIFFUSE_DIRECT = (1 << 12), - PASS_GLOSSY_DIRECT = (1 << 13), - PASS_TRANSMISSION_DIRECT = (1 << 14), - PASS_EMISSION = (1 << 15), - PASS_BACKGROUND = (1 << 16), - PASS_AO = (1 << 17), - PASS_SHADOW = (1 << 18), - PASS_MOTION = (1 << 19), - PASS_MOTION_WEIGHT = (1 << 20), - PASS_MIST = (1 << 21), - PASS_SUBSURFACE_DIRECT = (1 << 22), - PASS_SUBSURFACE_INDIRECT = (1 << 23), - PASS_SUBSURFACE_COLOR = (1 << 24), - PASS_LIGHT = (1 << 25), /* no real pass, used to force use_light_pass */ + + /* Main passes */ + PASS_COMBINED = 1, + PASS_DEPTH, + PASS_NORMAL, + PASS_UV, + PASS_OBJECT_ID, + PASS_MATERIAL_ID, + PASS_MOTION, + PASS_MOTION_WEIGHT, #ifdef __KERNEL_DEBUG__ - PASS_BVH_TRAVERSED_NODES = (1 << 26), - PASS_BVH_TRAVERSED_INSTANCES = (1 << 27), - PASS_BVH_INTERSECTIONS = (1 << 28), - PASS_RAY_BOUNCES = (1 << 29), + PASS_BVH_TRAVERSED_NODES, + PASS_BVH_TRAVERSED_INSTANCES, + PASS_BVH_INTERSECTIONS, + PASS_RAY_BOUNCES, #endif + PASS_CATEGORY_MAIN_END = 31, + + PASS_MIST = 32, + PASS_EMISSION, + PASS_BACKGROUND, + PASS_AO, + PASS_SHADOW, + PASS_LIGHT, /* no real pass, used to force use_light_pass */ + PASS_DIFFUSE_DIRECT, + PASS_DIFFUSE_INDIRECT, + PASS_DIFFUSE_COLOR, + PASS_GLOSSY_DIRECT, + PASS_GLOSSY_INDIRECT, + PASS_GLOSSY_COLOR, + PASS_TRANSMISSION_DIRECT, + PASS_TRANSMISSION_INDIRECT, + PASS_TRANSMISSION_COLOR, + PASS_SUBSURFACE_DIRECT, + PASS_SUBSURFACE_INDIRECT, + PASS_SUBSURFACE_COLOR, + PASS_CATEGORY_LIGHT_END = 63, } PassType; -#define PASS_ALL (~0) +#define PASS_ANY (~0) typedef enum DenoisingPassOffsets { DENOISING_PASS_NORMAL = 0, @@ -1179,6 +1191,7 @@ static_assert_align(KernelCamera, 16); typedef struct KernelFilm { float exposure; int pass_flag; + int light_pass_flag; int pass_stride; int use_light_pass; @@ -1215,7 +1228,6 @@ typedef struct KernelFilm { int pass_shadow; float pass_shadow_scale; int filter_table_offset; - int pass_pad2; int pass_mist; float mist_start; diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp index c8213d258d5..5acc6a9299d 100644 --- a/intern/cycles/render/film.cpp +++ b/intern/cycles/render/film.cpp @@ -85,52 +85,6 @@ void Pass::add(PassType type, array<Pass>& passes) pass.components = 1; pass.filter = false; break; - case PASS_DIFFUSE_COLOR: - case PASS_GLOSSY_COLOR: - case PASS_TRANSMISSION_COLOR: - case PASS_SUBSURFACE_COLOR: - pass.components = 4; - break; - case PASS_DIFFUSE_INDIRECT: - pass.components = 4; - pass.exposure = true; - pass.divide_type = PASS_DIFFUSE_COLOR; - break; - case PASS_GLOSSY_INDIRECT: - pass.components = 4; - pass.exposure = true; - pass.divide_type = PASS_GLOSSY_COLOR; - break; - case PASS_TRANSMISSION_INDIRECT: - pass.components = 4; - pass.exposure = true; - pass.divide_type = PASS_TRANSMISSION_COLOR; - break; - case PASS_SUBSURFACE_INDIRECT: - pass.components = 4; - pass.exposure = true; - pass.divide_type = PASS_SUBSURFACE_COLOR; - break; - case PASS_DIFFUSE_DIRECT: - pass.components = 4; - pass.exposure = true; - pass.divide_type = PASS_DIFFUSE_COLOR; - break; - case PASS_GLOSSY_DIRECT: - pass.components = 4; - pass.exposure = true; - pass.divide_type = PASS_GLOSSY_COLOR; - break; - case PASS_TRANSMISSION_DIRECT: - pass.components = 4; - pass.exposure = true; - pass.divide_type = PASS_TRANSMISSION_COLOR; - break; - case PASS_SUBSURFACE_DIRECT: - pass.components = 4; - pass.exposure = true; - pass.divide_type = PASS_SUBSURFACE_COLOR; - break; case PASS_EMISSION: case PASS_BACKGROUND: @@ -162,6 +116,41 @@ void Pass::add(PassType type, array<Pass>& passes) pass.exposure = false; break; #endif + + case PASS_DIFFUSE_COLOR: + case PASS_GLOSSY_COLOR: + case PASS_TRANSMISSION_COLOR: + case PASS_SUBSURFACE_COLOR: + pass.components = 4; + break; + case PASS_DIFFUSE_DIRECT: + case PASS_DIFFUSE_INDIRECT: + pass.components = 4; + pass.exposure = true; + pass.divide_type = PASS_DIFFUSE_COLOR; + break; + case PASS_GLOSSY_DIRECT: + case PASS_GLOSSY_INDIRECT: + pass.components = 4; + pass.exposure = true; + pass.divide_type = PASS_GLOSSY_COLOR; + break; + case PASS_TRANSMISSION_DIRECT: + case PASS_TRANSMISSION_INDIRECT: + pass.components = 4; + pass.exposure = true; + pass.divide_type = PASS_TRANSMISSION_COLOR; + break; + case PASS_SUBSURFACE_DIRECT: + case PASS_SUBSURFACE_INDIRECT: + pass.components = 4; + pass.exposure = true; + pass.divide_type = PASS_SUBSURFACE_COLOR; + break; + + default: + assert(false); + break; } passes.push_back_slow(pass); @@ -318,7 +307,19 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) for(size_t i = 0; i < passes.size(); i++) { Pass& pass = passes[i]; - kfilm->pass_flag |= pass.type; + + if(pass.type == PASS_NONE) + continue; + + int pass_flag = (1 << (pass.type % 32)); + if(pass.type <= PASS_CATEGORY_MAIN_END) { + kfilm->pass_flag |= pass_flag; + } + else { + assert(pass.type <= PASS_CATEGORY_LIGHT_END); + kfilm->use_light_pass = 1; + kfilm->light_pass_flag |= pass_flag; + } switch(pass.type) { case PASS_COMBINED: @@ -327,10 +328,6 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) case PASS_DEPTH: kfilm->pass_depth = kfilm->pass_stride; break; - case PASS_MIST: - kfilm->pass_mist = kfilm->pass_stride; - kfilm->use_light_pass = 1; - break; case PASS_NORMAL: kfilm->pass_normal = kfilm->pass_stride; break; @@ -349,74 +346,61 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) case PASS_MATERIAL_ID: kfilm->pass_material_id = kfilm->pass_stride; break; + + case PASS_MIST: + kfilm->pass_mist = kfilm->pass_stride; + break; + case PASS_EMISSION: + kfilm->pass_emission = kfilm->pass_stride; + break; + case PASS_BACKGROUND: + kfilm->pass_background = kfilm->pass_stride; + break; + case PASS_AO: + kfilm->pass_ao = kfilm->pass_stride; + break; + case PASS_SHADOW: + kfilm->pass_shadow = kfilm->pass_stride; + break; + + case PASS_LIGHT: + break; + case PASS_DIFFUSE_COLOR: kfilm->pass_diffuse_color = kfilm->pass_stride; - kfilm->use_light_pass = 1; break; case PASS_GLOSSY_COLOR: kfilm->pass_glossy_color = kfilm->pass_stride; - kfilm->use_light_pass = 1; break; case PASS_TRANSMISSION_COLOR: kfilm->pass_transmission_color = kfilm->pass_stride; - kfilm->use_light_pass = 1; break; case PASS_SUBSURFACE_COLOR: kfilm->pass_subsurface_color = kfilm->pass_stride; - kfilm->use_light_pass = 1; break; case PASS_DIFFUSE_INDIRECT: kfilm->pass_diffuse_indirect = kfilm->pass_stride; - kfilm->use_light_pass = 1; break; case PASS_GLOSSY_INDIRECT: kfilm->pass_glossy_indirect = kfilm->pass_stride; - kfilm->use_light_pass = 1; break; case PASS_TRANSMISSION_INDIRECT: kfilm->pass_transmission_indirect = kfilm->pass_stride; - kfilm->use_light_pass = 1; break; case PASS_SUBSURFACE_INDIRECT: kfilm->pass_subsurface_indirect = kfilm->pass_stride; - kfilm->use_light_pass = 1; break; case PASS_DIFFUSE_DIRECT: kfilm->pass_diffuse_direct = kfilm->pass_stride; - kfilm->use_light_pass = 1; break; case PASS_GLOSSY_DIRECT: kfilm->pass_glossy_direct = kfilm->pass_stride; - kfilm->use_light_pass = 1; break; case PASS_TRANSMISSION_DIRECT: kfilm->pass_transmission_direct = kfilm->pass_stride; - kfilm->use_light_pass = 1; break; case PASS_SUBSURFACE_DIRECT: kfilm->pass_subsurface_direct = kfilm->pass_stride; - kfilm->use_light_pass = 1; - break; - - case PASS_EMISSION: - kfilm->pass_emission = kfilm->pass_stride; - kfilm->use_light_pass = 1; - break; - case PASS_BACKGROUND: - kfilm->pass_background = kfilm->pass_stride; - kfilm->use_light_pass = 1; - break; - case PASS_AO: - kfilm->pass_ao = kfilm->pass_stride; - kfilm->use_light_pass = 1; - break; - case PASS_SHADOW: - kfilm->pass_shadow = kfilm->pass_stride; - kfilm->use_light_pass = 1; - break; - - case PASS_LIGHT: - kfilm->use_light_pass = 1; break; #ifdef WITH_CYCLES_DEBUG @@ -434,7 +418,8 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) break; #endif - case PASS_NONE: + default: + assert(false); break; } |