From 4baa561c97527713a3fc7c0755b0d043d7689a41 Mon Sep 17 00:00:00 2001 From: Jonah Friedman Date: Mon, 7 May 2018 15:03:02 -0400 Subject: [PATCH 1/6] Added failing test 000 for multiple cryptomattes with parallel node init --- tests/cryptomatte/000_mtoa_basic.ass | 5 +++++ tests/cryptomatte_tests.py | 1 + 2 files changed, 6 insertions(+) diff --git a/tests/cryptomatte/000_mtoa_basic.ass b/tests/cryptomatte/000_mtoa_basic.ass index c966d3c..225576f 100644 --- a/tests/cryptomatte/000_mtoa_basic.ass +++ b/tests/cryptomatte/000_mtoa_basic.ass @@ -43,6 +43,11 @@ cryptomatte run_unit_tests true } +cryptomatte +{ + name ADDITIONAL_CRYPTOMATTE_TO_TEST_PARALLEL_ISSUES +} + gaussian_filter { name defaultArnoldFilter@gaussian_filter diff --git a/tests/cryptomatte_tests.py b/tests/cryptomatte_tests.py index 0f9b4af..11bcc13 100644 --- a/tests/cryptomatte_tests.py +++ b/tests/cryptomatte_tests.py @@ -320,6 +320,7 @@ class Cryptomatte000(CryptomatteTestBase): """ ass = "cryptomatte/000_mtoa_basic.ass" arnold_v = 6 + arnold_t = 0 def test_compression_and_manifests(self): self.assertAllManifestsValidAndMatch() From 995022b0c02962218ee10caa3862dffd379717bd Mon Sep 17 00:00:00 2001 From: Jonah Friedman Date: Mon, 7 May 2018 15:04:01 -0400 Subject: [PATCH 2/6] Fixed crash with multiple Cryptomattes, added some more tests --- cryptomatte/cryptomatte.cpp | 2 ++ cryptomatte/cryptomatte.h | 9 +++++++-- tests/cryptomatte/002_multicam.ass | 8 ++++++++ tests/cryptomatte_tests.py | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cryptomatte/cryptomatte.cpp b/cryptomatte/cryptomatte.cpp index e28a7f4..e09f8d9 100644 --- a/cryptomatte/cryptomatte.cpp +++ b/cryptomatte/cryptomatte.cpp @@ -2,6 +2,8 @@ #include "MurmurHash3.h" #include +AtCritSec g_critsec; + // User data names const AtString CRYPTO_ASSET_UDATA("crypto_asset"); const AtString CRYPTO_OBJECT_UDATA("crypto_object"); diff --git a/cryptomatte/cryptomatte.h b/cryptomatte/cryptomatte.h index 72b0928..f030eb3 100644 --- a/cryptomatte/cryptomatte.h +++ b/cryptomatte/cryptomatte.h @@ -134,6 +134,8 @@ extern const AtString CRYPTO_ASSET_OFFSET_UDATA; extern const AtString CRYPTO_OBJECT_OFFSET_UDATA; extern const AtString CRYPTO_MATERIAL_OFFSET_UDATA; +extern AtCritSec g_critsec; + // Some static AtStrings to cache const AtString aStr_shader("shader"); const AtString aStr_list_aggregate("list_aggregate"); @@ -857,6 +859,7 @@ struct CryptomatteData { set_option_channels(CRYPTO_DEPTH_DEFAULT, CRYPTO_PREVIEWINEXR_DEFAULT); set_option_namespace_stripping(CRYPTO_NAME_ALL, CRYPTO_NAME_ALL); set_option_ice_pcloud_verbosity(CRYPTO_ICEPCLOUDVERB_DEFAULT); + AiCritSecInit(&g_critsec); } void setup_all(const AtString aov_cryptoasset_, const AtString aov_cryptoobject_, @@ -869,7 +872,10 @@ struct CryptomatteData { destroy_arrays(); user_cryptomattes = UserCryptomattes(uc_aov_array, uc_src_array); + + AiCritSecEnter(&g_critsec); setup_cryptomatte_nodes(); + AiCritSecLeave(&g_critsec); } void set_option_channels(int depth, bool exr_preview_channels) { @@ -1079,10 +1085,9 @@ struct CryptomatteData { } } - if (new_outputs.size()) + if (new_outputs.size()) { this->do_preview_channels = this->option_exr_preview_channels; - if (new_outputs.size()) { if (option_sidecar_manifests) { AtString manifest_driver_name("cryptomatte_manifest_driver"); AtNode* manifest_driver = AiNodeLookUpByName(manifest_driver_name); diff --git a/tests/cryptomatte/002_multicam.ass b/tests/cryptomatte/002_multicam.ass index 01a7dc8..53a1432 100644 --- a/tests/cryptomatte/002_multicam.ass +++ b/tests/cryptomatte/002_multicam.ass @@ -171,6 +171,14 @@ cryptomatte user_crypto_src_0 "special_chars_udata" } +cryptomatte +{ + name ADDITIONAL_CRYPTOMATTE_TO_TEST_PARALLEL_ISSUES + user_crypto_aov_0 "other_aov" + user_crypto_src_0 "other_aov_udata" +} + + gaussian_filter { name defaultArnoldFilter@gaussian_filter diff --git a/tests/cryptomatte_tests.py b/tests/cryptomatte_tests.py index 11bcc13..36ab4c9 100644 --- a/tests/cryptomatte_tests.py +++ b/tests/cryptomatte_tests.py @@ -370,6 +370,7 @@ class Cryptomatte002(CryptomatteTestBase): Multicamera renders with embedded manifests """ ass = "cryptomatte/002_multicam.ass" + arnold_t = 0 def test_compression_and_manifests(self): self.assertAllManifestsValidAndMatch() From 7dbdca91965e62f226f3d744b2124ffff38ec968 Mon Sep 17 00:00:00 2001 From: Jonah Friedman Date: Mon, 7 May 2018 16:23:13 -0400 Subject: [PATCH 3/6] Silence warning about NAN output --- cryptomatte/cryptomatte_shader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cryptomatte/cryptomatte_shader.cpp b/cryptomatte/cryptomatte_shader.cpp index ed60f35..84f4d9a 100644 --- a/cryptomatte/cryptomatte_shader.cpp +++ b/cryptomatte/cryptomatte_shader.cpp @@ -111,6 +111,7 @@ shader_evaluate { CryptomatteData* data = reinterpret_cast(AiNodeGetLocalData(node)); data->do_cryptomattes(sg); } + sg->out.RGBA() = AI_RGBA_ZERO; } void registerCryptomatte(AtNodeLib* node) { From 284534355ed56c089e77fbce88849626ca7b1516 Mon Sep 17 00:00:00 2001 From: Jonah Friedman Date: Mon, 14 May 2018 11:21:28 -0400 Subject: [PATCH 4/6] Increased version to Beta 4 --- CMakeLists.txt | 2 +- README.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52f5723..568af01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ project(alShaders2) set(ALS_MAJOR_VERSION 2) set(ALS_MINOR_VERSION 0) -set(ALS_PATCH_VERSION 0b3) +set(ALS_PATCH_VERSION 0b4) set(ALS_VERSION "${ALS_MAJOR_VERSION}.${ALS_MINOR_VERSION}.${ALS_PATCH_VERSION}") set(CMAKE_VERBOSE_MAKEFILE FALSE) diff --git a/README.md b/README.md index 8ed49ac..3e05817 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ For Cryptomatte documentation, see this repo's wiki. +### Beta 4 release notes: + +Bug fixes: +* Fixed crash with multiple Cryptomatte shaders in scene. + ### Beta 3 release notes: Features From 3d41ef54fb3cc7ff70c07645156e070eefe7912a Mon Sep 17 00:00:00 2001 From: Jonah Friedman Date: Thu, 17 May 2018 12:01:49 -0400 Subject: [PATCH 5/6] Added error detection for cryptomatte filter not getting set up properly. --- README.md | 1 + cryptomatte/cryptomatte_filter.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3e05817..5a3e0c8 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ For Cryptomatte documentation, see this repo's wiki. Bug fixes: * Fixed crash with multiple Cryptomatte shaders in scene. +* Added error detection for issue where Cryptomatte filters do not get set up correctly, (reported by one user by not reproducible). ### Beta 3 release notes: diff --git a/cryptomatte/cryptomatte_filter.cpp b/cryptomatte/cryptomatte_filter.cpp index a7d3956..d7a0638 100644 --- a/cryptomatte/cryptomatte_filter.cpp +++ b/cryptomatte/cryptomatte_filter.cpp @@ -12,7 +12,7 @@ // /////////////////////////////////////////////// -AI_FILTER_NODE_EXPORT_METHODS(cryptomatte_filterMtd) +AI_FILTER_NODE_EXPORT_METHODS(cryptomatte_filter_mtd) static const AtString ats_opacity("opacity"); @@ -42,13 +42,13 @@ node_parameters { AiMetaDataSetInt(nentry, nullptr, "maya.id", 0x00116420); AiParameterFlt("width", 2.0); - AiParameterInt("rank", 0); + AiParameterInt("rank", -1); AiParameterEnum("filter", p_filter_gaussian, filterEnumNames); AiParameterEnum("mode", p_mode_double_rgba, modeEnumNames); } void registerCryptomatteFilter(AtNodeLib* node) { - node->methods = cryptomatte_filterMtd; + node->methods = cryptomatte_filter_mtd; node->output_type = AI_TYPE_RGBA; node->name = "cryptomatte_filter"; node->node_type = AI_NODE_FILTER; @@ -70,9 +70,13 @@ node_finish { } node_update { + const int rank = AiNodeGetInt(node, "rank"); + if (rank < 0) + AiMsgError("Cryptomatte not set up correctly, %s rank not set.", AiNodeGetName(node)); + CryptomatteFilterData* data = (CryptomatteFilterData*)AiNodeGetLocalData(node); data->width = AiNodeGetFlt(node, "width"); - data->rank = AiNodeGetInt(node, "rank"); + data->rank = rank; data->filter = AiNodeGetInt(node, "filter"); switch (data->filter) { From fc6d171d40a4362055702f187aea6f8a10d6bbbe Mon Sep 17 00:00:00 2001 From: Jonah Friedman Date: Mon, 21 May 2018 10:42:08 -0400 Subject: [PATCH 6/6] Removed some cruft from cryptomatte filter --- cryptomatte/cryptomatte_filter.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/cryptomatte/cryptomatte_filter.cpp b/cryptomatte/cryptomatte_filter.cpp index d7a0638..e015615 100644 --- a/cryptomatte/cryptomatte_filter.cpp +++ b/cryptomatte/cryptomatte_filter.cpp @@ -20,7 +20,6 @@ enum cryptomatte_filterParams { p_width, p_rank, p_filter, - p_mode, }; struct CryptomatteFilterData { @@ -30,12 +29,6 @@ struct CryptomatteFilterData { int filter; }; -enum modeEnum { - p_mode_double_rgba, -}; - -static const char* modeEnumNames[] = {"double_rgba", nullptr}; - node_parameters { AiMetaDataSetStr(nentry, nullptr, "maya.attr_prefix", "filter_"); AiMetaDataSetStr(nentry, nullptr, "maya.translator", "cryptomatteFilter"); @@ -44,7 +37,6 @@ node_parameters { AiParameterFlt("width", 2.0); AiParameterInt("rank", -1); AiParameterEnum("filter", p_filter_gaussian, filterEnumNames); - AiParameterEnum("mode", p_mode_double_rgba, modeEnumNames); } void registerCryptomatteFilter(AtNodeLib* node) { @@ -73,7 +65,7 @@ node_update { const int rank = AiNodeGetInt(node, "rank"); if (rank < 0) AiMsgError("Cryptomatte not set up correctly, %s rank not set.", AiNodeGetName(node)); - + CryptomatteFilterData* data = (CryptomatteFilterData*)AiNodeGetLocalData(node); data->width = AiNodeGetFlt(node, "width"); data->rank = rank;