]> git.sesse.net Git - movit/commitdiff
Output the graph in dot form at finalize time.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 8 Oct 2012 12:45:32 +0000 (14:45 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 8 Oct 2012 12:45:32 +0000 (14:45 +0200)
18 files changed:
blur_effect.h
colorspace_conversion_effect.h
diffusion_effect.h
effect.h
effect_chain.cpp
effect_chain.h
flat_input.h
gamma_compression_effect.h
gamma_expansion_effect.h
glow_effect.h
lift_gamma_gain_effect.h
mirror_effect.h
mix_effect.h
resize_effect.h
sandbox_effect.h
saturation_effect.h
vignette_effect.h
ycbcr_input.h

index 9bacd535efb69ffdbf39192f8b678c00fec472c8..788d337b3de6d9af4556656022f50486974acfa2 100644 (file)
@@ -17,6 +17,8 @@ class BlurEffect : public Effect {
 public:
        BlurEffect();
 
+       virtual std::string effect_type_id() const { return "BlurEffect"; }
+
        // We want this for the same reason as ResizeEffect; we could end up scaling
        // down quite a lot.
        virtual bool needs_texture_bounce() const { return true; }
@@ -43,6 +45,8 @@ private:
 class SingleBlurPassEffect : public Effect {
 public:
        SingleBlurPassEffect();
+       virtual std::string effect_type_id() const { return "SingleBlurPassEffect"; }
+
        std::string output_fragment_shader();
 
        virtual bool needs_texture_bounce() const { return true; }
index e3c60ea81730af2a2eaaffe0370e23b3a71cf35c..1e7bd5b18dabdfa5881a89d7b52d1fa0181785f9 100644 (file)
@@ -14,6 +14,7 @@
 class ColorSpaceConversionEffect : public Effect {
 public:
        ColorSpaceConversionEffect();
+       virtual std::string effect_type_id() const { return "ColorSpaceConversionEffect"; }
        std::string output_fragment_shader();
 
        virtual bool needs_srgb_primaries() const { return false; }
index bda264932b897f20cb727cca6a236aa6c488cb58..f8ed77c35af528cdb71e896e80522dfa3c270ae8 100644 (file)
@@ -20,6 +20,7 @@ class OverlayMatteEffect;
 class DiffusionEffect : public Effect {
 public:
        DiffusionEffect();
+       virtual std::string effect_type_id() const { return "DiffusionEffect"; }
 
        virtual void add_self_to_effect_chain(EffectChain *chain, const std::vector<Effect *> &input);
        virtual bool set_float(const std::string &key, float value);
@@ -41,6 +42,7 @@ private:
 class OverlayMatteEffect : public Effect {
 public:
        OverlayMatteEffect();
+       virtual std::string effect_type_id() const { return "OverlayMatteEffect"; }
        std::string output_fragment_shader();
 
        unsigned num_inputs() const { return 2; }
index c016a55070c2fb63585cd381c46c9e69a4de77a4..f1520b797f9f658a3218838b379fd5c9b281ed8c 100644 (file)
--- a/effect.h
+++ b/effect.h
@@ -46,7 +46,12 @@ void set_uniform_vec3(GLuint glsl_program_num, const std::string &prefix, const
 void set_uniform_vec4_array(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values, size_t num_values);
 
 class Effect {
-public: 
+public:
+       // An identifier for this type of effect, mostly used for debug output
+       // (but some special names, like "ColorSpaceConversionEffect", holds special
+       // meaning). Same as the class name is fine.
+       virtual std::string effect_type_id() const = 0;
+
        // Whether this effects expects its input (and output) to be in
        // linear gamma, ie. without an applied gamma curve. Most effects
        // will want this, although the ones that never actually look at
index 1d84e897add7d95eeeba77267f90dba631743744..4f1900dadfa5e2847b7478ace9a0ba562e28c421 100644 (file)
@@ -414,6 +414,26 @@ void EffectChain::construct_glsl_programs(Node *output)
        std::reverse(phases.begin(), phases.end());
 }
 
+void EffectChain::output_dot(const char *filename)
+{
+       FILE *fp = fopen(filename, "w");
+       if (fp == NULL) {
+               perror(filename);
+               exit(1);
+       }
+
+       fprintf(fp, "digraph G {\n");
+       for (unsigned i = 0; i < nodes.size(); ++i) {
+               fprintf(fp, "  n%ld [label=\"%s\"];\n", (long)nodes[i], nodes[i]->effect->effect_type_id().c_str());
+               for (unsigned j = 0; j < nodes[i]->outgoing_links.size(); ++j) {
+                       fprintf(fp, "  n%ld -> n%ld;\n", (long)nodes[i], (long)nodes[i]->outgoing_links[j]);
+               }
+       }
+       fprintf(fp, "}\n");
+
+       fclose(fp);
+}
+
 void EffectChain::find_output_size(Phase *phase)
 {
        Node *output_node = phase->effects.back();
@@ -453,6 +473,8 @@ void EffectChain::find_output_size(Phase *phase)
 
 void EffectChain::finalize()
 {
+       output_dot("final.dot");
+
        // Find the output effect. This is, simply, one that has no outgoing links.
        // If there are multiple ones, the graph is malformed (we do not support
        // multiple outputs right now).
index 6aa5b48fe852ecb12dc4bcdede416c69837b2f0c..0abd51805793a2d40b4b9fd0f5394a056bad7dc0 100644 (file)
@@ -123,6 +123,10 @@ private:
        // that depends on it (whenever possible).
        void construct_glsl_programs(Node *output);
 
+       // Output the current graph to the given file in a Graphviz-compatible format;
+       // only useful for debugging.
+       void output_dot(const char *filename);
+
        unsigned width, height;
        ImageFormat output_format;
 
index 9266659596ad8026f7993380c3cf1053a655714f..3bcdc76d61a46a4555e7f8ab1b822ff101dc6efa 100644 (file)
@@ -9,6 +9,8 @@ class FlatInput : public Input {
 public:
        FlatInput(ImageFormat format, MovitPixelFormat pixel_format, unsigned width, unsigned height);
 
+       virtual std::string effect_type_id() const { return "FlatInput"; }
+
        // Create the texture itself. We cannot do this in the constructor,
        // because we don't necessarily know all the settings (sRGB texture,
        // mipmap generation) at that point.
index 4c77b4c2cb2268af48f662b321cdfe4e2972a68f..03cbb24133417da2a3da336d60b39edc04b4e781 100644 (file)
@@ -15,6 +15,7 @@
 class GammaCompressionEffect : public Effect {
 public:
        GammaCompressionEffect();
+       virtual std::string effect_type_id() const { return "GammaCompressionEffect"; }
        std::string output_fragment_shader();
 
        virtual bool needs_srgb_primaries() const { return false; }
index 79926176ddf21688b80a8739ed991ec701d00b81..b93848a70a9d04175098695c4606ed0c4d0a2a60 100644 (file)
@@ -15,6 +15,7 @@
 class GammaExpansionEffect : public Effect {
 public:
        GammaExpansionEffect();
+       virtual std::string effect_type_id() const { return "GammaExpansionEffect"; }
        std::string output_fragment_shader();
 
        virtual bool needs_linear_light() const { return false; }
index 7ee164dceab630d2d1ab2f7573ce4f581bbb037a..1b5644ba62db9a835e911484e21897b3bb1abf27 100644 (file)
@@ -11,6 +11,7 @@ class MixEffect;
 class GlowEffect : public Effect {
 public:
        GlowEffect();
+       virtual std::string effect_type_id() const { return "GlowEffect"; }
 
        virtual bool needs_srgb_primaries() const { return false; }
 
index 533a7b2f22aee450c33eef9a41f4a42d657ce7a0..131957009a37bd35ccc954035f05a85ac03e358f 100644 (file)
@@ -22,6 +22,7 @@
 class LiftGammaGainEffect : public Effect {
 public:
        LiftGammaGainEffect();
+       virtual std::string effect_type_id() const { return "LiftGammaGainEffect"; }
        std::string output_fragment_shader();
 
        void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num);
index 343eb173a52a96c717ee5bc49c44314bb9db6ae4..0e8dd7bff1824ae63a1efb624beb37e864458a43 100644 (file)
@@ -8,6 +8,7 @@
 class MirrorEffect : public Effect {
 public:
        MirrorEffect();
+       virtual std::string effect_type_id() const { return "MirrorEffect"; }
        std::string output_fragment_shader();
 
        virtual bool needs_linear_light() const { return false; }
index 7342b90500538b10c08fb27840a3744a1a304cb7..8032062077491e7b545fc0df5e208d0b13f20a45 100644 (file)
@@ -8,6 +8,7 @@
 class MixEffect : public Effect {
 public:
        MixEffect();
+       virtual std::string effect_type_id() const { return "MixEffect"; }
        std::string output_fragment_shader();
 
        virtual bool needs_srgb_primaries() const { return false; }
index 54c2b31bcca6e20b7cdc409bd69a344e3d1ae22c..4c3fe86c1991f231af8ad3cee7df2343d93b581e 100644 (file)
@@ -10,6 +10,7 @@
 class ResizeEffect : public Effect {
 public:
        ResizeEffect();
+       virtual std::string effect_type_id() const { return "ResizeEffect"; }
        std::string output_fragment_shader();
 
        // We want processing done pre-filtering and mipmapped,
index 44e8d3fdbee40464909a1f5192f21060db3868c0..4443ff7d29afc85126ca043b83e9679b55b76d48 100644 (file)
@@ -13,6 +13,7 @@
 class SandboxEffect : public Effect {
 public:
        SandboxEffect();
+       virtual std::string effect_type_id() const { return "SandboxEffect"; }
        std::string output_fragment_shader();
 
        void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num);
index 180210c7edc9682e97ca7db77ae2c78e62287543..4dd72e4da09b4b0805ecf6d6d7b0104e68f9cd1e 100644 (file)
@@ -12,6 +12,7 @@
 class SaturationEffect : public Effect {
 public:
        SaturationEffect();
+       virtual std::string effect_type_id() const { return "SaturationEffect"; }
        std::string output_fragment_shader();
 
 private:
index d7c66f63b0d4f2146972418169755e30f0810db7..b8634fc04d888e72e41af5e9b2bc37db1d431ba7 100644 (file)
@@ -9,6 +9,7 @@
 class VignetteEffect : public Effect {
 public:
        VignetteEffect();
+       virtual std::string effect_type_id() const { return "VignetteEffect"; }
        std::string output_fragment_shader();
 
        virtual bool needs_srgb_primaries() const { return false; }
index d4cdf9ffe3e3f05cf2c3434a77c1308ed5fa9140..43d1f1dc0d4ee2b2ddcd6fdf7df5f6950d152136 100644 (file)
@@ -31,6 +31,8 @@ public:
                   const YCbCrFormat &ycbcr_format,
                   unsigned width, unsigned height);
 
+       virtual std::string effect_type_id() const { return "YCbCrInput"; }
+
        // Create the texture itself. We cannot do this in the constructor,
        // because we don't necessarily know all the settings (sRGB texture,
        // mipmap generation) at that point.