From 6777956005f59a1f52851a50d5498bb17c910c4e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 20 Mar 2020 15:56:24 +0100 Subject: Fix T68370, T74973: Cycles cryptomatte not working when other passes are enabled Solution found by Blazej Floch. --- intern/cycles/render/film.cpp | 7 ++++--- intern/cycles/util/util_algorithm.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'intern') diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp index d1e2ef66c2c..baf02901123 100644 --- a/intern/cycles/render/film.cpp +++ b/intern/cycles/render/film.cpp @@ -203,9 +203,10 @@ void Pass::add(PassType type, vector &passes, const char *name) passes.push_back(pass); - /* order from by components, to ensure alignment so passes with size 4 - * come first and then passes with size 1 */ - sort(&passes[0], &passes[0] + passes.size(), compare_pass_order); + /* Order from by components, to ensure alignment so passes with size 4 + * come first and then passes with size 1. Note this must use stable sort + * so cryptomatte passes remain in the right order. */ + stable_sort(&passes[0], &passes[0] + passes.size(), compare_pass_order); if (pass.divide_type != PASS_NONE) Pass::add(pass.divide_type, passes); diff --git a/intern/cycles/util/util_algorithm.h b/intern/cycles/util/util_algorithm.h index 62093039625..63abd4e92a3 100644 --- a/intern/cycles/util/util_algorithm.h +++ b/intern/cycles/util/util_algorithm.h @@ -25,6 +25,7 @@ using std::max; using std::min; using std::remove; using std::sort; +using std::stable_sort; using std::swap; CCL_NAMESPACE_END -- cgit v1.2.3