X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=effect_chain.cpp;h=933553c7455f47df1f45268e1e771dc01f6dad3d;hp=68a60737878a76553b1e9f66b88cc692b0532a8a;hb=ad25340e74ef8553c8360d5aa3910629529a4634;hpb=ba6838ec8b6fb972ccda17b3e6be6e793a4157a3 diff --git a/effect_chain.cpp b/effect_chain.cpp index 68a6073..933553c 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -317,7 +317,7 @@ Phase *EffectChain::compile_glsl_program( // without any explicit recursion. void EffectChain::construct_glsl_programs(Node *output) { - // Which effects have already been completed in this phase? + // Which effects have already been completed? // We need to keep track of it, as an effect with multiple outputs // could otherwise be calculated multiple times. std::set completed_effects; @@ -348,10 +348,13 @@ void EffectChain::construct_glsl_programs(Node *output) // This should currently only happen for effects that are inputs // (either true inputs or phase outputs). We special-case inputs, // and then deduplicate phase outputs in compile_glsl_program(). - if (node->effect->num_inputs() == 0 && completed_effects.count(node)) { - continue; + if (node->effect->num_inputs() == 0) { + if (find(this_phase_effects.begin(), this_phase_effects.end(), node) != this_phase_effects.end()) { + continue; + } + } else { + assert(completed_effects.count(node) == 0); } - assert(completed_effects.count(node) == 0); this_phase_effects.push_back(node); completed_effects.insert(node); @@ -451,21 +454,26 @@ void EffectChain::output_dot(const char *filename) fprintf(fp, " output [shape=box label=\"(output)\"];\n"); for (unsigned i = 0; i < nodes.size(); ++i) { // Find out which phase this event belongs to. - int in_phase = -1; + std::vector in_phases; for (unsigned j = 0; j < phases.size(); ++j) { const Phase* p = phases[j]; if (std::find(p->effects.begin(), p->effects.end(), nodes[i]) != p->effects.end()) { - assert(in_phase == -1); - in_phase = j; + in_phases.push_back(j); } } - if (in_phase == -1) { + if (in_phases.empty()) { fprintf(fp, " n%ld [label=\"%s\"];\n", (long)nodes[i], nodes[i]->effect->effect_type_id().c_str()); - } else { + } else if (in_phases.size() == 1) { fprintf(fp, " n%ld [label=\"%s\" style=\"filled\" fillcolor=\"/accent8/%d\"];\n", (long)nodes[i], nodes[i]->effect->effect_type_id().c_str(), - (in_phase % 8) + 1); + (in_phases[0] % 8) + 1); + } else { + // If we had new enough Graphviz, style="wedged" would probably be ideal here. + // But alas. + fprintf(fp, " n%ld [label=\"%s [in multiple phases]\" style=\"filled\" fillcolor=\"/accent8/%d\"];\n", + (long)nodes[i], nodes[i]->effect->effect_type_id().c_str(), + (in_phases[0] % 8) + 1); } char from_node_id[256]; @@ -727,6 +735,10 @@ void EffectChain::find_color_spaces_for_inputs() default: assert(false); } + + if (node->output_alpha_type == ALPHA_PREMULTIPLIED) { + assert(node->output_gamma_curve == GAMMA_LINEAR); + } } } }