-
- // OK, only one effect uses this as the input. Keep iterating,
- // but first see if it requires a texture bounce; if so, give it
- // one by starting a new phase.
- node = next[0];
- if (node->needs_texture_bounce()) {
- phases.push_back(compile_glsl_program(this_phase_inputs, this_phase_effects));
- this_phase_inputs.clear();
- this_phase_effects.clear();
+ }
+
+ // Finally, since the phases are found from the output but must be executed
+ // from the input(s), reverse them, too.
+ std::reverse(phases.begin(), phases.end());
+}
+
+void EffectChain::find_output_size(EffectChain::Phase *phase)
+{
+ Effect *output_effect = phase->effects.back();
+
+ // If the last effect explicitly sets an output size,
+ // use that.
+ if (output_effect->changes_output_size()) {
+ output_effect->get_output_size(&phase->output_width, &phase->output_height);
+ return;
+ }
+
+ // If not, look at the input phases, if any. We select the largest one
+ // (really assuming they all have the same aspect currently), by pixel count.
+ if (!phase->inputs.empty()) {
+ unsigned best_width = 0, best_height = 0;
+ for (unsigned i = 0; i < phase->inputs.size(); ++i) {
+ Effect *input = phase->inputs[i];
+ assert(output_effects_to_phase.count(input) != 0);
+ const Phase *input_phase = output_effects_to_phase[input];
+ assert(input_phase->output_width != 0);
+ assert(input_phase->output_height != 0);
+ if (input_phase->output_width * input_phase->output_height > best_width * best_height) {
+ best_width = input_phase->output_width;
+ best_height = input_phase->output_height;
+ }