+// Set the "use_srgb_texture_format" option on all inputs that feed into this node,
+// and update the output_gamma_curve[] map as we go.
+//
+// NOTE: We assume that the only way we could actually get GAMMA_sRGB from an
+// effect (except from GammaCompressionCurve, which should never be inserted
+// into a chain when this is called) is by pass-through from a texture.
+// Thus, we can simply feed the flag up towards all inputs.
+void EffectChain::set_use_srgb_texture_format(Effect *effect)
+{
+ assert(output_gamma_curve.count(effect) != 0);
+ assert(output_gamma_curve[effect] == GAMMA_sRGB);
+ if (effect->num_inputs() == 0) {
+ effect->set_int("use_srgb_texture_format", 1);
+ } else {
+ assert(incoming_links.count(effect) == 1);
+ std::vector<Effect *> deps = incoming_links[effect];
+ assert(effect->num_inputs() == deps.size());
+ for (unsigned i = 0; i < deps.size(); ++i) {
+ set_use_srgb_texture_format(deps[i]);
+ assert(output_gamma_curve[deps[i]] == GAMMA_LINEAR);
+ }
+ }
+ output_gamma_curve[effect] = GAMMA_LINEAR;
+}
+