[Bf-blender-cvs] [9bb8e42] soc-2016-cycles_denoising: Cycles Denoiser: Store debug info in one exr per tile instead of many pfms
Lukas Stockner
noreply at git.blender.org
Tue Nov 22 04:25:45 CET 2016
Commit: 9bb8e42e6e57ba305e478785328e7f630c36fd60
Author: Lukas Stockner
Date: Sun Sep 11 06:08:24 2016 +0200
Branches: soc-2016-cycles_denoising
https://developer.blender.org/rB9bb8e42e6e57ba305e478785328e7f630c36fd60
Cycles Denoiser: Store debug info in one exr per tile instead of many pfms
===================================================================
M intern/cycles/device/device_cpu.cpp
M intern/cycles/util/util_debug.h
===================================================================
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index 9f1d6e5..c9df3df 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -291,8 +291,12 @@ public:
for(int i = 0; i < 9; i++) {
buffer[i] = buffers[i] + frame_strides[i]*frame;
}
+#ifdef WITH_CYCLES_DEBUG_FILTER
+ DenoiseDebug debug((rect.z - rect.x), h, 34);
+#endif
/* ==== Step 1: Prefilter general features. ==== */
{
+
float *unfiltered = filter_buffer + 16*pass_stride;
/* Order in render buffers:
* Normal[X, Y, Z] NormalVar[X, Y, Z] Albedo[R, G, B] AlbedoVar[R, G, B ] Depth DepthVar
@@ -319,7 +323,7 @@ public:
}
}
#ifdef WITH_CYCLES_DEBUG_FILTER
-#define WRITE_DEBUG(name, var) debug_write_pfm(string_printf("debug_%dx%d_feature%d_%s.pfm", tile_x[1], tile_y[1], i, name).c_str(), var, (rect.z - rect.x), h, 1, w)
+#define WRITE_DEBUG(name, var) debug.add_pass(string_printf("f%d_%s", i, name), var, 1, w);
WRITE_DEBUG("unfiltered", unfiltered);
WRITE_DEBUG("sampleV", filter_buffer + (offset_to[i]+1)*pass_stride);
WRITE_DEBUG("filtered", filter_buffer + offset_to[i]*pass_stride);
@@ -343,7 +347,7 @@ public:
}
}
#ifdef WITH_CYCLES_DEBUG_FILTER
-#define WRITE_DEBUG(name, var) debug_write_pfm(string_printf("debug_%dx%d_shadow_%s.pfm", tile_x[1], tile_y[1], name).c_str(), var, w, h, 1, w)
+#define WRITE_DEBUG(name, var) debug.add_pass(string_printf("shadow_%s", name), var, 1, w);
WRITE_DEBUG("unfilteredA", unfiltered);
WRITE_DEBUG("unfilteredB", unfiltered + pass_stride);
WRITE_DEBUG("bufferV", bufferV);
@@ -403,7 +407,8 @@ public:
}
#ifdef WITH_CYCLES_DEBUG_FILTER
WRITE_DEBUG("final", filter_buffer + 8*pass_stride);
- WRITE_DEBUG("finalV", filter_buffer + 9*pass_stride);
+ WRITE_DEBUG("finalV", filter_buffer + 9 * pass_stride);
+ debug.write(string_printf("debugf_%dx%d.exr", tile_x[1], tile_y[1]));
#undef WRITE_DEBUG
#endif
}
@@ -492,12 +497,14 @@ public:
}
}
#ifdef WITH_CYCLES_DEBUG_FILTER
-#define WRITE_DEBUG(name, var) debug_write_pfm(string_printf("debug_%dx%d_%s.pfm", filter_area.x, filter_area.y, name).c_str(), &storage[0].var, filter_area.z, filter_area.w, sizeof(FilterStorage)/sizeof(float), filter_area.z);
+ DenoiseDebug debug(filter_area.z, filter_area.w, 4 * DENOISE_FEATURES + 6);
+
+#define WRITE_DEBUG(name, var) debug.add_pass(name, &storage[0].var, sizeof(FilterStorage)/sizeof(float), filter_area.z);
for(int i = 0; i < DENOISE_FEATURES; i++) {
- WRITE_DEBUG(string_printf("mean_%d", i).c_str(), means[i]);
- WRITE_DEBUG(string_printf("scale_%d", i).c_str(), scales[i]);
- WRITE_DEBUG(string_printf("singular_%d", i).c_str(), singular[i]);
- WRITE_DEBUG(string_printf("bandwidth_%d", i).c_str(), bandwidth[i]);
+ WRITE_DEBUG(string_printf("mean_%d", i), means[i]);
+ WRITE_DEBUG(string_printf("scale_%d", i), scales[i]);
+ WRITE_DEBUG(string_printf("singular_%d", i), singular[i]);
+ WRITE_DEBUG(string_printf("bandwidth_%d", i), bandwidth[i]);
}
WRITE_DEBUG("singular_threshold", singular_threshold);
WRITE_DEBUG("feature_matrix_norm", feature_matrix_norm);
@@ -512,6 +519,7 @@ public:
WRITE_DEBUG("filtered_global_bandwidth", filtered_global_bandwidth);
WRITE_DEBUG("sum_weight", sum_weight);
WRITE_DEBUG("log_rmse_per_sample", log_rmse_per_sample);
+ debug.write(string_printf("debug_%dx%d.exr", filter_area.x, filter_area.y));
#undef WRITE_DEBUG
#endif
}
diff --git a/intern/cycles/util/util_debug.h b/intern/cycles/util/util_debug.h
index dc8a50e..e42fb71 100644
--- a/intern/cycles/util/util_debug.h
+++ b/intern/cycles/util/util_debug.h
@@ -21,6 +21,12 @@
#include <iostream>
#include "util_static_assert.h"
+#include <vector>
+
+#ifdef WITH_CYCLES_DEBUG_FILTER
+#include "OpenImageIO/imageio.h"
+OIIO_NAMESPACE_USING
+#endif
CCL_NAMESPACE_BEGIN
@@ -152,6 +158,51 @@ std::ostream& operator <<(std::ostream &os,
DebugFlagsConstRef debug_flags);
#ifdef WITH_CYCLES_DEBUG_FILTER
+class DenoiseDebug {
+public:
+ DenoiseDebug(int w, int h, int channels) : w(w), h(h), channels(channels), channel(0)
+ {
+ pixels = new float[w*h*channels];
+ }
+
+ ~DenoiseDebug()
+ {
+ delete[] pixels;
+ }
+
+ void add_pass(std::string name, float *data, int pixelstride, int linestride)
+ {
+ for (int y = 0; y < h; y++) {
+ for (int x = 0; x < w; x++) {
+ pixels[(y*w + x)*channels + channel] = data[(y*linestride + x)*pixelstride];
+ }
+ }
+ channel++;
+ passnames.push_back(name);
+ }
+
+ bool write(std::string name)
+ {
+ if (channel != channels) return false;
+ ImageOutput *out = ImageOutput::create(name);
+ if (!out) return false;
+
+ ImageSpec spec(w, h, channels, TypeDesc::FLOAT);
+ spec.channelnames = passnames;
+
+ out->open(name, spec);
+ out->write_image(TypeDesc::FLOAT, pixels);
+ out->close();
+ ImageOutput::destroy(out);
+
+ return true;
+ }
+
+ int w, h, channels, channel;
+ float *pixels;
+ std::vector<std::string> passnames;
+};
+
bool debug_write_pfm(const char *name, float *data, int w, int h, int pixelstride, int linestride);
#endif
More information about the Bf-blender-cvs
mailing list