+namespace {
+
+// Whether this effect will cause the phase it is in to become a compute shader phase.
+bool induces_compute_shader(Node *node)
+{
+ if (node->effect->is_compute_shader()) {
+ return true;
+ }
+ if (!node->effect->strong_one_to_one_sampling()) {
+ // This effect can't be chained after a compute shader.
+ return false;
+ }
+ // If at least one of the effects we depend on is a compute shader,
+ // one of them will be put in the same phase as us (the other ones,
+ // if any, will be bounced).
+ for (Node *dep : node->incoming_links) {
+ if (induces_compute_shader(dep)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+} // namespace
+