[Bf-blender-cvs] [6e7e64e58b] temp-cycles-denoising: Cycles Denoising: Remove unused functions in the buffer code
Lukas Stockner
noreply at git.blender.org
Mon Feb 13 02:05:51 CET 2017
Commit: 6e7e64e58bc7f60a702f190bce0409d9210af581
Author: Lukas Stockner
Date: Sun Feb 12 03:01:43 2017 +0100
Branches: temp-cycles-denoising
https://developer.blender.org/rB6e7e64e58bc7f60a702f190bce0409d9210af581
Cycles Denoising: Remove unused functions in the buffer code
===================================================================
M intern/cycles/blender/blender_sync.cpp
M intern/cycles/render/buffers.cpp
M intern/cycles/render/buffers.h
M intern/cycles/render/session.cpp
M intern/cycles/render/session.h
===================================================================
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index bca3872526..d8043105cd 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -732,75 +732,5 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
return params;
}
-RenderBuffers* BlenderSync::get_render_buffer(Device *device,
- BL::RenderLayer& b_rl,
- BL::RenderResult& b_rr,
- int samples)
-{
- BufferParams params;
- params.width = params.full_width = params.final_width = b_rr.resolution_x();
- params.height = params.full_height = params.final_height = b_rr.resolution_y();
-
- params.full_x = params.full_y = 0;
-
- BL::RenderLayer::passes_iterator b_pass;
-
- int denoising_passes = 0;
- for(b_rl.passes.begin(b_pass); b_pass != b_rl.passes.end(); ++b_pass) {
- PassType type = get_pass_type(*b_pass);
- if(type != PASS_NONE)
- Pass::add(type, params.passes);
-
- DenoisingPassType denoising_type = get_denoising_pass_type(*b_pass);
- if(denoising_type) {
- denoising_passes |= denoising_type;
- if(denoising_type == DENOISING_PASS_CLEAN)
- params.denoising_clean_pass = true;
- if(denoising_type == DENOISING_PASS_NOISY_B)
- params.denoising_split_pass = true;
- }
- }
- if(~denoising_passes & DENOISING_PASS_REQUIRED) {
- return NULL;
- }
- params.denoising_data_pass = true;
- assert(!params.denoising_split_pass || (denoising_passes & DENOISING_PASS_NOISY_B_VAR));
-
- RenderBuffers *buffer = new RenderBuffers(device);
- buffer->reset(device, params);
-
- int4 rect = make_int4(0, 0, params.width, params.height);
-
- /* Some passes are divided by another pass when exporting to a RenderPass.
- * Therefore, these passes need to be multiplied when importing, so some passes must be imported before others. */
- PassType import_first_array[] = {PASS_DIFFUSE_COLOR, PASS_GLOSSY_COLOR, PASS_TRANSMISSION_COLOR, PASS_SUBSURFACE_COLOR, PASS_MOTION_WEIGHT};
- std::set<PassType> import_first(import_first_array, import_first_array + 5);
- for(b_rl.passes.begin(b_pass); b_pass != b_rl.passes.end(); ++b_pass) {
- if(get_denoising_pass_type(*b_pass)) continue;
-
- PassType type = get_pass_type(*b_pass);
- if(!import_first.count(type)) continue;
-
- BL::DynamicArray<float> b_rect = b_pass->rect();
- buffer->get_pass_rect(type, 1.0f, samples, b_pass->channels(), rect, b_rect.data, true);
- }
-
- for(b_rl.passes.begin(b_pass); b_pass != b_rl.passes.end(); ++b_pass) {
- PassType type = get_pass_type(*b_pass);
- if(import_first.count(type)) continue;
-
- DenoisingPassType denoising_type = get_denoising_pass_type(*b_pass);
- BL::DynamicArray<float> b_rect = b_pass->rect();
- if(denoising_type)
- buffer->get_denoising_rect(denoising_type, 1.0f, samples, b_pass->channels(), rect, b_rect.data, true);
- else
- buffer->get_pass_rect(type, 1.0f, samples, b_pass->channels(), rect, b_rect.data, true);
- }
-
- buffer->copy_to_device();
-
- return buffer;
-}
-
CCL_NAMESPACE_END
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index f09467a6fd..83e9c977b7 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -176,16 +176,6 @@ bool RenderBuffers::copy_from_device()
return true;
}
-bool RenderBuffers::copy_to_device()
-{
- if(!buffer.device_pointer)
- return false;
-
- device->mem_copy_to(buffer);
-
- return true;
-}
-
/* When calling from the BlenderSession, rect is in final image coordinates.
* To make addressing the buffer easier, rect is brought to "buffer coordinates"
* where the buffer starts at (0, 0) and ends at (width, height). */
@@ -205,86 +195,7 @@ int4 RenderBuffers::rect_to_local(int4 rect) {
for(int y = rect.y; y < rect.w; y++, in += (params.width + rect.x - rect.z)*pass_stride) \
for(int x = rect.x; x < rect.z; x++, in += pass_stride, pixels += components)
-bool RenderBuffers::get_denoising_rect(int type, float exposure, int sample, int components, int4 rect, float *pixels, bool read_pixels)
-{
- if(!params.denoising_data_pass)
- /* The RenderBuffer doesn't have denoising passes. */
- return false;
- if(!(type & DENOISING_PASS_ALL))
- /* The type doesn't correspond to any denoising pass. */
- return false;
-
- rect = rect_to_local(rect);
-
- float scale = 1.0f;
- int type_offset = 0;
- switch(type) {
- case DENOISING_PASS_NONE: assert(0); break;
- case DENOISING_PASS_NORMAL: type_offset = 0; scale = 1.0f/sample; break;
- case DENOISING_PASS_NORMAL_VAR: type_offset = 3; scale = 1.0f/sample; break;
- case DENOISING_PASS_ALBEDO: type_offset = 6; scale = 1.0f/sample; break;
- case DENOISING_PASS_ALBEDO_VAR: type_offset = 9; scale = 1.0f/sample; break;
- case DENOISING_PASS_DEPTH: type_offset = 12; scale = 1.0f/sample; break;
- case DENOISING_PASS_DEPTH_VAR: type_offset = 13; scale = 1.0f/sample; break;
- case DENOISING_PASS_SHADOW_A: type_offset = 14; scale = 1.0f/sample; break;
- case DENOISING_PASS_SHADOW_B: type_offset = 17; scale = 1.0f/sample; break;
- case DENOISING_PASS_NOISY: type_offset = 20; scale = exposure/sample; break;
- case DENOISING_PASS_NOISY_VAR: type_offset = 23; scale = exposure*exposure/sample; break;
- case DENOISING_PASS_NOISY_B: type_offset = 26; scale = exposure/(sample/2); break;
- case DENOISING_PASS_NOISY_B_VAR: type_offset = 29; scale = exposure*exposure/(sample/2); break;
- case DENOISING_PASS_CLEAN: type_offset = params.denoising_split_pass? 32: 26; scale = exposure/sample; break;
- }
-
- if(read_pixels) {
- if(type == DENOISING_PASS_NOISY_B || type == DENOISING_PASS_NOISY_B_VAR) {
- scale = sample/2;
- }
- else {
- scale = sample;
- }
- }
-
- int pass_offset = params.get_denoise_offset() + type_offset;
- int pass_stride = params.get_passes_size();
- assert(pass_offset + components <= pass_stride);
-
- float *in = (float*)buffer.data_pointer + pass_offset;
-
- if(components == 1) {
- assert(type & (DENOISING_PASS_DEPTH | DENOISING_PASS_DEPTH_VAR));
- if(read_pixels) {
- FOREACH_PIXEL
- in[0] = pixels[0] * scale;
- }
- else {
- FOREACH_PIXEL
- pixels[0] = in[0] * scale;
- }
- }
- else {
- assert(components == 3);
- assert(!(type & (DENOISING_PASS_DEPTH | DENOISING_PASS_DEPTH_VAR)));
-
- if(read_pixels) {
- FOREACH_PIXEL {
- in[0] = pixels[0] * scale;
- in[1] = pixels[1] * scale;
- in[2] = pixels[2] * scale;
- }
- }
- else {
- FOREACH_PIXEL {
- pixels[0] = in[0] * scale;
- pixels[1] = in[1] * scale;
- pixels[2] = in[2] * scale;
- }
- }
- }
-
- return true;
-}
-
-bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int components, int4 rect, float *pixels, bool read_pixels)
+bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int components, int4 rect, float *pixels)
{
rect = rect_to_local(rect);
@@ -304,31 +215,18 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
float scale = (pass.filter)? 1.0f/(float)sample: 1.0f;
float scale_exposure = (pass.exposure)? scale*exposure: scale;
- if(read_pixels) {
- scale = scale_exposure = sample;
- }
if(components == 1) {
assert(pass.components == components);
/* scalar */
if(type == PASS_DEPTH) {
- if(read_pixels) {
- FOREACH_PIXEL
- in[0] = (pixels[0] == 1e10f)? 0.0f: pixels[0]*scale_exposure;
- }
- else {
- FOREACH_PIXEL
- pixels[0] = (in[0] == 0.0f)? 1e10f: in[0]*scale_exposure;
+ FOREACH_PIXEL {
+ pixels[0] = (in[0] == 0.0f)? 1e10f: in[0]*scale_exposure;
}
}
else if(type == PASS_MIST) {
- if(read_pixels) {
- FOREACH_PIXEL
- in[0] = pixels[0]*scale_exposure;
- }
- else {
- FOREACH_PIXEL
+ FOREACH_PIXEL {
pixels[0] = saturate(in[0]*scale_exposure);
}
}
@@ -336,25 +234,16 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
else if(type == PASS_BVH_TRAVERSED_NODES ||
type == PASS_BVH_TRAVERSED_INSTANCES ||
type == PASS_BVH_INTERSECTIONS ||
- type == PASS_RAY_BOUNCES) {
- if(read_pixels) {
- FOREACH_PIXEL
- in[0] = pixels[0]*scale;
- }
- else {
- FOREACH_PIXEL
- pixels[0] = in[0]*scale;
+ type == PASS_RAY_BOUNCES)
+ {
+ FOREACH_PIXEL {
+ pixels[0] = in[0]*scale;
}
}
#endif
else {
- if(read_pixels) {
- FOREACH_PIXEL
- in[0] = pixels[0]*scale_exposure;
- }
- else {
- FOREACH_PIXEL
- pixels[0] = in[0]*scale_exposure;
+ FOREACH_PIXEL {
+ pixels[0] = in[0]*scale_exposure;
}
}
}
@@ -363,23 +252,13 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
/* RGBA */
if(type == PASS_SHADOW) {
- if(read_pixels) {
- FOREACH_PIXEL {
- in[0] = pixels[0];
- in[1] = pixels[1];
- in[2] = pixels[2];
- in[3] = 1.0f;
- }
- }
- else {
- FOREACH_PIXEL {
- float w = in[3];
- float invw = (w > 0.0f)? 1.0f/w: 1.0f;
-
- pixels[0] = in[0]*invw;
- pixels[1] = in[1]*invw;
- pixels[2] = in[2]*invw;
- }
+ FOREACH_PIXEL {
+ float w = in[3];
+ float invw = (w > 0.0f)? 1.0f/w: 1.0f;
+
+ pixels[0] = in[0]*invw;
+ pixels[1] = in[1]*invw;
+ pixels[2] = in[2]*invw;
}
}
else if(pass.divide_type != PASS_NONE) {
@@ -392,41 +271,23 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
divide_offset += color_pass.components;
}
- if(read_pixels) {
- FOREACH_PIXEL {
- in[0] = pixels[0] * pixels[divide_offset];
- in[1] = pixels[1] * pixels[divide_offset + 1];
- in[2] = pixels[2] * pixels[divide_offset + 2];
- }
- }
- else {
- FOREACH_PIXEL {
- float3 f = make_float3(in[0], in[1], in[2]);
- float3 f_divide = make_float3(in[divide_offset], in[divide_offset+1], in[divide_offset+2]);
+ FOREACH_PIXEL {
+ float3 f = make_float3(in[0], in[1], in[2]);
+ flo
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list