From 20bf79273b1ded41c867d587abd032fbede87565 Mon Sep 17 00:00:00 2001 From: Aura Munoz Date: Tue, 19 Dec 2023 11:03:53 +0100 Subject: [PATCH 001/300] [build_usd] Update OpenImageIO to v2.5.6.0 - The current version v2.3.21.0 includes a bug that reports false positives when using the `-p` flag and having a very high value for the absolute tolerance. This is fixed in v2.5.6.0 in https://github.com/AcademySoftwareFoundation/OpenImageIO/pull/4061. --- build_scripts/build_usd.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_scripts/build_usd.py b/build_scripts/build_usd.py index 5c2db7ca7b..f17612a772 100644 --- a/build_scripts/build_usd.py +++ b/build_scripts/build_usd.py @@ -842,6 +842,7 @@ def InstallBoost_Helper(context, force, buildArgs): b2_settings.append("--with-date_time") if context.buildOIIO or context.enableOpenVDB: + b2_settings.append("--with-chrono") b2_settings.append("--with-system") b2_settings.append("--with-thread") @@ -1244,7 +1245,7 @@ def InstallOpenVDB(context, force, buildArgs): ############################################################ # OpenImageIO -OIIO_URL = "https://github.com/OpenImageIO/oiio/archive/refs/tags/v2.3.21.0.zip" +OIIO_URL = "https://github.com/OpenImageIO/oiio/archive/refs/tags/v2.5.6.0.zip" def InstallOpenImageIO(context, force, buildArgs): with CurrentWorkingDirectory(DownloadURL(OIIO_URL, context, force)): From e6aeb47f991e32c0326a0b670db997e615c1a316 Mon Sep 17 00:00:00 2001 From: Paul Molodowitch Date: Wed, 20 Mar 2024 00:54:55 -0700 Subject: [PATCH 002/300] [arch] Arch_DebuggerIsAttachedPosix: use TracerPid in /proc/self/status The old implemenation worked by trying to attach a ptrace to the current process, and if it failed, then we assumed it was being debugged. The problem is that we have no easy way to check if an EPERM result from ptrace is because it's being debugged, or an actual permissions error - and permissions checking process is somewhat complex - see the "Ptrace access mode checking" section here: https://man7.org/linux/man-pages/man2/ptrace.2.html On a basic Ubuntu-22.04 test system, ptrace would return EPERM even when the process was not being debugged, resulting in a "false positive". The new TracerPid method was more accurate in this case. Checking the /proc/self/status for TracerPid is also the same method that gperftools and even gdb itself use to check if a process is being debugged: - https://github.com/gperftools/gperftools/blob/02adc8ceab39bbeac1f65e10bde577e1753094fa/src/heap-checker.cc#L183 - https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/nat/linux-procfs.c;h=b17e3120792e0e0790271898212b69b0577847cc;hb=HEAD#l68 - https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/testsuite/gdb.threads/siginfo-threads.c;h=22c6038206ba77fc3432da5ee30284c80641f305;hb=HEAD#l373 --- pxr/base/arch/debugger.cpp | 74 +++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/pxr/base/arch/debugger.cpp b/pxr/base/arch/debugger.cpp index 4039d0d57e..a4492f52af 100644 --- a/pxr/base/arch/debugger.cpp +++ b/pxr/base/arch/debugger.cpp @@ -45,8 +45,10 @@ #include #include #include +#include #include #include +#include #endif #if defined(ARCH_OS_DARWIN) #include @@ -344,50 +346,58 @@ Arch_DebuggerAttachExecPosix(void* data) #if defined(ARCH_OS_LINUX) +// Reads /proc/self/status, finds the line starting with "field:", and +// returns the portion following the ":". +// Note that the returned string will generally include leading whitespace static -bool -Arch_DebuggerIsAttachedPosix() +std::string Arch_ReadProcStatusField(const std::string_view field) { - // Check for a ptrace based debugger by trying to ptrace. - pid_t parent = getpid(); - pid_t pid = nonLockingFork(); - if (pid < 0) { - // fork failed. We'll guess there's no debugger. - return false; + std::ifstream procStatusFile("/proc/self/status"); + if (!procStatusFile) { + ARCH_WARNING("Unable to open /proc/self/status"); + return std::string(); } - - // Child process. - if (pid == 0) { - // Attach to the parent with ptrace() this will fail if the - // parent is already being traced. - if (ptrace(PTRACE_ATTACH, parent, NULL, NULL) == -1) { - // A debugger is probably attached if the error is EPERM. - _exit(errno == EPERM ? 1 : 0); + for (std::string line; std::getline(procStatusFile, line);) { + // the field needs to start with the given fieldLen AND the ':' char + if (line.size() < field.size() + 1 ) { + continue; } - // Wait for the parent to stop as a result of the attach. - int status; - while (waitpid(parent, &status, 0) == -1 && errno == EINTR) { - // Do nothing + if (line.compare(0, field.size(), field) == 0 && line[field.size()] == ':') { + // We found our "field:" line + return line.substr(field.size() + 2); } + } - // Detach and continue the parent. - ptrace(PTRACE_DETACH, parent, 0, SIGCONT); + std::string warningStr("Unable to find given field in /proc/self/status: "); + warningStr += field; + ARCH_WARNING(warningStr.c_str()); + return std::string(); +} - // A debugger was not attached. - _exit(0); - } +constexpr int INVALID_INT_STR = -1; +constexpr int OUT_OF_RANGE_INT_STR = -2; - // Parent process - int status; - while (waitpid(pid, &status, 0) == -1 && errno == EINTR) { - // Do nothing +// Reads the "TracerPid:" field from /proc/self/status +// Returns a result < 0 if there was an error. +static +int Arch_ReadTracerPid() { + try { + return std::stoi(Arch_ReadProcStatusField("TracerPid")); } - if (WIFEXITED(status)) { - return WEXITSTATUS(status) != 0; + catch (std::invalid_argument const &ex) { + return INVALID_INT_STR; } - return false; + catch (std::out_of_range const &ex) { + return OUT_OF_RANGE_INT_STR; + } +} +static +bool +Arch_DebuggerIsAttachedPosix() +{ + return Arch_ReadTracerPid() > 0; } #elif defined(ARCH_OS_DARWIN) From f2ee21f8e4c6bb8330f2da727908824469fb58d9 Mon Sep 17 00:00:00 2001 From: Simon Haegler Date: Sun, 4 Aug 2024 15:24:28 +0200 Subject: [PATCH 003/300] Build (msvc/ninja): pre-compiled header bug fix: make sure the directory for the output pch file exists --- cmake/macros/Private.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/macros/Private.cmake b/cmake/macros/Private.cmake index 48fe107dd7..ec6e9c1d67 100644 --- a/cmake/macros/Private.cmake +++ b/cmake/macros/Private.cmake @@ -523,7 +523,8 @@ function(_pxr_enable_precompiled_header TARGET_NAME) # Headers live in subdirectories. set(rel_output_header_path "${PXR_PREFIX}/${TARGET_NAME}/${output_header_name}") set(abs_output_header_path "${PROJECT_BINARY_DIR}/include/${rel_output_header_path}") - set(abs_precompiled_path ${PROJECT_BINARY_DIR}/include/${PXR_PREFIX}/${TARGET_NAME}/${CMAKE_BUILD_TYPE}/${precompiled_name}) + set(abs_precompiled_container_path "${PROJECT_BINARY_DIR}/include/${PXR_PREFIX}/${TARGET_NAME}/${CMAKE_BUILD_TYPE}") + set(abs_precompiled_path "${abs_precompiled_container_path}/${precompiled_name}") # Additional compile flags to use precompiled header. This will be set(compile_flags "") @@ -555,6 +556,7 @@ function(_pxr_enable_precompiled_header TARGET_NAME) set(abs_output_source_path ${CMAKE_CURRENT_BINARY_DIR}/${output_header_name_we}.cpp) add_custom_command( OUTPUT "${abs_output_source_path}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${abs_precompiled_container_path}" COMMAND ${CMAKE_COMMAND} -E touch ${abs_output_source_path} ) From 4f089c3773a52af1567f6e001d0779acd7f5f343 Mon Sep 17 00:00:00 2001 From: Simon Haegler Date: Sun, 4 Aug 2024 15:26:09 +0200 Subject: [PATCH 004/300] Build (msvc/ninja): pre-compiled header bug fix: make sure to set file properties AFTER adding them to the target otherwise the custom command is not triggered --- cmake/macros/Private.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/macros/Private.cmake b/cmake/macros/Private.cmake index ec6e9c1d67..6fcb148948 100644 --- a/cmake/macros/Private.cmake +++ b/cmake/macros/Private.cmake @@ -560,19 +560,19 @@ function(_pxr_enable_precompiled_header TARGET_NAME) COMMAND ${CMAKE_COMMAND} -E touch ${abs_output_source_path} ) - # The trigger file gets a special compile flag (/Yc). - set_source_files_properties(${abs_output_source_path} PROPERTIES - COMPILE_FLAGS "/Yc\"${rel_output_header_path}\" /FI\"${rel_output_header_path}\" /Fp\"${abs_precompiled_path}\"" - OBJECT_OUTPUTS "${abs_precompiled_path}" - OBJECT_DEPENDS "${abs_output_header_path}" - ) - # Add the header file to the target. target_sources(${TARGET_NAME} PRIVATE "${abs_output_header_path}") # Add the trigger file to the target. target_sources(${TARGET_NAME} PRIVATE "${abs_output_source_path}") + # The trigger file gets a special compile flag (/Yc). + set_source_files_properties(${abs_output_source_path} PROPERTIES + COMPILE_FLAGS "/Yc\"${rel_output_header_path}\" /FI\"${rel_output_header_path}\" /Fp\"${abs_precompiled_path}\"" + OBJECT_OUTPUTS "${abs_precompiled_path}" + OBJECT_DEPENDS "${abs_output_header_path}" + ) + # Exclude the trigger. list(APPEND pch_EXCLUDE ${abs_output_source_path}) else() From 3353801c7d87269ce961e4345d42c25834803865 Mon Sep 17 00:00:00 2001 From: Simon Haegler Date: Sun, 4 Aug 2024 16:11:19 +0200 Subject: [PATCH 005/300] Build (msvc/ninja): enforce synchronous writes to PDB files (prevents compilation errors) --- cmake/defaults/msvcdefaults.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/defaults/msvcdefaults.cmake b/cmake/defaults/msvcdefaults.cmake index 78bde7a77e..e2b9470bf7 100644 --- a/cmake/defaults/msvcdefaults.cmake +++ b/cmake/defaults/msvcdefaults.cmake @@ -134,3 +134,9 @@ set(_PXR_CXX_FLAGS "${_PXR_CXX_FLAGS} /Gm-") # with no symbols in it. We do this a lot because of a pattern of having # a C++ source file for many header-only facilities, e.g. tf/bitUtils.cpp. set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4221") + +# Enforce synchronous PDB writes when using Ninja +# (this prevents "permission denied" compile errors on program databases) +if("${CMAKE_GENERATOR}" STREQUAL "Ninja") + set(_PXR_CXX_FLAGS "${_PXR_CXX_FLAGS} /FS") +endif() From a797c5f300de9c0c1bce515d1c184c38d0218e34 Mon Sep 17 00:00:00 2001 From: Edward Slavin Date: Mon, 12 Aug 2024 15:10:23 -0400 Subject: [PATCH 006/300] - Specialized TfStringify for integral types to support locale independent writes --- pxr/base/tf/stringUtils.cpp | 67 +++++++++++++++++++++++++++++ pxr/base/tf/stringUtils.h | 16 +++++++ pxr/base/tf/testenv/stringUtils.cpp | 38 ++++++++++++++++ 3 files changed, 121 insertions(+) diff --git a/pxr/base/tf/stringUtils.cpp b/pxr/base/tf/stringUtils.cpp index 7110aee3e8..35a168d5f8 100644 --- a/pxr/base/tf/stringUtils.cpp +++ b/pxr/base/tf/stringUtils.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "pxrDoubleConversion/double-conversion.h" #include "pxrDoubleConversion/utils.h" @@ -912,6 +913,72 @@ TfStringify(std::string const& s) return s; } +template +std::string +_TfStringifyIntegralImpl(const T& value) +{ + // plus one because for signed values, digits10 will give one less + // than what is actually needed in cases where the amount of characters + // could represent an overflow + constexpr size_t maxSize = std::numeric_limits::digits10 + 1 + + (std::numeric_limits::is_signed ? 1 : 0); + + std::string result(maxSize, '\0'); + auto [ptr, ec] = std::to_chars(result.data(), result.data() + maxSize, value); + TF_DEV_AXIOM(ec == std::errc()); + result.resize(std::distance(result.data(), ptr)); + + return result; +} + +std::string +TfStringify(short val) +{ + return _TfStringifyIntegralImpl(val); +} + +std::string +TfStringify(unsigned short val) +{ + return _TfStringifyIntegralImpl(val); +} + +std::string +TfStringify(int val) +{ + return _TfStringifyIntegralImpl(val); +} + +std::string +TfStringify(unsigned int val) +{ + return _TfStringifyIntegralImpl(val); +} + +std::string +TfStringify(long val) +{ + return _TfStringifyIntegralImpl(val); +} + +std::string +TfStringify(unsigned long val) +{ + return _TfStringifyIntegralImpl(val); +} + +std::string +TfStringify(long long val) +{ + return _TfStringifyIntegralImpl(val); +} + +std::string +TfStringify(unsigned long long val) +{ + return _TfStringifyIntegralImpl(val); +} + static const pxr_double_conversion::DoubleToStringConverter& diff --git a/pxr/base/tf/stringUtils.h b/pxr/base/tf/stringUtils.h index 4a75a210a0..aad4c7067b 100644 --- a/pxr/base/tf/stringUtils.h +++ b/pxr/base/tf/stringUtils.h @@ -572,6 +572,22 @@ TF_API std::string TfStringify(std::string const&); TF_API std::string TfStringify(float); /// \overload TF_API std::string TfStringify(double); +/// \overload +TF_API std::string TfStringify(short); +/// \overload +TF_API std::string TfStringify(unsigned short); +/// \overload +TF_API std::string TfStringify(int); +/// \overload +TF_API std::string TfStringify(unsigned int); +/// \overload +TF_API std::string TfStringify(long); +/// \overload +TF_API std::string TfStringify(unsigned long); +/// \overload +TF_API std::string TfStringify(long long); +/// \overload +TF_API std::string TfStringify(unsigned long long); /// Writes the string representation of \c d to \c buffer of length \c len. /// If \c emitTrailingZero is true, the string representation will end with .0 diff --git a/pxr/base/tf/testenv/stringUtils.cpp b/pxr/base/tf/testenv/stringUtils.cpp index 975d59885f..b33d4b958e 100644 --- a/pxr/base/tf/testenv/stringUtils.cpp +++ b/pxr/base/tf/testenv/stringUtils.cpp @@ -15,6 +15,7 @@ #include #include #include +#include using namespace std; PXR_NAMESPACE_USING_DIRECTIVE @@ -264,6 +265,14 @@ DoPrintfStr(const char *fmt, ...) return ret; } +template +bool +_RoundtripStringifyLimits() +{ + return (TfUnstringify(TfStringify(std::numeric_limits::min())) == std::numeric_limits::min()) && + (TfUnstringify(TfStringify(std::numeric_limits::max())) == std::numeric_limits::max()); +} + static bool TestStrings() { @@ -386,6 +395,35 @@ TestStrings() TF_AXIOM(TfUnstringify("a") == 'a'); TF_AXIOM(TfStringify("string") == "string"); TF_AXIOM(TfUnstringify("string") == "string"); + TF_AXIOM(TfStringify(1000) == "1000"); + + // make sure we can represent the min and max of each type + TF_AXIOM(_RoundtripStringifyLimits()); + TF_AXIOM(_RoundtripStringifyLimits()); + TF_AXIOM(_RoundtripStringifyLimits()); + TF_AXIOM(_RoundtripStringifyLimits()); + TF_AXIOM(_RoundtripStringifyLimits()); + TF_AXIOM(_RoundtripStringifyLimits()); + TF_AXIOM(_RoundtripStringifyLimits()); + TF_AXIOM(_RoundtripStringifyLimits()); + + // verify that TfStringify is agnostic to locale for + // numerical values + std::locale originalLocale; + std::locale::global(std::locale("")); + try + { + TF_AXIOM(TfStringify(1000.56) == "1000.56"); + TF_AXIOM(TfStringify(1000) == "1000"); + std::locale::global(originalLocale); + } + catch(...) + { + std::locale::global(originalLocale); + throw; + } + TF_AXIOM(TfStringify(1000) == "1000"); + TF_AXIOM(TfStringify(1000.56) == "1000.56"); bool unstringRet = true; TfUnstringify("this ain't no int", &unstringRet); From 0a727b4f0bf86daad02ee17b79e4b40cb2891b56 Mon Sep 17 00:00:00 2001 From: Edward Slavin Date: Tue, 13 Aug 2024 14:29:02 -0400 Subject: [PATCH 007/300] Changed const& to const --- pxr/base/tf/stringUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pxr/base/tf/stringUtils.cpp b/pxr/base/tf/stringUtils.cpp index 35a168d5f8..596d2e00fb 100644 --- a/pxr/base/tf/stringUtils.cpp +++ b/pxr/base/tf/stringUtils.cpp @@ -915,7 +915,7 @@ TfStringify(std::string const& s) template std::string -_TfStringifyIntegralImpl(const T& value) +_TfStringifyIntegralImpl(const T value) { // plus one because for signed values, digits10 will give one less // than what is actually needed in cases where the amount of characters From 421171efa6061ee3af66aa9ba390810d214effd9 Mon Sep 17 00:00:00 2001 From: Rasmus Bonnedal Date: Fri, 30 Aug 2024 18:09:02 +0200 Subject: [PATCH 008/300] [hdSt] Set GL_UNPACK_ALIGNMENT=1 to avoid texture distortion --- pxr/imaging/hgiGL/ops.cpp | 2 ++ pxr/imaging/hgiGL/texture.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pxr/imaging/hgiGL/ops.cpp b/pxr/imaging/hgiGL/ops.cpp index a0473c4797..20ae6ac777 100644 --- a/pxr/imaging/hgiGL/ops.cpp +++ b/pxr/imaging/hgiGL/ops.cpp @@ -137,6 +137,8 @@ HgiGLOps::CopyTextureCpuToGpu(HgiTextureCpuToGpuOp const& copyOp) HgiGLTexture* dstTexture = static_cast( copyOp.gpuDestinationTexture.Get()); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + switch(desc.type) { case HgiTextureType2D: if (isCompressed) { diff --git a/pxr/imaging/hgiGL/texture.cpp b/pxr/imaging/hgiGL/texture.cpp index 06f8f85a15..afae3cdeec 100644 --- a/pxr/imaging/hgiGL/texture.cpp +++ b/pxr/imaging/hgiGL/texture.cpp @@ -272,6 +272,8 @@ HgiGLTexture::HgiGLTexture(HgiTextureDesc const & desc) desc.dimensions, desc.layerCount); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + // Upload texel data if (desc.initialData && desc.pixelsByteSize > 0) { // Upload each (available) mip From 497bd46b3dccf7130554d07d5022e00900295b25 Mon Sep 17 00:00:00 2001 From: Olivia Howard <106042786+OliRosHow@users.noreply.github.com> Date: Fri, 30 Aug 2024 16:05:18 -0500 Subject: [PATCH 009/300] changed "(unsuppored type)" to "(unsupported type)" on line 188 of dataSourceValueTreeView.cpp --- extras/imaging/examples/hdui/dataSourceValueTreeView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/imaging/examples/hdui/dataSourceValueTreeView.cpp b/extras/imaging/examples/hdui/dataSourceValueTreeView.cpp index 99d2fe0400..bd3ec70f0b 100644 --- a/extras/imaging/examples/hdui/dataSourceValueTreeView.cpp +++ b/extras/imaging/examples/hdui/dataSourceValueTreeView.cpp @@ -185,7 +185,7 @@ class Hdui_UnsupportedTypeValueItemModel : public Hdui_ValueItemModel return QVariant(); } - return QVariant("(unsuppored type)"); + return QVariant("(unsupported type)"); } int rowCount(const QModelIndex &parent = QModelIndex()) const override { From b78f5881607a9424cf0a83c794f94c3df2b00f99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rob=20Piek=C3=A9?= Date: Wed, 11 Sep 2024 10:05:08 +0100 Subject: [PATCH 010/300] Moving logic for iterating over render delegate's material contexts from the scene delegate to the material schema. This ensures that the fallback context is only used if *all* the delegate's contexts fail --- pxr/imaging/hd/materialSchema.cpp | 10 ++++++---- pxr/imaging/hd/materialSchema.h | 4 ++-- pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp | 9 +-------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/pxr/imaging/hd/materialSchema.cpp b/pxr/imaging/hd/materialSchema.cpp index 14b04550f7..b5dde82d5b 100644 --- a/pxr/imaging/hd/materialSchema.cpp +++ b/pxr/imaging/hd/materialSchema.cpp @@ -41,10 +41,12 @@ HdMaterialSchema::GetMaterialNetwork() } HdMaterialNetworkSchema -HdMaterialSchema::GetMaterialNetwork(TfToken const &context) +HdMaterialSchema::GetMaterialNetwork(TfTokenVector const &contexts) { - if (auto b = _GetTypedDataSource(context)) { - return HdMaterialNetworkSchema(b); + for (TfToken const &context : contexts) { + if (auto b = _GetTypedDataSource(context)) { + return HdMaterialNetworkSchema(b); + } } // If we can't find the context-specific binding, return the fallback. @@ -93,4 +95,4 @@ HdMaterialSchema::GetDefaultLocator() return locator; } -PXR_NAMESPACE_CLOSE_SCOPE \ No newline at end of file +PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/imaging/hd/materialSchema.h b/pxr/imaging/hd/materialSchema.h index 660004805b..5e2ba23a33 100644 --- a/pxr/imaging/hd/materialSchema.h +++ b/pxr/imaging/hd/materialSchema.h @@ -145,7 +145,7 @@ class HdMaterialSchema : public HdSchema HdMaterialNetworkSchema GetMaterialNetwork(); HD_API - HdMaterialNetworkSchema GetMaterialNetwork(TfToken const &context); + HdMaterialNetworkSchema GetMaterialNetwork(TfTokenVector const &contexts); // --(END CUSTOM CODE: Schema Methods)-- @@ -183,4 +183,4 @@ class HdMaterialSchema : public HdSchema PXR_NAMESPACE_CLOSE_SCOPE -#endif \ No newline at end of file +#endif diff --git a/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp b/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp index 0de30d0d4c..978ac93cab 100644 --- a/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp +++ b/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp @@ -1190,14 +1190,7 @@ HdSceneIndexAdapterSceneDelegate::GetMaterialResource(SdfPath const & id) // Query for a material network to match the requested render contexts const TfTokenVector renderContexts = GetRenderIndex().GetRenderDelegate()->GetMaterialRenderContexts(); - HdMaterialNetworkSchema netSchema(nullptr); - for (TfToken const& networkSelector : renderContexts) { - netSchema = matSchema.GetMaterialNetwork(networkSelector); - if (netSchema) { - // Found a matching network - break; - } - } + HdMaterialNetworkSchema netSchema = matSchema.GetMaterialNetwork(renderContexts); if (!netSchema.IsDefined()) { return VtValue(); } From e121dcee2b5b821a03b97eb3180a60540c8b20e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rob=20Piek=C3=A9?= Date: Wed, 11 Sep 2024 10:26:02 +0100 Subject: [PATCH 011/300] Restore original function as well, since the RenderMan plugin uses that API --- pxr/imaging/hd/materialSchema.cpp | 14 ++++++++++++++ pxr/imaging/hd/materialSchema.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/pxr/imaging/hd/materialSchema.cpp b/pxr/imaging/hd/materialSchema.cpp index b5dde82d5b..8dd2ae57cd 100644 --- a/pxr/imaging/hd/materialSchema.cpp +++ b/pxr/imaging/hd/materialSchema.cpp @@ -40,6 +40,20 @@ HdMaterialSchema::GetMaterialNetwork() HdMaterialSchemaTokens->universalRenderContext)); } +HdMaterialNetworkSchema +HdMaterialSchema::GetMaterialNetwork(TfToken const &context) +{ + if (auto b = _GetTypedDataSource(context)) { + return HdMaterialNetworkSchema(b); + } + + // If we can't find the context-specific binding, return the fallback. + return + HdMaterialNetworkSchema( + _GetTypedDataSource( + HdMaterialSchemaTokens->universalRenderContext)); +} + HdMaterialNetworkSchema HdMaterialSchema::GetMaterialNetwork(TfTokenVector const &contexts) { diff --git a/pxr/imaging/hd/materialSchema.h b/pxr/imaging/hd/materialSchema.h index 5e2ba23a33..01645fa84d 100644 --- a/pxr/imaging/hd/materialSchema.h +++ b/pxr/imaging/hd/materialSchema.h @@ -144,6 +144,9 @@ class HdMaterialSchema : public HdSchema HD_API HdMaterialNetworkSchema GetMaterialNetwork(); + HD_API + HdMaterialNetworkSchema GetMaterialNetwork(TfToken const &context); + HD_API HdMaterialNetworkSchema GetMaterialNetwork(TfTokenVector const &contexts); From 5d4c16df9d05f1b61c283a7408926a14e761192a Mon Sep 17 00:00:00 2001 From: Ionut Ivana Date: Tue, 17 Sep 2024 15:22:31 +0300 Subject: [PATCH 012/300] Move the initialization of variable removalTestQueue before deleting the iterator it was using. --- pxr/imaging/hd/mergingSceneIndex.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pxr/imaging/hd/mergingSceneIndex.cpp b/pxr/imaging/hd/mergingSceneIndex.cpp index af564e8d74..0f99511b7e 100644 --- a/pxr/imaging/hd/mergingSceneIndex.cpp +++ b/pxr/imaging/hd/mergingSceneIndex.cpp @@ -137,6 +137,8 @@ HdMergingSceneIndex::RemoveInputScene(const HdSceneIndexBaseRefPtr &sceneIndex) return; } + std::vector removalTestQueue = { it->sceneRoot }; + sceneIndex->RemoveObserver(HdSceneIndexObserverPtr(&_observer)); _inputs.erase(it); @@ -144,8 +146,6 @@ HdMergingSceneIndex::RemoveInputScene(const HdSceneIndexBaseRefPtr &sceneIndex) return; } - std::vector removalTestQueue = { it->sceneRoot }; - // prims unique to this input get removed HdSceneIndexObserver::RemovedPrimEntries removedEntries; From bc7c18aac6961e7bd8f4a9ce8d2dd1d27700c0a3 Mon Sep 17 00:00:00 2001 From: Paul Molodowitch Date: Mon, 23 Sep 2024 10:07:57 -0700 Subject: [PATCH 013/300] [docs] update VERSIONS.md to note that OpenUSD requires Jinja2 >= 3.0 OpenUSD makes use of `jinja2.pass_context`: - https://github.com/PixarAnimationStudios/OpenUSD/blob/v24.08/pxr/imaging/hd/hdGenSchema.py#L9 - https://github.com/PixarAnimationStudios/OpenUSD/blob/v24.08/third_party/renderman-25/plugin/hdPrman/rileyGenPrim.py#L10 - https://github.com/PixarAnimationStudios/OpenUSD/blob/v24.08/third_party/renderman-26/plugin/hdPrman/rileyGenPrim.py#L10 ... which did not exist before 3.0 (was previously named `contextfunction`): - https://github.com/pallets/jinja/commit/788d8bc1728490196f75ba4f8b7b1794a1974f0a --- VERSIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSIONS.md b/VERSIONS.md index c3caf2ed56..121e0bbe6c 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -31,7 +31,7 @@ Our test machines have the following software versions installed. | Alembic | 1.8.5 | 1.8.5 | 1.8.5 | | OpenEXR | 3.1.11 | 3.1.11 | 3.1.11 | | MaterialX | 1.38.10 | 1.38.10 | 1.38.10 | -| Jinja2 | 2.0 | | | +| Jinja2 | >=3.0 | | | | Flex | 2.5.39 | | | | Bison | 2.4.1 | | | | Doxygen | 1.9.6 | | | From 4b7f2e35a73216a0012a3b3eb46501ccbfbf969d Mon Sep 17 00:00:00 2001 From: Dhruv Govil Date: Tue, 24 Sep 2024 14:25:26 -0700 Subject: [PATCH 014/300] Correct re-declaration of structs as classes --- pxr/imaging/hd/sortedIds.h | 2 +- pxr/usd/usd/prim.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pxr/imaging/hd/sortedIds.h b/pxr/imaging/hd/sortedIds.h index 4a41e3161f..de4c23a29f 100644 --- a/pxr/imaging/hd/sortedIds.h +++ b/pxr/imaging/hd/sortedIds.h @@ -72,7 +72,7 @@ class Hd_SortedIds { void Clear(); private: - class _UpdateImpl; + struct _UpdateImpl; enum _EditMode { _NoMode, _InsertMode, _RemoveMode, _UpdateMode }; diff --git a/pxr/usd/usd/prim.h b/pxr/usd/usd/prim.h index 4b32a46381..67ff74ca99 100644 --- a/pxr/usd/usd/prim.h +++ b/pxr/usd/usd/prim.h @@ -2196,10 +2196,10 @@ class UsdPrim : public UsdObject friend class UsdSchemaBase; friend class UsdAPISchemaBase; friend class UsdStage; - friend class Usd_StageImplAccess; friend class UsdPrimRange; friend class Usd_PrimData; friend class Usd_PrimFlagsPredicate; + friend struct Usd_StageImplAccess; friend struct UsdPrim_RelTargetFinder; friend struct UsdPrim_AttrConnectionFinder; From ae5a4afd9610f5fdfafa77a8342144dff4c11db8 Mon Sep 17 00:00:00 2001 From: Jerry Gamache Date: Thu, 5 Sep 2024 16:51:21 -0400 Subject: [PATCH 015/300] EMSUSD-1616 - Fix crash referencing image NodeDef --- pxr/usd/usdMtlx/reader.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pxr/usd/usdMtlx/reader.cpp b/pxr/usd/usdMtlx/reader.cpp index 473a359ced..6df29518af 100644 --- a/pxr/usd/usdMtlx/reader.cpp +++ b/pxr/usd/usdMtlx/reader.cpp @@ -434,8 +434,12 @@ _TypeSupportsColorSpace(const mx::ConstValueElementPtr& mxElem) bool colorImageNode = false; if (type == "filename") { // verify the output is color3 or color4 - mx::ConstNodeDefPtr parentNodeDef = - _GetNodeDef(mxElem->getParent()->asA()); + mx::ConstNodeDefPtr parentNodeDef; + if (mxElem->getParent()->isA()) { + parentNodeDef = _GetNodeDef(mxElem->getParent()->asA()); + } else if (mxElem->getParent()->isA()) { + parentNodeDef = mxElem->getParent()->asA(); + } if (parentNodeDef) { for (const mx::OutputPtr& output : parentNodeDef->getOutputs()) { const std::string &type = output->getType(); From 7c603a9c88bd50120c24e17ad5cdfc11126d779a Mon Sep 17 00:00:00 2001 From: Andy Shiue Date: Wed, 25 Sep 2024 11:32:46 -0400 Subject: [PATCH 016/300] Added TF_VERIFY_VK_RESULT to verify the result of the Vulkan call and print the result string if it fails. --- pxr/imaging/hgiVulkan/buffer.cpp | 22 +++++------- pxr/imaging/hgiVulkan/commandBuffer.cpp | 42 +++++----------------- pxr/imaging/hgiVulkan/commandQueue.cpp | 17 ++++----- pxr/imaging/hgiVulkan/computePipeline.cpp | 8 ++--- pxr/imaging/hgiVulkan/device.cpp | 30 ++++++---------- pxr/imaging/hgiVulkan/diagnostic.cpp | 22 ++++++++++-- pxr/imaging/hgiVulkan/diagnostic.h | 18 ++++++++++ pxr/imaging/hgiVulkan/graphicsPipeline.cpp | 16 ++++----- pxr/imaging/hgiVulkan/instance.cpp | 25 ++++++------- pxr/imaging/hgiVulkan/resourceBindings.cpp | 12 +++---- pxr/imaging/hgiVulkan/sampler.cpp | 5 +-- pxr/imaging/hgiVulkan/shaderCompiler.cpp | 4 +-- pxr/imaging/hgiVulkan/shaderFunction.cpp | 4 +-- pxr/imaging/hgiVulkan/texture.cpp | 16 ++++----- 14 files changed, 115 insertions(+), 126 deletions(-) diff --git a/pxr/imaging/hgiVulkan/buffer.cpp b/pxr/imaging/hgiVulkan/buffer.cpp index 2d3c0618b6..04e268aed0 100644 --- a/pxr/imaging/hgiVulkan/buffer.cpp +++ b/pxr/imaging/hgiVulkan/buffer.cpp @@ -40,7 +40,7 @@ HgiVulkanBuffer::HgiVulkanBuffer( VkBufferCreateInfo bi = {VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO}; bi.size = desc.byteSize; bi.usage = HgiVulkanConversions::GetBufferUsage(desc.usage); - bi.usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT | + bi.usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; bi.sharingMode = VK_SHARING_MODE_EXCLUSIVE; // gfx queue only @@ -52,9 +52,7 @@ HgiVulkanBuffer::HgiVulkanBuffer( VmaAllocationCreateInfo ai = {}; ai.preferredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; // GPU efficient - TF_VERIFY( - vmaCreateBuffer(vma,&bi,&ai,&_vkBuffer,&_vmaAllocation,0) == VK_SUCCESS - ); + TF_VERIFY_VK_RESULT(vmaCreateBuffer(vma,&bi,&ai,&_vkBuffer,&_vmaAllocation,0)); // Debug label if (!_descriptor.debugName.empty()) { @@ -150,11 +148,11 @@ HgiVulkanBuffer::GetCPUStagingAddress() } if (!_cpuStagingAddress) { - TF_VERIFY( + TF_VERIFY_VK_RESULT( vmaMapMemory( - _device->GetVulkanMemoryAllocator(), - _stagingBuffer->GetVulkanMemoryAllocation(), - &_cpuStagingAddress) == VK_SUCCESS + _device->GetVulkanMemoryAllocator(), + _stagingBuffer->GetVulkanMemoryAllocation(), + &_cpuStagingAddress) ); } @@ -210,7 +208,7 @@ HgiVulkanBuffer::CreateStagingBuffer( VkBufferCreateInfo bi = {VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO}; bi.size = desc.byteSize; bi.usage = HgiVulkanConversions::GetBufferUsage(desc.usage); - bi.usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT | + bi.usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; bi.sharingMode = VK_SHARING_MODE_EXCLUSIVE; // gfx queue only @@ -221,14 +219,12 @@ HgiVulkanBuffer::CreateStagingBuffer( VkBuffer buffer = 0; VmaAllocation alloc = 0; - TF_VERIFY( - vmaCreateBuffer(vma, &bi, &ai, &buffer, &alloc, 0) == VK_SUCCESS - ); + TF_VERIFY_VK_RESULT(vmaCreateBuffer(vma, &bi, &ai, &buffer, &alloc, 0)); // Map the (HOST_VISIBLE) buffer and upload data if (desc.initialData) { void* map; - TF_VERIFY(vmaMapMemory(vma, alloc, &map) == VK_SUCCESS); + TF_VERIFY_VK_RESULT(vmaMapMemory(vma, alloc, &map)); memcpy(map, desc.initialData, desc.byteSize); vmaUnmapMemory(vma, alloc); } diff --git a/pxr/imaging/hgiVulkan/commandBuffer.cpp b/pxr/imaging/hgiVulkan/commandBuffer.cpp index 3662257b9e..44dadf4649 100644 --- a/pxr/imaging/hgiVulkan/commandBuffer.cpp +++ b/pxr/imaging/hgiVulkan/commandBuffer.cpp @@ -36,12 +36,7 @@ HgiVulkanCommandBuffer::HgiVulkanCommandBuffer( allocInfo.commandPool = pool; allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; - TF_VERIFY( - vkAllocateCommandBuffers( - vkDevice, - &allocInfo, - &_vkCommandBuffer) == VK_SUCCESS - ); + TF_VERIFY_VK_RESULT(vkAllocateCommandBuffers(vkDevice, &allocInfo, &_vkCommandBuffer)); // Assign a debug label to command buffer uint64_t cmdBufHandle = (uint64_t)_vkCommandBuffer; @@ -58,23 +53,13 @@ HgiVulkanCommandBuffer::HgiVulkanCommandBuffer( VkFenceCreateInfo fenceInfo = {VK_STRUCTURE_TYPE_FENCE_CREATE_INFO}; fenceInfo.flags = 0; // Unsignaled starting state - TF_VERIFY( - vkCreateFence( - vkDevice, - &fenceInfo, - HgiVulkanAllocator(), - &_vkFence) == VK_SUCCESS - ); + TF_VERIFY_VK_RESULT(vkCreateFence(vkDevice, &fenceInfo, HgiVulkanAllocator(), &_vkFence)); // Create semaphore for GPU-GPU synchronization VkSemaphoreCreateInfo semaCreateInfo = {VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO}; - TF_VERIFY( - vkCreateSemaphore( - vkDevice, - &semaCreateInfo, - HgiVulkanAllocator(), - &_vkSemaphore) == VK_SUCCESS + TF_VERIFY_VK_RESULT( + vkCreateSemaphore(vkDevice, &semaCreateInfo, HgiVulkanAllocator(), &_vkSemaphore) ); // Assign a debug label to fence. @@ -105,9 +90,7 @@ HgiVulkanCommandBuffer::BeginCommandBuffer(uint8_t inflightId) {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO}; beginInfo.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - TF_VERIFY( - vkBeginCommandBuffer(_vkCommandBuffer, &beginInfo) == VK_SUCCESS - ); + TF_VERIFY_VK_RESULT(vkBeginCommandBuffer(_vkCommandBuffer, &beginInfo)); _inflightId = inflightId; _isInFlight = true; @@ -133,9 +116,7 @@ HgiVulkanCommandBuffer::EndCommandBuffer() TF_VERIFY(_isInFlight); TF_VERIFY(!_isSubmitted); - TF_VERIFY( - vkEndCommandBuffer(_vkCommandBuffer) == VK_SUCCESS - ); + TF_VERIFY_VK_RESULT(vkEndCommandBuffer(_vkCommandBuffer)); _isSubmitted = true; } @@ -163,8 +144,7 @@ HgiVulkanCommandBuffer::UpdateInFlightStatus(HgiSubmitWaitType wait) } static const uint64_t timeOut = 100000000000; - TF_VERIFY(vkWaitForFences( - vkDevice, 1, &_vkFence, VK_TRUE, timeOut) == VK_SUCCESS); + TF_VERIFY_VK_RESULT(vkWaitForFences(vkDevice, 1, &_vkFence, VK_TRUE, timeOut)); } _isInFlight = false; @@ -191,9 +171,7 @@ HgiVulkanCommandBuffer::ResetIfConsumedByGPU(HgiSubmitWaitType wait) VkDevice vkDevice = _device->GetVulkanDevice(); // GPU is done with command buffer, reset fence and command buffer. - TF_VERIFY( - vkResetFences(vkDevice, 1, &_vkFence) == VK_SUCCESS - ); + TF_VERIFY_VK_RESULT(vkResetFences(vkDevice, 1, &_vkFence)); // It might be more efficient to reset the cmd pool instead of individual // command buffers. But we may not have a clear 'StartFrame' / 'EndFrame' @@ -202,9 +180,7 @@ HgiVulkanCommandBuffer::ResetIfConsumedByGPU(HgiSubmitWaitType wait) // been consumed by the GPU. VkCommandBufferResetFlags flags = _GetCommandBufferResetFlags(); - TF_VERIFY( - vkResetCommandBuffer(_vkCommandBuffer, flags) == VK_SUCCESS - ); + TF_VERIFY_VK_RESULT(vkResetCommandBuffer(_vkCommandBuffer, flags)); // Command buffer may now be reused for new recordings / resource creation. _isSubmitted = false; diff --git a/pxr/imaging/hgiVulkan/commandQueue.cpp b/pxr/imaging/hgiVulkan/commandQueue.cpp index c70f479e8a..8928a79437 100644 --- a/pxr/imaging/hgiVulkan/commandQueue.cpp +++ b/pxr/imaging/hgiVulkan/commandQueue.cpp @@ -9,6 +9,7 @@ #include "pxr/imaging/hgiVulkan/device.h" #include "pxr/base/tf/diagnostic.h" +#include "pxr/imaging/hgiVulkan/diagnostic.h" PXR_NAMESPACE_OPEN_SCOPE @@ -27,12 +28,12 @@ _CreateCommandPool(HgiVulkanDevice* device) VkCommandPool pool = nullptr; - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkCreateCommandPool( device->GetVulkanDevice(), &poolCreateInfo, HgiVulkanAllocator(), - &pool) == VK_SUCCESS + &pool) ); HgiVulkanCommandQueue::HgiVulkan_CommandPool* newPool = @@ -110,9 +111,7 @@ HgiVulkanCommandQueue::SubmitToQueue( resourceInfo.signalSemaphoreCount = 1; resourceInfo.pSignalSemaphores = &semaphore; - TF_VERIFY( - vkQueueSubmit(_vkGfxQueue, 1, &resourceInfo, rFence) == VK_SUCCESS - ); + TF_VERIFY_VK_RESULT(vkQueueSubmit(_vkGfxQueue, 1, &resourceInfo, rFence)); _resourceCommandBuffer = nullptr; } @@ -139,17 +138,13 @@ HgiVulkanCommandQueue::SubmitToQueue( // Record and submission order does not guarantee execution order. // VK docs: "Execution Model" & "Implicit Synchronization Guarantees". // The vulkan queue must be externally synchronized. - TF_VERIFY( - vkQueueSubmit(_vkGfxQueue, 1, &workInfo, wFence) == VK_SUCCESS - ); + TF_VERIFY_VK_RESULT(vkQueueSubmit(_vkGfxQueue, 1, &workInfo, wFence)); // Optional blocking wait if (wait == HgiSubmitWaitTypeWaitUntilCompleted) { static const uint64_t timeOut = 100000000000; VkDevice vkDevice = _device->GetVulkanDevice(); - TF_VERIFY( - vkWaitForFences(vkDevice, 1, &wFence, VK_TRUE, timeOut)==VK_SUCCESS - ); + TF_VERIFY_VK_RESULT(vkWaitForFences(vkDevice, 1, &wFence, VK_TRUE, timeOut)); // When the client waits for the cmd buf to finish on GPU they will // expect to have the CompletedHandlers run. For example when the // client wants to do a GPU->CPU read back (memcpy) diff --git a/pxr/imaging/hgiVulkan/computePipeline.cpp b/pxr/imaging/hgiVulkan/computePipeline.cpp index 20129e0966..4c94e9daee 100644 --- a/pxr/imaging/hgiVulkan/computePipeline.cpp +++ b/pxr/imaging/hgiVulkan/computePipeline.cpp @@ -72,12 +72,12 @@ HgiVulkanComputePipeline::HgiVulkanComputePipeline( pipeLayCreateInfo.setLayoutCount = (uint32_t)_vkDescriptorSetLayouts.size(); pipeLayCreateInfo.pSetLayouts = _vkDescriptorSetLayouts.data(); - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkCreatePipelineLayout( _device->GetVulkanDevice(), &pipeLayCreateInfo, HgiVulkanAllocator(), - &_vkPipelineLayout) == VK_SUCCESS + &_vkPipelineLayout) ); // Debug label @@ -97,14 +97,14 @@ HgiVulkanComputePipeline::HgiVulkanComputePipeline( // HgiVulkanPipelineCache* pCache = device->GetPipelineCache(); - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkCreateComputePipelines( _device->GetVulkanDevice(), pCache->GetVulkanPipelineCache(), 1, &pipeCreateInfo, HgiVulkanAllocator(), - &_vkPipeline) == VK_SUCCESS + &_vkPipeline) ); // Debug label diff --git a/pxr/imaging/hgiVulkan/device.cpp b/pxr/imaging/hgiVulkan/device.cpp index 7b38eec9ff..4fceaefe57 100644 --- a/pxr/imaging/hgiVulkan/device.cpp +++ b/pxr/imaging/hgiVulkan/device.cpp @@ -77,11 +77,11 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) const uint32_t maxDevices = 64; VkPhysicalDevice physicalDevices[maxDevices]; uint32_t physicalDeviceCount = maxDevices; - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkEnumeratePhysicalDevices( instance->GetVulkanInstance(), &physicalDeviceCount, - physicalDevices) == VK_SUCCESS + physicalDevices) ); for (uint32_t i = 0; i < physicalDeviceCount; i++) { @@ -123,22 +123,22 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) // uint32_t extensionCount = 0; - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkEnumerateDeviceExtensionProperties( _vkPhysicalDevice, nullptr, &extensionCount, - nullptr) == VK_SUCCESS + nullptr) ); _vkExtensions.resize(extensionCount); - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkEnumerateDeviceExtensionProperties( _vkPhysicalDevice, nullptr, &extensionCount, - _vkExtensions.data()) == VK_SUCCESS + _vkExtensions.data()) ); // @@ -282,12 +282,8 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) createInfo.enabledExtensionCount = (uint32_t) extensions.size(); createInfo.pNext = &features; - TF_VERIFY( - vkCreateDevice( - _vkPhysicalDevice, - &createInfo, - HgiVulkanAllocator(), - &_vkDevice) == VK_SUCCESS + TF_VERIFY_VK_RESULT( + vkCreateDevice(_vkPhysicalDevice, &createInfo, HgiVulkanAllocator(), &_vkDevice) ); HgiVulkanSetupDeviceDebug(instance, this); @@ -315,9 +311,7 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) allocatorInfo.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT; } - TF_VERIFY( - vmaCreateAllocator(&allocatorInfo, &_vmaAllocator) == VK_SUCCESS - ); + TF_VERIFY_VK_RESULT(vmaCreateAllocator(&allocatorInfo, &_vmaAllocator)); // // Command Queue @@ -335,7 +329,7 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) HgiVulkanDevice::~HgiVulkanDevice() { // Make sure device is idle before destroying objects. - TF_VERIFY(vkDeviceWaitIdle(_vkDevice) == VK_SUCCESS); + TF_VERIFY_VK_RESULT(vkDeviceWaitIdle(_vkDevice)); delete _pipelineCache; delete _commandQueue; @@ -389,9 +383,7 @@ HgiVulkanDevice::GetPipelineCache() const void HgiVulkanDevice::WaitForIdle() { - TF_VERIFY( - vkDeviceWaitIdle(_vkDevice) == VK_SUCCESS - ); + TF_VERIFY_VK_RESULT(vkDeviceWaitIdle(_vkDevice)); } bool diff --git a/pxr/imaging/hgiVulkan/diagnostic.cpp b/pxr/imaging/hgiVulkan/diagnostic.cpp index 64ba485380..61cbd9658d 100644 --- a/pxr/imaging/hgiVulkan/diagnostic.cpp +++ b/pxr/imaging/hgiVulkan/diagnostic.cpp @@ -14,6 +14,8 @@ #include "pxr/base/tf/diagnostic.h" #include "pxr/base/tf/envSetting.h" +#include + #include @@ -21,7 +23,7 @@ PXR_NAMESPACE_OPEN_SCOPE TF_DEFINE_ENV_SETTING(HGIVULKAN_DEBUG, 0, "Enable debugging for HgiVulkan"); -TF_DEFINE_ENV_SETTING(HGIVULKAN_DEBUG_VERBOSE, 0, +TF_DEFINE_ENV_SETTING(HGIVULKAN_DEBUG_VERBOSE, 0, "Enable verbose debugging for HgiVulkan"); bool @@ -108,12 +110,12 @@ HgiVulkanCreateDebug(HgiVulkanInstance* instance) dbgMsgCreateInfo.pfnUserCallback = _VulkanDebugCallback; dbgMsgCreateInfo.pUserData = nullptr; - TF_VERIFY( + TF_VERIFY_VK_RESULT( instance->vkCreateDebugUtilsMessengerEXT( vkInstance, &dbgMsgCreateInfo, HgiVulkanAllocator(), - &instance->vkDebugMessenger) == VK_SUCCESS + &instance->vkDebugMessenger) ); } @@ -250,4 +252,18 @@ HgiVulkanEndQueueLabel(HgiVulkanDevice* device) device->vkQueueEndDebugUtilsLabelEXT(gfxQueue); } +const char* +HgiVulkanResultString(VkResult result) +{ + return string_VkResult(result); +} + +const char* +HgiVulkanCommandResultString(const char* cmd, VkResult result) +{ + static thread_local std::string buffer; + buffer = std::string(cmd) + ": " + string_VkResult(result); + return buffer.c_str(); +} + PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/imaging/hgiVulkan/diagnostic.h b/pxr/imaging/hgiVulkan/diagnostic.h index 84adc09cf7..9d00683a58 100644 --- a/pxr/imaging/hgiVulkan/diagnostic.h +++ b/pxr/imaging/hgiVulkan/diagnostic.h @@ -66,6 +66,24 @@ void HgiVulkanBeginQueueLabel( HGIVULKAN_API void HgiVulkanEndQueueLabel(HgiVulkanDevice* device); +/// Returns a string representation of VkResult +HGIVULKAN_API +const char* HgiVulkanResultString(VkResult result); + +/// Returns a string representation of the vulkan command and its result +HGIVULKAN_API +const char* HgiVulkanCommandResultString(const char* cmd, VkResult result); + +#define TF_VERIFY_VK_RESULT(cmd) \ + do { \ + const auto result = cmd; \ + if (ARCH_UNLIKELY(result != VK_SUCCESS)) { \ + Tf_PostErrorHelper(TF_CALL_CONTEXT, \ + TF_DIAGNOSTIC_CODING_ERROR_TYPE, \ + std::string{HgiVulkanCommandResultString(#cmd, result)}); \ + } \ + } while(0) + PXR_NAMESPACE_CLOSE_SCOPE #endif diff --git a/pxr/imaging/hgiVulkan/graphicsPipeline.cpp b/pxr/imaging/hgiVulkan/graphicsPipeline.cpp index 053d8d4e7d..88a9f67fd6 100755 --- a/pxr/imaging/hgiVulkan/graphicsPipeline.cpp +++ b/pxr/imaging/hgiVulkan/graphicsPipeline.cpp @@ -330,12 +330,12 @@ HgiVulkanGraphicsPipeline::HgiVulkanGraphicsPipeline( pipeLayCreateInfo.setLayoutCount= (uint32_t) _vkDescriptorSetLayouts.size(); pipeLayCreateInfo.pSetLayouts = _vkDescriptorSetLayouts.data(); - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkCreatePipelineLayout( _device->GetVulkanDevice(), &pipeLayCreateInfo, HgiVulkanAllocator(), - &_vkPipelineLayout) == VK_SUCCESS + &_vkPipelineLayout) ); // Debug label @@ -362,14 +362,14 @@ HgiVulkanGraphicsPipeline::HgiVulkanGraphicsPipeline( // HgiVulkanPipelineCache* pCache = device->GetPipelineCache(); - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkCreateGraphicsPipelines( _device->GetVulkanDevice(), pCache->GetVulkanPipelineCache(), 1, &pipeCreateInfo, HgiVulkanAllocator(), - &_vkPipeline) == VK_SUCCESS + &_vkPipeline) ); // Debug label @@ -503,12 +503,12 @@ HgiVulkanGraphicsPipeline::AcquireVulkanFramebuffer( fbCreateInfo.height = framebuffer.dimensions[1]; fbCreateInfo.layers = 1; - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkCreateFramebuffer( _device->GetVulkanDevice(), &fbCreateInfo, HgiVulkanAllocator(), - &framebuffer.vkFramebuffer) == VK_SUCCESS + &framebuffer.vkFramebuffer) ); // Debug label @@ -766,12 +766,12 @@ HgiVulkanGraphicsPipeline::_CreateRenderPass() vkCreateRenderPass2KHR = (PFN_vkCreateRenderPass2KHR) vkGetDeviceProcAddr( _device->GetVulkanDevice(), "vkCreateRenderPass2KHR"); - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkCreateRenderPass2KHR( _device->GetVulkanDevice(), &renderPassInfo, HgiVulkanAllocator(), - &_vkRenderPass) == VK_SUCCESS + &_vkRenderPass) ); // Debug label diff --git a/pxr/imaging/hgiVulkan/instance.cpp b/pxr/imaging/hgiVulkan/instance.cpp index a48d43297f..b304e4c51d 100755 --- a/pxr/imaging/hgiVulkan/instance.cpp +++ b/pxr/imaging/hgiVulkan/instance.cpp @@ -19,20 +19,20 @@ PXR_NAMESPACE_OPEN_SCOPE static bool _CheckInstanceValidationLayerSupport(const char * layerName) -{ - uint32_t layerCount; - vkEnumerateInstanceLayerProperties(&layerCount, nullptr); +{ + uint32_t layerCount; + vkEnumerateInstanceLayerProperties(&layerCount, nullptr); std::vector availableLayers(layerCount); - + vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data()); - for (const auto& layerProperties : availableLayers) { - if (strcmp(layerName, layerProperties.layerName) == 0) { + for (const auto& layerProperties : availableLayers) { + if (strcmp(layerName, layerProperties.layerName) == 0) { return true; - } - } + } + } - return false; + return false; } static @@ -133,12 +133,7 @@ HgiVulkanInstance::HgiVulkanInstance() } #endif - TF_VERIFY( - vkCreateInstance( - &createInfo, - HgiVulkanAllocator(), - &_vkInstance) == VK_SUCCESS - ); + TF_VERIFY_VK_RESULT(vkCreateInstance(&createInfo, HgiVulkanAllocator(), &_vkInstance)); HgiVulkanCreateDebug(this); } diff --git a/pxr/imaging/hgiVulkan/resourceBindings.cpp b/pxr/imaging/hgiVulkan/resourceBindings.cpp index 24e1cdd194..b5f9035335 100644 --- a/pxr/imaging/hgiVulkan/resourceBindings.cpp +++ b/pxr/imaging/hgiVulkan/resourceBindings.cpp @@ -35,12 +35,12 @@ _CreateDescriptorSetLayout( setCreateInfo.pNext = nullptr; VkDescriptorSetLayout layout = nullptr; - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkCreateDescriptorSetLayout( device->GetVulkanDevice(), &setCreateInfo, HgiVulkanAllocator(), - &layout) == VK_SUCCESS + &layout) ); // Debug label @@ -170,12 +170,12 @@ HgiVulkanResourceBindings::HgiVulkanResourceBindings( pool_info.poolSizeCount = (uint32_t) poolSizes.size(); pool_info.pPoolSizes = poolSizes.data(); - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkCreateDescriptorPool( _device->GetVulkanDevice(), &pool_info, HgiVulkanAllocator(), - &_vkDescriptorPool) == VK_SUCCESS + &_vkDescriptorPool) ); // Debug label @@ -198,11 +198,11 @@ HgiVulkanResourceBindings::HgiVulkanResourceBindings( allocateInfo.descriptorSetCount = _descriptorSetCnt; allocateInfo.pSetLayouts = &_vkDescriptorSetLayout; - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkAllocateDescriptorSets( _device->GetVulkanDevice(), &allocateInfo, - &_vkDescriptorSet) == VK_SUCCESS + &_vkDescriptorSet) ); // Debug label diff --git a/pxr/imaging/hgiVulkan/sampler.cpp b/pxr/imaging/hgiVulkan/sampler.cpp index 3f99b1f0e4..fdf4bcb02e 100644 --- a/pxr/imaging/hgiVulkan/sampler.cpp +++ b/pxr/imaging/hgiVulkan/sampler.cpp @@ -10,6 +10,7 @@ #include "pxr/imaging/hgiVulkan/conversions.h" #include "pxr/imaging/hgiVulkan/device.h" #include "pxr/imaging/hgiVulkan/sampler.h" +#include "pxr/imaging/hgiVulkan/diagnostic.h" #include @@ -58,12 +59,12 @@ HgiVulkanSampler::HgiVulkanSampler( static_cast(TfGetEnvSetting(HGI_MAX_ANISOTROPY))}) : 1.0f; } - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkCreateSampler( device->GetVulkanDevice(), &sampler, HgiVulkanAllocator(), - &_vkSampler) == VK_SUCCESS + &_vkSampler) ); } diff --git a/pxr/imaging/hgiVulkan/shaderCompiler.cpp b/pxr/imaging/hgiVulkan/shaderCompiler.cpp index 7f285e7a6c..94c4aaedd1 100644 --- a/pxr/imaging/hgiVulkan/shaderCompiler.cpp +++ b/pxr/imaging/hgiVulkan/shaderCompiler.cpp @@ -102,12 +102,12 @@ _CreateDescriptorSetLayout( std::string const& debugName) { VkDescriptorSetLayout layout = nullptr; - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkCreateDescriptorSetLayout( device->GetVulkanDevice(), &createInfo, HgiVulkanAllocator(), - &layout) == VK_SUCCESS + &layout) ); // Debug label diff --git a/pxr/imaging/hgiVulkan/shaderFunction.cpp b/pxr/imaging/hgiVulkan/shaderFunction.cpp index 9c2bffd8c7..c3ebc68ca1 100644 --- a/pxr/imaging/hgiVulkan/shaderFunction.cpp +++ b/pxr/imaging/hgiVulkan/shaderFunction.cpp @@ -57,12 +57,12 @@ HgiVulkanShaderFunction::HgiVulkanShaderFunction( shaderCreateInfo.codeSize = _spirvByteSize; shaderCreateInfo.pCode = (uint32_t*) spirv.data(); - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkCreateShaderModule( device->GetVulkanDevice(), &shaderCreateInfo, HgiVulkanAllocator(), - &_vkShaderModule) == VK_SUCCESS + &_vkShaderModule) ); // Debug label diff --git a/pxr/imaging/hgiVulkan/texture.cpp b/pxr/imaging/hgiVulkan/texture.cpp index 6a9cff0186..8fde509a56 100644 --- a/pxr/imaging/hgiVulkan/texture.cpp +++ b/pxr/imaging/hgiVulkan/texture.cpp @@ -107,14 +107,14 @@ HgiVulkanTexture::HgiVulkanTexture( // Equivalent to: vkCreateImage, vkAllocateMemory, vkBindImageMemory VmaAllocationCreateInfo allocInfo = {}; allocInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; - TF_VERIFY( + TF_VERIFY_VK_RESULT( vmaCreateImage( device->GetVulkanMemoryAllocator(), &imageCreateInfo, &allocInfo, &_vkImage, &_vmaImageAllocation, - nullptr) == VK_SUCCESS + nullptr) ); TF_VERIFY(_vkImage, "Failed to create image"); @@ -164,12 +164,12 @@ HgiVulkanTexture::HgiVulkanTexture( view.subresourceRange.levelCount = desc.mipLevels; view.image = _vkImage; - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkCreateImageView( device->GetVulkanDevice(), &view, HgiVulkanAllocator(), - &_vkImageView) == VK_SUCCESS + &_vkImageView) ); // Debug label @@ -286,12 +286,12 @@ HgiVulkanTexture::HgiVulkanTexture( view.subresourceRange.levelCount = desc.mipLevels; view.image = srcTexture->GetImage(); - TF_VERIFY( + TF_VERIFY_VK_RESULT( vkCreateImageView( device->GetVulkanDevice(), &view, HgiVulkanAllocator(), - &_vkImageView) == VK_SUCCESS + &_vkImageView) ); // Debug label @@ -358,11 +358,11 @@ HgiVulkanTexture::GetCPUStagingAddress() } if (!_cpuStagingAddress) { - TF_VERIFY( + TF_VERIFY_VK_RESULT( vmaMapMemory( _device->GetVulkanMemoryAllocator(), _stagingBuffer->GetVulkanMemoryAllocation(), - &_cpuStagingAddress) == VK_SUCCESS + &_cpuStagingAddress) ); } From b720f73d42353f020377abc3bb11ec98d05967b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rob=20Piek=C3=A9?= Date: Tue, 8 Oct 2024 15:04:00 +0100 Subject: [PATCH 017/300] Ensuring the SceneDelegate pulls the "correct" (RenderDelegate-preferred) material binding. Note there still remain calls to the generic GetMaterialBinding() in: * collectionPredicateLibrary - hd * materialPrimvarTransferSceneIndex - hdSi * dependencySceneIndexPlugin - hdSt * retesselationSceneIndexPlugin - hdPrman --- .../hd/sceneIndexAdapterSceneDelegate.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp b/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp index 8919d6a421..eeecf95417 100644 --- a/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp +++ b/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp @@ -477,11 +477,11 @@ _IsVisible(const HdContainerDataSourceHandle& primSource) } static SdfPath -_GetBoundMaterialPath(const HdContainerDataSourceHandle& ds) +_GetBoundMaterialPath(const HdContainerDataSourceHandle& ds, const TfToken& purpose) { if (const auto bindingsSchema = HdMaterialBindingsSchema::GetFromParent(ds)) { if (const HdMaterialBindingSchema bindingSchema = - bindingsSchema.GetMaterialBinding()) { + bindingsSchema.GetMaterialBinding(purpose)) { if (const HdPathDataSourceHandle ds = bindingSchema.GetPath()) { return ds->GetTypedValue(0.0f); } @@ -514,7 +514,8 @@ static void _GatherGeomSubsets( const SdfPath& parentPath, const HdSceneIndexBaseRefPtr& sceneIndex, - HdTopology* topology) + HdTopology* topology, + const TfToken& materialBindingPurpose) { TF_VERIFY(topology); HdGeomSubsets subsets; @@ -563,7 +564,7 @@ _GatherGeomSubsets( } continue; } - const SdfPath materialId = _GetBoundMaterialPath(child.dataSource); + const SdfPath materialId = _GetBoundMaterialPath(child.dataSource, materialBindingPurpose); if (materialId.IsEmpty()) { continue; } @@ -631,8 +632,9 @@ HdSceneIndexAdapterSceneDelegate::GetMeshTopology(SdfPath const &id) faceVertexCountsDataSource->GetTypedValue(0.0f), faceVertexIndicesDataSource->GetTypedValue(0.0f), holeIndices); - - _GatherGeomSubsets(id, _inputSceneIndex, &meshTopology); + + TfToken materialBindingPurpose = GetRenderIndex().GetRenderDelegate()->GetMaterialBindingPurpose(); + _GatherGeomSubsets(id, _inputSceneIndex, &meshTopology, materialBindingPurpose); return meshTopology; } @@ -916,8 +918,9 @@ HdSceneIndexAdapterSceneDelegate::GetMaterialId(SdfPath const & id) HdMaterialBindingsSchema materialBindings = HdMaterialBindingsSchema::GetFromParent( prim.dataSource); + TfToken purpose = GetRenderIndex().GetRenderDelegate()->GetMaterialBindingPurpose(); HdMaterialBindingSchema materialBinding = - materialBindings.GetMaterialBinding(); + materialBindings.GetMaterialBinding(purpose); if (HdPathDataSourceHandle const ds = materialBinding.GetPath()) { return ds->GetTypedValue(0.0f); } From d51366bb31e871d154606bf0f09bd3464688a1a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rob=20Piek=C3=A9?= Date: Tue, 8 Oct 2024 15:35:26 +0100 Subject: [PATCH 018/300] Missed two lines from the previous commit --- pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp b/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp index eeecf95417..bf6271d5be 100644 --- a/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp +++ b/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp @@ -843,7 +843,8 @@ HdSceneIndexAdapterSceneDelegate::GetBasisCurvesTopology(SdfPath const &id) curveVertexCountsDataSource->GetTypedValue(0.0f), curveIndices); - _GatherGeomSubsets(id, _inputSceneIndex, &result); + TfToken materialBindingPurpose = GetRenderIndex().GetRenderDelegate()->GetMaterialBindingPurpose(); + _GatherGeomSubsets(id, _inputSceneIndex, &result, materialBindingPurpose); return result; } From 1463d063d5c41c36f2f8a0e4725cf4d61a28e32a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?furby=E2=84=A2?= Date: Wed, 9 Oct 2024 08:23:25 -0600 Subject: [PATCH 019/300] Compiler Warnings: Overrides a member function but is not marked override #3335 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: furby™ --- pxr/usd/usdUtils/assetLocalizationDelegate.h | 2 +- pxr/usdImaging/usdImaging/cylinderLightAdapter.h | 4 ++-- pxr/usdImaging/usdImaging/portalLightAdapter.h | 4 ++-- pxr/usdImaging/usdImaging/tetMeshAdapter.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pxr/usd/usdUtils/assetLocalizationDelegate.h b/pxr/usd/usdUtils/assetLocalizationDelegate.h index 4a36dcb48e..531636bfda 100644 --- a/pxr/usd/usdUtils/assetLocalizationDelegate.h +++ b/pxr/usd/usdUtils/assetLocalizationDelegate.h @@ -273,7 +273,7 @@ class UsdUtils_ReadOnlyLocalizationDelegate virtual std::vector ProcessPayloads( const SdfLayerRefPtr &layer, - const SdfPrimSpecHandle &primSpec); + const SdfPrimSpecHandle &primSpec) override; virtual std::vector ProcessReferences( const SdfLayerRefPtr &layer, diff --git a/pxr/usdImaging/usdImaging/cylinderLightAdapter.h b/pxr/usdImaging/usdImaging/cylinderLightAdapter.h index 74dbda5852..91d78ce6d9 100644 --- a/pxr/usdImaging/usdImaging/cylinderLightAdapter.h +++ b/pxr/usdImaging/usdImaging/cylinderLightAdapter.h @@ -49,10 +49,10 @@ class UsdImagingCylinderLightAdapter : public UsdImagingLightAdapter { USDIMAGING_API virtual SdfPath Populate(UsdPrim const& prim, UsdImagingIndexProxy* index, - UsdImagingInstancerContext const* instancerContext = NULL); + UsdImagingInstancerContext const* instancerContext = NULL) override; USDIMAGING_API - virtual bool IsSupported(UsdImagingIndexProxy const* index) const; + virtual bool IsSupported(UsdImagingIndexProxy const* index) const override; protected: virtual void _RemovePrim(SdfPath const& cachePath, diff --git a/pxr/usdImaging/usdImaging/portalLightAdapter.h b/pxr/usdImaging/usdImaging/portalLightAdapter.h index 9472a40b23..4a3a68c35a 100644 --- a/pxr/usdImaging/usdImaging/portalLightAdapter.h +++ b/pxr/usdImaging/usdImaging/portalLightAdapter.h @@ -36,10 +36,10 @@ class UsdImagingPortalLightAdapter : public UsdImagingLightAdapter { USDIMAGING_API virtual SdfPath Populate(UsdPrim const& prim, UsdImagingIndexProxy* index, - UsdImagingInstancerContext const* instancerContext = NULL); + UsdImagingInstancerContext const* instancerContext = NULL) override; USDIMAGING_API - virtual bool IsSupported(UsdImagingIndexProxy const* index) const; + virtual bool IsSupported(UsdImagingIndexProxy const* index) const override; // ---------------------------------------------------------------------- // /// \name Scene Index Support diff --git a/pxr/usdImaging/usdImaging/tetMeshAdapter.h b/pxr/usdImaging/usdImaging/tetMeshAdapter.h index 00cbe5873f..a503cf58e5 100644 --- a/pxr/usdImaging/usdImaging/tetMeshAdapter.h +++ b/pxr/usdImaging/usdImaging/tetMeshAdapter.h @@ -81,7 +81,7 @@ class UsdImagingTetMeshAdapter : public UsdImagingGprimAdapter SdfPath const& cachePath, HdDirtyBits* timeVaryingBits, UsdImagingInstancerContext const* - instancerContext = nullptr) const; + instancerContext = nullptr) const override; // ---------------------------------------------------------------------- // /// \name Change Processing From d78222ed69ca15f8074c91a5cef55ef55c914727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?furby=E2=84=A2?= Date: Wed, 9 Oct 2024 10:35:39 -0600 Subject: [PATCH 020/300] Compiler Warnings: Static Functions that should be Static Inline #3324 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: furby™ --- pxr/base/vt/wrapArray.h | 2 +- pxr/imaging/hdSt/unitTestHelper.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pxr/base/vt/wrapArray.h b/pxr/base/vt/wrapArray.h index 344938e291..2a9f188180 100644 --- a/pxr/base/vt/wrapArray.h +++ b/pxr/base/vt/wrapArray.h @@ -303,7 +303,7 @@ static void streamValue(std::ostringstream &stream, T const &value) { } } -static unsigned int +static inline unsigned int Vt_ComputeEffectiveRankAndLastDimSize( Vt_ShapeData const *sd, size_t *lastDimSize) { diff --git a/pxr/imaging/hdSt/unitTestHelper.h b/pxr/imaging/hdSt/unitTestHelper.h index 1ce3405017..90716dfd45 100644 --- a/pxr/imaging/hdSt/unitTestHelper.h +++ b/pxr/imaging/hdSt/unitTestHelper.h @@ -210,7 +210,7 @@ HdSt_TestDriverBase::_Init(HdReprSelector const &reprSelector) tracker.AddCollection(_collection.GetName()); } -static +static inline HdCamera::Projection _ToHd(const GfCamera::Projection projection) { From c01c7119daa2f778d4b07cd5d586db15072f8b42 Mon Sep 17 00:00:00 2001 From: pixar-oss Date: Fri, 16 Feb 2024 13:46:08 -0800 Subject: [PATCH 021/300] Merge branch 'volk-test' into feature-hgi-vulkan --- pxr/imaging/hgiVulkan/CMakeLists.txt | 1 + pxr/imaging/hgiVulkan/device.cpp | 52 ++++++++++++++++++++++++++-- pxr/imaging/hgiVulkan/instance.cpp | 6 ++++ pxr/imaging/hgiVulkan/volk.cpp | 26 ++++++++++++++ pxr/imaging/hgiVulkan/volk.h | 31 +++++++++++++++++ pxr/imaging/hgiVulkan/vulkan.h | 2 +- 6 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 pxr/imaging/hgiVulkan/volk.cpp create mode 100644 pxr/imaging/hgiVulkan/volk.h diff --git a/pxr/imaging/hgiVulkan/CMakeLists.txt b/pxr/imaging/hgiVulkan/CMakeLists.txt index 97e4228944..61ea8bd71f 100644 --- a/pxr/imaging/hgiVulkan/CMakeLists.txt +++ b/pxr/imaging/hgiVulkan/CMakeLists.txt @@ -41,6 +41,7 @@ pxr_library(hgiVulkan shaderSection texture vk_mem_alloc + volk PUBLIC_HEADERS api.h diff --git a/pxr/imaging/hgiVulkan/device.cpp b/pxr/imaging/hgiVulkan/device.cpp index 7b38eec9ff..f948c55121 100644 --- a/pxr/imaging/hgiVulkan/device.cpp +++ b/pxr/imaging/hgiVulkan/device.cpp @@ -11,7 +11,6 @@ #include "pxr/imaging/hgiVulkan/hgi.h" #include "pxr/imaging/hgiVulkan/instance.h" #include "pxr/imaging/hgiVulkan/pipelineCache.h" -#include "pxr/imaging/hgiVulkan/vk_mem_alloc.h" #include "pxr/base/tf/diagnostic.h" @@ -42,16 +41,34 @@ _GetGraphicsQueueFamilyIndex(VkPhysicalDevice physicalDevice) static bool _SupportsPresentation( + HgiVulkanInstance* instance, VkPhysicalDevice physicalDevice, uint32_t familyIndex) { + // XXX With volk, these functions weren't loaded correctly for me (would + // crash when called). Loading them like this seems to work. Unsure why. #if defined(VK_USE_PLATFORM_WIN32_KHR) + VkInstance vkInstance = instance->GetVulkanInstance(); + PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR + vkGetPhysicalDeviceWin32PresentationSupportKHR = + (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR) + vkGetInstanceProcAddr( + vkInstance, + "vkGetPhysicalDeviceWin32PresentationSupportKHR"); return vkGetPhysicalDeviceWin32PresentationSupportKHR( physicalDevice, familyIndex); #elif defined(VK_USE_PLATFORM_XLIB_KHR) Display* dsp = XOpenDisplay(nullptr); VisualID visualID = XVisualIDFromVisual( DefaultVisual(dsp, DefaultScreen(dsp))); + + VkInstance vkInstance = instance->GetVulkanInstance(); + PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR + vkGetPhysicalDeviceXlibPresentationSupportKHR = + (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR) + vkGetInstanceProcAddr( + vkInstance, + "vkGetPhysicalDeviceXlibPresentationSupportKHR"); return vkGetPhysicalDeviceXlibPresentationSupportKHR( physicalDevice, familyIndex, dsp, visualID); #elif defined(VK_USE_PLATFORM_METAL_EXT) @@ -94,7 +111,7 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) if (familyIndex == VK_QUEUE_FAMILY_IGNORED) continue; // Assume we always want a presentation capable device for now. - if (!_SupportsPresentation(physicalDevices[i], familyIndex)) { + if (!_SupportsPresentation(instance, physicalDevices[i], familyIndex)) { continue; } @@ -290,6 +307,8 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) &_vkDevice) == VK_SUCCESS ); + volkLoadDevice(_vkDevice); + HgiVulkanSetupDeviceDebug(instance, this); // @@ -315,6 +334,35 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) allocatorInfo.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT; } + // If we ever wish to use functions from Vulkan 1.1+ (i.e. use a later + // version of VMA), we'll need to add those functions here. + VmaVulkanFunctions vmaVulkanFunctions = {}; + vmaVulkanFunctions.vkGetInstanceProcAddr = vkGetInstanceProcAddr; + vmaVulkanFunctions.vkGetDeviceProcAddr = vkGetDeviceProcAddr; + vmaVulkanFunctions.vkAllocateMemory = vkAllocateMemory; + vmaVulkanFunctions.vkBindBufferMemory = vkBindBufferMemory; + vmaVulkanFunctions.vkBindImageMemory = vkBindImageMemory; + vmaVulkanFunctions.vkCreateBuffer = vkCreateBuffer; + vmaVulkanFunctions.vkCreateImage = vkCreateImage; + vmaVulkanFunctions.vkDestroyBuffer = vkDestroyBuffer; + vmaVulkanFunctions.vkDestroyImage = vkDestroyImage; + vmaVulkanFunctions.vkFlushMappedMemoryRanges = vkFlushMappedMemoryRanges; + vmaVulkanFunctions.vkFreeMemory = vkFreeMemory; + vmaVulkanFunctions.vkGetBufferMemoryRequirements = + vkGetBufferMemoryRequirements; + vmaVulkanFunctions.vkGetImageMemoryRequirements = + vkGetImageMemoryRequirements; + vmaVulkanFunctions.vkGetPhysicalDeviceMemoryProperties = + vkGetPhysicalDeviceMemoryProperties; + vmaVulkanFunctions.vkGetPhysicalDeviceProperties = + vkGetPhysicalDeviceProperties; + vmaVulkanFunctions.vkInvalidateMappedMemoryRanges = + vkInvalidateMappedMemoryRanges; + vmaVulkanFunctions.vkMapMemory = vkMapMemory; + vmaVulkanFunctions.vkUnmapMemory = vkUnmapMemory; + vmaVulkanFunctions.vkCmdCopyBuffer = vkCmdCopyBuffer; + allocatorInfo.pVulkanFunctions = &vmaVulkanFunctions; + TF_VERIFY( vmaCreateAllocator(&allocatorInfo, &_vmaAllocator) == VK_SUCCESS ); diff --git a/pxr/imaging/hgiVulkan/instance.cpp b/pxr/imaging/hgiVulkan/instance.cpp index a48d43297f..a48fe615c0 100755 --- a/pxr/imaging/hgiVulkan/instance.cpp +++ b/pxr/imaging/hgiVulkan/instance.cpp @@ -71,6 +71,10 @@ HgiVulkanInstance::HgiVulkanInstance() , vkDestroyDebugUtilsMessengerEXT(nullptr) , _vkInstance(nullptr) { + TF_VERIFY( + volkInitialize() == VK_SUCCESS + ); + VkApplicationInfo appInfo = {VK_STRUCTURE_TYPE_APPLICATION_INFO}; appInfo.apiVersion = VK_API_VERSION_1_3; @@ -140,6 +144,8 @@ HgiVulkanInstance::HgiVulkanInstance() &_vkInstance) == VK_SUCCESS ); + volkLoadInstance(_vkInstance); + HgiVulkanCreateDebug(this); } diff --git a/pxr/imaging/hgiVulkan/volk.cpp b/pxr/imaging/hgiVulkan/volk.cpp new file mode 100644 index 0000000000..bd4166caed --- /dev/null +++ b/pxr/imaging/hgiVulkan/volk.cpp @@ -0,0 +1,26 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the Apache License, Version 2.0 (the "Apache License") +// with the following modification; you may not use this file except in +// compliance with the Apache License and the following modification to it: +// Section 6. Trademarks. is deleted and replaced with: +// +// 6. Trademarks. This License does not grant permission to use the trade +// names, trademarks, service marks, or product names of the Licensor +// and its affiliates, except as required to comply with Section 4(c) of +// the License and to reproduce the content of the NOTICE file. +// +// You may obtain a copy of the Apache License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the Apache License with the above modification is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the Apache License for the specific +// language governing permissions and limitations under the Apache License. +// +#define VOLK_IMPLEMENTATION + +#include "pxr/imaging/hgiVulkan/volk.h" diff --git a/pxr/imaging/hgiVulkan/volk.h b/pxr/imaging/hgiVulkan/volk.h new file mode 100644 index 0000000000..6e099c125e --- /dev/null +++ b/pxr/imaging/hgiVulkan/volk.h @@ -0,0 +1,31 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the Apache License, Version 2.0 (the "Apache License") +// with the following modification; you may not use this file except in +// compliance with the Apache License and the following modification to it: +// Section 6. Trademarks. is deleted and replaced with: +// +// 6. Trademarks. This License does not grant permission to use the trade +// names, trademarks, service marks, or product names of the Licensor +// and its affiliates, except as required to comply with Section 4(c) of +// the License and to reproduce the content of the NOTICE file. +// +// You may obtain a copy of the Apache License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the Apache License with the above modification is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the Apache License for the specific +// language governing permissions and limitations under the Apache License. +// +#ifndef PXR_IMAGING_HGIVULKAN_VOLK_H +#define PXR_IMAGING_HGIVULKAN_VOLK_H + +// This is an implementation of Volk included from the Vulkan SDK. + +#include + +#endif diff --git a/pxr/imaging/hgiVulkan/vulkan.h b/pxr/imaging/hgiVulkan/vulkan.h index 3ea215679f..76327e7813 100644 --- a/pxr/imaging/hgiVulkan/vulkan.h +++ b/pxr/imaging/hgiVulkan/vulkan.h @@ -20,7 +20,7 @@ #error Unsupported Platform #endif -#include +#include "pxr/imaging/hgiVulkan/volk.h" #include "pxr/imaging/hgiVulkan/vk_mem_alloc.h" From 367d84a9e9b9ce03d2a1d6a61792010907124974 Mon Sep 17 00:00:00 2001 From: pixar-oss Date: Tue, 9 Apr 2024 12:58:28 -0700 Subject: [PATCH 022/300] Volk Fix: Provides interface to borrow function pointer of vkGetInstanceProcAddr. --- pxr/imaging/hgiVulkan/instance.cpp | 5 +++++ pxr/imaging/hgiVulkan/instance.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/pxr/imaging/hgiVulkan/instance.cpp b/pxr/imaging/hgiVulkan/instance.cpp index a48fe615c0..e48b78609d 100755 --- a/pxr/imaging/hgiVulkan/instance.cpp +++ b/pxr/imaging/hgiVulkan/instance.cpp @@ -161,5 +161,10 @@ HgiVulkanInstance::GetVulkanInstance() const return _vkInstance; } +PFN_vkGetInstanceProcAddr +HgiVulkanInstance::GetPFNInstancProcAddr() +{ + return vkGetInstanceProcAddr; +} PXR_NAMESPACE_CLOSE_SCOPE \ No newline at end of file diff --git a/pxr/imaging/hgiVulkan/instance.h b/pxr/imaging/hgiVulkan/instance.h index 935374ed55..fb1b62caa3 100644 --- a/pxr/imaging/hgiVulkan/instance.h +++ b/pxr/imaging/hgiVulkan/instance.h @@ -37,6 +37,9 @@ class HgiVulkanInstance final PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT = 0; PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT = 0; + HGIVULKAN_API + PFN_vkGetInstanceProcAddr GetPFNInstancProcAddr(); + private: VkInstance _vkInstance; }; From cbd73aca32bc798d87758a97c24c7e654c8948cb Mon Sep 17 00:00:00 2001 From: pixar-oss Date: Thu, 10 Oct 2024 12:20:29 -0700 Subject: [PATCH 023/300] Autodesk fix: check for vkGetPhysicalDeviceXlibPresentationSupportKHR before using --- pxr/imaging/hgiVulkan/device.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pxr/imaging/hgiVulkan/device.cpp b/pxr/imaging/hgiVulkan/device.cpp index f948c55121..19d7eb103f 100644 --- a/pxr/imaging/hgiVulkan/device.cpp +++ b/pxr/imaging/hgiVulkan/device.cpp @@ -69,7 +69,8 @@ _SupportsPresentation( vkGetInstanceProcAddr( vkInstance, "vkGetPhysicalDeviceXlibPresentationSupportKHR"); - return vkGetPhysicalDeviceXlibPresentationSupportKHR( + return vkGetPhysicalDeviceXlibPresentationSupportKHR && + vkGetPhysicalDeviceXlibPresentationSupportKHR( physicalDevice, familyIndex, dsp, visualID); #elif defined(VK_USE_PLATFORM_METAL_EXT) // Presentation currently always supported on Metal / MoltenVk From 27b272efa2a4a8997d7dfb82033b0aca860f895c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rob=20Piek=C3=A9?= Date: Thu, 17 Oct 2024 21:37:25 +0100 Subject: [PATCH 024/300] Ensure HdDependenciesSchema::GetEntries is linkable Adding `HD_API` to `HdDependenciesSchema::GetEntries` so that the symbol will be found on Windows. --- pxr/imaging/hd/dependenciesSchema.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pxr/imaging/hd/dependenciesSchema.h b/pxr/imaging/hd/dependenciesSchema.h index 1586680b20..ebf8fcb13b 100644 --- a/pxr/imaging/hd/dependenciesSchema.h +++ b/pxr/imaging/hd/dependenciesSchema.h @@ -67,6 +67,7 @@ class HdDependenciesSchema : public HdSchema using EntryPair = std::pair; using EntryVector = TfSmallVector; + HD_API EntryVector GetEntries(); // --(END CUSTOM CODE: Schema Methods)-- @@ -105,4 +106,4 @@ class HdDependenciesSchema : public HdSchema PXR_NAMESPACE_CLOSE_SCOPE -#endif \ No newline at end of file +#endif From 1da407eb227ecedb3b88f6af570955df08f0e938 Mon Sep 17 00:00:00 2001 From: Joshua Miller Date: Wed, 6 Mar 2024 12:18:40 -0800 Subject: [PATCH 025/300] [hdSt, hgi] Fix unitTestHelper for incorrect byteSize ASan identified a stack-buffer-overflow for byteSize in unitTestHelper --- pxr/imaging/hdSt/unitTestHelper.cpp | 4 ++-- pxr/imaging/hgi/unitTestHelper.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pxr/imaging/hdSt/unitTestHelper.cpp b/pxr/imaging/hdSt/unitTestHelper.cpp index 584e3ab940..75cecd7ce4 100644 --- a/pxr/imaging/hdSt/unitTestHelper.cpp +++ b/pxr/imaging/hdSt/unitTestHelper.cpp @@ -565,13 +565,13 @@ HdSt_TextureTestDriver::_CreateBufferResources() vboDesc.vertexStride = elementsPerVertex * sizeof(vertData[0]); _vertexBuffer = _hgi->CreateBuffer(vboDesc); - static const int32_t indices[3] = { 0, 1, 2 }; + constexpr int32_t indices[3] = { 0, 1, 2 }; HgiBufferDesc iboDesc; iboDesc.debugName = "HdSt_TextureTestDriver IndexBuffer"; iboDesc.usage = HgiBufferUsageIndex32; iboDesc.initialData = indices; - iboDesc.byteSize = sizeof(indices) * sizeof(indices[0]); + iboDesc.byteSize = sizeof(indices); _indexBuffer = _hgi->CreateBuffer(iboDesc); } diff --git a/pxr/imaging/hgi/unitTestHelper.cpp b/pxr/imaging/hgi/unitTestHelper.cpp index fb4c08c264..e5ba39a13e 100644 --- a/pxr/imaging/hgi/unitTestHelper.cpp +++ b/pxr/imaging/hgi/unitTestHelper.cpp @@ -358,13 +358,13 @@ HgiGfxCmdBfrExecutionTestDriver::_CreateResourceBuffers() return false; } - static const int32_t indices[3] = { 0, 1, 2 }; + constexpr int32_t indices[3] = { 0, 1, 2 }; HgiBufferDesc iboDesc; iboDesc.debugName = "IndexBuffer"; iboDesc.usage = HgiBufferUsageIndex32; iboDesc.initialData = indices; - iboDesc.byteSize = sizeof(indices) * sizeof(indices[0]); + iboDesc.byteSize = sizeof(indices); _indexBuffer = _hgi->CreateBuffer(iboDesc); if (!_indexBuffer) { return false; From 143629deb18b4f92618a60d53cefc335628592ab Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Fri, 25 Oct 2024 14:45:43 -0700 Subject: [PATCH 026/300] Bump USD version to next anticipated release 25.02 (Internal change: 2345782) --- cmake/defaults/Version.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/defaults/Version.cmake b/cmake/defaults/Version.cmake index e9657e399e..6dd5d5f2d9 100644 --- a/cmake/defaults/Version.cmake +++ b/cmake/defaults/Version.cmake @@ -6,7 +6,7 @@ # # Versioning information set(PXR_MAJOR_VERSION "0") -set(PXR_MINOR_VERSION "24") -set(PXR_PATCH_VERSION "11") # NOTE: Must not have leading 0 for single digits +set(PXR_MINOR_VERSION "25") +set(PXR_PATCH_VERSION "2") # NOTE: Must not have leading 0 for single digits math(EXPR PXR_VERSION "${PXR_MAJOR_VERSION} * 10000 + ${PXR_MINOR_VERSION} * 100 + ${PXR_PATCH_VERSION}") From d369b980e5fcc5bc6969fa34ff85d7fe597c05f8 Mon Sep 17 00:00:00 2001 From: katpet Date: Mon, 14 Oct 2024 11:34:46 -0700 Subject: [PATCH 027/300] Fix a bug where the code that maps common USD names of AOVs like 'normal' to RenderMan style names, like 'Nn', would inadvertently happen even when the AOV already had an associated 'lpe'. Only do the mapping if the sourceType wasn't already specified to be 'lpe' or 'primvar'. (Internal change: 2343773) --- .../plugin/hdPrman/renderParam.cpp | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/third_party/renderman-26/plugin/hdPrman/renderParam.cpp b/third_party/renderman-26/plugin/hdPrman/renderParam.cpp index 31fd4977aa..f8f3a68ce2 100644 --- a/third_party/renderman-26/plugin/hdPrman/renderParam.cpp +++ b/third_party/renderman-26/plugin/hdPrman/renderParam.cpp @@ -3420,46 +3420,43 @@ _UpdateRmanAovAndSourceName( // If the sourceType hints that the source is an lpe or primvar, make sure // it starts with "lpe:" or "primvars:" as required by prman. - if(sourceType == "lpe") - { + if(sourceType == "lpe") { std::string sn = rmanSourceName->CStr(); if(sn.rfind("lpe:", 0) == std::string::npos) sn = "lpe:" + sn; *rmanSourceName = RtUString(sn.c_str()); - } - else if(sourceType == "primvar") - { + } else if(sourceType == "primvar") { std::string sn = rmanSourceName->CStr(); if(sn.rfind("primvars:", 0) == std::string::npos) sn = "primvars:" + sn; *rmanSourceName = RtUString(sn.c_str()); } - // Update the Aov and Source names by mapping the HdAovName to an - // equivalent Prman name - if (hdAovName == HdAovTokens->color || hdAovName.GetString() == "ci") { - *rmanAovName = RixStr.k_Ci; - *rmanSourceName = RixStr.k_Ci; - } else if (hdAovName == HdAovTokens->depth) { - *rmanSourceName = RixStr.k_z; - } else if (hdAovName == HdAovTokens->normal) { - *rmanSourceName= RixStr.k_Nn; - } else if (hdAovName == HdAovTokens->primId) { - *rmanAovName = RixStr.k_id; - *rmanSourceName = RixStr.k_id; - } else if (hdAovName == HdAovTokens->instanceId) { - *rmanAovName = RixStr.k_id2; - *rmanSourceName = RixStr.k_id2; - } else if (hdAovName == HdAovTokens->elementId) { - *rmanAovName = RixStr.k_faceindex; - *rmanSourceName = RixStr.k_faceindex; - } else if (*rmanAovName == us_primvars_st) { - *rmanSourceName = us_st; - } - - // If no sourceName is specified, assume name is a standard prman aov - if (rmanSourceName->Empty()) { - *rmanSourceName = *rmanAovName; + if(rmanSourceName->Empty()) { + // Update the Aov and Source names by mapping the HdAovName to an + // equivalent Prman name + if (hdAovName == HdAovTokens->color || hdAovName.GetString() == "ci") { + *rmanAovName = RixStr.k_Ci; + *rmanSourceName = RixStr.k_Ci; + } else if (hdAovName == HdAovTokens->depth) { + *rmanSourceName = RixStr.k_z; + } else if (hdAovName == HdAovTokens->normal) { + *rmanSourceName= RixStr.k_Nn; + } else if (hdAovName == HdAovTokens->primId) { + *rmanAovName = RixStr.k_id; + *rmanSourceName = RixStr.k_id; + } else if (hdAovName == HdAovTokens->instanceId) { + *rmanAovName = RixStr.k_id2; + *rmanSourceName = RixStr.k_id2; + } else if (hdAovName == HdAovTokens->elementId) { + *rmanAovName = RixStr.k_faceindex; + *rmanSourceName = RixStr.k_faceindex; + } else if (*rmanAovName == us_primvars_st) { + *rmanSourceName = us_st; + } else { + // If no sourceName is specified, assume name is a standard prman aov + *rmanSourceName = *rmanAovName; + } } } From ab98317e6588af5475865a4dde56c36ac922a338 Mon Sep 17 00:00:00 2001 From: clach Date: Mon, 14 Oct 2024 11:35:24 -0700 Subject: [PATCH 028/300] [hdSt, hgiVulkan] One piece of Autodesk pull request #3170, a change meant to fix failing HdSt tests when using Lavapipe. From PR description: Autodesk: Fix HdSt tests failing under HgiVulkan with Lavapipe Note: This PR is for feature-hgi-vulkan branch. The goal of this PR is to fix various issue with HgiVulkan to enable Lavapipe (software rasterizer) compatibility. This was done by fixing bugs found when running the HdSt tests. Lavapipe is a conformant Vulkan 1.3 implementation: all issues encountered are actually Vulkan API usage problems, and could very well be encountered on actual hardware device. No special code is required for supporting Lavapipe as long as HgiVulkan uses the Vulkan API correctly. Most fixes fall into two categories: - Device limits are ignored, mostly max memory size and alignment requirements - Tests are OpenGL specific and should explicitly disable Vulkan - testHgiVulkan - Problem: assumes Vulkan debugging is enabled - Fix: add HGI_ENABLE_VULKAN=1 and HGIVULKAN_DEBUG=1 to pxr_register_test ENV argument - testHdStBufferAggregation - Problem: assumes that VkPhysicalDeviceLimits::minUniformBufferOffsetAlignment is 256 - Fix: use HgiCapabilities::GetUniformBufferOffsetAlignment() - Problem: can generate more than 2GB of log files on failure - Fix: limit log to first 300 incorrect values in the huge buffer test - testHdStBufferArray - Problem: output is device dependent (uboSize depends on VkPhysicalDeviceLimits::minUniformBufferOffsetAlignment) and diff'd against a constant baseline - Fix: ignore uboSize in diff. ssboSize is also ignored for the same reason as uboSize (depends on minStorageBufferOffsetAlignment) - testHdStBarAllocationLimit - Problem: assumes that VkPhysicalDeviceLimits::maxStorageBufferRange is 2^30 (default value of setting HD_MAX_VBO_SIZE) - Fix: use the smallest of HgiCapabilities::GetMaxShaderStorageBlockSize() and HD_MAX_VBO_SIZE - testHdStBufferAggregation - Problem: assumes that VkPhysicalDeviceLimits::maxStorageBufferRange is 2^30 (default value of setting HD_MAX_VBO_SIZE) when checking the vboRelocated performance counter (expects it to be 9) - Fix: use the smallest of HgiCapabilities::GetMaxShaderStorageBlockSize() and HD_MAX_VBO_SIZE to compute the correct expected value of vboRelocated. - testHdStHWFaceCulling - Problem: output is device dependent (uboSize depends on VkPhysicalDeviceLimits::minUniformBufferOffsetAlignment) and diff'd against a constant baseline - Fix: ignore uboSize in diff. ssboSize is also ignored for the same reason as uboSize (depends on minStorageBufferOffsetAlignment) - testHdStPrimvars - Problem: output is device dependent (uboSize depends on VkPhysicalDeviceLimits::minUniformBufferOffsetAlignment) and diff'd against a constant baseline - Fix: ignore uboSize in diff. ssboSize is also ignored for the same reason as uboSize (depends on minStorageBufferOffsetAlignment) - N/A See github pull request #3170. Fixes #3170 (Internal change: 2343821) --- pxr/imaging/hdSt/CMakeLists.txt | 10 ++-- .../testenv/testHdStBarAllocationLimit.cpp | 12 +++-- .../testenv/testHdStBufferAggregation.cpp | 50 ++++++++++++++----- .../hdSt/testenv/testHdStDrawItemsCache.cpp | 4 +- pxr/imaging/hdSt/unitTestHelper.h | 5 ++ pxr/imaging/hdSt/vboMemoryManager.cpp | 6 ++- pxr/imaging/hdSt/vboSimpleMemoryManager.cpp | 6 ++- pxr/imaging/hgiVulkan/CMakeLists.txt | 3 ++ pxr/imaging/hgiVulkan/graphicsPipeline.cpp | 2 +- 9 files changed, 72 insertions(+), 26 deletions(-) diff --git a/pxr/imaging/hdSt/CMakeLists.txt b/pxr/imaging/hdSt/CMakeLists.txt index 320036d5da..0e62a6a9f1 100644 --- a/pxr/imaging/hdSt/CMakeLists.txt +++ b/pxr/imaging/hdSt/CMakeLists.txt @@ -2324,8 +2324,7 @@ pxr_register_test(testHdStBufferArray COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStBufferArray" EXPECTED_RETURN_CODE 0 STDOUT_REDIRECT testHdStBufferArray-Run1-stdout.txt - POST_COMMAND "diff -I drawingShader -I computeShader -I gpuMemoryUsed -I meshTopology -I basisCurvesTopology testHdStBufferArray-Run1-stdout.txt ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStBufferArray/baseline/testHdStBufferArray-Run1-stdout.txt" - TESTENV testHdStBufferArray + POST_COMMAND "diff -I drawingShader -I computeShader -I gpuMemoryUsed -I meshTopology -I basisCurvesTopology -I uboSize -I ssboSize testHdStBufferArray-Run1-stdout.txt ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStBufferArray/baseline/testHdStBufferArray-Run1-stdout.txt" TESTENV testHdStBufferArray ENV TF_DEBUG=HD_SAFE_MODE HD_ENABLE_DOUBLE_MATRIX=1 @@ -2335,7 +2334,7 @@ pxr_register_test(testHdStBufferArrayInstancingDisabled COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStBufferArray" EXPECTED_RETURN_CODE 0 STDOUT_REDIRECT testHdStBufferArrayInstancingDisabled-Run1-stdout.txt - POST_COMMAND "diff -I drawingShader -I computeShader -I gpuMemoryUsed -I meshTopology -I basisCurvesTopology testHdStBufferArrayInstancingDisabled-Run1-stdout.txt ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStBufferArrayInstancingDisabled/baseline/testHdStBufferArrayInstancingDisabled-Run1-stdout.txt" + POST_COMMAND "diff -I drawingShader -I computeShader -I gpuMemoryUsed -I meshTopology -I basisCurvesTopology -I uboSize -I ssboSize testHdStBufferArrayInstancingDisabled-Run1-stdout.txt ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStBufferArrayInstancingDisabled/baseline/testHdStBufferArrayInstancingDisabled-Run1-stdout.txt" TESTENV testHdStBufferArrayInstancingDisabled ENV HDST_ENABLE_RESOURCE_INSTANCING=0 @@ -2740,6 +2739,7 @@ pxr_register_test(testHdStDrawBatching HD_ENABLE_DOUBLE_MATRIX=1 HD_ENABLE_GPU_COUNT_VISIBLE_INSTANCES=1 HD_ENABLE_PACKED_NORMALS=0 + HGI_ENABLE_VULKAN=0 ) pxr_register_test(testHdStDrawItemIntegrity COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStDrawItemIntegrity --offscreen" @@ -2895,7 +2895,7 @@ pxr_register_test(testHdStHWFaceCulling COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStHWFaceCulling" EXPECTED_RETURN_CODE 0 STDOUT_REDIRECT testHdStHWFaceCulling-Run1-stdout.txt - POST_COMMAND "diff -I computeShader -I drawingShader -I gpuMemoryUsed testHdStHWFaceCulling-Run1-stdout.txt ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStHWFaceCulling/baseline/testHdStHWFaceCulling-Run1-stdout.txt" + POST_COMMAND "diff -I computeShader -I drawingShader -I gpuMemoryUsed -I uboSize -I ssboSize testHdStHWFaceCulling-Run1-stdout.txt ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStHWFaceCulling/baseline/testHdStHWFaceCulling-Run1-stdout.txt" TESTENV testHdStHWFaceCulling ) pxr_register_test(testHdStIndirectDrawBatchCodeGen @@ -3155,7 +3155,7 @@ pxr_register_test(testHdStPrimvars COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStPrimvars" EXPECTED_RETURN_CODE 0 STDOUT_REDIRECT testHdStPrimvars-Run1-stdout.txt - POST_COMMAND "diff -I computeShader -I drawingShader -I gpuMemoryUsed testHdStPrimvars-Run1-stdout.txt ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStPrimvars/baseline/testHdStPrimvars-Run1-stdout.txt" + POST_COMMAND "diff -I computeShader -I drawingShader -I gpuMemoryUsed -I uboSize -I ssboSize testHdStPrimvars-Run1-stdout.txt ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStPrimvars/baseline/testHdStPrimvars-Run1-stdout.txt" TESTENV testHdStPrimvars ENV HDST_ENABLE_MATERIAL_PRIMVAR_FILTERING=0 diff --git a/pxr/imaging/hdSt/testenv/testHdStBarAllocationLimit.cpp b/pxr/imaging/hdSt/testenv/testHdStBarAllocationLimit.cpp index ec181a4e0e..62fd5f07c4 100644 --- a/pxr/imaging/hdSt/testenv/testHdStBarAllocationLimit.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStBarAllocationLimit.cpp @@ -9,6 +9,8 @@ #include "pxr/imaging/hdSt/unitTestGLDrawing.h" #include "pxr/imaging/hdSt/unitTestHelper.h" +#include "pxr/imaging/hgi/capabilities.h" + #include "pxr/base/gf/matrix4d.h" #include "pxr/base/gf/rotation.h" #include "pxr/base/gf/vec3d.h" @@ -119,11 +121,13 @@ My_TestGLDrawing::AddLargeCurve(HdUnitTestDelegate *delegate) HdInterpolation colorInterp, widthInterp, opacityInterp; colorInterp = widthInterp = opacityInterp = HdInterpolationConstant; - const size_t vboSizeLimit = 1 << 30; // see HD_MAX_VBO_SIZE - const size_t maxPointsInVBO = vboSizeLimit / sizeof(GfVec3f); - const size_t numControlVertsPerCurve = 1 << 2; + static constexpr size_t vboMaxSize = 1 << 30; // default for HD_MAX_VBO_SIZE + const size_t storageMaxSize = _driver->GetHgi()->GetCapabilities()-> + GetMaxShaderStorageBlockSize(); + const size_t maxPointsInVBO = std::min(storageMaxSize, vboMaxSize) / sizeof(GfVec3f); + static constexpr size_t numControlVertsPerCurve = 1 << 2; const size_t numCurves = maxPointsInVBO / numControlVertsPerCurve + 1; - + std::vector curveVertexCounts(numCurves, numControlVertsPerCurve); GfVec3f basePoints[] = { diff --git a/pxr/imaging/hdSt/testenv/testHdStBufferAggregation.cpp b/pxr/imaging/hdSt/testenv/testHdStBufferAggregation.cpp index a54842a164..ce52d47289 100644 --- a/pxr/imaging/hdSt/testenv/testHdStBufferAggregation.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStBufferAggregation.cpp @@ -832,9 +832,10 @@ OverAggregationTest(HdStResourceRegistry *registry) // * 50 // 8 entries = 915MB // split into 7 buffers. - int count = 50; + static constexpr size_t count = 50; + static constexpr size_t countPerCommit = count / 2; std::vector ranges; - for (int i = 0; i < count/2; ++i) { + for (size_t i = 0; i < countPerCommit; ++i) { HdBufferSourceSharedPtrVector sources; sources.push_back( std::make_shared( @@ -854,9 +855,9 @@ OverAggregationTest(HdStResourceRegistry *registry) registry->Commit(); - // Schedule some more resources which will aggregate with the + // Schedule some more resources which will aggregate with the // previously committed resources. - for (int i = count/2; i < count; ++i) { + for (size_t i = countPerCommit; i < count; ++i) { HdBufferSourceSharedPtrVector sources; sources.push_back( std::make_shared( @@ -877,26 +878,36 @@ OverAggregationTest(HdStResourceRegistry *registry) registry->Commit(); // read - for (int i = 0; i < count; ++i) { + for (size_t i = 0; i < count; ++i) { VtValue const& rangeData = ranges[i]->ReadData(HdTokens->points); if (points != rangeData) { // XXX The below code is added for debugging why this test // sometimes fails. We suspect a floating-point compare issue where // we may need to have a small epsilon for comparing floats? TF_VERIFY(rangeData.IsHolding>()); - VtArray const& vec3fArray = + VtArray const& vec3fArray = rangeData.UncheckedGet>(); std::cerr << "point size: " << points.size() << std::endl; std::cerr << "rangeData size: " << vec3fArray.size() << std::endl; - for (size_t x=0; x maxFailureCountPrint) { + std::cerr << "And " << (failureCount - maxFailureCountPrint) << + " more failures omitted (" << (static_cast(failureCount) / + points.size() * 100) << "% failed)" << std::endl; + } + TF_VERIFY(false); } } @@ -905,8 +916,24 @@ OverAggregationTest(HdStResourceRegistry *registry) std::cerr << perfLog.GetCounter(HdStPerfTokens->copyBufferCpuToGpu) << "\n"; std::cerr << perfLog.GetCounter(HdStPerfTokens->copyBufferGpuToGpu) << "\n"; + // Relocation count depends on the VBO max size. Smaller size means more relocations. + // If it's the default 2^30, there will be 9 relocations. But smaller can have much more: + // For example Lavapipe limits the size to 2^27 and has 51 relocations. + static constexpr size_t vboMaxSize = 1 << 30; // default for HD_MAX_VBO_SIZE + const size_t storageMaxSize = + registry->GetHgi()->GetCapabilities()->GetMaxShaderStorageBlockSize(); + const size_t rangesPerBuffer = std::min(storageMaxSize, vboMaxSize) / + (points.size() * sizeof(GfVec3f)); + const size_t relocationsFirstCommit = + (countPerCommit - 1) / rangesPerBuffer + 1; + const size_t relocationsSecondCommit = + (countPerCommit - 1 + rangesPerBuffer) / rangesPerBuffer + 1; + const size_t totalRelocations = + relocationsFirstCommit + relocationsSecondCommit; + // check perf counters - TF_VERIFY(perfLog.GetCounter(HdPerfTokens->vboRelocated) == 9); + TF_VERIFY(perfLog.GetCounter( + HdPerfTokens->vboRelocated) == totalRelocations); TF_VERIFY(perfLog.GetCounter(HdStPerfTokens->copyBufferCpuToGpu) == 50); TF_VERIFY(perfLog.GetCounter(HdStPerfTokens->copyBufferGpuToGpu) == 1); @@ -1063,5 +1090,4 @@ int main(int argc, char *argv[]) std::cout << "FAILED" << std::endl; return EXIT_FAILURE; } -} - +} \ No newline at end of file diff --git a/pxr/imaging/hdSt/testenv/testHdStDrawItemsCache.cpp b/pxr/imaging/hdSt/testenv/testHdStDrawItemsCache.cpp index ac647f271f..add2da504d 100644 --- a/pxr/imaging/hdSt/testenv/testHdStDrawItemsCache.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStDrawItemsCache.cpp @@ -136,7 +136,7 @@ class HdSt_MyTestDriver : public HdSt_TestDriverBase public: HdSt_MyTestDriver(); - void Draw(std::vector viewerIds); + void Draw(const std::vector &viewerIds); const HdStRenderPassStateSharedPtr &GetRenderPassState() const { return _renderPassStates[0]; @@ -211,7 +211,7 @@ HdSt_MyTestDriver::HdSt_MyTestDriver() } void -HdSt_MyTestDriver::Draw(std::vector viewerIds) +HdSt_MyTestDriver::Draw(const std::vector &viewerIds) { for (size_t const &vidx : viewerIds) { if (vidx < _viewers.size()) { diff --git a/pxr/imaging/hdSt/unitTestHelper.h b/pxr/imaging/hdSt/unitTestHelper.h index 1ce3405017..6cdc6567aa 100644 --- a/pxr/imaging/hdSt/unitTestHelper.h +++ b/pxr/imaging/hdSt/unitTestHelper.h @@ -550,6 +550,11 @@ class HdSt_TestDriver final : public HdSt_TestDriverBase HDST_API const HdRenderPassSharedPtr &GetRenderPass(); + + HDST_API + Hgi* GetHgi() { + return _GetHgi(); + } private: void _CreateRenderPassState(); diff --git a/pxr/imaging/hdSt/vboMemoryManager.cpp b/pxr/imaging/hdSt/vboMemoryManager.cpp index 41a2f0fa62..145bedaf94 100644 --- a/pxr/imaging/hdSt/vboMemoryManager.cpp +++ b/pxr/imaging/hdSt/vboMemoryManager.cpp @@ -20,6 +20,7 @@ #include "pxr/imaging/hgi/blitCmds.h" #include "pxr/imaging/hgi/blitCmdsOps.h" #include "pxr/imaging/hgi/buffer.h" +#include "pxr/imaging/hgi/capabilities.h" #include "pxr/base/arch/hash.h" #include "pxr/base/tf/diagnostic.h" @@ -440,7 +441,10 @@ size_t HdStVBOMemoryManager::_StripedBufferArray::GetMaxNumElements() const { static size_t vboMaxSize = TfGetEnvSetting(HD_MAX_VBO_SIZE); - return vboMaxSize / _maxBytesPerElement; + Hgi* hgi = _resourceRegistry->GetHgi(); + const size_t storageMaxSize = hgi->GetCapabilities()-> + GetMaxShaderStorageBlockSize(); + return std::min(storageMaxSize, vboMaxSize) / _maxBytesPerElement; } void diff --git a/pxr/imaging/hdSt/vboSimpleMemoryManager.cpp b/pxr/imaging/hdSt/vboSimpleMemoryManager.cpp index 40a2f1fe8a..678ae12b0e 100644 --- a/pxr/imaging/hdSt/vboSimpleMemoryManager.cpp +++ b/pxr/imaging/hdSt/vboSimpleMemoryManager.cpp @@ -22,6 +22,7 @@ #include "pxr/imaging/hgi/blitCmds.h" #include "pxr/imaging/hgi/blitCmdsOps.h" #include "pxr/imaging/hgi/buffer.h" +#include "pxr/imaging/hgi/capabilities.h" #include "pxr/imaging/hf/perfLog.h" @@ -342,7 +343,10 @@ size_t HdStVBOSimpleMemoryManager::_SimpleBufferArray::GetMaxNumElements() const { static size_t vboMaxSize = TfGetEnvSetting(HD_MAX_VBO_SIZE); - return vboMaxSize / _maxBytesPerElement; + Hgi* hgi = _resourceRegistry->GetHgi(); + const size_t storageMaxSize = hgi->GetCapabilities()-> + GetMaxShaderStorageBlockSize(); + return std::min(storageMaxSize, vboMaxSize) / _maxBytesPerElement; } void diff --git a/pxr/imaging/hgiVulkan/CMakeLists.txt b/pxr/imaging/hgiVulkan/CMakeLists.txt index 97e4228944..00ad754480 100644 --- a/pxr/imaging/hgiVulkan/CMakeLists.txt +++ b/pxr/imaging/hgiVulkan/CMakeLists.txt @@ -92,6 +92,9 @@ pxr_register_test(testHgiVulkan FAIL_PERCENT 0.001 PERCEPTUAL EXPECTED_RETURN_CODE 0 + ENV + HGI_ENABLE_VULKAN=1 + HGIVULKAN_DEBUG=1 ) # This test is not currently supported on static builds as it relies on diff --git a/pxr/imaging/hgiVulkan/graphicsPipeline.cpp b/pxr/imaging/hgiVulkan/graphicsPipeline.cpp index 053d8d4e7d..dcce492acc 100755 --- a/pxr/imaging/hgiVulkan/graphicsPipeline.cpp +++ b/pxr/imaging/hgiVulkan/graphicsPipeline.cpp @@ -702,7 +702,7 @@ HgiVulkanGraphicsPipeline::_CreateRenderPass() if (hasDepth && _descriptor.resolveAttachments) { depthResolve.pDepthStencilResolveAttachment = &vkDepthResolveReference; depthResolve.depthResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; - depthResolve.stencilResolveMode = VK_RESOLVE_MODE_NONE; + depthResolve.stencilResolveMode = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; subpassDesc.pNext = &depthResolve; } From d9323e54dfef30e8f5f0eab4ee9aa9946d79bc3f Mon Sep 17 00:00:00 2001 From: samwarring Date: Mon, 14 Oct 2024 11:35:56 -0700 Subject: [PATCH 029/300] Add more test cases for UsdNotice::ObjectsChanged To design scene change handling for OpenExec, we want to know how USD communicates different types of scene changes. Specifically, we want more clarity as to which scene changes are Resyncs and which are only field changes. These test cases document the existing behavior, and they capture assumptions about scene change processing used in OpenExec. (Internal change: 2343945) --- pxr/usd/usd/CMakeLists.txt | 7 + .../testenv/testUsdObjectsChangedNotices.py | 496 ++++++++++++++++++ 2 files changed, 503 insertions(+) create mode 100644 pxr/usd/usd/testenv/testUsdObjectsChangedNotices.py diff --git a/pxr/usd/usd/CMakeLists.txt b/pxr/usd/usd/CMakeLists.txt index 2915831ddc..87c8a01bba 100644 --- a/pxr/usd/usd/CMakeLists.txt +++ b/pxr/usd/usd/CMakeLists.txt @@ -236,6 +236,7 @@ pxr_test_scripts( testenv/testUsdNamespaceEditor.py testenv/testUsdNamespaceEditorProperties.py testenv/testUsdNotices.py + testenv/testUsdObjectsChangedNotices.py testenv/testUsdOpaqueAttributes.py testenv/testUsdPathExpressionAttrs.py testenv/testUsdPayloads.py @@ -1261,6 +1262,12 @@ pxr_register_test(testUsdNotices EXPECTED_RETURN_CODE 0 ) +pxr_register_test(testUsdObjectsChangedNotices + PYTHON + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdObjectsChangedNotices" + EXPECTED_RETURN_CODE 0 +) + pxr_register_test(testUsdNamespaceEditor PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdNamespaceEditor" diff --git a/pxr/usd/usd/testenv/testUsdObjectsChangedNotices.py b/pxr/usd/usd/testenv/testUsdObjectsChangedNotices.py new file mode 100644 index 0000000000..7a91d65bc5 --- /dev/null +++ b/pxr/usd/usd/testenv/testUsdObjectsChangedNotices.py @@ -0,0 +1,496 @@ +#!/pxrpythonsubst +# +# Copyright 2024 Pixar +# +# Licensed under the terms set forth in the LICENSE.txt file available at +# https://openusd.org/license. + +import unittest +from pxr import Kind, Sdf, Tf, Usd + +_LAYER_CONTENTS = '''#usda 1.0 +def Sphere "Ref1" ( + prepend apiSchemas = ["CollectionAPI:Ref1Collection"] +){ + def Scope "Ref1Child" { + } +} + +def Scope "Ref2" { +} + +def Scope "Parent1" { + + int attr1 = 1 + int attr2 = 2 + int attr2.connect = + int attr3 = 3 + + rel rel1 = + + def Sphere "Child1" { + } + + def Sphere "Child2" { + } +} +def "Parent2" ( + references = +){ +} +''' + +class TestUsdObjectsChangedNotices(unittest.TestCase): + def setUp(self): + self._layer = Sdf.Layer.CreateAnonymous('layer.usda') + self._layer.ImportFromString(_LAYER_CONTENTS) + self._stage = Usd.Stage.Open(self._layer) + self.assertTrue(self._stage) + self._editor = Usd.NamespaceEditor(self._stage) + + self._parent1 = self._stage.GetPrimAtPath('/Parent1') + self._parent2 = self._stage.GetPrimAtPath('/Parent2') + self._child1 = self._stage.GetPrimAtPath('/Parent1/Child1') + self._child2 = self._stage.GetPrimAtPath('/Parent1/Child2') + self._attr1 = self._parent1.GetAttribute('attr1') + self._attr2 = self._parent1.GetAttribute('attr2') + self._attr3 = self._parent1.GetAttribute('attr3') + self._rel1 = self._parent1.GetRelationship('rel1') + + self.assertTrue(self._parent1) + self.assertTrue(self._parent2) + self.assertTrue(self._child1) + self.assertTrue(self._child2) + self.assertTrue(self._attr1) + self.assertTrue(self._attr2) + self.assertTrue(self._attr3) + self.assertTrue(self._rel1) + + # Each ObjectsChanged notice is converted to a dictionary and appended + # to self._notices. The list of notices is reset before each test. + self._notices = [] + self._noticeKey = Tf.Notice.Register( + Usd.Notice.ObjectsChanged, + self._onObjectsChanged, + self._stage) + + def _onObjectsChanged(self, notice, sender): + asDict = {} + resynced = notice.GetResyncedPaths() + changedInfoOnly = notice.GetChangedInfoOnlyPaths() + resolvedAssetPathsResynced = notice.GetResolvedAssetPathsResyncedPaths() + if resynced: + asDict['Resynced'] = { + str(path): notice.GetChangedFields(path) + for path in resynced + } + if changedInfoOnly: + asDict['ChangedInfoOnly'] = { + str(path): notice.GetChangedFields(path) + for path in changedInfoOnly + } + if resolvedAssetPathsResynced: + asDict['ResolvedAssetPathsResynced'] = { + str(path): notice.GetChangedFields(path) + for path in resolvedAssetPathsResynced + } + self._notices.append(asDict) + + def test_ObjectSetMetadata(self): + self._parent1.SetMetadata('comment', 'test') + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + '/Parent1': ['comment'] + } + }) + + def test_ObjectSetMetadataByDictKey(self): + self._parent1.SetMetadataByDictKey('customData', 'a:b', 42) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + '/Parent1': ['customData'] + } + }) + + def test_StageDefinePrim(self): + self._stage.DefinePrim('/Parent3', 'Sphere') + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent3': [ + 'specifier', + 'typeName', + ] + } + }) + + def test_PrimSetSpecifier(self): + self._parent1.SetSpecifier(Sdf.SpecifierClass) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1': ['specifier'] + } + }) + + def test_PrimSetTypeName(self): + self._parent1.SetTypeName('Cylinder') + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1': ['typeName'] + } + }) + + def test_PrimClearTypeName(self): + self._parent1.ClearTypeName() + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1': ['typeName'] + } + }) + + def test_PrimSetActive(self): + self._parent1.SetActive(False) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1': ['active'] + } + }) + + def test_PrimSetPropertyOrder(self): + self._parent1.SetPropertyOrder(['attr2', 'attr1', 'attr3']) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + # XXX:USD-10220: Shouldn't this be ['propertyOrder']? + '/Parent1': [] + } + }) + + def test_PrimRemoveProperty(self): + self._parent1.RemoveProperty('attr2') + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + # Note: attr2 had connections, but the connectionPaths field + # is omitted. + '/Parent1.attr2': [] + } + }) + + def test_PrimSetKind(self): + self._parent1.SetKind(Kind.Tokens.model) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1': ['kind'] + } + }) + + def test_PrimAddAppliedSchema(self): + self._parent1.AddAppliedSchema('CollectionAPI:myCollection') + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1': ['apiSchemas'] + } + }) + + def test_PrimSetChildrenReorder(self): + self._parent1.SetChildrenReorder(['Child2', 'Child1']) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1': ['primOrder'] + } + }) + + def test_PrimChangeReferences(self): + # In this case, the referenced prim has apiSchemas that are added to + # the referencing prim. Even though the 'apiSchemas' field will change, + # only the 'references' field is reported to have changed. + self._parent1.GetReferences().AddReference( + self._layer.identifier, '/Ref1') + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1': ['references'] + } + }) + self.assertTrue(self._stage.GetPrimAtPath('/Parent1/Ref1Child')) + self.assertTrue(self._stage.GetRelationshipAtPath( + '/Parent1.collection:Ref1Collection:includes')) + + def test_PrimChangeReferencesChangesTypeName(self): + self.assertEqual(self._parent2.GetTypeName(), 'Scope') + self._parent2.GetReferences().SetReferences([ + Sdf.Reference(self._layer.identifier, '/Ref1') + ]) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent2': ['references'] + } + }) + self.assertEqual(self._parent2.GetTypeName(), 'Sphere') + + def test_PropertySetDisplayGroup(self): + self._attr1.SetDisplayGroup('test') + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + '/Parent1.attr1': ['displayGroup'] + } + }) + + def test_PropertySetNestedDisplayGroups(self): + self._attr1.SetNestedDisplayGroups(['test', 'test2']) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + '/Parent1.attr1': ['displayGroup'] + } + }) + + def test_PropertySetCustom(self): + self._attr1.SetCustom(True) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + '/Parent1.attr1': ['custom'] + } + }) + + def test_AttributeSetVariability(self): + self._attr1.SetVariability(Sdf.VariabilityUniform) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + '/Parent1.attr1': ['variability'] + } + }) + + def test_AttributeSetTypename(self): + self._attr1.SetTypeName(Sdf.ValueTypeNames.Double) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + '/Parent1.attr1': ['typeName'] + } + }) + + def test_AttributeSet(self): + self._attr1.Set(42) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + '/Parent1.attr1': ['default'] + } + }) + + def test_AttributeAddConnection(self): + self._attr1.AddConnection(self._attr2.GetPath()) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + '/Parent1.attr1': ['connectionPaths'] + } + }) + + def test_AttributeClearConnections(self): + self._attr2.ClearConnections() + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + '/Parent1.attr2': ['connectionPaths'] + } + }) + + def test_RelationshipAddTarget(self): + self._rel1.AddTarget(self._parent2.GetPath()) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + '/Parent1.rel1': ['targetPaths'] + } + }) + + def test_RelationshipRemoveTarget(self): + self._rel1.RemoveTarget(self._child1.GetPath()) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + '/Parent1.rel1': ['targetPaths'] + } + }) + + # Removing target that does not exist should not trigger a notice. + self._rel1.RemoveTarget(self._child1.GetPath()) + self.assertEqual(len(self._notices), 1) + + def test_RelationshipSetTargets(self): + self._rel1.SetTargets([self._child1.GetPath(), self._child2.GetPath()]) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + '/Parent1.rel1': ['targetPaths'] + } + }) + + def test_RelationshipClearTargets(self): + self._rel1.ClearTargets(removeSpec = False) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'ChangedInfoOnly': { + '/Parent1.rel1': ['targetPaths'] + } + }) + + self._rel1.ClearTargets(removeSpec = True) + self.assertEqual(len(self._notices), 2) + self.assertDictEqual(self._notices[1], { + 'Resynced': { + '/Parent1.rel1': [] + } + }) + + def test_NamespaceEditorDeletePrimAtPath(self): + self._editor.DeletePrimAtPath('/Parent1') + self._editor.ApplyEdits() + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1': [] + } + }) + + def test_NamespaceEditorMovePrimAtPath(self): + self._editor.MovePrimAtPath('/Parent2', '/Parent1/Parent3') + self._editor.ApplyEdits() + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent2': [], + '/Parent1/Parent3': [] + } + }) + + def test_NamespaceEditorRenamePrim(self): + self._editor.RenamePrim(self._child1, 'Child3') + self._editor.ApplyEdits() + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1/Child1': [], + '/Parent1/Child3': [] + }, + 'ChangedInfoOnly': { + '/Parent1.rel1': ['targetPaths'] + } + }) + + def test_NamespaceEditorReparentPrim(self): + self._editor.ReparentPrim(self._child1, self._parent2) + self._editor.ApplyEdits() + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1/Child1': [], + '/Parent2/Child1': [] + }, + 'ChangedInfoOnly': { + '/Parent1.rel1': ['targetPaths'] + } + }) + + def test_NamespaceEditorDeleteProperty(self): + self._editor.DeleteProperty(self._attr3) + self._editor.ApplyEdits() + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1.attr3': [] + }, + 'ChangedInfoOnly': { + '/Parent1.attr2': ['connectionPaths'] + } + }) + + def test_NamespaceEditorMovePropertyAtPath(self): + self._editor.MovePropertyAtPath( + self._attr3.GetPath(), + '/Parent2.newName') + self._editor.ApplyEdits() + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1.attr3': [], + '/Parent2.newName': [] + }, + 'ChangedInfoOnly': { + '/Parent1.attr2': ['connectionPaths'] + } + }) + + def test_NamespaceEditorReparentProperty(self): + self._editor.ReparentProperty(self._attr3, self._parent2) + self._editor.ApplyEdits() + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1.attr3': [], + '/Parent2.attr3': [] + }, + 'ChangedInfoOnly': { + '/Parent1.attr2': ['connectionPaths'] + } + }) + + def test_SdfChangeBlockChangeTypeThenDelete(self): + with Sdf.ChangeBlock(): + parentSpec = self._layer.GetPrimAtPath('/Parent1') + parentSpec.typeName = 'Cylinder' + del(self._layer.rootPrims['Parent1']) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1': ['typeName'] + } + }) + self.assertFalse(self._stage.GetPrimAtPath('/Parent1')) + + def test_SdfChangeBlockAppendAPISchemaThenDelete(self): + with Sdf.ChangeBlock(): + parentSpec = self._layer.GetPrimAtPath('/Parent1') + schemas = Sdf.TokenListOp.Create(['CollectionAPI:myCollection']) + parentSpec.SetInfo('apiSchemas', schemas) + del(self._layer.rootPrims['Parent1']) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1': ['apiSchemas'] + } + }) + self.assertFalse(self._stage.GetPrimAtPath('/Parent1')) + + def test_SdfChangeBlockReorderChildrenThenDelete(self): + with Sdf.ChangeBlock(): + parentSpec = self._layer.GetPrimAtPath('/Parent1') + parentSpec.nameChildrenOrder = ['Child2', 'Child1'] + del(self._layer.rootPrims['Parent1']) + self.assertEqual(len(self._notices), 1) + self.assertDictEqual(self._notices[0], { + 'Resynced': { + '/Parent1': ['primOrder'] + } + }) + self.assertFalse(self._stage.GetPrimAtPath('/Parent1')) + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file From 689110d7d925364b4c88b80326795e57be349316 Mon Sep 17 00:00:00 2001 From: diyajoy Date: Mon, 14 Oct 2024 11:53:10 -0700 Subject: [PATCH 030/300] Ensure usdGenSchema does not write out an alias if the alias would be the same as the class name. (Internal change: 2344166) --- pxr/usd/usd/codegenTemplates/schemaClass.cpp | 4 + .../basic/generatedSchema.classes.txt | 2 + .../baseline/basic/generatedSchema.module.h | 1 + .../baseline/basic/generatedSchema.usda | 4 + .../baseline/basic/noAlias.cpp | 107 +++++++++++++ .../testUsdGenSchema/baseline/basic/noAlias.h | 147 ++++++++++++++++++ .../baseline/basic/plugInfo.json | 8 + .../baseline/basic/tokens.cpp | 4 +- .../testUsdGenSchema/baseline/basic/tokens.h | 4 + .../baseline/basic/wrapNoAlias.cpp | 107 +++++++++++++ .../baseline/basic/wrapTokens.cpp | 1 + .../baseline/codeless/plugInfo.json | 8 + .../testUsdGenSchema/codeless_schema.usda | 9 ++ .../usd/testenv/testUsdGenSchema/schema.usda | 9 ++ pxr/usd/usd/usdGenSchema.py | 6 +- pxr/usd/usdMtlx/reader.cpp | 6 +- 16 files changed, 422 insertions(+), 5 deletions(-) create mode 100644 pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/noAlias.cpp create mode 100644 pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/noAlias.h create mode 100644 pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/wrapNoAlias.cpp diff --git a/pxr/usd/usd/codegenTemplates/schemaClass.cpp b/pxr/usd/usd/codegenTemplates/schemaClass.cpp index 885c8a05ec..19b072ec39 100644 --- a/pxr/usd/usd/codegenTemplates/schemaClass.cpp +++ b/pxr/usd/usd/codegenTemplates/schemaClass.cpp @@ -22,12 +22,16 @@ TF_REGISTRY_FUNCTION(TfType) TfType::Bases< {{ cls.parentCppClassName }} > >(); {% if cls.isConcrete %} +{% if cls.cppClassName != cls.usdPrimTypeName %} // Register the usd prim typename as an alias under UsdSchemaBase. This // enables one to call // TfType::Find().FindDerivedByName("{{ cls.usdPrimTypeName }}") // to find TfType<{{ cls.cppClassName }}>, which is how IsA queries are // answered. TfType::AddAlias("{{ cls.usdPrimTypeName }}"); +{% else %} + // Skip registering an alias as it would be the same as the class name. +{% endif %} {% endif %} } diff --git a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/generatedSchema.classes.txt b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/generatedSchema.classes.txt index b83a90a9d5..de709a2b70 100644 --- a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/generatedSchema.classes.txt +++ b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/generatedSchema.classes.txt @@ -7,6 +7,7 @@ derivedNonAppliedAPI emptyMultipleApplyAPI multipleApplyAPI multipleApplyAPI_1 +noAlias nonAppliedAPI publicMultipleApplyAPI singleApplyAPI @@ -24,6 +25,7 @@ wrapDerivedNonAppliedAPI.cpp wrapEmptyMultipleApplyAPI.cpp wrapMultipleApplyAPI.cpp wrapMultipleApplyAPI_1.cpp +wrapNoAlias.cpp wrapNonAppliedAPI.cpp wrapPublicMultipleApplyAPI.cpp wrapSingleApplyAPI.cpp diff --git a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/generatedSchema.module.h b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/generatedSchema.module.h index 0a7079f947..585f6647d7 100644 --- a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/generatedSchema.module.h +++ b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/generatedSchema.module.h @@ -19,4 +19,5 @@ TF_WRAP(UsdContrivedTestHairman_1); TF_WRAP(UsdContrivedTestNoVersion0_2); TF_WRAP(UsdContrivedSingleApplyAPI_1); TF_WRAP(UsdContrivedMultipleApplyAPI_1); +TF_WRAP(UsdContrivedNoAlias); TF_WRAP(UsdContrivedTokens); diff --git a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/generatedSchema.usda b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/generatedSchema.usda index 6e34a74280..dd9c0ee1aa 100644 --- a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/generatedSchema.usda +++ b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/generatedSchema.usda @@ -415,3 +415,7 @@ class "MultipleApplyAPI_1" double testNewVersion:__INSTANCE_NAME__:testAttrTwo } +class UsdContrivedNoAlias "UsdContrivedNoAlias" +{ +} + diff --git a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/noAlias.cpp b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/noAlias.cpp new file mode 100644 index 0000000000..fad4ee7466 --- /dev/null +++ b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/noAlias.cpp @@ -0,0 +1,107 @@ +// +// Copyright 2016 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +#include "pxr/usd/usdContrived/noAlias.h" +#include "pxr/usd/usd/schemaRegistry.h" +#include "pxr/usd/usd/typed.h" + +#include "pxr/usd/sdf/types.h" +#include "pxr/usd/sdf/assetPath.h" + +PXR_NAMESPACE_OPEN_SCOPE + +// Register the schema with the TfType system. +TF_REGISTRY_FUNCTION(TfType) +{ + TfType::Define >(); + + // Skip registering an alias as it would be the same as the class name. +} + +/* virtual */ +UsdContrivedNoAlias::~UsdContrivedNoAlias() +{ +} + +/* static */ +UsdContrivedNoAlias +UsdContrivedNoAlias::Get(const UsdStagePtr &stage, const SdfPath &path) +{ + if (!stage) { + TF_CODING_ERROR("Invalid stage"); + return UsdContrivedNoAlias(); + } + return UsdContrivedNoAlias(stage->GetPrimAtPath(path)); +} + +/* static */ +UsdContrivedNoAlias +UsdContrivedNoAlias::Define( + const UsdStagePtr &stage, const SdfPath &path) +{ + static TfToken usdPrimTypeName("UsdContrivedNoAlias"); + if (!stage) { + TF_CODING_ERROR("Invalid stage"); + return UsdContrivedNoAlias(); + } + return UsdContrivedNoAlias( + stage->DefinePrim(path, usdPrimTypeName)); +} + +/* virtual */ +UsdSchemaKind UsdContrivedNoAlias::_GetSchemaKind() const +{ + return UsdContrivedNoAlias::schemaKind; +} + +/* static */ +const TfType & +UsdContrivedNoAlias::_GetStaticTfType() +{ + static TfType tfType = TfType::Find(); + return tfType; +} + +/* static */ +bool +UsdContrivedNoAlias::_IsTypedSchema() +{ + static bool isTyped = _GetStaticTfType().IsA(); + return isTyped; +} + +/* virtual */ +const TfType & +UsdContrivedNoAlias::_GetTfType() const +{ + return _GetStaticTfType(); +} + +/*static*/ +const TfTokenVector& +UsdContrivedNoAlias::GetSchemaAttributeNames(bool includeInherited) +{ + static TfTokenVector localNames; + static TfTokenVector allNames = + UsdTyped::GetSchemaAttributeNames(true); + + if (includeInherited) + return allNames; + else + return localNames; +} + +PXR_NAMESPACE_CLOSE_SCOPE + +// ===================================================================== // +// Feel free to add custom code below this line. It will be preserved by +// the code generator. +// +// Just remember to wrap code in the appropriate delimiters: +// 'PXR_NAMESPACE_OPEN_SCOPE', 'PXR_NAMESPACE_CLOSE_SCOPE'. +// ===================================================================== // +// --(BEGIN CUSTOM CODE)-- diff --git a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/noAlias.h b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/noAlias.h new file mode 100644 index 0000000000..102c1722f6 --- /dev/null +++ b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/noAlias.h @@ -0,0 +1,147 @@ +// +// Copyright 2016 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +#ifndef USDCONTRIVED_GENERATED_NOALIAS_H +#define USDCONTRIVED_GENERATED_NOALIAS_H + +/// \file usdContrived/noAlias.h + +#include "pxr/pxr.h" +#include "pxr/usd/usdContrived/api.h" +#include "pxr/usd/usd/typed.h" +#include "pxr/usd/usd/prim.h" +#include "pxr/usd/usd/stage.h" + +#include "pxr/base/vt/value.h" + +#include "pxr/base/gf/vec3d.h" +#include "pxr/base/gf/vec3f.h" +#include "pxr/base/gf/matrix4d.h" + +#include "pxr/base/tf/token.h" +#include "pxr/base/tf/type.h" + +PXR_NAMESPACE_OPEN_SCOPE + +class SdfAssetPath; + +// -------------------------------------------------------------------------- // +// USDCONTRIVEDNOALIAS // +// -------------------------------------------------------------------------- // + +/// \class UsdContrivedNoAlias +/// +/// +class UsdContrivedNoAlias : public UsdTyped +{ +public: + /// Compile time constant representing what kind of schema this class is. + /// + /// \sa UsdSchemaKind + static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped; + + /// Construct a UsdContrivedNoAlias on UsdPrim \p prim . + /// Equivalent to UsdContrivedNoAlias::Get(prim.GetStage(), prim.GetPath()) + /// for a \em valid \p prim, but will not immediately throw an error for + /// an invalid \p prim + explicit UsdContrivedNoAlias(const UsdPrim& prim=UsdPrim()) + : UsdTyped(prim) + { + } + + /// Construct a UsdContrivedNoAlias on the prim held by \p schemaObj . + /// Should be preferred over UsdContrivedNoAlias(schemaObj.GetPrim()), + /// as it preserves SchemaBase state. + explicit UsdContrivedNoAlias(const UsdSchemaBase& schemaObj) + : UsdTyped(schemaObj) + { + } + + /// Destructor. + USDCONTRIVED_API + virtual ~UsdContrivedNoAlias(); + + /// Return a vector of names of all pre-declared attributes for this schema + /// class and all its ancestor classes. Does not include attributes that + /// may be authored by custom/extended methods of the schemas involved. + USDCONTRIVED_API + static const TfTokenVector & + GetSchemaAttributeNames(bool includeInherited=true); + + /// Return a UsdContrivedNoAlias holding the prim adhering to this + /// schema at \p path on \p stage. If no prim exists at \p path on + /// \p stage, or if the prim at that path does not adhere to this schema, + /// return an invalid schema object. This is shorthand for the following: + /// + /// \code + /// UsdContrivedNoAlias(stage->GetPrimAtPath(path)); + /// \endcode + /// + USDCONTRIVED_API + static UsdContrivedNoAlias + Get(const UsdStagePtr &stage, const SdfPath &path); + + /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path + /// is defined (according to UsdPrim::IsDefined()) on this stage. + /// + /// If a prim adhering to this schema at \p path is already defined on this + /// stage, return that prim. Otherwise author an \a SdfPrimSpec with + /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for + /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s + /// with \p specifier == \a SdfSpecifierDef and empty typeName at the + /// current EditTarget for any nonexistent, or existing but not \a Defined + /// ancestors. + /// + /// The given \a path must be an absolute prim path that does not contain + /// any variant selections. + /// + /// If it is impossible to author any of the necessary PrimSpecs, (for + /// example, in case \a path cannot map to the current UsdEditTarget's + /// namespace) issue an error and return an invalid \a UsdPrim. + /// + /// Note that this method may return a defined prim whose typeName does not + /// specify this schema class, in case a stronger typeName opinion overrides + /// the opinion at the current EditTarget. + /// + USDCONTRIVED_API + static UsdContrivedNoAlias + Define(const UsdStagePtr &stage, const SdfPath &path); + +protected: + /// Returns the kind of schema this class belongs to. + /// + /// \sa UsdSchemaKind + USDCONTRIVED_API + UsdSchemaKind _GetSchemaKind() const override; + +private: + // needs to invoke _GetStaticTfType. + friend class UsdSchemaRegistry; + USDCONTRIVED_API + static const TfType &_GetStaticTfType(); + + static bool _IsTypedSchema(); + + // override SchemaBase virtuals. + USDCONTRIVED_API + const TfType &_GetTfType() const override; + +public: + // ===================================================================== // + // Feel free to add custom code below this line, it will be preserved by + // the code generator. + // + // Just remember to: + // - Close the class declaration with }; + // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE + // - Close the include guard with #endif + // ===================================================================== // + // --(BEGIN CUSTOM CODE)-- +}; + +PXR_NAMESPACE_CLOSE_SCOPE + +#endif diff --git a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/plugInfo.json b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/plugInfo.json index 8529488299..95df9a061d 100644 --- a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/plugInfo.json +++ b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/plugInfo.json @@ -116,6 +116,14 @@ "schemaIdentifier": "MultipleApplyAPI_1", "schemaKind": "multipleApplyAPI" }, + "UsdContrivedNoAlias": { + "autoGenerated": true, + "bases": [ + "UsdTyped" + ], + "schemaIdentifier": "UsdContrivedNoAlias", + "schemaKind": "concreteTyped" + }, "UsdContrivedNonAppliedAPI": { "alias": { "UsdSchemaBase": "NonAppliedAPI" diff --git a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/tokens.cpp b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/tokens.cpp index 15c2541c23..e6567983a7 100644 --- a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/tokens.cpp +++ b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/tokens.cpp @@ -163,6 +163,7 @@ UsdContrivedTokensType::UsdContrivedTokensType() : TestNoVersion0_2("TestNoVersion0_2", TfToken::Immortal), TestPxHairman("TestPxHairman", TfToken::Immortal), TestPxHairman_1("TestPxHairman_1", TfToken::Immortal), + UsdContrivedNoAlias("UsdContrivedNoAlias", TfToken::Immortal), allTokens({ asset, assetArray, @@ -317,7 +318,8 @@ UsdContrivedTokensType::UsdContrivedTokensType() : TestNoVersion0, TestNoVersion0_2, TestPxHairman, - TestPxHairman_1 + TestPxHairman_1, + UsdContrivedNoAlias }) { } diff --git a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/tokens.h b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/tokens.h index be293e0378..f2b56cd2df 100644 --- a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/tokens.h +++ b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/tokens.h @@ -661,6 +661,10 @@ struct UsdContrivedTokensType { /// /// Schema identifer for UsdContrivedTestHairman_1 const TfToken TestPxHairman_1; + /// \brief "UsdContrivedNoAlias" + /// + /// Schema identifer and family for UsdContrivedNoAlias + const TfToken UsdContrivedNoAlias; /// A vector of all of the tokens listed above. const std::vector allTokens; }; diff --git a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/wrapNoAlias.cpp b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/wrapNoAlias.cpp new file mode 100644 index 0000000000..964f685f99 --- /dev/null +++ b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/wrapNoAlias.cpp @@ -0,0 +1,107 @@ +// +// Copyright 2016 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +#include "pxr/usd/usdContrived/noAlias.h" +#include "pxr/usd/usd/schemaBase.h" + +#include "pxr/usd/sdf/primSpec.h" + +#include "pxr/usd/usd/pyConversions.h" +#include "pxr/base/tf/pyContainerConversions.h" +#include "pxr/base/tf/pyResultConversions.h" +#include "pxr/base/tf/pyUtils.h" +#include "pxr/base/tf/wrapTypeHelpers.h" + +#include "pxr/external/boost/python.hpp" + +#include + +PXR_NAMESPACE_USING_DIRECTIVE + +using namespace pxr_boost::python; + +namespace { + +#define WRAP_CUSTOM \ + template static void _CustomWrapCode(Cls &_class) + +// fwd decl. +WRAP_CUSTOM; + + +static std::string +_Repr(const UsdContrivedNoAlias &self) +{ + std::string primRepr = TfPyRepr(self.GetPrim()); + return TfStringPrintf( + "UsdContrived.NoAlias(%s)", + primRepr.c_str()); +} + +} // anonymous namespace + +void wrapUsdContrivedNoAlias() +{ + typedef UsdContrivedNoAlias This; + + class_ > + cls("NoAlias"); + + cls + .def(init(arg("prim"))) + .def(init(arg("schemaObj"))) + .def(TfTypePythonClass()) + + .def("Get", &This::Get, (arg("stage"), arg("path"))) + .staticmethod("Get") + + .def("Define", &This::Define, (arg("stage"), arg("path"))) + .staticmethod("Define") + + .def("GetSchemaAttributeNames", + &This::GetSchemaAttributeNames, + arg("includeInherited")=true, + return_value_policy()) + .staticmethod("GetSchemaAttributeNames") + + .def("_GetStaticTfType", (TfType const &(*)()) TfType::Find, + return_value_policy()) + .staticmethod("_GetStaticTfType") + + .def(!self) + + + .def("__repr__", ::_Repr) + ; + + _CustomWrapCode(cls); +} + +// ===================================================================== // +// Feel free to add custom code below this line, it will be preserved by +// the code generator. The entry point for your custom code should look +// minimally like the following: +// +// WRAP_CUSTOM { +// _class +// .def("MyCustomMethod", ...) +// ; +// } +// +// Of course any other ancillary or support code may be provided. +// +// Just remember to wrap code in the appropriate delimiters: +// 'namespace {', '}'. +// +// ===================================================================== // +// --(BEGIN CUSTOM CODE)-- + +namespace { + +WRAP_CUSTOM { +} + +} diff --git a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/wrapTokens.cpp b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/wrapTokens.cpp index 1663971066..793acd567b 100644 --- a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/wrapTokens.cpp +++ b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/basic/wrapTokens.cpp @@ -171,4 +171,5 @@ void wrapUsdContrivedTokens() _ADD_TOKEN(cls, TestNoVersion0_2); _ADD_TOKEN(cls, TestPxHairman); _ADD_TOKEN(cls, TestPxHairman_1); + _ADD_TOKEN(cls, UsdContrivedNoAlias); } diff --git a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/codeless/plugInfo.json b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/codeless/plugInfo.json index a397c7765b..7e47925508 100644 --- a/pxr/usd/usd/testenv/testUsdGenSchema/baseline/codeless/plugInfo.json +++ b/pxr/usd/usd/testenv/testUsdGenSchema/baseline/codeless/plugInfo.json @@ -116,6 +116,14 @@ "schemaIdentifier": "MultipleApplyAPI_1", "schemaKind": "multipleApplyAPI" }, + "UsdContrivedNoAlias": { + "autoGenerated": true, + "bases": [ + "UsdTyped" + ], + "schemaIdentifier": "UsdContrivedNoAlias", + "schemaKind": "concreteTyped" + }, "UsdContrivedNonAppliedAPI": { "alias": { "UsdSchemaBase": "NonAppliedAPI" diff --git a/pxr/usd/usd/testenv/testUsdGenSchema/codeless_schema.usda b/pxr/usd/usd/testenv/testUsdGenSchema/codeless_schema.usda index 9270bf6bbf..857c4df614 100644 --- a/pxr/usd/usd/testenv/testUsdGenSchema/codeless_schema.usda +++ b/pxr/usd/usd/testenv/testUsdGenSchema/codeless_schema.usda @@ -553,3 +553,12 @@ class "MultipleApplyAPI_1" ( int testAttrOne double testAttrTwo } + +class UsdContrivedNoAlias "UsdContrivedNoAlias" ( + inherits = + customData = { + string className = "NoAlias" + } +) +{ +} \ No newline at end of file diff --git a/pxr/usd/usd/testenv/testUsdGenSchema/schema.usda b/pxr/usd/usd/testenv/testUsdGenSchema/schema.usda index 48ba508962..bd1a040dc8 100644 --- a/pxr/usd/usd/testenv/testUsdGenSchema/schema.usda +++ b/pxr/usd/usd/testenv/testUsdGenSchema/schema.usda @@ -552,3 +552,12 @@ class "MultipleApplyAPI_1" ( int testAttrOne double testAttrTwo } + +class UsdContrivedNoAlias "UsdContrivedNoAlias" ( + inherits = + customData = { + string className = "NoAlias" + } +) +{ +} \ No newline at end of file diff --git a/pxr/usd/usd/usdGenSchema.py b/pxr/usd/usd/usdGenSchema.py index b89ada0d55..aa456ab75b 100644 --- a/pxr/usd/usd/usdGenSchema.py +++ b/pxr/usd/usd/usdGenSchema.py @@ -1508,8 +1508,10 @@ def GeneratePlugInfo(templatePath, codeGenPath, classes, validate, env, # for multiple apply schemas. _UpdatePlugInfoWithAPISchemaApplyInfo(clsDict, cls) - # Write out alias/primdefs for all schemas - clsDict['alias'] = {'UsdSchemaBase': cls.usdPrimTypeName} + # Write out aliases for schemas where the cpp class name and + # prim type name do not match. + if cls.usdPrimTypeName != cls.cppClassName: + clsDict['alias'] = {'UsdSchemaBase': cls.usdPrimTypeName} # Write out schema identifier clsDict['schemaIdentifier'] = cls.usdPrimTypeName diff --git a/pxr/usd/usdMtlx/reader.cpp b/pxr/usd/usdMtlx/reader.cpp index b62f5bfd72..6a3a91b12f 100644 --- a/pxr/usd/usdMtlx/reader.cpp +++ b/pxr/usd/usdMtlx/reader.cpp @@ -433,13 +433,15 @@ _TypeSupportsColorSpace(const mx::ConstValueElementPtr& mxElem) bool colorImageNode = false; if (type == "filename") { - // verify the output is color3 or color4 mx::ConstNodeDefPtr parentNodeDef; if (mxElem->getParent()->isA()) { parentNodeDef = _GetNodeDef(mxElem->getParent()->asA()); - } else if (mxElem->getParent()->isA()) { + } + else if (mxElem->getParent()->isA()) { parentNodeDef = mxElem->getParent()->asA(); } + + // Verify the output is color3 or color4 if (parentNodeDef) { for (const mx::OutputPtr& output : parentNodeDef->getOutputs()) { const std::string &type = output->getType(); From 9c1a75d4f3f909bb85ff4718e5c33239f02b5ce3 Mon Sep 17 00:00:00 2001 From: unhyperbolic Date: Mon, 14 Oct 2024 11:53:20 -0700 Subject: [PATCH 031/300] Add helpers for getting data source locators for members (Internal change: 2344175) --- pxr/imaging/hd/hdSchemaDefs.py | 1 + pxr/imaging/hd/renderBufferSchema.cpp | 30 +++++++++++++++++++++++++++ pxr/imaging/hd/renderBufferSchema.h | 22 ++++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/pxr/imaging/hd/hdSchemaDefs.py b/pxr/imaging/hd/hdSchemaDefs.py index 302f89dec4..3bdb4aeefc 100644 --- a/pxr/imaging/hd/hdSchemaDefs.py +++ b/pxr/imaging/hd/hdSchemaDefs.py @@ -866,6 +866,7 @@ SCHEMA_NAME = 'RenderBuffer', SCHEMA_TOKEN = 'renderBuffer', MEMBERS = [ + ('ALL_MEMBERS', '', dict(ADD_LOCATOR = True)), ('dimensions', T_VEC3I, {}), ('format', T_FORMAT, {}), ('multiSampled', T_BOOL, {}), diff --git a/pxr/imaging/hd/renderBufferSchema.cpp b/pxr/imaging/hd/renderBufferSchema.cpp index 6b8e3e7e3d..ab65a3c3f6 100644 --- a/pxr/imaging/hd/renderBufferSchema.cpp +++ b/pxr/imaging/hd/renderBufferSchema.cpp @@ -142,6 +142,36 @@ HdRenderBufferSchema::GetDefaultLocator() { static const HdDataSourceLocator locator(GetSchemaToken()); return locator; +} + +/* static */ +const HdDataSourceLocator & +HdRenderBufferSchema::GetDimensionsLocator() +{ + static const HdDataSourceLocator locator = + GetDefaultLocator().Append( + HdRenderBufferSchemaTokens->dimensions); + return locator; +} + +/* static */ +const HdDataSourceLocator & +HdRenderBufferSchema::GetFormatLocator() +{ + static const HdDataSourceLocator locator = + GetDefaultLocator().Append( + HdRenderBufferSchemaTokens->format); + return locator; +} + +/* static */ +const HdDataSourceLocator & +HdRenderBufferSchema::GetMultiSampledLocator() +{ + static const HdDataSourceLocator locator = + GetDefaultLocator().Append( + HdRenderBufferSchemaTokens->multiSampled); + return locator; } PXR_NAMESPACE_CLOSE_SCOPE \ No newline at end of file diff --git a/pxr/imaging/hd/renderBufferSchema.h b/pxr/imaging/hd/renderBufferSchema.h index c355843223..2a8a5a43d5 100644 --- a/pxr/imaging/hd/renderBufferSchema.h +++ b/pxr/imaging/hd/renderBufferSchema.h @@ -94,6 +94,28 @@ class HdRenderBufferSchema : public HdSchema HD_API static const HdDataSourceLocator &GetDefaultLocator(); + /// @} + + /// \name Data source locators for members + /// + /// The following methods return an HdDataSourceLocator (relative to the + /// prim-level data source) where the data source for a member can be found. + /// + /// This is often useful for checking intersection against the + /// HdDataSourceLocatorSet sent with HdDataSourceObserver::PrimsDirtied. + /// @{ + + /// Prim-level relative data source locator to locate dimensions. + HD_API + static const HdDataSourceLocator &GetDimensionsLocator(); + + /// Prim-level relative data source locator to locate format. + HD_API + static const HdDataSourceLocator &GetFormatLocator(); + + /// Prim-level relative data source locator to locate multiSampled. + HD_API + static const HdDataSourceLocator &GetMultiSampledLocator(); /// @} /// \name Schema construction From 303b2ae7119c05647a91d75461c133ca993fba05 Mon Sep 17 00:00:00 2001 From: clach Date: Mon, 14 Oct 2024 11:57:29 -0700 Subject: [PATCH 032/300] [hdSt] One piece of Autodesk pull request #3170, a change meant to fix failing HdSt tests when using Lavapipe. From PR description: testHdStBasicDrawing Problem: geometry shaders with more than VkPhysicalDeviceLimits::maxGeometryInputComponents input locations are being generated. Fix: Inputs are passed as arrays of int, consuming one location per int. Instead pack them into ivec4 (for array sizes smaller or equal to 4, which is the max right now for quads), to pass up to 4 values per location. See #3170. (Internal change: 2344215) --- pxr/imaging/hdSt/codeGen.cpp | 384 ++++++++++++------ pxr/imaging/hdSt/codeGen.h | 29 +- .../baseline/codegen_curves_bindless.out | 204 ++++------ .../baseline/codegen_curves_indirect.out | 204 ++++------ .../codegen_mesh_bindless_indirect.out | 272 +++++-------- ...gen_mesh_bindless_indirect_doubleSided.out | 272 +++++-------- ...gen_mesh_bindless_indirect_faceVarying.out | 272 +++++-------- ...odegen_mesh_bindless_indirect_instance.out | 328 ++++++--------- ...n_mesh_bindless_indirect_smoothNormals.out | 272 +++++-------- .../baseline/codegen_mesh_edgeonly.out | 272 +++++-------- .../codegen_mesh_edgeonly_blendwireframe.out | 272 +++++-------- .../baseline/codegen_mesh_indirect.out | 272 +++++-------- .../codegen_mesh_indirect_instance.out | 328 ++++++--------- .../baseline/codegen_points_bindless.out | 68 ++-- .../baseline/codegen_points_indirect.out | 68 ++-- .../baseline/codegen_curves_indirect.out | 220 ++++------ .../baseline/codegen_mesh_edgeonly.out | 296 ++++++-------- .../codegen_mesh_edgeonly_blendwireframe.out | 296 ++++++-------- .../baseline/codegen_mesh_indirect.out | 296 ++++++-------- .../codegen_mesh_indirect_doubleSided.out | 296 ++++++-------- .../codegen_mesh_indirect_faceVarying.out | 296 ++++++-------- .../codegen_mesh_indirect_instance.out | 352 +++++++--------- .../codegen_mesh_indirect_smoothNormals.out | 296 ++++++-------- .../baseline/codegen_points_indirect.out | 80 ++-- 24 files changed, 2428 insertions(+), 3517 deletions(-) diff --git a/pxr/imaging/hdSt/codeGen.cpp b/pxr/imaging/hdSt/codeGen.cpp index 15a40a3185..2f41936567 100644 --- a/pxr/imaging/hdSt/codeGen.cpp +++ b/pxr/imaging/hdSt/codeGen.cpp @@ -35,7 +35,7 @@ #include "pxr/base/tf/hash.h" #include -#include +#include #if defined(__APPLE__) #include @@ -129,6 +129,7 @@ TF_DEFINE_PRIVATE_TOKENS( (triangle_strip) (early_fragment_tests) (OsdPerPatchVertexBezier) + (interstageDrawingCoord) ); TF_DEFINE_ENV_SETTING(HDST_ENABLE_HGI_RESOURCE_GENERATION, false, @@ -1589,67 +1590,174 @@ HdSt_CodeGen::_GetShaderResourceLayouts( } void -HdSt_CodeGen::_PlumbInterstageElements( - TfToken const &name, - TfToken const &dataType) +HdSt_CodeGen::_PlumbInterstageElements() { - // Add resource elements to plumb interstage elements, e.g. - // drawingCoord and interpolated primvar through active stages. + // Graphics devices impose limits on the number of input/output locations + // available. We can quickly exceeed such limits on low spec devices if we + // naively use one location per drawing coord. This is because arrays take + // one location per item, regardless of the item size. This means that: + // layout(location = 0) in int someCoord[gl_MaxPatchVertices] + // consumes as many locations (gl_MaxPatchVertices) as: + // layout(location = 0) in ivec4 someCoord[gl_MaxPatchVertices] + // while holding 4x fewer values. Instead if we do: + // layout(location = 0) in ivec4 someCoord[ + // divRoundUp(gl_MaxPatchVertices, 4)] + // and pack the coord values into the vector elements, we can use 4x fewer + // locations. In practice, since we have many coord in/out fields, it's + // simpler to pack across fields instead of within a field, but the idea is + // the same. This means that: + // flat layout(location = 0) in int someCoord1[gl_MaxPatchVertices]; + // flat layout(location = 1) in int someCoord2[gl_MaxPatchVertices]; + // < 7 more fields omitted > + // flat layout(location = 9) in int someCoord10[gl_MaxPatchVertices]; + // becomes: + // flat layout(location = 0) in ivec4 someCoord1To4[gl_MaxPatchVertices]; + // flat layout(location = 1) in ivec4 someCoord5to8[gl_MaxPatchVertices]; + // flat layout(location = 2) in ivec4 someCoord8to10[gl_MaxPatchVertices]; + // where someCoord1To4[i].x is someCoord1[i], someCoord1To4[i].y is + // someCoord2[i], someCoord1To4[i].z is someCoord3[i], someCoord1To4[i].w + // is someCoord4[i]. + // + // Ref: https://docs.vulkan.org/spec/latest/chapters/interfaces.html#interfaces-iointerfaces-locations - std::string const &baseName = name.GetString(); - TfToken const vs_outName( "vs_" + baseName); - TfToken const tcs_outName("tcs_" + baseName); - TfToken const tes_outName("tes_" + baseName); - TfToken const gs_outName( "gs_" + baseName); + // This code automates such packing. It identifies fields with the same + // scalar type, and groups them into 4 element vectors. It also generates + // mapping data, so the original field can be mapped to its vector + // component. - // Empty token for variables with no array size - TfToken const noArraySize; + struct _ProcessedElement { + TfToken name; + TfToken dataType; + }; + using _ProcessedElementVector = std::vector<_ProcessedElement>; - // Interstage variables of type "int" require "flat" interpolation - TfToken const &qualifier = - (dataType == _tokens->_int) ? _tokens->flat : _tokens->_default; + struct _ElementGroup { + TfToken commonDataType; + ElementVector elements; + }; + + _ProcessedElementVector processedElements; + std::vector<_ElementGroup> packedElementGroups; + std::map elementGroupsToFill; + for (auto const& element : _resInterstage) { + TfToken const& dataType = element.dataType; + if (dataType != _tokens->_int && dataType != _tokens->_float) { + processedElements.push_back({element.name, dataType}); + continue; + } - // Vertex attrib input for VS, PTCS, PTVS - _resAttrib.emplace_back(InOut::STAGE_OUT, Kind::VALUE, dataType, - vs_outName, noArraySize, qualifier); + // Add to an existing group, or create a new one. + _ElementGroup* group; + if (const auto iter = elementGroupsToFill.find(dataType); + iter != elementGroupsToFill.end()) { + group = &iter->second; + } else { + group = &elementGroupsToFill.try_emplace( + dataType, _ElementGroup{dataType}).first->second; + } - if (_hasTCS) { - _resTCS.emplace_back(InOut::STAGE_IN, Kind::VALUE, dataType, - vs_outName, _tokens->gl_MaxPatchVertices, qualifier); - _resTCS.emplace_back(InOut::STAGE_OUT, Kind::VALUE, dataType, - tcs_outName, _tokens->HD_NUM_PATCH_EVAL_VERTS, qualifier); + // When a group is full, move it to the fully packed groups list. + TF_VERIFY(group->elements.size() < 4); + group->elements.push_back(element); + if (group->elements.size() == 4) { + packedElementGroups.push_back(std::move(*group)); + elementGroupsToFill.erase(dataType); + } } - if (_hasTES) { - _resTES.emplace_back(InOut::STAGE_IN, Kind::VALUE, dataType, - tcs_outName, _tokens->gl_MaxPatchVertices, qualifier); - _resTES.emplace_back(InOut::STAGE_OUT, Kind::VALUE, dataType, - tes_outName, noArraySize, qualifier); + // Some groups won't be full if the number of elements is not cleanly + // divisible by 4. + for (auto& [_, group] : elementGroupsToFill) { + packedElementGroups.push_back(std::move(group)); } - // Geometry shader inputs come from previous active stage - if (_hasGS && _hasTES) { - _resGS.emplace_back(InOut::STAGE_IN, Kind::VALUE, dataType, - tes_outName, _tokens->HD_NUM_PRIMITIVE_VERTS, qualifier); - _resGS.emplace_back(InOut::STAGE_OUT, Kind::VALUE, dataType, - gs_outName, noArraySize, qualifier); - } else if (_hasGS) { - _resGS.emplace_back(InOut::STAGE_IN, Kind::VALUE, dataType, - vs_outName, _tokens->HD_NUM_PRIMITIVE_VERTS, qualifier); - _resGS.emplace_back(InOut::STAGE_OUT, Kind::VALUE, dataType, - gs_outName, noArraySize, qualifier); + // Generate the mapping data. + _resInterstagePackedMappings.clear(); + size_t packedElementGroup = 0; + for (const auto& [commonDataType, elements] : packedElementGroups) { + std::stringstream groupNameBuffer; + TfToken const groupName = TfToken( + _tokens->interstageDrawingCoord.GetString() + + std::to_string(packedElementGroup++)); + + for (size_t i = 0; i < elements.size(); i++) { + _PackedResourceMapping mapping; + mapping.groupName = groupName; + mapping.component = '[' + std::to_string(i) + ']'; + _resInterstagePackedMappings.try_emplace( + elements[i].name.GetString(), std::move(mapping)); + } + + if (commonDataType == _tokens->_int) { + processedElements.push_back({groupName, _tokens->ivec4}); + } else if (commonDataType == _tokens->_float) { + processedElements.push_back({groupName, _tokens->vec4}); + } else { + TF_CODING_ERROR("Invalid element group data type"); + } } - // Fragment shader inputs come from previous active stage - if (_hasGS) { - _resFS.emplace_back(InOut::STAGE_IN, Kind::VALUE, dataType, - gs_outName, noArraySize, qualifier); - } else if (_hasTES) { - _resFS.emplace_back(InOut::STAGE_IN, Kind::VALUE, dataType, - tes_outName, noArraySize, qualifier); - } else { - _resFS.emplace_back(InOut::STAGE_IN, Kind::VALUE, dataType, - vs_outName, noArraySize, qualifier); + for (auto const& [name, dataType] : processedElements) { + bool const isInteger = (dataType == _tokens->ivec4); + + // Add resource elements to plumb interstage elements, e.g. + // drawingCoord and interpolated primvar through active stages. + + std::string const &baseName = name.GetString(); + TfToken const vs_outName( "vs_" + baseName); + TfToken const tcs_outName("tcs_" + baseName); + TfToken const tes_outName("tes_" + baseName); + TfToken const gs_outName( "gs_" + baseName); + + // Empty token for variables with no array size + TfToken const noArraySize; + + // Interstage variables of base type "int" require "flat" interpolation + TfToken const &qualifier = isInteger ? + _tokens->flat : _tokens->_default; + + // Vertex attrib input for VS, PTCS, PTVS + _resAttrib.emplace_back(InOut::STAGE_OUT, Kind::VALUE, dataType, + vs_outName, noArraySize, qualifier); + + if (_hasTCS) { + _resTCS.emplace_back(InOut::STAGE_IN, Kind::VALUE, dataType, + vs_outName, _tokens->gl_MaxPatchVertices, qualifier); + _resTCS.emplace_back(InOut::STAGE_OUT, Kind::VALUE, dataType, + tcs_outName, _tokens->HD_NUM_PATCH_EVAL_VERTS, qualifier); + } + + if (_hasTES) { + _resTES.emplace_back(InOut::STAGE_IN, Kind::VALUE, dataType, + tcs_outName, _tokens->gl_MaxPatchVertices, qualifier); + _resTES.emplace_back(InOut::STAGE_OUT, Kind::VALUE, dataType, + tes_outName, noArraySize, qualifier); + } + + // Geometry shader inputs come from previous active stage + if (_hasGS && _hasTES) { + _resGS.emplace_back(InOut::STAGE_IN, Kind::VALUE, dataType, + tes_outName, _tokens->HD_NUM_PRIMITIVE_VERTS, qualifier); + _resGS.emplace_back(InOut::STAGE_OUT, Kind::VALUE, dataType, + gs_outName, noArraySize, qualifier); + } else if (_hasGS) { + _resGS.emplace_back(InOut::STAGE_IN, Kind::VALUE, dataType, + vs_outName, _tokens->HD_NUM_PRIMITIVE_VERTS, qualifier); + _resGS.emplace_back(InOut::STAGE_OUT, Kind::VALUE, dataType, + gs_outName, noArraySize, qualifier); + } + + // Fragment shader inputs come from previous active stage + if (_hasGS) { + _resFS.emplace_back(InOut::STAGE_IN, Kind::VALUE, dataType, + gs_outName, noArraySize, qualifier); + } else if (_hasTES) { + _resFS.emplace_back(InOut::STAGE_IN, Kind::VALUE, dataType, + tes_outName, noArraySize, qualifier); + } else { + _resFS.emplace_back(InOut::STAGE_IN, Kind::VALUE, dataType, + vs_outName, noArraySize, qualifier); + } } } @@ -2500,11 +2608,6 @@ HdSt_CodeGen::_CompileWithGeneratedGLSLResources( // Generator assigns attribute and binding locations _ResourceGenerator resourceGen; - // Create additional resource elements needed by interstage elements - for (auto const &element : _resInterstage) { - _PlumbInterstageElements(element.name, element.dataType); - } - // create GLSL program. HdStGLSLProgramSharedPtr glslProgram = std::make_shared(HdTokens->drawingShader, registry); @@ -2696,12 +2799,6 @@ HdSt_CodeGen::_CompileWithGeneratedHgiResources( // Generator assigns attribute and binding locations _ResourceGenerator resourceGen; - // Create additional resource elements needed by interstage elements. - // For compute-only shaders, we don't have a HdSt_GeometricShader. - for (auto const &element : _resInterstage) { - _PlumbInterstageElements(element.name, element.dataType); - } - // create GLSL program. HdStGLSLProgramSharedPtr glslProgram = std::make_shared(HdTokens->drawingShader, registry); @@ -4104,58 +4201,82 @@ static void _EmitFVarAccessor( << " { return HdGet_" << name << "(0); }\n"; } -// Helper function to generate the implementation of "GetDrawingCoord()". -static void -_GetDrawingCoord(std::stringstream &ss, - std::vector const &drawingCoordParams, - int const instanceIndexWidth, - char const *inputPrefix, - char const *inArraySize) +HdSt_CodeGen::_PackedResourceMapping +HdSt_CodeGen::_GetDrawingCoordMapping(std::string const& name) +{ + // Given a drawing coord un-prefixed name, return a mapping to + // a component in a vector of packed interstage drawing coords. + if (const auto iter = _resInterstagePackedMappings.find("dc_" + name); + iter != _resInterstagePackedMappings.end()) + { + return iter->second; + } + + return {TfToken(name), TfToken()}; +} + +void +HdSt_CodeGen::_GetDrawingCoord( + std::stringstream &ss, + std::vector const &drawingCoordParams, + int instanceIndexWidth, + char const *inputPrefix, + char const *inArraySize) { ss << "hd_drawingCoord GetDrawingCoord() { \n" << " hd_drawingCoord dc; \n"; for (std::string const & param : drawingCoordParams) { + const auto [groupName, component] = _GetDrawingCoordMapping(param); + ss << " dc." << param - << " = " << inputPrefix << param << inArraySize << ";\n"; + << " = " << inputPrefix << groupName << inArraySize << component + << ";\n"; } for(int i = 0; i < instanceIndexWidth; ++i) { - ss << " dc.instanceIndex[" << std::to_string(i) << "]" - << " = " << inputPrefix - << "instanceIndexI" << std::to_string(i) << inArraySize << ";\n"; + const auto [groupName, component] = _GetDrawingCoordMapping( + "instanceIndexI" + std::to_string(i)); + ss << " dc.instanceIndex[" << i << "]" + << " = " << inputPrefix << groupName << inArraySize << component + << ";\n"; } for(int i = 0; i < instanceIndexWidth-1; ++i) { - ss << " dc.instanceCoords[" << std::to_string(i) << "]" - << " = " << inputPrefix - << "instanceCoordsI" << std::to_string(i) << inArraySize << ";\n"; + const auto [groupName, component] = _GetDrawingCoordMapping( + "instanceCoordsI" + std::to_string(i)); + ss << " dc.instanceCoords[" << i << "]" + << " = " << inputPrefix << groupName << inArraySize << component + << ";\n"; } ss << " return dc; \n" << "}\n"; } -// Helper function to generate drawingCoord interstage processing. -static void -_ProcessDrawingCoord(std::stringstream &ss, - std::vector const &drawingCoordParams, - int const instanceIndexWidth, - char const *outputPrefix, - char const *outArraySize) +void +HdSt_CodeGen::_ProcessDrawingCoord( + std::stringstream &ss, + std::vector const &drawingCoordParams, + int instanceIndexWidth, + char const *outputPrefix, + char const *outArraySize) { ss << " hd_drawingCoord dc = GetDrawingCoord();\n"; for (std::string const & param : drawingCoordParams) { - ss << " " << outputPrefix << param << outArraySize - << " = " << "dc." << param << ";\n"; + const auto [groupName, component] = _GetDrawingCoordMapping(param); + ss << " " << outputPrefix << groupName << outArraySize << component + << " = " << "dc." << param << ";\n"; } for(int i = 0; i < instanceIndexWidth; ++i) { - std::string const index = std::to_string(i); - ss << " " << outputPrefix << "instanceIndexI" << index << outArraySize - << " = " << "dc.instanceIndex[" << index << "]" << ";\n"; + const auto [groupName, component] = _GetDrawingCoordMapping( + "instanceIndexI" + std::to_string(i)); + ss << " " << outputPrefix << groupName << outArraySize << component + << " = " << "dc.instanceIndex[" << i << "]" << ";\n"; } for(int i = 0; i < instanceIndexWidth-1; ++i) { - std::string const index = std::to_string(i); - ss << " " << outputPrefix << "instanceCoordsI" << index << outArraySize - << " = " << "dc.instanceCoords[" << index << "]" << ";\n"; + const auto [groupName, component] = _GetDrawingCoordMapping( + "instanceCoordsI" + std::to_string(i)); + ss << " " << outputPrefix << groupName << outArraySize << component + << " = " << "dc.instanceCoords[" << i << "]" << ";\n"; } } @@ -4276,6 +4397,34 @@ HdSt_CodeGen::_GenerateDrawingCoord( "varyingCoord" }; + const int instanceIndexWidth = _metaData->instancerNumLevels + 1; + + if (!_hasCS) { + for (std::string const & param : drawingCoordParams) { + TfToken const drawingCoordParamName("dc_" + param); + _AddInterstageElement(&_resInterstage, + HioGlslfxResourceLayout::InOut::NONE, + /*name=*/drawingCoordParamName, + /*dataType=*/_tokens->_int); + } + for (int i = 0; i < instanceIndexWidth; ++i) { + TfToken const name(TfStringPrintf("dc_instanceIndexI%d", i)); + _AddInterstageElement(&_resInterstage, + HioGlslfxResourceLayout::InOut::NONE, + /*name=*/name, + /*dataType=*/_tokens->_int); + } + for (int i = 0; i < instanceIndexWidth; ++i) { + TfToken const name(TfStringPrintf("dc_instanceCoordsI%d", i)); + _AddInterstageElement(&_resInterstage, + HioGlslfxResourceLayout::InOut::NONE, + /*name=*/name, + /*dataType=*/_tokens->_int); + } + + _PlumbInterstageElements(); + } + // common // // note: instanceCoords should be [HD_INSTANCER_NUM_LEVELS], but since @@ -4293,8 +4442,6 @@ HdSt_CodeGen::_GenerateDrawingCoord( _genDecl << "FORWARD_DECL(hd_drawingCoord GetDrawingCoord());\n" "FORWARD_DECL(int HgiGetBaseVertex());\n"; - int instanceIndexWidth = _metaData->instancerNumLevels + 1; - // vertex shader // [immediate] @@ -4324,7 +4471,10 @@ HdSt_CodeGen::_GenerateDrawingCoord( // patch instance offset exists on Apple Silicon. Use primitiveCoord // subtracted from the primitive ID for those cases if (requiresBasePrimitiveOffset) { - primitiveID << "int GetBasePrimitiveOffset() { return vs_dc_primitiveCoord; }\n"; + const auto [groupName, component] = + _GetDrawingCoordMapping("primitiveCoord"); + primitiveID << "int GetBasePrimitiveOffset() { return vs_" + << groupName << component << "; }\n"; _genPTCS << "int GetBasePrimitiveOffset() { return drawingCoord0[0].w; }\n"; _genPTVS << "int GetBasePrimitiveOffset() { return drawingCoord0[0].w; }\n"; } else { @@ -4589,30 +4739,6 @@ HdSt_CodeGen::_GenerateDrawingCoord( << " hd_instanceIndex r; r.indices[0] = 0; return r; }\n"; } - if (!_hasCS) { - for (std::string const & param : drawingCoordParams) { - TfToken const drawingCoordParamName("dc_" + param); - _AddInterstageElement(&_resInterstage, - HioGlslfxResourceLayout::InOut::NONE, - /*name=*/drawingCoordParamName, - /*dataType=*/_tokens->_int); - } - for (int i = 0; i < instanceIndexWidth; ++i) { - TfToken const name(TfStringPrintf("dc_instanceIndexI%d", i)); - _AddInterstageElement(&_resInterstage, - HioGlslfxResourceLayout::InOut::NONE, - /*name=*/name, - /*dataType=*/_tokens->_int); - } - for (int i = 0; i < instanceIndexWidth; ++i) { - TfToken const name(TfStringPrintf("dc_instanceCoordsI%d", i)); - _AddInterstageElement(&_resInterstage, - HioGlslfxResourceLayout::InOut::NONE, - /*name=*/name, - /*dataType=*/_tokens->_int); - } - } - _genVS << genAttr.str(); _genPTCS << genAttr.str(); _genPTVS << genAttr.str(); @@ -4715,52 +4841,52 @@ HdSt_CodeGen::_GenerateDrawingCoord( // VS/PTVS from attributes _ProcessDrawingCoord(_procVS, drawingCoordParams, instanceIndexWidth, - "vs_dc_", ""); + "vs_", ""); _ProcessDrawingCoord(_procPTVSOut, drawingCoordParams, instanceIndexWidth, - "vs_dc_", ""); + "vs_", ""); // TCS from VS if (_hasTCS) { _GetDrawingCoord(_genTCS, drawingCoordParams, instanceIndexWidth, - "vs_dc_", "[0]"); + "vs_", "[0]"); _ProcessDrawingCoord(_procTCS, drawingCoordParams, instanceIndexWidth, - "tcs_dc_", "[gl_InvocationID]"); + "tcs_", "[gl_InvocationID]"); } // TES from TCS if (_hasTES) { _GetDrawingCoord(_genTES, drawingCoordParams, instanceIndexWidth, - "tcs_dc_", "[0]"); + "tcs_", "[0]"); _ProcessDrawingCoord(_procTES, drawingCoordParams, instanceIndexWidth, - "tes_dc_", ""); + "tes_", ""); } // GS if (_hasGS && _hasTES) { // from TES _GetDrawingCoord(_genGS, drawingCoordParams, instanceIndexWidth, - "tes_dc_", "[0]"); + "tes_", "[0]"); } else if (_hasGS) { // from VS _GetDrawingCoord(_genGS, drawingCoordParams, instanceIndexWidth, - "vs_dc_", "[0]"); + "vs_", "[0]"); } _ProcessDrawingCoord(_procGS, drawingCoordParams, instanceIndexWidth, - "gs_dc_", ""); + "gs_", ""); // FS if (_hasGS) { // from GS _GetDrawingCoord(_genFS, drawingCoordParams, instanceIndexWidth, - "gs_dc_", ""); + "gs_", ""); } else if (_hasTES) { // from TES _GetDrawingCoord(_genFS, drawingCoordParams, instanceIndexWidth, - "tes_dc_", ""); + "tes_", ""); } else { // from VS/PTVS _GetDrawingCoord(_genFS, drawingCoordParams, instanceIndexWidth, - "vs_dc_", ""); + "vs_", ""); } } diff --git a/pxr/imaging/hdSt/codeGen.h b/pxr/imaging/hdSt/codeGen.h index b2fcb99865..fef9b6d2d4 100644 --- a/pxr/imaging/hdSt/codeGen.h +++ b/pxr/imaging/hdSt/codeGen.h @@ -14,7 +14,7 @@ #include "pxr/imaging/hdSt/glslProgram.h" #include "pxr/imaging/hio/glslfxResourceLayout.h" -#include +#include #include #include @@ -129,7 +129,30 @@ class HdSt_CodeGen std::string _GetFallbackScalarSwizzleString(TfToken const &returnType, TfToken const ¶mName); - void _PlumbInterstageElements(TfToken const &name, TfToken const &dataType); + void _PlumbInterstageElements(); + + // The packed field name (grouping vector) and name of its component that + // holds the resource. + struct _PackedResourceMapping { + TfToken groupName; + std::string component; + }; + + _PackedResourceMapping _GetDrawingCoordMapping(std::string const &name); + + void _GetDrawingCoord( + std::stringstream &ss, + std::vector const &drawingCoordParams, + int instanceIndexWidth, + char const *inputPrefix, + char const *inArraySize); + + void _ProcessDrawingCoord( + std::stringstream &ss, + std::vector const &drawingCoordParams, + int instanceIndexWidth, + char const *outputPrefix, + char const *outArraySize); void _GenerateComputeParameters(HgiShaderFunctionDesc *csDesc); @@ -171,6 +194,8 @@ class HdSt_CodeGen ElementVector _resCS; ElementVector _resInterstage; + std::unordered_map + _resInterstagePackedMappings; ElementVector _resCommon; ElementVector _resAttrib; diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_bindless.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_bindless.out index 1379eaaab9..e3ec0a77c9 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_bindless.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_bindless.out @@ -164,22 +164,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform float *faceVisibility; out CurveVertexData { @@ -255,16 +247,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -829,6 +821,12 @@ in CurveVertexData { out CurveVertexData { vec4 Peye; } outData[HD_NUM_PATCH_EVAL_VERTS]; +in flat ivec4 vs_interstageDrawingCoord0[gl_MaxPatchVertices]; +out flat ivec4 tcs_interstageDrawingCoord0[HD_NUM_PATCH_EVAL_VERTS]; +in flat ivec4 vs_interstageDrawingCoord1[gl_MaxPatchVertices]; +out flat ivec4 tcs_interstageDrawingCoord1[HD_NUM_PATCH_EVAL_VERTS]; +in flat ivec4 vs_interstageDrawingCoord2[gl_MaxPatchVertices]; +out flat ivec4 tcs_interstageDrawingCoord2[HD_NUM_PATCH_EVAL_VERTS]; in PrimvarData { vec3 points; vec3 normals; @@ -837,28 +835,6 @@ out PrimvarData { vec3 points; vec3 normals; } outPrimvars[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_modelCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_modelCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_constantCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_constantCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_elementCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_elementCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_primitiveCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_primitiveCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_fvarCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_fvarCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_shaderCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_shaderCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_vertexCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_vertexCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_topologyVisibilityCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_topologyVisibilityCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_varyingCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_varyingCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_instanceIndexI0[gl_MaxPatchVertices]; -out flat int tcs_dc_instanceIndexI0[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_instanceCoordsI0[gl_MaxPatchVertices]; -out flat int tcs_dc_instanceCoordsI0[HD_NUM_PATCH_EVAL_VERTS]; // //////// Codegen Accessors //////// mat4 HdGet_transform(int localIndex) { @@ -902,16 +878,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int GetElementID() { @@ -966,16 +942,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc TCS //////// void ProcessPrimvarsOut() { hd_drawingCoord dc = GetDrawingCoord(); - tcs_dc_modelCoord[gl_InvocationID] = dc.modelCoord; - tcs_dc_constantCoord[gl_InvocationID] = dc.constantCoord; - tcs_dc_elementCoord[gl_InvocationID] = dc.elementCoord; - tcs_dc_primitiveCoord[gl_InvocationID] = dc.primitiveCoord; - tcs_dc_fvarCoord[gl_InvocationID] = dc.fvarCoord; - tcs_dc_shaderCoord[gl_InvocationID] = dc.shaderCoord; - tcs_dc_vertexCoord[gl_InvocationID] = dc.vertexCoord; - tcs_dc_topologyVisibilityCoord[gl_InvocationID] = dc.topologyVisibilityCoord; - tcs_dc_varyingCoord[gl_InvocationID] = dc.varyingCoord; - tcs_dc_instanceIndexI0[gl_InvocationID] = dc.instanceIndex[0]; + tcs_interstageDrawingCoord0[gl_InvocationID][0] = dc.modelCoord; + tcs_interstageDrawingCoord0[gl_InvocationID][1] = dc.constantCoord; + tcs_interstageDrawingCoord0[gl_InvocationID][2] = dc.elementCoord; + tcs_interstageDrawingCoord0[gl_InvocationID][3] = dc.primitiveCoord; + tcs_interstageDrawingCoord1[gl_InvocationID][0] = dc.fvarCoord; + tcs_interstageDrawingCoord1[gl_InvocationID][1] = dc.shaderCoord; + tcs_interstageDrawingCoord1[gl_InvocationID][2] = dc.vertexCoord; + tcs_interstageDrawingCoord1[gl_InvocationID][3] = dc.topologyVisibilityCoord; + tcs_interstageDrawingCoord2[gl_InvocationID][0] = dc.varyingCoord; + tcs_interstageDrawingCoord2[gl_InvocationID][1] = dc.instanceIndex[0]; outPrimvars[gl_InvocationID].points = inPrimvars[gl_InvocationID].points; outPrimvars[gl_InvocationID].normals = inPrimvars[gl_InvocationID].normals; } @@ -1360,6 +1336,12 @@ in CurveVertexData { out CurveVertexData { vec4 Peye; } outData; +in flat ivec4 tcs_interstageDrawingCoord0[gl_MaxPatchVertices]; +out flat ivec4 tes_interstageDrawingCoord0; +in flat ivec4 tcs_interstageDrawingCoord1[gl_MaxPatchVertices]; +out flat ivec4 tes_interstageDrawingCoord1; +in flat ivec4 tcs_interstageDrawingCoord2[gl_MaxPatchVertices]; +out flat ivec4 tes_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; @@ -1368,28 +1350,6 @@ out PrimvarData { vec3 points; vec3 normals; } outPrimvars; -in flat int tcs_dc_modelCoord[gl_MaxPatchVertices]; -out flat int tes_dc_modelCoord; -in flat int tcs_dc_constantCoord[gl_MaxPatchVertices]; -out flat int tes_dc_constantCoord; -in flat int tcs_dc_elementCoord[gl_MaxPatchVertices]; -out flat int tes_dc_elementCoord; -in flat int tcs_dc_primitiveCoord[gl_MaxPatchVertices]; -out flat int tes_dc_primitiveCoord; -in flat int tcs_dc_fvarCoord[gl_MaxPatchVertices]; -out flat int tes_dc_fvarCoord; -in flat int tcs_dc_shaderCoord[gl_MaxPatchVertices]; -out flat int tes_dc_shaderCoord; -in flat int tcs_dc_vertexCoord[gl_MaxPatchVertices]; -out flat int tes_dc_vertexCoord; -in flat int tcs_dc_topologyVisibilityCoord[gl_MaxPatchVertices]; -out flat int tes_dc_topologyVisibilityCoord; -in flat int tcs_dc_varyingCoord[gl_MaxPatchVertices]; -out flat int tes_dc_varyingCoord; -in flat int tcs_dc_instanceIndexI0[gl_MaxPatchVertices]; -out flat int tes_dc_instanceIndexI0; -in flat int tcs_dc_instanceCoordsI0[gl_MaxPatchVertices]; -out flat int tes_dc_instanceCoordsI0; // //////// Codegen Accessors //////// mat4 HdGet_transform(int localIndex) { @@ -1433,16 +1393,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = tcs_dc_modelCoord[0]; - dc.constantCoord = tcs_dc_constantCoord[0]; - dc.elementCoord = tcs_dc_elementCoord[0]; - dc.primitiveCoord = tcs_dc_primitiveCoord[0]; - dc.fvarCoord = tcs_dc_fvarCoord[0]; - dc.shaderCoord = tcs_dc_shaderCoord[0]; - dc.vertexCoord = tcs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = tcs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = tcs_dc_varyingCoord[0]; - dc.instanceIndex[0] = tcs_dc_instanceIndexI0[0]; + dc.modelCoord = tcs_interstageDrawingCoord0[0][0]; + dc.constantCoord = tcs_interstageDrawingCoord0[0][1]; + dc.elementCoord = tcs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = tcs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = tcs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = tcs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = tcs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = tcs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = tcs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = tcs_interstageDrawingCoord2[0][1]; return dc; } int GetElementID() { @@ -1501,16 +1461,16 @@ vec3 InterpolatePrimvar(vec3 inPv0, vec3 inPv1, vec3 inPv2, vec3 inPv3, vec4 bas vec4 InterpolatePrimvar(vec4 inPv0, vec4 inPv1, vec4 inPv3, vec4 inPv3, vec4 basis, vec2 uv); void ProcessPrimvarsOut(vec4 basis, int i0, int i1, int i2, int i3, vec2 uv) { hd_drawingCoord dc = GetDrawingCoord(); - tes_dc_modelCoord = dc.modelCoord; - tes_dc_constantCoord = dc.constantCoord; - tes_dc_elementCoord = dc.elementCoord; - tes_dc_primitiveCoord = dc.primitiveCoord; - tes_dc_fvarCoord = dc.fvarCoord; - tes_dc_shaderCoord = dc.shaderCoord; - tes_dc_vertexCoord = dc.vertexCoord; - tes_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - tes_dc_varyingCoord = dc.varyingCoord; - tes_dc_instanceIndexI0 = dc.instanceIndex[0]; + tes_interstageDrawingCoord0[0] = dc.modelCoord; + tes_interstageDrawingCoord0[1] = dc.constantCoord; + tes_interstageDrawingCoord0[2] = dc.elementCoord; + tes_interstageDrawingCoord0[3] = dc.primitiveCoord; + tes_interstageDrawingCoord1[0] = dc.fvarCoord; + tes_interstageDrawingCoord1[1] = dc.shaderCoord; + tes_interstageDrawingCoord1[2] = dc.vertexCoord; + tes_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + tes_interstageDrawingCoord2[0] = dc.varyingCoord; + tes_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = basis[0] * inPrimvars[i0].points + basis[1] * inPrimvars[i1].points + basis[2] * inPrimvars[i2].points + basis[3] * inPrimvars[i3].points; outPrimvars.normals = basis[0] * inPrimvars[i0].normals + basis[1] * inPrimvars[i1].normals + basis[2] * inPrimvars[i2].normals + basis[3] * inPrimvars[i3].normals; } @@ -2126,21 +2086,13 @@ in CurveVertexData { vec4 Peye; } inData; layout (location = 0) out vec4 colorOut; +in flat ivec4 tes_interstageDrawingCoord0; +in flat ivec4 tes_interstageDrawingCoord1; +in flat ivec4 tes_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; } inPrimvars; -in flat int tes_dc_modelCoord; -in flat int tes_dc_constantCoord; -in flat int tes_dc_elementCoord; -in flat int tes_dc_primitiveCoord; -in flat int tes_dc_fvarCoord; -in flat int tes_dc_shaderCoord; -in flat int tes_dc_vertexCoord; -in flat int tes_dc_topologyVisibilityCoord; -in flat int tes_dc_varyingCoord; -in flat int tes_dc_instanceIndexI0; -in flat int tes_dc_instanceCoordsI0; // //////// Codegen Accessors //////// mat4 HdGet_transform(int localIndex) { @@ -2189,16 +2141,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = tes_dc_modelCoord; - dc.constantCoord = tes_dc_constantCoord; - dc.elementCoord = tes_dc_elementCoord; - dc.primitiveCoord = tes_dc_primitiveCoord; - dc.fvarCoord = tes_dc_fvarCoord; - dc.shaderCoord = tes_dc_shaderCoord; - dc.vertexCoord = tes_dc_vertexCoord; - dc.topologyVisibilityCoord = tes_dc_topologyVisibilityCoord; - dc.varyingCoord = tes_dc_varyingCoord; - dc.instanceIndex[0] = tes_dc_instanceIndexI0; + dc.modelCoord = tes_interstageDrawingCoord0[0]; + dc.constantCoord = tes_interstageDrawingCoord0[1]; + dc.elementCoord = tes_interstageDrawingCoord0[2]; + dc.primitiveCoord = tes_interstageDrawingCoord0[3]; + dc.fvarCoord = tes_interstageDrawingCoord1[0]; + dc.shaderCoord = tes_interstageDrawingCoord1[1]; + dc.vertexCoord = tes_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = tes_interstageDrawingCoord1[3]; + dc.varyingCoord = tes_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = tes_interstageDrawingCoord2[1]; return dc; } int GetElementID() { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out index 1379eaaab9..e3ec0a77c9 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out @@ -164,22 +164,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform float *faceVisibility; out CurveVertexData { @@ -255,16 +247,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -829,6 +821,12 @@ in CurveVertexData { out CurveVertexData { vec4 Peye; } outData[HD_NUM_PATCH_EVAL_VERTS]; +in flat ivec4 vs_interstageDrawingCoord0[gl_MaxPatchVertices]; +out flat ivec4 tcs_interstageDrawingCoord0[HD_NUM_PATCH_EVAL_VERTS]; +in flat ivec4 vs_interstageDrawingCoord1[gl_MaxPatchVertices]; +out flat ivec4 tcs_interstageDrawingCoord1[HD_NUM_PATCH_EVAL_VERTS]; +in flat ivec4 vs_interstageDrawingCoord2[gl_MaxPatchVertices]; +out flat ivec4 tcs_interstageDrawingCoord2[HD_NUM_PATCH_EVAL_VERTS]; in PrimvarData { vec3 points; vec3 normals; @@ -837,28 +835,6 @@ out PrimvarData { vec3 points; vec3 normals; } outPrimvars[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_modelCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_modelCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_constantCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_constantCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_elementCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_elementCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_primitiveCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_primitiveCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_fvarCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_fvarCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_shaderCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_shaderCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_vertexCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_vertexCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_topologyVisibilityCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_topologyVisibilityCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_varyingCoord[gl_MaxPatchVertices]; -out flat int tcs_dc_varyingCoord[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_instanceIndexI0[gl_MaxPatchVertices]; -out flat int tcs_dc_instanceIndexI0[HD_NUM_PATCH_EVAL_VERTS]; -in flat int vs_dc_instanceCoordsI0[gl_MaxPatchVertices]; -out flat int tcs_dc_instanceCoordsI0[HD_NUM_PATCH_EVAL_VERTS]; // //////// Codegen Accessors //////// mat4 HdGet_transform(int localIndex) { @@ -902,16 +878,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int GetElementID() { @@ -966,16 +942,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc TCS //////// void ProcessPrimvarsOut() { hd_drawingCoord dc = GetDrawingCoord(); - tcs_dc_modelCoord[gl_InvocationID] = dc.modelCoord; - tcs_dc_constantCoord[gl_InvocationID] = dc.constantCoord; - tcs_dc_elementCoord[gl_InvocationID] = dc.elementCoord; - tcs_dc_primitiveCoord[gl_InvocationID] = dc.primitiveCoord; - tcs_dc_fvarCoord[gl_InvocationID] = dc.fvarCoord; - tcs_dc_shaderCoord[gl_InvocationID] = dc.shaderCoord; - tcs_dc_vertexCoord[gl_InvocationID] = dc.vertexCoord; - tcs_dc_topologyVisibilityCoord[gl_InvocationID] = dc.topologyVisibilityCoord; - tcs_dc_varyingCoord[gl_InvocationID] = dc.varyingCoord; - tcs_dc_instanceIndexI0[gl_InvocationID] = dc.instanceIndex[0]; + tcs_interstageDrawingCoord0[gl_InvocationID][0] = dc.modelCoord; + tcs_interstageDrawingCoord0[gl_InvocationID][1] = dc.constantCoord; + tcs_interstageDrawingCoord0[gl_InvocationID][2] = dc.elementCoord; + tcs_interstageDrawingCoord0[gl_InvocationID][3] = dc.primitiveCoord; + tcs_interstageDrawingCoord1[gl_InvocationID][0] = dc.fvarCoord; + tcs_interstageDrawingCoord1[gl_InvocationID][1] = dc.shaderCoord; + tcs_interstageDrawingCoord1[gl_InvocationID][2] = dc.vertexCoord; + tcs_interstageDrawingCoord1[gl_InvocationID][3] = dc.topologyVisibilityCoord; + tcs_interstageDrawingCoord2[gl_InvocationID][0] = dc.varyingCoord; + tcs_interstageDrawingCoord2[gl_InvocationID][1] = dc.instanceIndex[0]; outPrimvars[gl_InvocationID].points = inPrimvars[gl_InvocationID].points; outPrimvars[gl_InvocationID].normals = inPrimvars[gl_InvocationID].normals; } @@ -1360,6 +1336,12 @@ in CurveVertexData { out CurveVertexData { vec4 Peye; } outData; +in flat ivec4 tcs_interstageDrawingCoord0[gl_MaxPatchVertices]; +out flat ivec4 tes_interstageDrawingCoord0; +in flat ivec4 tcs_interstageDrawingCoord1[gl_MaxPatchVertices]; +out flat ivec4 tes_interstageDrawingCoord1; +in flat ivec4 tcs_interstageDrawingCoord2[gl_MaxPatchVertices]; +out flat ivec4 tes_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; @@ -1368,28 +1350,6 @@ out PrimvarData { vec3 points; vec3 normals; } outPrimvars; -in flat int tcs_dc_modelCoord[gl_MaxPatchVertices]; -out flat int tes_dc_modelCoord; -in flat int tcs_dc_constantCoord[gl_MaxPatchVertices]; -out flat int tes_dc_constantCoord; -in flat int tcs_dc_elementCoord[gl_MaxPatchVertices]; -out flat int tes_dc_elementCoord; -in flat int tcs_dc_primitiveCoord[gl_MaxPatchVertices]; -out flat int tes_dc_primitiveCoord; -in flat int tcs_dc_fvarCoord[gl_MaxPatchVertices]; -out flat int tes_dc_fvarCoord; -in flat int tcs_dc_shaderCoord[gl_MaxPatchVertices]; -out flat int tes_dc_shaderCoord; -in flat int tcs_dc_vertexCoord[gl_MaxPatchVertices]; -out flat int tes_dc_vertexCoord; -in flat int tcs_dc_topologyVisibilityCoord[gl_MaxPatchVertices]; -out flat int tes_dc_topologyVisibilityCoord; -in flat int tcs_dc_varyingCoord[gl_MaxPatchVertices]; -out flat int tes_dc_varyingCoord; -in flat int tcs_dc_instanceIndexI0[gl_MaxPatchVertices]; -out flat int tes_dc_instanceIndexI0; -in flat int tcs_dc_instanceCoordsI0[gl_MaxPatchVertices]; -out flat int tes_dc_instanceCoordsI0; // //////// Codegen Accessors //////// mat4 HdGet_transform(int localIndex) { @@ -1433,16 +1393,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = tcs_dc_modelCoord[0]; - dc.constantCoord = tcs_dc_constantCoord[0]; - dc.elementCoord = tcs_dc_elementCoord[0]; - dc.primitiveCoord = tcs_dc_primitiveCoord[0]; - dc.fvarCoord = tcs_dc_fvarCoord[0]; - dc.shaderCoord = tcs_dc_shaderCoord[0]; - dc.vertexCoord = tcs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = tcs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = tcs_dc_varyingCoord[0]; - dc.instanceIndex[0] = tcs_dc_instanceIndexI0[0]; + dc.modelCoord = tcs_interstageDrawingCoord0[0][0]; + dc.constantCoord = tcs_interstageDrawingCoord0[0][1]; + dc.elementCoord = tcs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = tcs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = tcs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = tcs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = tcs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = tcs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = tcs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = tcs_interstageDrawingCoord2[0][1]; return dc; } int GetElementID() { @@ -1501,16 +1461,16 @@ vec3 InterpolatePrimvar(vec3 inPv0, vec3 inPv1, vec3 inPv2, vec3 inPv3, vec4 bas vec4 InterpolatePrimvar(vec4 inPv0, vec4 inPv1, vec4 inPv3, vec4 inPv3, vec4 basis, vec2 uv); void ProcessPrimvarsOut(vec4 basis, int i0, int i1, int i2, int i3, vec2 uv) { hd_drawingCoord dc = GetDrawingCoord(); - tes_dc_modelCoord = dc.modelCoord; - tes_dc_constantCoord = dc.constantCoord; - tes_dc_elementCoord = dc.elementCoord; - tes_dc_primitiveCoord = dc.primitiveCoord; - tes_dc_fvarCoord = dc.fvarCoord; - tes_dc_shaderCoord = dc.shaderCoord; - tes_dc_vertexCoord = dc.vertexCoord; - tes_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - tes_dc_varyingCoord = dc.varyingCoord; - tes_dc_instanceIndexI0 = dc.instanceIndex[0]; + tes_interstageDrawingCoord0[0] = dc.modelCoord; + tes_interstageDrawingCoord0[1] = dc.constantCoord; + tes_interstageDrawingCoord0[2] = dc.elementCoord; + tes_interstageDrawingCoord0[3] = dc.primitiveCoord; + tes_interstageDrawingCoord1[0] = dc.fvarCoord; + tes_interstageDrawingCoord1[1] = dc.shaderCoord; + tes_interstageDrawingCoord1[2] = dc.vertexCoord; + tes_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + tes_interstageDrawingCoord2[0] = dc.varyingCoord; + tes_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = basis[0] * inPrimvars[i0].points + basis[1] * inPrimvars[i1].points + basis[2] * inPrimvars[i2].points + basis[3] * inPrimvars[i3].points; outPrimvars.normals = basis[0] * inPrimvars[i0].normals + basis[1] * inPrimvars[i1].normals + basis[2] * inPrimvars[i2].normals + basis[3] * inPrimvars[i3].normals; } @@ -2126,21 +2086,13 @@ in CurveVertexData { vec4 Peye; } inData; layout (location = 0) out vec4 colorOut; +in flat ivec4 tes_interstageDrawingCoord0; +in flat ivec4 tes_interstageDrawingCoord1; +in flat ivec4 tes_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; } inPrimvars; -in flat int tes_dc_modelCoord; -in flat int tes_dc_constantCoord; -in flat int tes_dc_elementCoord; -in flat int tes_dc_primitiveCoord; -in flat int tes_dc_fvarCoord; -in flat int tes_dc_shaderCoord; -in flat int tes_dc_vertexCoord; -in flat int tes_dc_topologyVisibilityCoord; -in flat int tes_dc_varyingCoord; -in flat int tes_dc_instanceIndexI0; -in flat int tes_dc_instanceCoordsI0; // //////// Codegen Accessors //////// mat4 HdGet_transform(int localIndex) { @@ -2189,16 +2141,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = tes_dc_modelCoord; - dc.constantCoord = tes_dc_constantCoord; - dc.elementCoord = tes_dc_elementCoord; - dc.primitiveCoord = tes_dc_primitiveCoord; - dc.fvarCoord = tes_dc_fvarCoord; - dc.shaderCoord = tes_dc_shaderCoord; - dc.vertexCoord = tes_dc_vertexCoord; - dc.topologyVisibilityCoord = tes_dc_topologyVisibilityCoord; - dc.varyingCoord = tes_dc_varyingCoord; - dc.instanceIndex[0] = tes_dc_instanceIndexI0; + dc.modelCoord = tes_interstageDrawingCoord0[0]; + dc.constantCoord = tes_interstageDrawingCoord0[1]; + dc.elementCoord = tes_interstageDrawingCoord0[2]; + dc.primitiveCoord = tes_interstageDrawingCoord0[3]; + dc.fvarCoord = tes_interstageDrawingCoord1[0]; + dc.shaderCoord = tes_interstageDrawingCoord1[1]; + dc.vertexCoord = tes_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = tes_interstageDrawingCoord1[3]; + dc.varyingCoord = tes_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = tes_interstageDrawingCoord2[1]; return dc; } int GetElementID() { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect.out index 59998b24c6..7ee8a125f8 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect.out @@ -162,22 +162,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform int *primitiveParam; layout(location = 2) uniform int *edgeIndices; @@ -256,16 +248,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -851,6 +843,12 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; @@ -860,28 +858,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -926,16 +902,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1028,16 +1004,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1662,22 +1638,14 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -1736,16 +1704,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2838,22 +2806,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform int *primitiveParam; layout(location = 2) uniform ivec2 *edgeIndices; @@ -2932,16 +2892,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -3527,6 +3487,12 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; @@ -3536,28 +3502,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -3602,16 +3546,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3704,16 +3648,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4367,22 +4311,14 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -4441,16 +4377,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_doubleSided.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_doubleSided.out index d0d438b400..5776e78e69 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_doubleSided.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_doubleSided.out @@ -162,22 +162,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform int *primitiveParam; layout(location = 2) uniform int *edgeIndices; @@ -256,16 +248,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -851,6 +843,12 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; @@ -860,28 +858,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -926,16 +902,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1028,16 +1004,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1662,22 +1638,14 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -1736,16 +1704,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2837,22 +2805,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform int *primitiveParam; layout(location = 2) uniform ivec2 *edgeIndices; @@ -2931,16 +2891,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -3526,6 +3486,12 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; @@ -3535,28 +3501,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -3601,16 +3545,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3703,16 +3647,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4366,22 +4310,14 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -4440,16 +4376,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_faceVarying.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_faceVarying.out index 59998b24c6..7ee8a125f8 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_faceVarying.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_faceVarying.out @@ -162,22 +162,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform int *primitiveParam; layout(location = 2) uniform int *edgeIndices; @@ -256,16 +248,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -851,6 +843,12 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; @@ -860,28 +858,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -926,16 +902,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1028,16 +1004,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1662,22 +1638,14 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -1736,16 +1704,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2838,22 +2806,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform int *primitiveParam; layout(location = 2) uniform ivec2 *edgeIndices; @@ -2932,16 +2892,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -3527,6 +3487,12 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; @@ -3536,28 +3502,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -3602,16 +3546,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3704,16 +3648,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4367,22 +4311,14 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -4441,16 +4377,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_instance.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_instance.out index 63f827af51..9960bc8fe8 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_instance.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_instance.out @@ -164,25 +164,16 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; +out flat ivec4 vs_interstageDrawingCoord3; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 5) in int drawingCoordI0; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceIndexI1; -out flat int vs_dc_instanceCoordsI0; -out flat int vs_dc_instanceCoordsI1; layout(location = 6) uniform int *instanceIndices; layout(location = 7) uniform int *culledInstanceIndices; layout(location = 0) uniform ConstantData10 *constantPrimvars; @@ -305,18 +296,18 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; - vs_dc_instanceIndexI1 = dc.instanceIndex[1]; - vs_dc_instanceCoordsI0 = dc.instanceCoords[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; + vs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; + vs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -907,6 +898,14 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; +in flat ivec4 vs_interstageDrawingCoord3[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord3; in PrimvarData { vec3 points; vec3 normals; @@ -916,32 +915,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceIndexI1[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI1; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; -in flat int vs_dc_instanceCoordsI1[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI1; layout(location = 5) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -1004,18 +977,18 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; - dc.instanceIndex[1] = vs_dc_instanceIndexI1[0]; - dc.instanceCoords[0] = vs_dc_instanceCoordsI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; + dc.instanceIndex[1] = vs_interstageDrawingCoord2[0][2]; + dc.instanceCoords[0] = vs_interstageDrawingCoord2[0][3]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1108,18 +1081,18 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; - gs_dc_instanceIndexI1 = dc.instanceIndex[1]; - gs_dc_instanceCoordsI0 = dc.instanceCoords[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; + gs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; + gs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1749,24 +1722,15 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; +in flat ivec4 gs_interstageDrawingCoord3; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceIndexI1; -in flat int gs_dc_instanceCoordsI0; -in flat int gs_dc_instanceCoordsI1; layout(location = 5) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -1843,18 +1807,18 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; - dc.instanceIndex[1] = gs_dc_instanceIndexI1; - dc.instanceCoords[0] = gs_dc_instanceCoordsI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; + dc.instanceIndex[1] = gs_interstageDrawingCoord2[2]; + dc.instanceCoords[0] = gs_interstageDrawingCoord2[3]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2949,25 +2913,16 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; +out flat ivec4 vs_interstageDrawingCoord3; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 5) in int drawingCoordI0; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceIndexI1; -out flat int vs_dc_instanceCoordsI0; -out flat int vs_dc_instanceCoordsI1; layout(location = 6) uniform int *instanceIndices; layout(location = 7) uniform int *culledInstanceIndices; layout(location = 0) uniform ConstantData10 *constantPrimvars; @@ -3090,18 +3045,18 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; - vs_dc_instanceIndexI1 = dc.instanceIndex[1]; - vs_dc_instanceCoordsI0 = dc.instanceCoords[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; + vs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; + vs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -3692,6 +3647,14 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; +in flat ivec4 vs_interstageDrawingCoord3[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord3; in PrimvarData { vec3 points; vec3 normals; @@ -3701,32 +3664,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceIndexI1[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI1; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; -in flat int vs_dc_instanceCoordsI1[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI1; layout(location = 5) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -3789,18 +3726,18 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; - dc.instanceIndex[1] = vs_dc_instanceIndexI1[0]; - dc.instanceCoords[0] = vs_dc_instanceCoordsI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; + dc.instanceIndex[1] = vs_interstageDrawingCoord2[0][2]; + dc.instanceCoords[0] = vs_interstageDrawingCoord2[0][3]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3893,18 +3830,18 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; - gs_dc_instanceIndexI1 = dc.instanceIndex[1]; - gs_dc_instanceCoordsI0 = dc.instanceCoords[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; + gs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; + gs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4563,24 +4500,15 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; +in flat ivec4 gs_interstageDrawingCoord3; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceIndexI1; -in flat int gs_dc_instanceCoordsI0; -in flat int gs_dc_instanceCoordsI1; layout(location = 5) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -4657,18 +4585,18 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; - dc.instanceIndex[1] = gs_dc_instanceIndexI1; - dc.instanceCoords[0] = gs_dc_instanceCoordsI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; + dc.instanceIndex[1] = gs_interstageDrawingCoord2[2]; + dc.instanceCoords[0] = gs_interstageDrawingCoord2[3]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_smoothNormals.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_smoothNormals.out index d546ea62b4..3b23416cb3 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_smoothNormals.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_smoothNormals.out @@ -162,22 +162,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 smoothNormals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform int *primitiveParam; layout(location = 2) uniform int *edgeIndices; @@ -256,16 +248,16 @@ float HdGetScalar_smoothNormals() { return HdGet_smoothNormals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.smoothNormals = smoothNormals; } @@ -864,6 +856,12 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 smoothNormals; @@ -873,28 +871,6 @@ out PrimvarData { vec3 smoothNormals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -939,16 +915,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1041,16 +1017,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.smoothNormals = inPrimvars[index].smoothNormals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1662,22 +1638,14 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 smoothNormals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -1736,16 +1704,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2838,22 +2806,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 smoothNormals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform int *primitiveParam; layout(location = 2) uniform ivec2 *edgeIndices; @@ -2932,16 +2892,16 @@ float HdGetScalar_smoothNormals() { return HdGet_smoothNormals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.smoothNormals = smoothNormals; } @@ -3540,6 +3500,12 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 smoothNormals; @@ -3549,28 +3515,6 @@ out PrimvarData { vec3 smoothNormals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -3615,16 +3559,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3717,16 +3661,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.smoothNormals = inPrimvars[index].smoothNormals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4367,22 +4311,14 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 smoothNormals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -4441,16 +4377,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out index cb6007195a..294b7071e9 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out @@ -162,22 +162,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform int *primitiveParam; layout(location = 2) uniform int *edgeIndices; @@ -256,16 +248,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -851,6 +843,12 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; @@ -860,28 +858,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -926,16 +902,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1028,16 +1004,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1662,22 +1638,14 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -1736,16 +1704,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2887,22 +2855,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform int *primitiveParam; layout(location = 2) uniform ivec2 *edgeIndices; @@ -2981,16 +2941,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -3576,6 +3536,12 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; @@ -3585,28 +3551,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -3651,16 +3595,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3753,16 +3697,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4416,22 +4360,14 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -4490,16 +4426,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out index ac23cf5bda..d962cc16e9 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out @@ -162,22 +162,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform int *primitiveParam; layout(location = 2) uniform int *edgeIndices; @@ -256,16 +248,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -851,6 +843,12 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; @@ -860,28 +858,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -926,16 +902,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1028,16 +1004,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1662,22 +1638,14 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -1736,16 +1704,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2893,22 +2861,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform int *primitiveParam; layout(location = 2) uniform ivec2 *edgeIndices; @@ -2987,16 +2947,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -3582,6 +3542,12 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; @@ -3591,28 +3557,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -3657,16 +3601,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3759,16 +3703,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4422,22 +4366,14 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -4496,16 +4432,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out index 59998b24c6..7ee8a125f8 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out @@ -162,22 +162,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform int *primitiveParam; layout(location = 2) uniform int *edgeIndices; @@ -256,16 +248,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -851,6 +843,12 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; @@ -860,28 +858,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -926,16 +902,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1028,16 +1004,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1662,22 +1638,14 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -1736,16 +1704,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2838,22 +2806,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; layout(location = 1) uniform int *primitiveParam; layout(location = 2) uniform ivec2 *edgeIndices; @@ -2932,16 +2892,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -3527,6 +3487,12 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; @@ -3536,28 +3502,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -3602,16 +3546,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3704,16 +3648,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4367,22 +4311,14 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceCoordsI0; layout(location = 4) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -4441,16 +4377,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out index 63f827af51..9960bc8fe8 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out @@ -164,25 +164,16 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; +out flat ivec4 vs_interstageDrawingCoord3; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 5) in int drawingCoordI0; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceIndexI1; -out flat int vs_dc_instanceCoordsI0; -out flat int vs_dc_instanceCoordsI1; layout(location = 6) uniform int *instanceIndices; layout(location = 7) uniform int *culledInstanceIndices; layout(location = 0) uniform ConstantData10 *constantPrimvars; @@ -305,18 +296,18 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; - vs_dc_instanceIndexI1 = dc.instanceIndex[1]; - vs_dc_instanceCoordsI0 = dc.instanceCoords[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; + vs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; + vs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -907,6 +898,14 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; +in flat ivec4 vs_interstageDrawingCoord3[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord3; in PrimvarData { vec3 points; vec3 normals; @@ -916,32 +915,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceIndexI1[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI1; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; -in flat int vs_dc_instanceCoordsI1[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI1; layout(location = 5) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -1004,18 +977,18 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; - dc.instanceIndex[1] = vs_dc_instanceIndexI1[0]; - dc.instanceCoords[0] = vs_dc_instanceCoordsI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; + dc.instanceIndex[1] = vs_interstageDrawingCoord2[0][2]; + dc.instanceCoords[0] = vs_interstageDrawingCoord2[0][3]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1108,18 +1081,18 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; - gs_dc_instanceIndexI1 = dc.instanceIndex[1]; - gs_dc_instanceCoordsI0 = dc.instanceCoords[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; + gs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; + gs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1749,24 +1722,15 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; +in flat ivec4 gs_interstageDrawingCoord3; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceIndexI1; -in flat int gs_dc_instanceCoordsI0; -in flat int gs_dc_instanceCoordsI1; layout(location = 5) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -1843,18 +1807,18 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; - dc.instanceIndex[1] = gs_dc_instanceIndexI1; - dc.instanceCoords[0] = gs_dc_instanceCoordsI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; + dc.instanceIndex[1] = gs_interstageDrawingCoord2[2]; + dc.instanceCoords[0] = gs_interstageDrawingCoord2[3]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2949,25 +2913,16 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; +out flat ivec4 vs_interstageDrawingCoord3; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 5) in int drawingCoordI0; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceIndexI1; -out flat int vs_dc_instanceCoordsI0; -out flat int vs_dc_instanceCoordsI1; layout(location = 6) uniform int *instanceIndices; layout(location = 7) uniform int *culledInstanceIndices; layout(location = 0) uniform ConstantData10 *constantPrimvars; @@ -3090,18 +3045,18 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; - vs_dc_instanceIndexI1 = dc.instanceIndex[1]; - vs_dc_instanceCoordsI0 = dc.instanceCoords[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; + vs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; + vs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -3692,6 +3647,14 @@ out VertexData { } outData; out vec4 gsPatchCoord; out noperspective vec3 hd_barycentricCoord; +in flat ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord2; +in flat ivec4 vs_interstageDrawingCoord3[HD_NUM_PRIMITIVE_VERTS]; +out flat ivec4 gs_interstageDrawingCoord3; in PrimvarData { vec3 points; vec3 normals; @@ -3701,32 +3664,6 @@ out PrimvarData { vec3 normals; vec2 dispTextureCoord; } outPrimvars; -in flat int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_modelCoord; -in flat int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_constantCoord; -in flat int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_elementCoord; -in flat int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_fvarCoord; -in flat int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_shaderCoord; -in flat int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI0; -in flat int vs_dc_instanceIndexI1[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceIndexI1; -in flat int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI0; -in flat int vs_dc_instanceCoordsI1[HD_NUM_PRIMITIVE_VERTS]; -out flat int gs_dc_instanceCoordsI1; layout(location = 5) uniform vec2 *dispTextureCoord; // //////// Codegen Accessors //////// @@ -3789,18 +3726,18 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; - dc.instanceIndex[1] = vs_dc_instanceIndexI1[0]; - dc.instanceCoords[0] = vs_dc_instanceCoordsI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; + dc.instanceIndex[1] = vs_interstageDrawingCoord2[0][2]; + dc.instanceCoords[0] = vs_interstageDrawingCoord2[0][3]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3893,18 +3830,18 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; - gs_dc_instanceIndexI1 = dc.instanceIndex[1]; - gs_dc_instanceCoordsI0 = dc.instanceCoords[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; + gs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; + gs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4563,24 +4500,15 @@ in VertexData { } inData; layout (location = 0) out vec4 colorOut; in noperspective vec3 hd_barycentricCoord; +in flat ivec4 gs_interstageDrawingCoord0; +in flat ivec4 gs_interstageDrawingCoord1; +in flat ivec4 gs_interstageDrawingCoord2; +in flat ivec4 gs_interstageDrawingCoord3; in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; } inPrimvars; -in flat int gs_dc_modelCoord; -in flat int gs_dc_constantCoord; -in flat int gs_dc_elementCoord; -in flat int gs_dc_primitiveCoord; -in flat int gs_dc_fvarCoord; -in flat int gs_dc_shaderCoord; -in flat int gs_dc_vertexCoord; -in flat int gs_dc_topologyVisibilityCoord; -in flat int gs_dc_varyingCoord; -in flat int gs_dc_instanceIndexI0; -in flat int gs_dc_instanceIndexI1; -in flat int gs_dc_instanceCoordsI0; -in flat int gs_dc_instanceCoordsI1; layout(location = 5) uniform vec2 *dispTextureCoord; vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) { @@ -4657,18 +4585,18 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; - dc.instanceIndex[1] = gs_dc_instanceIndexI1; - dc.instanceCoords[0] = gs_dc_instanceCoordsI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; + dc.instanceIndex[1] = gs_interstageDrawingCoord2[2]; + dc.instanceCoords[0] = gs_interstageDrawingCoord2[3]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_bindless.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_bindless.out index fe4aba326c..ebd462d16f 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_bindless.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_bindless.out @@ -159,22 +159,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; out VertexData { vec4 Peye; @@ -250,16 +242,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -1248,21 +1240,13 @@ in VertexData { } inData; in flat int vsPointId; layout (location = 0) out vec4 colorOut; +in flat ivec4 vs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; } inPrimvars; -in flat int vs_dc_modelCoord; -in flat int vs_dc_constantCoord; -in flat int vs_dc_elementCoord; -in flat int vs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord; -in flat int vs_dc_shaderCoord; -in flat int vs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0; // //////// Codegen Accessors //////// mat4 HdGet_transform(int localIndex) { @@ -1311,16 +1295,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord; - dc.constantCoord = vs_dc_constantCoord; - dc.elementCoord = vs_dc_elementCoord; - dc.primitiveCoord = vs_dc_primitiveCoord; - dc.fvarCoord = vs_dc_fvarCoord; - dc.shaderCoord = vs_dc_shaderCoord; - dc.vertexCoord = vs_dc_vertexCoord; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord; - dc.varyingCoord = vs_dc_varyingCoord; - dc.instanceIndex[0] = vs_dc_instanceIndexI0; + dc.modelCoord = vs_interstageDrawingCoord0[0]; + dc.constantCoord = vs_interstageDrawingCoord0[1]; + dc.elementCoord = vs_interstageDrawingCoord0[2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0]; + dc.shaderCoord = vs_interstageDrawingCoord1[1]; + dc.vertexCoord = vs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[1]; return dc; } int GetElementID() { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out index fe4aba326c..ebd462d16f 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out @@ -159,22 +159,14 @@ FORWARD_DECL(int GetElementID()); FORWARD_DECL(int GetAggregatedElementID()); FORWARD_DECL(int GetPrimitiveEdgeId()); FORWARD_DECL(float GetSelectedEdgeOpacity()); +out flat ivec4 vs_interstageDrawingCoord0; +out flat ivec4 vs_interstageDrawingCoord1; +out flat ivec4 vs_interstageDrawingCoord2; layout (location = 2) in ivec4 drawingCoord0; layout (location = 3) in ivec4 drawingCoord1; layout (location = 4) in ivec2 drawingCoord2; layout (location = 0) in vec3 points; layout (location = 1) in vec3 normals; -out flat int vs_dc_modelCoord; -out flat int vs_dc_constantCoord; -out flat int vs_dc_elementCoord; -out flat int vs_dc_primitiveCoord; -out flat int vs_dc_fvarCoord; -out flat int vs_dc_shaderCoord; -out flat int vs_dc_vertexCoord; -out flat int vs_dc_topologyVisibilityCoord; -out flat int vs_dc_varyingCoord; -out flat int vs_dc_instanceIndexI0; -out flat int vs_dc_instanceCoordsI0; layout(location = 0) uniform ConstantData10 *constantPrimvars; out VertexData { vec4 Peye; @@ -250,16 +242,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -1248,21 +1240,13 @@ in VertexData { } inData; in flat int vsPointId; layout (location = 0) out vec4 colorOut; +in flat ivec4 vs_interstageDrawingCoord0; +in flat ivec4 vs_interstageDrawingCoord1; +in flat ivec4 vs_interstageDrawingCoord2; in PrimvarData { vec3 points; vec3 normals; } inPrimvars; -in flat int vs_dc_modelCoord; -in flat int vs_dc_constantCoord; -in flat int vs_dc_elementCoord; -in flat int vs_dc_primitiveCoord; -in flat int vs_dc_fvarCoord; -in flat int vs_dc_shaderCoord; -in flat int vs_dc_vertexCoord; -in flat int vs_dc_topologyVisibilityCoord; -in flat int vs_dc_varyingCoord; -in flat int vs_dc_instanceIndexI0; -in flat int vs_dc_instanceCoordsI0; // //////// Codegen Accessors //////// mat4 HdGet_transform(int localIndex) { @@ -1311,16 +1295,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord; - dc.constantCoord = vs_dc_constantCoord; - dc.elementCoord = vs_dc_elementCoord; - dc.primitiveCoord = vs_dc_primitiveCoord; - dc.fvarCoord = vs_dc_fvarCoord; - dc.shaderCoord = vs_dc_shaderCoord; - dc.vertexCoord = vs_dc_vertexCoord; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord; - dc.varyingCoord = vs_dc_varyingCoord; - dc.instanceIndex[0] = vs_dc_instanceIndexI0; + dc.modelCoord = vs_interstageDrawingCoord0[0]; + dc.constantCoord = vs_interstageDrawingCoord0[1]; + dc.elementCoord = vs_interstageDrawingCoord0[2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0]; + dc.shaderCoord = vs_interstageDrawingCoord1[1]; + dc.vertexCoord = vs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[1]; return dc; } int GetElementID() { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out index 071379f20f..c7b6f0e0d5 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out @@ -166,21 +166,13 @@ layout(location = 1) in vec3 normals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceCoordsI0; -layout(location = 11) out CurveVertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +layout(location = 3) out CurveVertexData { vec4 Peye; } outData; -layout(location = 12) out PrimvarData { +layout(location = 4) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -252,16 +244,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -812,39 +804,23 @@ layout (vertices = HD_NUM_PATCH_EVAL_VERTS) out; // //////// Global Member Declarations //////// layout(std430, binding = 0) readonly buffer ssbo_constantPrimvars { ConstantData7 constantPrimvars[]; }; layout(std430, binding = 1) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[gl_MaxPatchVertices]; -flat layout(location = 1) in int vs_dc_constantCoord[gl_MaxPatchVertices]; -flat layout(location = 2) in int vs_dc_elementCoord[gl_MaxPatchVertices]; -flat layout(location = 3) in int vs_dc_primitiveCoord[gl_MaxPatchVertices]; -flat layout(location = 4) in int vs_dc_fvarCoord[gl_MaxPatchVertices]; -flat layout(location = 5) in int vs_dc_shaderCoord[gl_MaxPatchVertices]; -flat layout(location = 6) in int vs_dc_vertexCoord[gl_MaxPatchVertices]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[gl_MaxPatchVertices]; -flat layout(location = 8) in int vs_dc_varyingCoord[gl_MaxPatchVertices]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[gl_MaxPatchVertices]; -flat layout(location = 10) in int vs_dc_instanceCoordsI0[gl_MaxPatchVertices]; -layout(location = 11) in CurveVertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[gl_MaxPatchVertices]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[gl_MaxPatchVertices]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[gl_MaxPatchVertices]; +layout(location = 3) in CurveVertexData { vec4 Peye; } inData[gl_MaxPatchVertices]; -layout(location = 12) in PrimvarData { +layout(location = 4) in PrimvarData { vec3 points; vec3 normals; } inPrimvars[gl_MaxPatchVertices]; -flat layout(location = 3) out int tcs_dc_modelCoord[HD_NUM_PATCH_EVAL_VERTS]; -flat layout(location = 4) out int tcs_dc_constantCoord[HD_NUM_PATCH_EVAL_VERTS]; -flat layout(location = 5) out int tcs_dc_elementCoord[HD_NUM_PATCH_EVAL_VERTS]; -flat layout(location = 6) out int tcs_dc_primitiveCoord[HD_NUM_PATCH_EVAL_VERTS]; -flat layout(location = 7) out int tcs_dc_fvarCoord[HD_NUM_PATCH_EVAL_VERTS]; -flat layout(location = 8) out int tcs_dc_shaderCoord[HD_NUM_PATCH_EVAL_VERTS]; -flat layout(location = 9) out int tcs_dc_vertexCoord[HD_NUM_PATCH_EVAL_VERTS]; -flat layout(location = 10) out int tcs_dc_topologyVisibilityCoord[HD_NUM_PATCH_EVAL_VERTS]; -flat layout(location = 11) out int tcs_dc_varyingCoord[HD_NUM_PATCH_EVAL_VERTS]; -flat layout(location = 12) out int tcs_dc_instanceIndexI0[HD_NUM_PATCH_EVAL_VERTS]; -flat layout(location = 13) out int tcs_dc_instanceCoordsI0[HD_NUM_PATCH_EVAL_VERTS]; +flat layout(location = 1) out ivec4 tcs_interstageDrawingCoord0[HD_NUM_PATCH_EVAL_VERTS]; +flat layout(location = 2) out ivec4 tcs_interstageDrawingCoord1[HD_NUM_PATCH_EVAL_VERTS]; +flat layout(location = 3) out ivec4 tcs_interstageDrawingCoord2[HD_NUM_PATCH_EVAL_VERTS]; layout(location = 0) out CurveVertexData { vec4 Peye; } outData[HD_NUM_PATCH_EVAL_VERTS]; -layout(location = 1) out PrimvarData { +layout(location = 4) out PrimvarData { vec3 points; vec3 normals; } outPrimvars[HD_NUM_PATCH_EVAL_VERTS]; @@ -894,16 +870,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int GetElementID() { @@ -958,16 +934,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc TCS //////// void ProcessPrimvarsOut() { hd_drawingCoord dc = GetDrawingCoord(); - tcs_dc_modelCoord[gl_InvocationID] = dc.modelCoord; - tcs_dc_constantCoord[gl_InvocationID] = dc.constantCoord; - tcs_dc_elementCoord[gl_InvocationID] = dc.elementCoord; - tcs_dc_primitiveCoord[gl_InvocationID] = dc.primitiveCoord; - tcs_dc_fvarCoord[gl_InvocationID] = dc.fvarCoord; - tcs_dc_shaderCoord[gl_InvocationID] = dc.shaderCoord; - tcs_dc_vertexCoord[gl_InvocationID] = dc.vertexCoord; - tcs_dc_topologyVisibilityCoord[gl_InvocationID] = dc.topologyVisibilityCoord; - tcs_dc_varyingCoord[gl_InvocationID] = dc.varyingCoord; - tcs_dc_instanceIndexI0[gl_InvocationID] = dc.instanceIndex[0]; + tcs_interstageDrawingCoord0[gl_InvocationID][0] = dc.modelCoord; + tcs_interstageDrawingCoord0[gl_InvocationID][1] = dc.constantCoord; + tcs_interstageDrawingCoord0[gl_InvocationID][2] = dc.elementCoord; + tcs_interstageDrawingCoord0[gl_InvocationID][3] = dc.primitiveCoord; + tcs_interstageDrawingCoord1[gl_InvocationID][0] = dc.fvarCoord; + tcs_interstageDrawingCoord1[gl_InvocationID][1] = dc.shaderCoord; + tcs_interstageDrawingCoord1[gl_InvocationID][2] = dc.vertexCoord; + tcs_interstageDrawingCoord1[gl_InvocationID][3] = dc.topologyVisibilityCoord; + tcs_interstageDrawingCoord2[gl_InvocationID][0] = dc.varyingCoord; + tcs_interstageDrawingCoord2[gl_InvocationID][1] = dc.instanceIndex[0]; outPrimvars[gl_InvocationID].points = inPrimvars[gl_InvocationID].points; outPrimvars[gl_InvocationID].normals = inPrimvars[gl_InvocationID].normals; } @@ -1338,39 +1314,23 @@ layout (cw) in; // //////// Global Member Declarations //////// layout(std430, binding = 0) readonly buffer ssbo_constantPrimvars { ConstantData7 constantPrimvars[]; }; layout(std430, binding = 1) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; -flat layout(location = 3) in int tcs_dc_modelCoord[gl_MaxPatchVertices]; -flat layout(location = 4) in int tcs_dc_constantCoord[gl_MaxPatchVertices]; -flat layout(location = 5) in int tcs_dc_elementCoord[gl_MaxPatchVertices]; -flat layout(location = 6) in int tcs_dc_primitiveCoord[gl_MaxPatchVertices]; -flat layout(location = 7) in int tcs_dc_fvarCoord[gl_MaxPatchVertices]; -flat layout(location = 8) in int tcs_dc_shaderCoord[gl_MaxPatchVertices]; -flat layout(location = 9) in int tcs_dc_vertexCoord[gl_MaxPatchVertices]; -flat layout(location = 10) in int tcs_dc_topologyVisibilityCoord[gl_MaxPatchVertices]; -flat layout(location = 11) in int tcs_dc_varyingCoord[gl_MaxPatchVertices]; -flat layout(location = 12) in int tcs_dc_instanceIndexI0[gl_MaxPatchVertices]; -flat layout(location = 13) in int tcs_dc_instanceCoordsI0[gl_MaxPatchVertices]; +flat layout(location = 1) in ivec4 tcs_interstageDrawingCoord0[gl_MaxPatchVertices]; +flat layout(location = 2) in ivec4 tcs_interstageDrawingCoord1[gl_MaxPatchVertices]; +flat layout(location = 3) in ivec4 tcs_interstageDrawingCoord2[gl_MaxPatchVertices]; layout(location = 0) in CurveVertexData { vec4 Peye; } inData[gl_MaxPatchVertices]; -layout(location = 1) in PrimvarData { +layout(location = 4) in PrimvarData { vec3 points; vec3 normals; } inPrimvars[gl_MaxPatchVertices]; -flat layout(location = 3) out int tes_dc_modelCoord; -flat layout(location = 4) out int tes_dc_constantCoord; -flat layout(location = 5) out int tes_dc_elementCoord; -flat layout(location = 6) out int tes_dc_primitiveCoord; -flat layout(location = 7) out int tes_dc_fvarCoord; -flat layout(location = 8) out int tes_dc_shaderCoord; -flat layout(location = 9) out int tes_dc_vertexCoord; -flat layout(location = 10) out int tes_dc_topologyVisibilityCoord; -flat layout(location = 11) out int tes_dc_varyingCoord; -flat layout(location = 12) out int tes_dc_instanceIndexI0; -flat layout(location = 13) out int tes_dc_instanceCoordsI0; +flat layout(location = 1) out ivec4 tes_interstageDrawingCoord0; +flat layout(location = 2) out ivec4 tes_interstageDrawingCoord1; +flat layout(location = 3) out ivec4 tes_interstageDrawingCoord2; layout(location = 0) out CurveVertexData { vec4 Peye; } outData; -layout(location = 1) out PrimvarData { +layout(location = 4) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -1420,16 +1380,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = tcs_dc_modelCoord[0]; - dc.constantCoord = tcs_dc_constantCoord[0]; - dc.elementCoord = tcs_dc_elementCoord[0]; - dc.primitiveCoord = tcs_dc_primitiveCoord[0]; - dc.fvarCoord = tcs_dc_fvarCoord[0]; - dc.shaderCoord = tcs_dc_shaderCoord[0]; - dc.vertexCoord = tcs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = tcs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = tcs_dc_varyingCoord[0]; - dc.instanceIndex[0] = tcs_dc_instanceIndexI0[0]; + dc.modelCoord = tcs_interstageDrawingCoord0[0][0]; + dc.constantCoord = tcs_interstageDrawingCoord0[0][1]; + dc.elementCoord = tcs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = tcs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = tcs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = tcs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = tcs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = tcs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = tcs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = tcs_interstageDrawingCoord2[0][1]; return dc; } int GetElementID() { @@ -1488,16 +1448,16 @@ vec3 InterpolatePrimvar(vec3 inPv0, vec3 inPv1, vec3 inPv2, vec3 inPv3, vec4 bas vec4 InterpolatePrimvar(vec4 inPv0, vec4 inPv1, vec4 inPv3, vec4 inPv3, vec4 basis, vec2 uv); void ProcessPrimvarsOut(vec4 basis, int i0, int i1, int i2, int i3, vec2 uv) { hd_drawingCoord dc = GetDrawingCoord(); - tes_dc_modelCoord = dc.modelCoord; - tes_dc_constantCoord = dc.constantCoord; - tes_dc_elementCoord = dc.elementCoord; - tes_dc_primitiveCoord = dc.primitiveCoord; - tes_dc_fvarCoord = dc.fvarCoord; - tes_dc_shaderCoord = dc.shaderCoord; - tes_dc_vertexCoord = dc.vertexCoord; - tes_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - tes_dc_varyingCoord = dc.varyingCoord; - tes_dc_instanceIndexI0 = dc.instanceIndex[0]; + tes_interstageDrawingCoord0[0] = dc.modelCoord; + tes_interstageDrawingCoord0[1] = dc.constantCoord; + tes_interstageDrawingCoord0[2] = dc.elementCoord; + tes_interstageDrawingCoord0[3] = dc.primitiveCoord; + tes_interstageDrawingCoord1[0] = dc.fvarCoord; + tes_interstageDrawingCoord1[1] = dc.shaderCoord; + tes_interstageDrawingCoord1[2] = dc.vertexCoord; + tes_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + tes_interstageDrawingCoord2[0] = dc.varyingCoord; + tes_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = basis[0] * inPrimvars[i0].points + basis[1] * inPrimvars[i1].points + basis[2] * inPrimvars[i2].points + basis[3] * inPrimvars[i3].points; outPrimvars.normals = basis[0] * inPrimvars[i0].normals + basis[1] * inPrimvars[i1].normals + basis[2] * inPrimvars[i2].normals + basis[3] * inPrimvars[i3].normals; } @@ -2101,21 +2061,13 @@ FORWARD_DECL(float GetSelectedEdgeOpacity()); // //////// Global Member Declarations //////// layout(std430, binding = 0) readonly buffer ssbo_constantPrimvars { ConstantData7 constantPrimvars[]; }; layout(std430, binding = 1) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; -flat layout(location = 3) in int tes_dc_modelCoord; -flat layout(location = 4) in int tes_dc_constantCoord; -flat layout(location = 5) in int tes_dc_elementCoord; -flat layout(location = 6) in int tes_dc_primitiveCoord; -flat layout(location = 7) in int tes_dc_fvarCoord; -flat layout(location = 8) in int tes_dc_shaderCoord; -flat layout(location = 9) in int tes_dc_vertexCoord; -flat layout(location = 10) in int tes_dc_topologyVisibilityCoord; -flat layout(location = 11) in int tes_dc_varyingCoord; -flat layout(location = 12) in int tes_dc_instanceIndexI0; -flat layout(location = 13) in int tes_dc_instanceCoordsI0; +flat layout(location = 1) in ivec4 tes_interstageDrawingCoord0; +flat layout(location = 2) in ivec4 tes_interstageDrawingCoord1; +flat layout(location = 3) in ivec4 tes_interstageDrawingCoord2; layout(location = 0) in CurveVertexData { vec4 Peye; } inData; -layout(location = 1) in PrimvarData { +layout(location = 4) in PrimvarData { vec3 points; vec3 normals; } inPrimvars; @@ -2170,16 +2122,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = tes_dc_modelCoord; - dc.constantCoord = tes_dc_constantCoord; - dc.elementCoord = tes_dc_elementCoord; - dc.primitiveCoord = tes_dc_primitiveCoord; - dc.fvarCoord = tes_dc_fvarCoord; - dc.shaderCoord = tes_dc_shaderCoord; - dc.vertexCoord = tes_dc_vertexCoord; - dc.topologyVisibilityCoord = tes_dc_topologyVisibilityCoord; - dc.varyingCoord = tes_dc_varyingCoord; - dc.instanceIndex[0] = tes_dc_instanceIndexI0; + dc.modelCoord = tes_interstageDrawingCoord0[0]; + dc.constantCoord = tes_interstageDrawingCoord0[1]; + dc.elementCoord = tes_interstageDrawingCoord0[2]; + dc.primitiveCoord = tes_interstageDrawingCoord0[3]; + dc.fvarCoord = tes_interstageDrawingCoord1[0]; + dc.shaderCoord = tes_interstageDrawingCoord1[1]; + dc.vertexCoord = tes_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = tes_interstageDrawingCoord1[3]; + dc.varyingCoord = tes_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = tes_interstageDrawingCoord2[1]; return dc; } int GetElementID() { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out index d2f21a241a..b9234ebf1a 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out @@ -166,22 +166,14 @@ layout(location = 1) in vec3 normals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceCoordsI0; -layout(location = 11) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +layout(location = 3) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 13) out PrimvarData { +layout(location = 5) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -253,16 +245,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -831,43 +823,27 @@ layout(std430, binding = 1) readonly buffer ssbo_primitiveParam { int primitiveP layout(std430, binding = 2) readonly buffer ssbo_edgeIndices { int edgeIndices[]; }; layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 1) in int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 2) in int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 3) in int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 4) in int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 5) in int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 6) in int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 8) in int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 10) in int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -layout(location = 11) in VertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +layout(location = 3) in VertexData { vec4 Peye; vec3 Neye; } inData[3]; -layout(location = 13) in PrimvarData { +layout(location = 5) in PrimvarData { vec3 points; vec3 normals; } inPrimvars[HD_NUM_PRIMITIVE_VERTS]; layout(location = 2) out vec4 gsPatchCoord; noperspective layout(location = 3) out vec3 hd_barycentricCoord; -flat layout(location = 7) out int gs_dc_modelCoord; -flat layout(location = 8) out int gs_dc_constantCoord; -flat layout(location = 9) out int gs_dc_elementCoord; -flat layout(location = 10) out int gs_dc_primitiveCoord; -flat layout(location = 11) out int gs_dc_fvarCoord; -flat layout(location = 12) out int gs_dc_shaderCoord; -flat layout(location = 13) out int gs_dc_vertexCoord; -flat layout(location = 14) out int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) out int gs_dc_varyingCoord; -flat layout(location = 16) out int gs_dc_instanceIndexI0; -flat layout(location = 17) out int gs_dc_instanceCoordsI0; +flat layout(location = 4) out ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) out ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) out ivec4 gs_interstageDrawingCoord2; layout(location = 0) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 4) out PrimvarData { +layout(location = 7) out PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -918,16 +894,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1020,16 +996,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1651,22 +1627,14 @@ layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisi layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; layout(location = 2) in vec4 gsPatchCoord; noperspective layout(location = 3) in vec3 hd_barycentricCoord; -flat layout(location = 7) in int gs_dc_modelCoord; -flat layout(location = 8) in int gs_dc_constantCoord; -flat layout(location = 9) in int gs_dc_elementCoord; -flat layout(location = 10) in int gs_dc_primitiveCoord; -flat layout(location = 11) in int gs_dc_fvarCoord; -flat layout(location = 12) in int gs_dc_shaderCoord; -flat layout(location = 13) in int gs_dc_vertexCoord; -flat layout(location = 14) in int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) in int gs_dc_varyingCoord; -flat layout(location = 16) in int gs_dc_instanceIndexI0; -flat layout(location = 17) in int gs_dc_instanceCoordsI0; +flat layout(location = 4) in ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) in ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) in ivec4 gs_interstageDrawingCoord2; layout(location = 0) in VertexData { vec4 Peye; vec3 Neye; } inData; -layout(location = 4) in PrimvarData { +layout(location = 7) in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -1722,16 +1690,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2877,22 +2845,14 @@ layout(location = 1) in vec3 normals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceCoordsI0; -layout(location = 11) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +layout(location = 3) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 13) out PrimvarData { +layout(location = 5) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -2964,16 +2924,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -3542,43 +3502,27 @@ layout(std430, binding = 1) readonly buffer ssbo_primitiveParam { int primitiveP layout(std430, binding = 2) readonly buffer ssbo_edgeIndices { ivec2 edgeIndices[]; }; layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 1) in int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 2) in int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 3) in int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 4) in int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 5) in int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 6) in int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 8) in int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 10) in int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -layout(location = 11) in VertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +layout(location = 3) in VertexData { vec4 Peye; vec3 Neye; } inData[4]; -layout(location = 13) in PrimvarData { +layout(location = 5) in PrimvarData { vec3 points; vec3 normals; } inPrimvars[HD_NUM_PRIMITIVE_VERTS]; layout(location = 2) out vec4 gsPatchCoord; noperspective layout(location = 3) out vec3 hd_barycentricCoord; -flat layout(location = 7) out int gs_dc_modelCoord; -flat layout(location = 8) out int gs_dc_constantCoord; -flat layout(location = 9) out int gs_dc_elementCoord; -flat layout(location = 10) out int gs_dc_primitiveCoord; -flat layout(location = 11) out int gs_dc_fvarCoord; -flat layout(location = 12) out int gs_dc_shaderCoord; -flat layout(location = 13) out int gs_dc_vertexCoord; -flat layout(location = 14) out int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) out int gs_dc_varyingCoord; -flat layout(location = 16) out int gs_dc_instanceIndexI0; -flat layout(location = 17) out int gs_dc_instanceCoordsI0; +flat layout(location = 4) out ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) out ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) out ivec4 gs_interstageDrawingCoord2; layout(location = 0) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 4) out PrimvarData { +layout(location = 7) out PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -3629,16 +3573,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3731,16 +3675,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4391,22 +4335,14 @@ layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisi layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; layout(location = 2) in vec4 gsPatchCoord; noperspective layout(location = 3) in vec3 hd_barycentricCoord; -flat layout(location = 7) in int gs_dc_modelCoord; -flat layout(location = 8) in int gs_dc_constantCoord; -flat layout(location = 9) in int gs_dc_elementCoord; -flat layout(location = 10) in int gs_dc_primitiveCoord; -flat layout(location = 11) in int gs_dc_fvarCoord; -flat layout(location = 12) in int gs_dc_shaderCoord; -flat layout(location = 13) in int gs_dc_vertexCoord; -flat layout(location = 14) in int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) in int gs_dc_varyingCoord; -flat layout(location = 16) in int gs_dc_instanceIndexI0; -flat layout(location = 17) in int gs_dc_instanceCoordsI0; +flat layout(location = 4) in ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) in ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) in ivec4 gs_interstageDrawingCoord2; layout(location = 0) in VertexData { vec4 Peye; vec3 Neye; } inData; -layout(location = 4) in PrimvarData { +layout(location = 7) in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -4462,16 +4398,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out index 97c1426762..bf10479360 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out @@ -166,22 +166,14 @@ layout(location = 1) in vec3 normals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceCoordsI0; -layout(location = 11) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +layout(location = 3) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 13) out PrimvarData { +layout(location = 5) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -253,16 +245,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -831,43 +823,27 @@ layout(std430, binding = 1) readonly buffer ssbo_primitiveParam { int primitiveP layout(std430, binding = 2) readonly buffer ssbo_edgeIndices { int edgeIndices[]; }; layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 1) in int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 2) in int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 3) in int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 4) in int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 5) in int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 6) in int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 8) in int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 10) in int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -layout(location = 11) in VertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +layout(location = 3) in VertexData { vec4 Peye; vec3 Neye; } inData[3]; -layout(location = 13) in PrimvarData { +layout(location = 5) in PrimvarData { vec3 points; vec3 normals; } inPrimvars[HD_NUM_PRIMITIVE_VERTS]; layout(location = 2) out vec4 gsPatchCoord; noperspective layout(location = 3) out vec3 hd_barycentricCoord; -flat layout(location = 7) out int gs_dc_modelCoord; -flat layout(location = 8) out int gs_dc_constantCoord; -flat layout(location = 9) out int gs_dc_elementCoord; -flat layout(location = 10) out int gs_dc_primitiveCoord; -flat layout(location = 11) out int gs_dc_fvarCoord; -flat layout(location = 12) out int gs_dc_shaderCoord; -flat layout(location = 13) out int gs_dc_vertexCoord; -flat layout(location = 14) out int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) out int gs_dc_varyingCoord; -flat layout(location = 16) out int gs_dc_instanceIndexI0; -flat layout(location = 17) out int gs_dc_instanceCoordsI0; +flat layout(location = 4) out ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) out ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) out ivec4 gs_interstageDrawingCoord2; layout(location = 0) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 4) out PrimvarData { +layout(location = 7) out PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -918,16 +894,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1020,16 +996,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1651,22 +1627,14 @@ layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisi layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; layout(location = 2) in vec4 gsPatchCoord; noperspective layout(location = 3) in vec3 hd_barycentricCoord; -flat layout(location = 7) in int gs_dc_modelCoord; -flat layout(location = 8) in int gs_dc_constantCoord; -flat layout(location = 9) in int gs_dc_elementCoord; -flat layout(location = 10) in int gs_dc_primitiveCoord; -flat layout(location = 11) in int gs_dc_fvarCoord; -flat layout(location = 12) in int gs_dc_shaderCoord; -flat layout(location = 13) in int gs_dc_vertexCoord; -flat layout(location = 14) in int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) in int gs_dc_varyingCoord; -flat layout(location = 16) in int gs_dc_instanceIndexI0; -flat layout(location = 17) in int gs_dc_instanceCoordsI0; +flat layout(location = 4) in ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) in ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) in ivec4 gs_interstageDrawingCoord2; layout(location = 0) in VertexData { vec4 Peye; vec3 Neye; } inData; -layout(location = 4) in PrimvarData { +layout(location = 7) in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -1722,16 +1690,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2883,22 +2851,14 @@ layout(location = 1) in vec3 normals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceCoordsI0; -layout(location = 11) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +layout(location = 3) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 13) out PrimvarData { +layout(location = 5) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -2970,16 +2930,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -3548,43 +3508,27 @@ layout(std430, binding = 1) readonly buffer ssbo_primitiveParam { int primitiveP layout(std430, binding = 2) readonly buffer ssbo_edgeIndices { ivec2 edgeIndices[]; }; layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 1) in int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 2) in int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 3) in int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 4) in int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 5) in int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 6) in int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 8) in int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 10) in int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -layout(location = 11) in VertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +layout(location = 3) in VertexData { vec4 Peye; vec3 Neye; } inData[4]; -layout(location = 13) in PrimvarData { +layout(location = 5) in PrimvarData { vec3 points; vec3 normals; } inPrimvars[HD_NUM_PRIMITIVE_VERTS]; layout(location = 2) out vec4 gsPatchCoord; noperspective layout(location = 3) out vec3 hd_barycentricCoord; -flat layout(location = 7) out int gs_dc_modelCoord; -flat layout(location = 8) out int gs_dc_constantCoord; -flat layout(location = 9) out int gs_dc_elementCoord; -flat layout(location = 10) out int gs_dc_primitiveCoord; -flat layout(location = 11) out int gs_dc_fvarCoord; -flat layout(location = 12) out int gs_dc_shaderCoord; -flat layout(location = 13) out int gs_dc_vertexCoord; -flat layout(location = 14) out int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) out int gs_dc_varyingCoord; -flat layout(location = 16) out int gs_dc_instanceIndexI0; -flat layout(location = 17) out int gs_dc_instanceCoordsI0; +flat layout(location = 4) out ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) out ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) out ivec4 gs_interstageDrawingCoord2; layout(location = 0) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 4) out PrimvarData { +layout(location = 7) out PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -3635,16 +3579,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3737,16 +3681,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4397,22 +4341,14 @@ layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisi layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; layout(location = 2) in vec4 gsPatchCoord; noperspective layout(location = 3) in vec3 hd_barycentricCoord; -flat layout(location = 7) in int gs_dc_modelCoord; -flat layout(location = 8) in int gs_dc_constantCoord; -flat layout(location = 9) in int gs_dc_elementCoord; -flat layout(location = 10) in int gs_dc_primitiveCoord; -flat layout(location = 11) in int gs_dc_fvarCoord; -flat layout(location = 12) in int gs_dc_shaderCoord; -flat layout(location = 13) in int gs_dc_vertexCoord; -flat layout(location = 14) in int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) in int gs_dc_varyingCoord; -flat layout(location = 16) in int gs_dc_instanceIndexI0; -flat layout(location = 17) in int gs_dc_instanceCoordsI0; +flat layout(location = 4) in ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) in ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) in ivec4 gs_interstageDrawingCoord2; layout(location = 0) in VertexData { vec4 Peye; vec3 Neye; } inData; -layout(location = 4) in PrimvarData { +layout(location = 7) in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -4468,16 +4404,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out index ccc3bbfadc..f95f474377 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out @@ -166,22 +166,14 @@ layout(location = 1) in vec3 normals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceCoordsI0; -layout(location = 11) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +layout(location = 3) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 13) out PrimvarData { +layout(location = 5) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -253,16 +245,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -831,43 +823,27 @@ layout(std430, binding = 1) readonly buffer ssbo_primitiveParam { int primitiveP layout(std430, binding = 2) readonly buffer ssbo_edgeIndices { int edgeIndices[]; }; layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 1) in int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 2) in int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 3) in int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 4) in int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 5) in int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 6) in int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 8) in int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 10) in int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -layout(location = 11) in VertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +layout(location = 3) in VertexData { vec4 Peye; vec3 Neye; } inData[3]; -layout(location = 13) in PrimvarData { +layout(location = 5) in PrimvarData { vec3 points; vec3 normals; } inPrimvars[HD_NUM_PRIMITIVE_VERTS]; layout(location = 2) out vec4 gsPatchCoord; noperspective layout(location = 3) out vec3 hd_barycentricCoord; -flat layout(location = 7) out int gs_dc_modelCoord; -flat layout(location = 8) out int gs_dc_constantCoord; -flat layout(location = 9) out int gs_dc_elementCoord; -flat layout(location = 10) out int gs_dc_primitiveCoord; -flat layout(location = 11) out int gs_dc_fvarCoord; -flat layout(location = 12) out int gs_dc_shaderCoord; -flat layout(location = 13) out int gs_dc_vertexCoord; -flat layout(location = 14) out int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) out int gs_dc_varyingCoord; -flat layout(location = 16) out int gs_dc_instanceIndexI0; -flat layout(location = 17) out int gs_dc_instanceCoordsI0; +flat layout(location = 4) out ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) out ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) out ivec4 gs_interstageDrawingCoord2; layout(location = 0) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 4) out PrimvarData { +layout(location = 7) out PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -918,16 +894,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1020,16 +996,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1651,22 +1627,14 @@ layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisi layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; layout(location = 2) in vec4 gsPatchCoord; noperspective layout(location = 3) in vec3 hd_barycentricCoord; -flat layout(location = 7) in int gs_dc_modelCoord; -flat layout(location = 8) in int gs_dc_constantCoord; -flat layout(location = 9) in int gs_dc_elementCoord; -flat layout(location = 10) in int gs_dc_primitiveCoord; -flat layout(location = 11) in int gs_dc_fvarCoord; -flat layout(location = 12) in int gs_dc_shaderCoord; -flat layout(location = 13) in int gs_dc_vertexCoord; -flat layout(location = 14) in int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) in int gs_dc_varyingCoord; -flat layout(location = 16) in int gs_dc_instanceIndexI0; -flat layout(location = 17) in int gs_dc_instanceCoordsI0; +flat layout(location = 4) in ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) in ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) in ivec4 gs_interstageDrawingCoord2; layout(location = 0) in VertexData { vec4 Peye; vec3 Neye; } inData; -layout(location = 4) in PrimvarData { +layout(location = 7) in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -1722,16 +1690,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2828,22 +2796,14 @@ layout(location = 1) in vec3 normals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceCoordsI0; -layout(location = 11) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +layout(location = 3) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 13) out PrimvarData { +layout(location = 5) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -2915,16 +2875,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -3493,43 +3453,27 @@ layout(std430, binding = 1) readonly buffer ssbo_primitiveParam { int primitiveP layout(std430, binding = 2) readonly buffer ssbo_edgeIndices { ivec2 edgeIndices[]; }; layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 1) in int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 2) in int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 3) in int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 4) in int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 5) in int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 6) in int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 8) in int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 10) in int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -layout(location = 11) in VertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +layout(location = 3) in VertexData { vec4 Peye; vec3 Neye; } inData[4]; -layout(location = 13) in PrimvarData { +layout(location = 5) in PrimvarData { vec3 points; vec3 normals; } inPrimvars[HD_NUM_PRIMITIVE_VERTS]; layout(location = 2) out vec4 gsPatchCoord; noperspective layout(location = 3) out vec3 hd_barycentricCoord; -flat layout(location = 7) out int gs_dc_modelCoord; -flat layout(location = 8) out int gs_dc_constantCoord; -flat layout(location = 9) out int gs_dc_elementCoord; -flat layout(location = 10) out int gs_dc_primitiveCoord; -flat layout(location = 11) out int gs_dc_fvarCoord; -flat layout(location = 12) out int gs_dc_shaderCoord; -flat layout(location = 13) out int gs_dc_vertexCoord; -flat layout(location = 14) out int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) out int gs_dc_varyingCoord; -flat layout(location = 16) out int gs_dc_instanceIndexI0; -flat layout(location = 17) out int gs_dc_instanceCoordsI0; +flat layout(location = 4) out ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) out ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) out ivec4 gs_interstageDrawingCoord2; layout(location = 0) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 4) out PrimvarData { +layout(location = 7) out PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -3580,16 +3524,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3682,16 +3626,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4342,22 +4286,14 @@ layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisi layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; layout(location = 2) in vec4 gsPatchCoord; noperspective layout(location = 3) in vec3 hd_barycentricCoord; -flat layout(location = 7) in int gs_dc_modelCoord; -flat layout(location = 8) in int gs_dc_constantCoord; -flat layout(location = 9) in int gs_dc_elementCoord; -flat layout(location = 10) in int gs_dc_primitiveCoord; -flat layout(location = 11) in int gs_dc_fvarCoord; -flat layout(location = 12) in int gs_dc_shaderCoord; -flat layout(location = 13) in int gs_dc_vertexCoord; -flat layout(location = 14) in int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) in int gs_dc_varyingCoord; -flat layout(location = 16) in int gs_dc_instanceIndexI0; -flat layout(location = 17) in int gs_dc_instanceCoordsI0; +flat layout(location = 4) in ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) in ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) in ivec4 gs_interstageDrawingCoord2; layout(location = 0) in VertexData { vec4 Peye; vec3 Neye; } inData; -layout(location = 4) in PrimvarData { +layout(location = 7) in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -4413,16 +4349,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out index d5bfce162e..3ca7b27104 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out @@ -166,22 +166,14 @@ layout(location = 1) in vec3 normals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceCoordsI0; -layout(location = 11) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +layout(location = 3) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 13) out PrimvarData { +layout(location = 5) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -253,16 +245,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -831,43 +823,27 @@ layout(std430, binding = 1) readonly buffer ssbo_primitiveParam { int primitiveP layout(std430, binding = 2) readonly buffer ssbo_edgeIndices { int edgeIndices[]; }; layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 1) in int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 2) in int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 3) in int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 4) in int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 5) in int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 6) in int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 8) in int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 10) in int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -layout(location = 11) in VertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +layout(location = 3) in VertexData { vec4 Peye; vec3 Neye; } inData[3]; -layout(location = 13) in PrimvarData { +layout(location = 5) in PrimvarData { vec3 points; vec3 normals; } inPrimvars[HD_NUM_PRIMITIVE_VERTS]; layout(location = 2) out vec4 gsPatchCoord; noperspective layout(location = 3) out vec3 hd_barycentricCoord; -flat layout(location = 7) out int gs_dc_modelCoord; -flat layout(location = 8) out int gs_dc_constantCoord; -flat layout(location = 9) out int gs_dc_elementCoord; -flat layout(location = 10) out int gs_dc_primitiveCoord; -flat layout(location = 11) out int gs_dc_fvarCoord; -flat layout(location = 12) out int gs_dc_shaderCoord; -flat layout(location = 13) out int gs_dc_vertexCoord; -flat layout(location = 14) out int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) out int gs_dc_varyingCoord; -flat layout(location = 16) out int gs_dc_instanceIndexI0; -flat layout(location = 17) out int gs_dc_instanceCoordsI0; +flat layout(location = 4) out ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) out ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) out ivec4 gs_interstageDrawingCoord2; layout(location = 0) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 4) out PrimvarData { +layout(location = 7) out PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -918,16 +894,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1020,16 +996,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1651,22 +1627,14 @@ layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisi layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; layout(location = 2) in vec4 gsPatchCoord; noperspective layout(location = 3) in vec3 hd_barycentricCoord; -flat layout(location = 7) in int gs_dc_modelCoord; -flat layout(location = 8) in int gs_dc_constantCoord; -flat layout(location = 9) in int gs_dc_elementCoord; -flat layout(location = 10) in int gs_dc_primitiveCoord; -flat layout(location = 11) in int gs_dc_fvarCoord; -flat layout(location = 12) in int gs_dc_shaderCoord; -flat layout(location = 13) in int gs_dc_vertexCoord; -flat layout(location = 14) in int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) in int gs_dc_varyingCoord; -flat layout(location = 16) in int gs_dc_instanceIndexI0; -flat layout(location = 17) in int gs_dc_instanceCoordsI0; +flat layout(location = 4) in ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) in ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) in ivec4 gs_interstageDrawingCoord2; layout(location = 0) in VertexData { vec4 Peye; vec3 Neye; } inData; -layout(location = 4) in PrimvarData { +layout(location = 7) in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -1722,16 +1690,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2827,22 +2795,14 @@ layout(location = 1) in vec3 normals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceCoordsI0; -layout(location = 11) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +layout(location = 3) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 13) out PrimvarData { +layout(location = 5) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -2914,16 +2874,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -3492,43 +3452,27 @@ layout(std430, binding = 1) readonly buffer ssbo_primitiveParam { int primitiveP layout(std430, binding = 2) readonly buffer ssbo_edgeIndices { ivec2 edgeIndices[]; }; layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 1) in int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 2) in int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 3) in int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 4) in int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 5) in int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 6) in int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 8) in int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 10) in int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -layout(location = 11) in VertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +layout(location = 3) in VertexData { vec4 Peye; vec3 Neye; } inData[4]; -layout(location = 13) in PrimvarData { +layout(location = 5) in PrimvarData { vec3 points; vec3 normals; } inPrimvars[HD_NUM_PRIMITIVE_VERTS]; layout(location = 2) out vec4 gsPatchCoord; noperspective layout(location = 3) out vec3 hd_barycentricCoord; -flat layout(location = 7) out int gs_dc_modelCoord; -flat layout(location = 8) out int gs_dc_constantCoord; -flat layout(location = 9) out int gs_dc_elementCoord; -flat layout(location = 10) out int gs_dc_primitiveCoord; -flat layout(location = 11) out int gs_dc_fvarCoord; -flat layout(location = 12) out int gs_dc_shaderCoord; -flat layout(location = 13) out int gs_dc_vertexCoord; -flat layout(location = 14) out int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) out int gs_dc_varyingCoord; -flat layout(location = 16) out int gs_dc_instanceIndexI0; -flat layout(location = 17) out int gs_dc_instanceCoordsI0; +flat layout(location = 4) out ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) out ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) out ivec4 gs_interstageDrawingCoord2; layout(location = 0) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 4) out PrimvarData { +layout(location = 7) out PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -3579,16 +3523,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3681,16 +3625,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4341,22 +4285,14 @@ layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisi layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; layout(location = 2) in vec4 gsPatchCoord; noperspective layout(location = 3) in vec3 hd_barycentricCoord; -flat layout(location = 7) in int gs_dc_modelCoord; -flat layout(location = 8) in int gs_dc_constantCoord; -flat layout(location = 9) in int gs_dc_elementCoord; -flat layout(location = 10) in int gs_dc_primitiveCoord; -flat layout(location = 11) in int gs_dc_fvarCoord; -flat layout(location = 12) in int gs_dc_shaderCoord; -flat layout(location = 13) in int gs_dc_vertexCoord; -flat layout(location = 14) in int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) in int gs_dc_varyingCoord; -flat layout(location = 16) in int gs_dc_instanceIndexI0; -flat layout(location = 17) in int gs_dc_instanceCoordsI0; +flat layout(location = 4) in ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) in ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) in ivec4 gs_interstageDrawingCoord2; layout(location = 0) in VertexData { vec4 Peye; vec3 Neye; } inData; -layout(location = 4) in PrimvarData { +layout(location = 7) in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -4412,16 +4348,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out index ccc3bbfadc..f95f474377 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out @@ -166,22 +166,14 @@ layout(location = 1) in vec3 normals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceCoordsI0; -layout(location = 11) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +layout(location = 3) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 13) out PrimvarData { +layout(location = 5) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -253,16 +245,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -831,43 +823,27 @@ layout(std430, binding = 1) readonly buffer ssbo_primitiveParam { int primitiveP layout(std430, binding = 2) readonly buffer ssbo_edgeIndices { int edgeIndices[]; }; layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 1) in int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 2) in int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 3) in int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 4) in int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 5) in int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 6) in int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 8) in int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 10) in int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -layout(location = 11) in VertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +layout(location = 3) in VertexData { vec4 Peye; vec3 Neye; } inData[3]; -layout(location = 13) in PrimvarData { +layout(location = 5) in PrimvarData { vec3 points; vec3 normals; } inPrimvars[HD_NUM_PRIMITIVE_VERTS]; layout(location = 2) out vec4 gsPatchCoord; noperspective layout(location = 3) out vec3 hd_barycentricCoord; -flat layout(location = 7) out int gs_dc_modelCoord; -flat layout(location = 8) out int gs_dc_constantCoord; -flat layout(location = 9) out int gs_dc_elementCoord; -flat layout(location = 10) out int gs_dc_primitiveCoord; -flat layout(location = 11) out int gs_dc_fvarCoord; -flat layout(location = 12) out int gs_dc_shaderCoord; -flat layout(location = 13) out int gs_dc_vertexCoord; -flat layout(location = 14) out int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) out int gs_dc_varyingCoord; -flat layout(location = 16) out int gs_dc_instanceIndexI0; -flat layout(location = 17) out int gs_dc_instanceCoordsI0; +flat layout(location = 4) out ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) out ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) out ivec4 gs_interstageDrawingCoord2; layout(location = 0) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 4) out PrimvarData { +layout(location = 7) out PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -918,16 +894,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1020,16 +996,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1651,22 +1627,14 @@ layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisi layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; layout(location = 2) in vec4 gsPatchCoord; noperspective layout(location = 3) in vec3 hd_barycentricCoord; -flat layout(location = 7) in int gs_dc_modelCoord; -flat layout(location = 8) in int gs_dc_constantCoord; -flat layout(location = 9) in int gs_dc_elementCoord; -flat layout(location = 10) in int gs_dc_primitiveCoord; -flat layout(location = 11) in int gs_dc_fvarCoord; -flat layout(location = 12) in int gs_dc_shaderCoord; -flat layout(location = 13) in int gs_dc_vertexCoord; -flat layout(location = 14) in int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) in int gs_dc_varyingCoord; -flat layout(location = 16) in int gs_dc_instanceIndexI0; -flat layout(location = 17) in int gs_dc_instanceCoordsI0; +flat layout(location = 4) in ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) in ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) in ivec4 gs_interstageDrawingCoord2; layout(location = 0) in VertexData { vec4 Peye; vec3 Neye; } inData; -layout(location = 4) in PrimvarData { +layout(location = 7) in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -1722,16 +1690,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2828,22 +2796,14 @@ layout(location = 1) in vec3 normals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceCoordsI0; -layout(location = 11) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +layout(location = 3) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 13) out PrimvarData { +layout(location = 5) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -2915,16 +2875,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -3493,43 +3453,27 @@ layout(std430, binding = 1) readonly buffer ssbo_primitiveParam { int primitiveP layout(std430, binding = 2) readonly buffer ssbo_edgeIndices { ivec2 edgeIndices[]; }; layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 1) in int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 2) in int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 3) in int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 4) in int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 5) in int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 6) in int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 8) in int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 10) in int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -layout(location = 11) in VertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +layout(location = 3) in VertexData { vec4 Peye; vec3 Neye; } inData[4]; -layout(location = 13) in PrimvarData { +layout(location = 5) in PrimvarData { vec3 points; vec3 normals; } inPrimvars[HD_NUM_PRIMITIVE_VERTS]; layout(location = 2) out vec4 gsPatchCoord; noperspective layout(location = 3) out vec3 hd_barycentricCoord; -flat layout(location = 7) out int gs_dc_modelCoord; -flat layout(location = 8) out int gs_dc_constantCoord; -flat layout(location = 9) out int gs_dc_elementCoord; -flat layout(location = 10) out int gs_dc_primitiveCoord; -flat layout(location = 11) out int gs_dc_fvarCoord; -flat layout(location = 12) out int gs_dc_shaderCoord; -flat layout(location = 13) out int gs_dc_vertexCoord; -flat layout(location = 14) out int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) out int gs_dc_varyingCoord; -flat layout(location = 16) out int gs_dc_instanceIndexI0; -flat layout(location = 17) out int gs_dc_instanceCoordsI0; +flat layout(location = 4) out ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) out ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) out ivec4 gs_interstageDrawingCoord2; layout(location = 0) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 4) out PrimvarData { +layout(location = 7) out PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -3580,16 +3524,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3682,16 +3626,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4342,22 +4286,14 @@ layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisi layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; layout(location = 2) in vec4 gsPatchCoord; noperspective layout(location = 3) in vec3 hd_barycentricCoord; -flat layout(location = 7) in int gs_dc_modelCoord; -flat layout(location = 8) in int gs_dc_constantCoord; -flat layout(location = 9) in int gs_dc_elementCoord; -flat layout(location = 10) in int gs_dc_primitiveCoord; -flat layout(location = 11) in int gs_dc_fvarCoord; -flat layout(location = 12) in int gs_dc_shaderCoord; -flat layout(location = 13) in int gs_dc_vertexCoord; -flat layout(location = 14) in int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) in int gs_dc_varyingCoord; -flat layout(location = 16) in int gs_dc_instanceIndexI0; -flat layout(location = 17) in int gs_dc_instanceCoordsI0; +flat layout(location = 4) in ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) in ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) in ivec4 gs_interstageDrawingCoord2; layout(location = 0) in VertexData { vec4 Peye; vec3 Neye; } inData; -layout(location = 4) in PrimvarData { +layout(location = 7) in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -4413,16 +4349,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out index 067d4f433a..607e326867 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out @@ -172,24 +172,15 @@ layout(location = 1) in vec3 normals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceIndexI1; -flat layout(location = 11) out int vs_dc_instanceCoordsI0; -flat layout(location = 12) out int vs_dc_instanceCoordsI1; -layout(location = 13) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +flat layout(location = 3) out ivec4 vs_interstageDrawingCoord3; +layout(location = 4) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 15) out PrimvarData { +layout(location = 6) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -302,18 +293,18 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; - vs_dc_instanceIndexI1 = dc.instanceIndex[1]; - vs_dc_instanceCoordsI0 = dc.instanceCoords[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; + vs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; + vs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -887,47 +878,29 @@ layout(std430, binding = 2) readonly buffer ssbo_primitiveParam { int primitiveP layout(std430, binding = 3) readonly buffer ssbo_edgeIndices { int edgeIndices[]; }; layout(std430, binding = 4) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; layout(std430, binding = 5) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 1) in int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 2) in int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 3) in int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 4) in int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 5) in int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 6) in int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 8) in int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 10) in int vs_dc_instanceIndexI1[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 11) in int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 12) in int vs_dc_instanceCoordsI1[HD_NUM_PRIMITIVE_VERTS]; -layout(location = 13) in VertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 3) in ivec4 vs_interstageDrawingCoord3[HD_NUM_PRIMITIVE_VERTS]; +layout(location = 4) in VertexData { vec4 Peye; vec3 Neye; } inData[3]; -layout(location = 15) in PrimvarData { +layout(location = 6) in PrimvarData { vec3 points; vec3 normals; } inPrimvars[HD_NUM_PRIMITIVE_VERTS]; layout(location = 2) out vec4 gsPatchCoord; noperspective layout(location = 3) out vec3 hd_barycentricCoord; -flat layout(location = 7) out int gs_dc_modelCoord; -flat layout(location = 8) out int gs_dc_constantCoord; -flat layout(location = 9) out int gs_dc_elementCoord; -flat layout(location = 10) out int gs_dc_primitiveCoord; -flat layout(location = 11) out int gs_dc_fvarCoord; -flat layout(location = 12) out int gs_dc_shaderCoord; -flat layout(location = 13) out int gs_dc_vertexCoord; -flat layout(location = 14) out int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) out int gs_dc_varyingCoord; -flat layout(location = 16) out int gs_dc_instanceIndexI0; -flat layout(location = 17) out int gs_dc_instanceIndexI1; -flat layout(location = 18) out int gs_dc_instanceCoordsI0; -flat layout(location = 19) out int gs_dc_instanceCoordsI1; +flat layout(location = 4) out ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) out ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) out ivec4 gs_interstageDrawingCoord2; +flat layout(location = 7) out ivec4 gs_interstageDrawingCoord3; layout(location = 0) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 4) out PrimvarData { +layout(location = 8) out PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -996,18 +969,18 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; - dc.instanceIndex[1] = vs_dc_instanceIndexI1[0]; - dc.instanceCoords[0] = vs_dc_instanceCoordsI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; + dc.instanceIndex[1] = vs_interstageDrawingCoord2[0][2]; + dc.instanceCoords[0] = vs_interstageDrawingCoord2[0][3]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1100,18 +1073,18 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; - gs_dc_instanceIndexI1 = dc.instanceIndex[1]; - gs_dc_instanceCoordsI0 = dc.instanceCoords[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; + gs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; + gs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1738,24 +1711,15 @@ layout(std430, binding = 4) readonly buffer ssbo_faceVisibility { float faceVisi layout(std430, binding = 5) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; layout(location = 2) in vec4 gsPatchCoord; noperspective layout(location = 3) in vec3 hd_barycentricCoord; -flat layout(location = 7) in int gs_dc_modelCoord; -flat layout(location = 8) in int gs_dc_constantCoord; -flat layout(location = 9) in int gs_dc_elementCoord; -flat layout(location = 10) in int gs_dc_primitiveCoord; -flat layout(location = 11) in int gs_dc_fvarCoord; -flat layout(location = 12) in int gs_dc_shaderCoord; -flat layout(location = 13) in int gs_dc_vertexCoord; -flat layout(location = 14) in int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) in int gs_dc_varyingCoord; -flat layout(location = 16) in int gs_dc_instanceIndexI0; -flat layout(location = 17) in int gs_dc_instanceIndexI1; -flat layout(location = 18) in int gs_dc_instanceCoordsI0; -flat layout(location = 19) in int gs_dc_instanceCoordsI1; +flat layout(location = 4) in ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) in ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) in ivec4 gs_interstageDrawingCoord2; +flat layout(location = 7) in ivec4 gs_interstageDrawingCoord3; layout(location = 0) in VertexData { vec4 Peye; vec3 Neye; } inData; -layout(location = 4) in PrimvarData { +layout(location = 8) in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -1829,18 +1793,18 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; - dc.instanceIndex[1] = gs_dc_instanceIndexI1; - dc.instanceCoords[0] = gs_dc_instanceCoordsI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; + dc.instanceIndex[1] = gs_interstageDrawingCoord2[2]; + dc.instanceCoords[0] = gs_interstageDrawingCoord2[3]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2943,24 +2907,15 @@ layout(location = 1) in vec3 normals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceIndexI1; -flat layout(location = 11) out int vs_dc_instanceCoordsI0; -flat layout(location = 12) out int vs_dc_instanceCoordsI1; -layout(location = 13) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +flat layout(location = 3) out ivec4 vs_interstageDrawingCoord3; +layout(location = 4) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 15) out PrimvarData { +layout(location = 6) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -3073,18 +3028,18 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; - vs_dc_instanceIndexI1 = dc.instanceIndex[1]; - vs_dc_instanceCoordsI0 = dc.instanceCoords[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; + vs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; + vs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -3658,47 +3613,29 @@ layout(std430, binding = 2) readonly buffer ssbo_primitiveParam { int primitiveP layout(std430, binding = 3) readonly buffer ssbo_edgeIndices { ivec2 edgeIndices[]; }; layout(std430, binding = 4) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; layout(std430, binding = 5) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 1) in int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 2) in int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 3) in int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 4) in int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 5) in int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 6) in int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 8) in int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 10) in int vs_dc_instanceIndexI1[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 11) in int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 12) in int vs_dc_instanceCoordsI1[HD_NUM_PRIMITIVE_VERTS]; -layout(location = 13) in VertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 3) in ivec4 vs_interstageDrawingCoord3[HD_NUM_PRIMITIVE_VERTS]; +layout(location = 4) in VertexData { vec4 Peye; vec3 Neye; } inData[4]; -layout(location = 15) in PrimvarData { +layout(location = 6) in PrimvarData { vec3 points; vec3 normals; } inPrimvars[HD_NUM_PRIMITIVE_VERTS]; layout(location = 2) out vec4 gsPatchCoord; noperspective layout(location = 3) out vec3 hd_barycentricCoord; -flat layout(location = 7) out int gs_dc_modelCoord; -flat layout(location = 8) out int gs_dc_constantCoord; -flat layout(location = 9) out int gs_dc_elementCoord; -flat layout(location = 10) out int gs_dc_primitiveCoord; -flat layout(location = 11) out int gs_dc_fvarCoord; -flat layout(location = 12) out int gs_dc_shaderCoord; -flat layout(location = 13) out int gs_dc_vertexCoord; -flat layout(location = 14) out int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) out int gs_dc_varyingCoord; -flat layout(location = 16) out int gs_dc_instanceIndexI0; -flat layout(location = 17) out int gs_dc_instanceIndexI1; -flat layout(location = 18) out int gs_dc_instanceCoordsI0; -flat layout(location = 19) out int gs_dc_instanceCoordsI1; +flat layout(location = 4) out ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) out ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) out ivec4 gs_interstageDrawingCoord2; +flat layout(location = 7) out ivec4 gs_interstageDrawingCoord3; layout(location = 0) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 4) out PrimvarData { +layout(location = 8) out PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -3767,18 +3704,18 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; - dc.instanceIndex[1] = vs_dc_instanceIndexI1[0]; - dc.instanceCoords[0] = vs_dc_instanceCoordsI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; + dc.instanceIndex[1] = vs_interstageDrawingCoord2[0][2]; + dc.instanceCoords[0] = vs_interstageDrawingCoord2[0][3]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3871,18 +3808,18 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; - gs_dc_instanceIndexI1 = dc.instanceIndex[1]; - gs_dc_instanceCoordsI0 = dc.instanceCoords[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; + gs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; + gs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.normals = inPrimvars[index].normals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4538,24 +4475,15 @@ layout(std430, binding = 4) readonly buffer ssbo_faceVisibility { float faceVisi layout(std430, binding = 5) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; layout(location = 2) in vec4 gsPatchCoord; noperspective layout(location = 3) in vec3 hd_barycentricCoord; -flat layout(location = 7) in int gs_dc_modelCoord; -flat layout(location = 8) in int gs_dc_constantCoord; -flat layout(location = 9) in int gs_dc_elementCoord; -flat layout(location = 10) in int gs_dc_primitiveCoord; -flat layout(location = 11) in int gs_dc_fvarCoord; -flat layout(location = 12) in int gs_dc_shaderCoord; -flat layout(location = 13) in int gs_dc_vertexCoord; -flat layout(location = 14) in int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) in int gs_dc_varyingCoord; -flat layout(location = 16) in int gs_dc_instanceIndexI0; -flat layout(location = 17) in int gs_dc_instanceIndexI1; -flat layout(location = 18) in int gs_dc_instanceCoordsI0; -flat layout(location = 19) in int gs_dc_instanceCoordsI1; +flat layout(location = 4) in ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) in ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) in ivec4 gs_interstageDrawingCoord2; +flat layout(location = 7) in ivec4 gs_interstageDrawingCoord3; layout(location = 0) in VertexData { vec4 Peye; vec3 Neye; } inData; -layout(location = 4) in PrimvarData { +layout(location = 8) in PrimvarData { vec3 points; vec3 normals; vec2 dispTextureCoord; @@ -4629,18 +4557,18 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; - dc.instanceIndex[1] = gs_dc_instanceIndexI1; - dc.instanceCoords[0] = gs_dc_instanceCoordsI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; + dc.instanceIndex[1] = gs_interstageDrawingCoord2[2]; + dc.instanceCoords[0] = gs_interstageDrawingCoord2[3]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out index 5fc79148e0..e5807d1ad8 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out @@ -166,22 +166,14 @@ layout(location = 1) in vec3 smoothNormals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceCoordsI0; -layout(location = 11) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +layout(location = 3) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 13) out PrimvarData { +layout(location = 5) out PrimvarData { vec3 points; vec3 smoothNormals; } outPrimvars; @@ -253,16 +245,16 @@ float HdGetScalar_smoothNormals() { return HdGet_smoothNormals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.smoothNormals = smoothNormals; } @@ -844,43 +836,27 @@ layout(std430, binding = 1) readonly buffer ssbo_primitiveParam { int primitiveP layout(std430, binding = 2) readonly buffer ssbo_edgeIndices { int edgeIndices[]; }; layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 1) in int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 2) in int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 3) in int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 4) in int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 5) in int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 6) in int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 8) in int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 10) in int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -layout(location = 11) in VertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +layout(location = 3) in VertexData { vec4 Peye; vec3 Neye; } inData[3]; -layout(location = 13) in PrimvarData { +layout(location = 5) in PrimvarData { vec3 points; vec3 smoothNormals; } inPrimvars[HD_NUM_PRIMITIVE_VERTS]; layout(location = 2) out vec4 gsPatchCoord; noperspective layout(location = 3) out vec3 hd_barycentricCoord; -flat layout(location = 7) out int gs_dc_modelCoord; -flat layout(location = 8) out int gs_dc_constantCoord; -flat layout(location = 9) out int gs_dc_elementCoord; -flat layout(location = 10) out int gs_dc_primitiveCoord; -flat layout(location = 11) out int gs_dc_fvarCoord; -flat layout(location = 12) out int gs_dc_shaderCoord; -flat layout(location = 13) out int gs_dc_vertexCoord; -flat layout(location = 14) out int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) out int gs_dc_varyingCoord; -flat layout(location = 16) out int gs_dc_instanceIndexI0; -flat layout(location = 17) out int gs_dc_instanceCoordsI0; +flat layout(location = 4) out ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) out ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) out ivec4 gs_interstageDrawingCoord2; layout(location = 0) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 4) out PrimvarData { +layout(location = 7) out PrimvarData { vec3 points; vec3 smoothNormals; vec2 dispTextureCoord; @@ -931,16 +907,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -1033,16 +1009,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.smoothNormals = inPrimvars[index].smoothNormals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -1651,22 +1627,14 @@ layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisi layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; layout(location = 2) in vec4 gsPatchCoord; noperspective layout(location = 3) in vec3 hd_barycentricCoord; -flat layout(location = 7) in int gs_dc_modelCoord; -flat layout(location = 8) in int gs_dc_constantCoord; -flat layout(location = 9) in int gs_dc_elementCoord; -flat layout(location = 10) in int gs_dc_primitiveCoord; -flat layout(location = 11) in int gs_dc_fvarCoord; -flat layout(location = 12) in int gs_dc_shaderCoord; -flat layout(location = 13) in int gs_dc_vertexCoord; -flat layout(location = 14) in int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) in int gs_dc_varyingCoord; -flat layout(location = 16) in int gs_dc_instanceIndexI0; -flat layout(location = 17) in int gs_dc_instanceCoordsI0; +flat layout(location = 4) in ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) in ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) in ivec4 gs_interstageDrawingCoord2; layout(location = 0) in VertexData { vec4 Peye; vec3 Neye; } inData; -layout(location = 4) in PrimvarData { +layout(location = 7) in PrimvarData { vec3 points; vec3 smoothNormals; vec2 dispTextureCoord; @@ -1722,16 +1690,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -2828,22 +2796,14 @@ layout(location = 1) in vec3 smoothNormals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceCoordsI0; -layout(location = 11) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +layout(location = 3) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 13) out PrimvarData { +layout(location = 5) out PrimvarData { vec3 points; vec3 smoothNormals; } outPrimvars; @@ -2915,16 +2875,16 @@ float HdGetScalar_smoothNormals() { return HdGet_smoothNormals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.smoothNormals = smoothNormals; } @@ -3506,43 +3466,27 @@ layout(std430, binding = 1) readonly buffer ssbo_primitiveParam { int primitiveP layout(std430, binding = 2) readonly buffer ssbo_edgeIndices { ivec2 edgeIndices[]; }; layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisibility[]; }; layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; -flat layout(location = 0) in int vs_dc_modelCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 1) in int vs_dc_constantCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 2) in int vs_dc_elementCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 3) in int vs_dc_primitiveCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 4) in int vs_dc_fvarCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 5) in int vs_dc_shaderCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 6) in int vs_dc_vertexCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 8) in int vs_dc_varyingCoord[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 9) in int vs_dc_instanceIndexI0[HD_NUM_PRIMITIVE_VERTS]; -flat layout(location = 10) in int vs_dc_instanceCoordsI0[HD_NUM_PRIMITIVE_VERTS]; -layout(location = 11) in VertexData { +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1[HD_NUM_PRIMITIVE_VERTS]; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2[HD_NUM_PRIMITIVE_VERTS]; +layout(location = 3) in VertexData { vec4 Peye; vec3 Neye; } inData[4]; -layout(location = 13) in PrimvarData { +layout(location = 5) in PrimvarData { vec3 points; vec3 smoothNormals; } inPrimvars[HD_NUM_PRIMITIVE_VERTS]; layout(location = 2) out vec4 gsPatchCoord; noperspective layout(location = 3) out vec3 hd_barycentricCoord; -flat layout(location = 7) out int gs_dc_modelCoord; -flat layout(location = 8) out int gs_dc_constantCoord; -flat layout(location = 9) out int gs_dc_elementCoord; -flat layout(location = 10) out int gs_dc_primitiveCoord; -flat layout(location = 11) out int gs_dc_fvarCoord; -flat layout(location = 12) out int gs_dc_shaderCoord; -flat layout(location = 13) out int gs_dc_vertexCoord; -flat layout(location = 14) out int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) out int gs_dc_varyingCoord; -flat layout(location = 16) out int gs_dc_instanceIndexI0; -flat layout(location = 17) out int gs_dc_instanceCoordsI0; +flat layout(location = 4) out ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) out ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) out ivec4 gs_interstageDrawingCoord2; layout(location = 0) out VertexData { vec4 Peye; vec3 Neye; } outData; -layout(location = 4) out PrimvarData { +layout(location = 7) out PrimvarData { vec3 points; vec3 smoothNormals; vec2 dispTextureCoord; @@ -3593,16 +3537,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord[0]; - dc.constantCoord = vs_dc_constantCoord[0]; - dc.elementCoord = vs_dc_elementCoord[0]; - dc.primitiveCoord = vs_dc_primitiveCoord[0]; - dc.fvarCoord = vs_dc_fvarCoord[0]; - dc.shaderCoord = vs_dc_shaderCoord[0]; - dc.vertexCoord = vs_dc_vertexCoord[0]; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord[0]; - dc.varyingCoord = vs_dc_varyingCoord[0]; - dc.instanceIndex[0] = vs_dc_instanceIndexI0[0]; + dc.modelCoord = vs_interstageDrawingCoord0[0][0]; + dc.constantCoord = vs_interstageDrawingCoord0[0][1]; + dc.elementCoord = vs_interstageDrawingCoord0[0][2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[0][3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0][0]; + dc.shaderCoord = vs_interstageDrawingCoord1[0][1]; + dc.vertexCoord = vs_interstageDrawingCoord1[0][2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[0][3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0][0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[0][1]; return dc; } int HdGet_primitiveParam(int localIndex) { @@ -3695,16 +3639,16 @@ void ProcessPrimvarsOut(int index) { ); hd_barycentricCoord = coords[index]; hd_drawingCoord dc = GetDrawingCoord(); - gs_dc_modelCoord = dc.modelCoord; - gs_dc_constantCoord = dc.constantCoord; - gs_dc_elementCoord = dc.elementCoord; - gs_dc_primitiveCoord = dc.primitiveCoord; - gs_dc_fvarCoord = dc.fvarCoord; - gs_dc_shaderCoord = dc.shaderCoord; - gs_dc_vertexCoord = dc.vertexCoord; - gs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - gs_dc_varyingCoord = dc.varyingCoord; - gs_dc_instanceIndexI0 = dc.instanceIndex[0]; + gs_interstageDrawingCoord0[0] = dc.modelCoord; + gs_interstageDrawingCoord0[1] = dc.constantCoord; + gs_interstageDrawingCoord0[2] = dc.elementCoord; + gs_interstageDrawingCoord0[3] = dc.primitiveCoord; + gs_interstageDrawingCoord1[0] = dc.fvarCoord; + gs_interstageDrawingCoord1[1] = dc.shaderCoord; + gs_interstageDrawingCoord1[2] = dc.vertexCoord; + gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + gs_interstageDrawingCoord2[0] = dc.varyingCoord; + gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = inPrimvars[index].points; outPrimvars.smoothNormals = inPrimvars[index].smoothNormals; outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); @@ -4342,22 +4286,14 @@ layout(std430, binding = 3) readonly buffer ssbo_faceVisibility { float faceVisi layout(std430, binding = 4) readonly buffer ssbo_dispTextureCoord { vec2 dispTextureCoord[]; }; layout(location = 2) in vec4 gsPatchCoord; noperspective layout(location = 3) in vec3 hd_barycentricCoord; -flat layout(location = 7) in int gs_dc_modelCoord; -flat layout(location = 8) in int gs_dc_constantCoord; -flat layout(location = 9) in int gs_dc_elementCoord; -flat layout(location = 10) in int gs_dc_primitiveCoord; -flat layout(location = 11) in int gs_dc_fvarCoord; -flat layout(location = 12) in int gs_dc_shaderCoord; -flat layout(location = 13) in int gs_dc_vertexCoord; -flat layout(location = 14) in int gs_dc_topologyVisibilityCoord; -flat layout(location = 15) in int gs_dc_varyingCoord; -flat layout(location = 16) in int gs_dc_instanceIndexI0; -flat layout(location = 17) in int gs_dc_instanceCoordsI0; +flat layout(location = 4) in ivec4 gs_interstageDrawingCoord0; +flat layout(location = 5) in ivec4 gs_interstageDrawingCoord1; +flat layout(location = 6) in ivec4 gs_interstageDrawingCoord2; layout(location = 0) in VertexData { vec4 Peye; vec3 Neye; } inData; -layout(location = 4) in PrimvarData { +layout(location = 7) in PrimvarData { vec3 points; vec3 smoothNormals; vec2 dispTextureCoord; @@ -4413,16 +4349,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = gs_dc_modelCoord; - dc.constantCoord = gs_dc_constantCoord; - dc.elementCoord = gs_dc_elementCoord; - dc.primitiveCoord = gs_dc_primitiveCoord; - dc.fvarCoord = gs_dc_fvarCoord; - dc.shaderCoord = gs_dc_shaderCoord; - dc.vertexCoord = gs_dc_vertexCoord; - dc.topologyVisibilityCoord = gs_dc_topologyVisibilityCoord; - dc.varyingCoord = gs_dc_varyingCoord; - dc.instanceIndex[0] = gs_dc_instanceIndexI0; + dc.modelCoord = gs_interstageDrawingCoord0[0]; + dc.constantCoord = gs_interstageDrawingCoord0[1]; + dc.elementCoord = gs_interstageDrawingCoord0[2]; + dc.primitiveCoord = gs_interstageDrawingCoord0[3]; + dc.fvarCoord = gs_interstageDrawingCoord1[0]; + dc.shaderCoord = gs_interstageDrawingCoord1[1]; + dc.vertexCoord = gs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; + dc.varyingCoord = gs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; return dc; } int HdGet_primitiveParam(int localIndex) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out index 73823268af..17c0dd2246 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out @@ -160,22 +160,14 @@ layout(location = 1) in vec3 normals; uint hd_VertexID = gl_VertexIndex; uint hd_InstanceID = gl_InstanceIndex; uint hd_BaseInstance = HgiGetBaseInstance(); -flat layout(location = 0) out int vs_dc_modelCoord; -flat layout(location = 1) out int vs_dc_constantCoord; -flat layout(location = 2) out int vs_dc_elementCoord; -flat layout(location = 3) out int vs_dc_primitiveCoord; -flat layout(location = 4) out int vs_dc_fvarCoord; -flat layout(location = 5) out int vs_dc_shaderCoord; -flat layout(location = 6) out int vs_dc_vertexCoord; -flat layout(location = 7) out int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) out int vs_dc_varyingCoord; -flat layout(location = 9) out int vs_dc_instanceIndexI0; -flat layout(location = 10) out int vs_dc_instanceCoordsI0; -flat layout(location = 12) out int vsPointId; -layout(location = 11) out VertexData { +flat layout(location = 0) out ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) out ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) out ivec4 vs_interstageDrawingCoord2; +flat layout(location = 4) out int vsPointId; +layout(location = 3) out VertexData { vec4 Peye; } outData; -layout(location = 13) out PrimvarData { +layout(location = 5) out PrimvarData { vec3 points; vec3 normals; } outPrimvars; @@ -247,16 +239,16 @@ float HdGetScalar_normals() { return HdGet_normals(0).x; } // //////// Codegen Proc VS //////// void ProcessPrimvarsIn() { hd_drawingCoord dc = GetDrawingCoord(); - vs_dc_modelCoord = dc.modelCoord; - vs_dc_constantCoord = dc.constantCoord; - vs_dc_elementCoord = dc.elementCoord; - vs_dc_primitiveCoord = dc.primitiveCoord; - vs_dc_fvarCoord = dc.fvarCoord; - vs_dc_shaderCoord = dc.shaderCoord; - vs_dc_vertexCoord = dc.vertexCoord; - vs_dc_topologyVisibilityCoord = dc.topologyVisibilityCoord; - vs_dc_varyingCoord = dc.varyingCoord; - vs_dc_instanceIndexI0 = dc.instanceIndex[0]; + vs_interstageDrawingCoord0[0] = dc.modelCoord; + vs_interstageDrawingCoord0[1] = dc.constantCoord; + vs_interstageDrawingCoord0[2] = dc.elementCoord; + vs_interstageDrawingCoord0[3] = dc.primitiveCoord; + vs_interstageDrawingCoord1[0] = dc.fvarCoord; + vs_interstageDrawingCoord1[1] = dc.shaderCoord; + vs_interstageDrawingCoord1[2] = dc.vertexCoord; + vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; + vs_interstageDrawingCoord2[0] = dc.varyingCoord; + vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; outPrimvars.points = points; outPrimvars.normals = normals; } @@ -1232,22 +1224,14 @@ FORWARD_DECL(float GetSelectedEdgeOpacity()); // //////// Global Member Declarations //////// layout(std430, binding = 0) readonly buffer ssbo_constantPrimvars { ConstantData7 constantPrimvars[]; }; -flat layout(location = 12) in int vsPointId; -flat layout(location = 0) in int vs_dc_modelCoord; -flat layout(location = 1) in int vs_dc_constantCoord; -flat layout(location = 2) in int vs_dc_elementCoord; -flat layout(location = 3) in int vs_dc_primitiveCoord; -flat layout(location = 4) in int vs_dc_fvarCoord; -flat layout(location = 5) in int vs_dc_shaderCoord; -flat layout(location = 6) in int vs_dc_vertexCoord; -flat layout(location = 7) in int vs_dc_topologyVisibilityCoord; -flat layout(location = 8) in int vs_dc_varyingCoord; -flat layout(location = 9) in int vs_dc_instanceIndexI0; -flat layout(location = 10) in int vs_dc_instanceCoordsI0; -layout(location = 11) in VertexData { +flat layout(location = 4) in int vsPointId; +flat layout(location = 0) in ivec4 vs_interstageDrawingCoord0; +flat layout(location = 1) in ivec4 vs_interstageDrawingCoord1; +flat layout(location = 2) in ivec4 vs_interstageDrawingCoord2; +layout(location = 3) in VertexData { vec4 Peye; } inData; -layout(location = 13) in PrimvarData { +layout(location = 5) in PrimvarData { vec3 points; vec3 normals; } inPrimvars; @@ -1302,16 +1286,16 @@ int GetPrimitiveIndex() { } hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = vs_dc_modelCoord; - dc.constantCoord = vs_dc_constantCoord; - dc.elementCoord = vs_dc_elementCoord; - dc.primitiveCoord = vs_dc_primitiveCoord; - dc.fvarCoord = vs_dc_fvarCoord; - dc.shaderCoord = vs_dc_shaderCoord; - dc.vertexCoord = vs_dc_vertexCoord; - dc.topologyVisibilityCoord = vs_dc_topologyVisibilityCoord; - dc.varyingCoord = vs_dc_varyingCoord; - dc.instanceIndex[0] = vs_dc_instanceIndexI0; + dc.modelCoord = vs_interstageDrawingCoord0[0]; + dc.constantCoord = vs_interstageDrawingCoord0[1]; + dc.elementCoord = vs_interstageDrawingCoord0[2]; + dc.primitiveCoord = vs_interstageDrawingCoord0[3]; + dc.fvarCoord = vs_interstageDrawingCoord1[0]; + dc.shaderCoord = vs_interstageDrawingCoord1[1]; + dc.vertexCoord = vs_interstageDrawingCoord1[2]; + dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[3]; + dc.varyingCoord = vs_interstageDrawingCoord2[0]; + dc.instanceIndex[0] = vs_interstageDrawingCoord2[1]; return dc; } int GetElementID() { From a41ecb04d7189db637b8bdc94004491b963bd7de Mon Sep 17 00:00:00 2001 From: clach Date: Mon, 14 Oct 2024 13:10:15 -0700 Subject: [PATCH 033/300] [hdSt] Remove "bindless" arg from testHdStCodeGen, as it hasn't done anything in years. (Internal change: 2344495) --- pxr/imaging/hdSt/CMakeLists.txt | 76 +- pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp | 19 +- .../baseline/codegen_curves_bindless.out | 2648 -------- ...gen_mesh_bindless_indirect_faceVarying.out | 5321 ---------------- ...odegen_mesh_bindless_indirect_instance.out | 5531 ----------------- ... => codegen_mesh_indirect_doubleSided.out} | 0 ... => codegen_mesh_indirect_faceVarying.out} | 0 ...> codegen_mesh_indirect_smoothNormals.out} | 0 .../baseline/codegen_points_bindless.out | 1760 ------ 9 files changed, 19 insertions(+), 15336 deletions(-) delete mode 100644 pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_bindless.out delete mode 100644 pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_faceVarying.out delete mode 100644 pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_instance.out rename pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/{codegen_mesh_bindless_indirect_doubleSided.out => codegen_mesh_indirect_doubleSided.out} (100%) rename pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/{codegen_mesh_bindless_indirect.out => codegen_mesh_indirect_faceVarying.out} (100%) rename pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/{codegen_mesh_bindless_indirect_smoothNormals.out => codegen_mesh_indirect_smoothNormals.out} (100%) delete mode 100644 pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_bindless.out diff --git a/pxr/imaging/hdSt/CMakeLists.txt b/pxr/imaging/hdSt/CMakeLists.txt index 0e62a6a9f1..b5d4156117 100644 --- a/pxr/imaging/hdSt/CMakeLists.txt +++ b/pxr/imaging/hdSt/CMakeLists.txt @@ -2386,24 +2386,11 @@ pxr_register_test(testHdStCodeGen_GL_Mesh_Indirect HGIGL_GLSL_VERSION=450 HGI_ENABLE_VULKAN=0 ) -pxr_register_test(testHdStCodeGen_GL_Mesh_Bindless_Indirect - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --bindless | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_bindless_indirect.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_bindless_indirect.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect.out" - TESTENV testHdStCodeGen_GL - ENV - TF_DEBUG=HD_SAFE_MODE - HGIGL_ENABLE_BINDLESS_BUFFER=1 - HGIGL_ENABLE_BINDLESS_TEXTURE=1 - HGIGL_GLSL_VERSION=450 - HGI_ENABLE_VULKAN=0 -) -pxr_register_test(testHdStCodeGen_GL_Mesh_Bindless_Indirect_SmoothNormals - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --bindless --smoothNormals | grep -v '// line'" +pxr_register_test(testHdStCodeGen_GL_Mesh_Indirect_SmoothNormals + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --smoothNormals | grep -v '// line'" EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_bindless_indirect_smoothNormals.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_bindless_indirect_smoothNormals.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_smoothNormals.out" + STDOUT_REDIRECT codegen_mesh_indirect_smoothNormals.out + POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_smoothNormals.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out" TESTENV testHdStCodeGen_GL ENV TF_DEBUG=HD_SAFE_MODE @@ -2412,11 +2399,11 @@ pxr_register_test(testHdStCodeGen_GL_Mesh_Bindless_Indirect_SmoothNormals HGIGL_GLSL_VERSION=450 HGI_ENABLE_VULKAN=0 ) -pxr_register_test(testHdStCodeGen_GL_Mesh_Bindless_Indirect_DoubleSided - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --bindless --doubleSided | grep -v '// line'" +pxr_register_test(testHdStCodeGen_GL_Mesh_Indirect_DoubleSided + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --doubleSided | grep -v '// line'" EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_bindless_indirect_doubleSided.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_bindless_indirect_doubleSided.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_doubleSided.out" + STDOUT_REDIRECT codegen_mesh_indirect_doubleSided.out + POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_doubleSided.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out" TESTENV testHdStCodeGen_GL ENV TF_DEBUG=HD_SAFE_MODE @@ -2425,11 +2412,11 @@ pxr_register_test(testHdStCodeGen_GL_Mesh_Bindless_Indirect_DoubleSided HGIGL_GLSL_VERSION=450 HGI_ENABLE_VULKAN=0 ) -pxr_register_test(testHdStCodeGen_GL_Mesh_Bindless_Indirect_FaceVarying - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --bindless --faceVarying | grep -v '// line'" +pxr_register_test(testHdStCodeGen_GL_Mesh_Indirect_FaceVarying + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --faceVarying | grep -v '// line'" EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_bindless_indirect_faceVarying.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_bindless_indirect_faceVarying.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_faceVarying.out" + STDOUT_REDIRECT codegen_mesh_indirect_faceVarying.out + POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_faceVarying.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out" TESTENV testHdStCodeGen_GL ENV TF_DEBUG=HD_SAFE_MODE @@ -2451,19 +2438,6 @@ pxr_register_test(testHdStCodeGen_GL_Mesh_Indirect_Instance HGIGL_GLSL_VERSION=450 HGI_ENABLE_VULKAN=0 ) -pxr_register_test(testHdStCodeGen_GL_Mesh_Bindless_Indirect_Instance - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --bindless --instance | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_bindless_indirect_instance.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_bindless_indirect_instance.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_instance.out" - TESTENV testHdStCodeGen_GL - ENV - TF_DEBUG=HD_SAFE_MODE - HGIGL_ENABLE_BINDLESS_BUFFER=1 - HGIGL_ENABLE_BINDLESS_TEXTURE=1 - HGIGL_GLSL_VERSION=450 - HGI_ENABLE_VULKAN=0 -) pxr_register_test(testHdStCodeGen_GL_Mesh_EdgeOnly COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --edgeOnly | grep -v '// line'" EXPECTED_RETURN_CODE 0 @@ -2490,19 +2464,6 @@ pxr_register_test(testHdStCodeGen_GL_Mesh_EdgeOnly_BlendWireframe HGIGL_GLSL_VERSION=450 HGI_ENABLE_VULKAN=0 ) -pxr_register_test(testHdStCodeGen_GL_Curves_Bindless - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --curves --bindless | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_curves_bindless.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_curves_bindless.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_curves_bindless.out" - TESTENV testHdStCodeGen_GL - ENV - TF_DEBUG=HD_SAFE_MODE - HGIGL_ENABLE_BINDLESS_BUFFER=1 - HGIGL_ENABLE_BINDLESS_TEXTURE=1 - HGIGL_GLSL_VERSION=450 - HGI_ENABLE_VULKAN=0 -) pxr_register_test(testHdStCodeGen_GL_Curves_Indirect COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --curves | grep -v '// line'" EXPECTED_RETURN_CODE 0 @@ -2516,19 +2477,6 @@ pxr_register_test(testHdStCodeGen_GL_Curves_Indirect HGIGL_GLSL_VERSION=450 HGI_ENABLE_VULKAN=0 ) -pxr_register_test(testHdStCodeGen_GL_Points_Bindless - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --points --bindless | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_points_bindless.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_points_bindless.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_points_bindless.out" - TESTENV testHdStCodeGen_GL - ENV - TF_DEBUG=HD_SAFE_MODE - HGIGL_ENABLE_BINDLESS_BUFFER=1 - HGIGL_ENABLE_BINDLESS_TEXTURE=1 - HGIGL_GLSL_VERSION=450 - HGI_ENABLE_VULKAN=0 -) pxr_register_test(testHdStCodeGen_GL_Points_Indirect COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --points | grep -v '// line'" EXPECTED_RETURN_CODE 0 diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp b/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp index c20dcc256b..c968776adc 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp @@ -60,8 +60,7 @@ TF_DEFINE_PRIVATE_TOKENS( ); static bool -CodeGenTest(HdSt_ShaderKey const &key, bool useBindlessBuffer, - bool instance, bool smoothNormals) +CodeGenTest(HdSt_ShaderKey const &key, bool instance, bool smoothNormals) { TfErrorMark mark; @@ -300,11 +299,10 @@ CodeGenTest(HdSt_ShaderKey const &key, bool useBindlessBuffer, } bool -TestShader(HdSt_ShaderKey const &key, bool bindless, - bool instance, bool smoothNormals) +TestShader(HdSt_ShaderKey const &key, bool instance, bool smoothNormals) { bool success = true; - success &= CodeGenTest(key, bindless, instance, smoothNormals); + success &= CodeGenTest(key, instance, smoothNormals); return success; } @@ -324,7 +322,6 @@ int main(int argc, char *argv[]) bool mesh = false; bool curves = false; bool points = false; - bool bindless = false; HdMeshGeomStyle geomStyle = HdMeshGeomStyleSurf; for (int i=0; isurfaceShader, topologicalVisibility, /* isWidget */ false, false), - bindless, instance, false); + instance, false); } // points if (points) { success &= TestShader(HdSt_PointsShaderKey(), - bindless, instance, false); + instance, false); } if (success) { diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_bindless.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_bindless.out deleted file mode 100644 index e3ec0a77c9..0000000000 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_bindless.out +++ /dev/null @@ -1,2648 +0,0 @@ -------------------------------------------------------- --- glslfx version 0.1 -#import $TOOLS/hdSt/shaders/basisCurves.glslfx --- configuration -{"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "Curves.Vertex.Wire", "Curves.Vertex.Normal.Implicit", "PointId.Vertex.None"] } -, "tessControlShader" : { "source" : ["Curves.CommonData", "Curves.TessFactorsGLSL", "Curves.CommonControl", "Curves.Tess.CurveData.Wire", "Curves.TessControl.Cubic.Wire"] } -, "tessEvalShader" : { "source" : ["Curves.CommonData", "Instancing.Transform", "Curves.Tess.CurveData.Wire", "Curves.TessEval.Cubic.Wire", "Curves.BezierBasis", "Curves.Cubic.VaryingInterpolation"] } -, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Curves.Fragment.Wire"] } -}}} -------------------------------------------------------- -======================================================= - VERTEX SHADER -======================================================= -#version 450 -#extension GL_NV_shader_buffer_load : require -#extension GL_NV_gpu_shader5 : require -#extension GL_ARB_bindless_texture : require -#extension GL_ARB_shader_draw_parameters : require -int HgiGetBaseVertex() { - return gl_BaseVertexARB; -} -#define REF(space,type) inout type -#define FORWARD_DECL(func_decl) func_decl; -#define ATOMIC_LOAD(a) (a) -#define ATOMIC_STORE(a, v) (a) = (v) -#define ATOMIC_ADD(a, v) atomicAdd(a, v) -#define ATOMIC_EXCHANGE(a, v) atomicExchange(a, v) -#define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) -#define atomic_int int -#define atomic_uint uint - -#define HGI_HAS_DOUBLE_TYPE 1 - - -struct hgi_ivec3 { int x, y, z; }; -struct hgi_vec3 { float x, y, z; }; -struct hgi_dvec3 { double x, y, z; }; -struct hgi_mat3 { float m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; -struct hgi_dmat3 { double m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; - - -// //////// Codegen Defines //////// -#define HD_SHADER_API 2 -#define MAT4 mat4 -// Alias hgi vec and matrix types to hd. -#define hd_ivec3 hgi_ivec3 -#define hd_vec3 hgi_vec3 -#define hd_dvec3 hgi_dvec3 -#define hd_mat3 hgi_mat3 -#define hd_dmat3 hgi_dmat3 - -ivec3 hd_ivec3_get(hd_ivec3 v) { return ivec3(v.x, v.y, v.z); } -ivec3 hd_ivec3_get(ivec3 v) { return v; } -vec3 hd_vec3_get(hd_vec3 v) { return vec3(v.x, v.y, v.z); } -vec3 hd_vec3_get(vec3 v) { return v; } -dvec3 hd_dvec3_get(hd_dvec3 v) { return dvec3(v.x, v.y, v.z); } -dvec3 hd_dvec3_get(dvec3 v) { return v; } -mat3 hd_mat3_get(hd_mat3 v) { return mat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -mat3 hd_mat3_get(mat3 v) { return v; } -dmat3 hd_dmat3_get(hd_dmat3 v) { return dmat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -dmat3 hd_dmat3_get(dmat3 v) { return v; } -hd_ivec3 hd_ivec3_set(hd_ivec3 v) { return v; } -hd_ivec3 hd_ivec3_set(ivec3 v) { return hd_ivec3(v.x, v.y, v.z); } -hd_vec3 hd_vec3_set(hd_vec3 v) { return v; } -hd_vec3 hd_vec3_set(vec3 v) { return hd_vec3(v.x, v.y, v.z); } -hd_dvec3 hd_dvec3_set(hd_dvec3 v) { return v; } -hd_dvec3 hd_dvec3_set(dvec3 v) { return hd_dvec3(v.x, v.y, v.z); } -hd_mat3 hd_mat3_set(hd_mat3 v) { return v; } -hd_mat3 hd_mat3_set(mat3 v) { return hd_mat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -hd_dmat3 hd_dmat3_set(hd_dmat3 v) { return v; } -hd_dmat3 hd_dmat3_set(dmat3 v) { return hd_dmat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -int hd_int_get(int v) { return v; } -int hd_int_get(ivec2 v) { return v.x; } -int hd_int_get(ivec3 v) { return v.x; } -int hd_int_get(ivec4 v) { return v.x; } -vec3 hd_sample_udim(vec2 v) { -vec2 vf = floor(v); -return vec3(v.x - vf.x, v.y - vf.y, clamp(vf.x, 0.0, 10.0) + 10.0 * vf.y); -} -vec4 hd_vec4_2_10_10_10_get(int v) { - ivec4 unpacked = ivec4((v & 0x3ff) << 22, (v & 0xffc00) << 12, - (v & 0x3ff00000) << 2, (v & 0xc0000000)); - return vec4(unpacked) / 2147483647.0; } -int hd_vec4_2_10_10_10_set(vec4 v) { - return ( (int(v.x * 511.0) & 0x3ff) | - ((int(v.y * 511.0) & 0x3ff) << 10) | - ((int(v.z * 511.0) & 0x3ff) << 20) | - ((int(v.w) & 0x1) << 30)); } -vec2 hd_half2_get(uint v) { - return unpackHalf2x16(v); } -uint hd_half2_set(vec2 v) { - return packHalf2x16(v); } -vec4 hd_half4_get(uvec2 v) { - return vec4(unpackHalf2x16(v.x), unpackHalf2x16(v.y)); } -uvec2 hd_half4_set(vec4 v) { - return uvec2(packHalf2x16(v.xy), packHalf2x16(v.zw)); } -#define HD_NUM_PATCH_VERTS 4 -#define HD_NUM_PATCH_EVAL_VERTS 4 -#define HD_NUM_PRIMITIVE_VERTS 3 -#define HD_HAS_transform 1 -#define HD_HAS_transformInverse 1 -#define HD_HAS_color 1 -#define HD_HAS_primID 1 -#define HD_HAS_widths 1 -#define HD_INSTANCER_NUM_LEVELS 0 -#define HD_INSTANCE_INDEX_WIDTH 1 -#define HD_HAS_faceVisibility 1 -#define HD_HAS_points 1 -#define HD_HAS_normals 1 - - -// //////// Global Includes //////// - -// //////// Global Macros //////// - -// //////// Global Structs //////// - -// //////// Global Member Declarations //////// -uint hd_VertexID = gl_VertexID; -uint hd_InstanceID = gl_InstanceID; -uint hd_BaseInstance = 0; - -// //////// Global Function Definitions //////// - - -// //////// Codegen Decl //////// -struct hd_drawingCoord { - int modelCoord; - int constantCoord; - int elementCoord; - int primitiveCoord; - int fvarCoord; - int shaderCoord; - int vertexCoord; - int topologyVisibilityCoord; - int varyingCoord; - int instanceIndex[HD_INSTANCE_INDEX_WIDTH]; - int instanceCoords[HD_INSTANCE_INDEX_WIDTH]; -}; -FORWARD_DECL(hd_drawingCoord GetDrawingCoord()); -FORWARD_DECL(int HgiGetBaseVertex()); -struct hd_instanceIndex { int indices[HD_INSTANCE_INDEX_WIDTH]; }; -struct ConstantData10 { - mat4 transform; - mat4 transformInverse; - vec4 color; - vec4 primID; - float widths; -}; -FORWARD_DECL(int GetElementID()); -FORWARD_DECL(int GetAggregatedElementID()); -FORWARD_DECL(int GetPrimitiveEdgeId()); -FORWARD_DECL(float GetSelectedEdgeOpacity()); -out flat ivec4 vs_interstageDrawingCoord0; -out flat ivec4 vs_interstageDrawingCoord1; -out flat ivec4 vs_interstageDrawingCoord2; -layout (location = 2) in ivec4 drawingCoord0; -layout (location = 3) in ivec4 drawingCoord1; -layout (location = 4) in ivec2 drawingCoord2; -layout (location = 0) in vec3 points; -layout (location = 1) in vec3 normals; -layout(location = 0) uniform ConstantData10 *constantPrimvars; -layout(location = 1) uniform float *faceVisibility; -out CurveVertexData { - vec4 Peye; -} outData; -out PrimvarData { - vec3 points; - vec3 normals; -} outPrimvars; - -// //////// Codegen Accessors //////// -mat4 HdGet_transform(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transform); -} -mat4 HdGet_transform() { return HdGet_transform(0); } -mat4 HdGet_transformInverse(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transformInverse); -} -mat4 HdGet_transformInverse() { return HdGet_transformInverse(0); } -vec4 HdGet_color(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].color); -} -vec4 HdGet_color() { return HdGet_color(0); } -float HdGetScalar_color(int localIndex) { return HdGet_color(localIndex).x; } -float HdGetScalar_color() { return HdGet_color(0).x; } -vec4 HdGet_primID(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].primID); -} -vec4 HdGet_primID() { return HdGet_primID(0); } -float HdGetScalar_primID(int localIndex) { return HdGet_primID(localIndex).x; } -float HdGetScalar_primID() { return HdGet_primID(0).x; } -float HdGet_widths(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return float(constantPrimvars[index].widths); -} -float HdGet_widths() { return HdGet_widths(0); } -float HdGetScalar_widths(int localIndex) { return HdGet_widths(localIndex); } -float HdGetScalar_widths() { return HdGet_widths(0); } - -// //////// Codegen VS Source //////// -#define HD_BINDLESS_BUFFERS_ENABLED -int GetBaseVertexOffset() { - return HgiGetBaseVertex(); -} -hd_instanceIndex GetInstanceIndex() { hd_instanceIndex r; r.indices[0] = 0; return r; } -hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = drawingCoord0.x; - dc.constantCoord = drawingCoord0.y; - dc.elementCoord = drawingCoord0.z; - dc.primitiveCoord = drawingCoord0.w; - dc.fvarCoord = drawingCoord1.x; - dc.shaderCoord = drawingCoord1.z; - dc.vertexCoord = drawingCoord1.w; - dc.topologyVisibilityCoord = drawingCoord2.x; - dc.varyingCoord = drawingCoord2.y; - hd_instanceIndex r = GetInstanceIndex(); - dc.instanceIndex[0] = r.indices[0]; - return dc; -} -vec3 HdGet_points(int localIndex) { return hd_vec3_get(points);} -vec3 HdGet_points() { return HdGet_points(0); } -float HdGetScalar_points(int localIndex) { return HdGet_points(localIndex).x; } -float HdGetScalar_points() { return HdGet_points(0).x; } -vec3 HdGet_normals(int localIndex) { return hd_vec3_get(normals);} -vec3 HdGet_normals() { return HdGet_normals(0); } -float HdGetScalar_normals(int localIndex) { return HdGet_normals(localIndex).x; } -float HdGetScalar_normals() { return HdGet_normals(0).x; } - -// //////// Codegen Proc VS //////// -void ProcessPrimvarsIn() { - hd_drawingCoord dc = GetDrawingCoord(); - vs_interstageDrawingCoord0[0] = dc.modelCoord; - vs_interstageDrawingCoord0[1] = dc.constantCoord; - vs_interstageDrawingCoord0[2] = dc.elementCoord; - vs_interstageDrawingCoord0[3] = dc.primitiveCoord; - vs_interstageDrawingCoord1[0] = dc.fvarCoord; - vs_interstageDrawingCoord1[1] = dc.shaderCoord; - vs_interstageDrawingCoord1[2] = dc.vertexCoord; - vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; - vs_interstageDrawingCoord2[0] = dc.varyingCoord; - vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; - outPrimvars.points = points; - outPrimvars.normals = normals; -} - -// --------------------------------------------------------------------------- -// global defines -// --------------------------------------------------------------------------- -// codeGen can override this range (currently not). -// quadro 4000's max is 189. -#ifndef HD_GL_POINT_SIZE_MAX -#define HD_GL_POINT_SIZE_MAX 100.0 -#endif -#ifndef HD_GL_POINT_SIZE_MIN -#define HD_GL_POINT_SIZE_MIN .45 -#endif - -// --------------------------------------------------------------------------- -// render pass states -// --------------------------------------------------------------------------- - -MAT4 GetWorldToViewMatrix() { -#if defined(HD_HAS_worldToViewMatrix) - return MAT4(HdGet_worldToViewMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetWorldToViewInverseMatrix() { -#if defined(HD_HAS_worldToViewInverseMatrix) - return MAT4(HdGet_worldToViewInverseMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetProjectionMatrix() { -#if defined(HD_HAS_projectionMatrix) - return MAT4(HdGet_projectionMatrix()); -#else - return MAT4(1); -#endif -} -vec3 GetPositionInWorldSpace(vec3 windowRelativeCoord) -{ -#if defined(HD_HAS_imageToWorldMatrix) - vec4 pImage = vec4(windowRelativeCoord, 1.0); - vec4 pWorld = vec4(HdGet_imageToWorldMatrix() * pImage); - return (pWorld / pWorld.w).xyz; -#else - return windowRelativeCoord; -#endif -} -float GetLightingBlendAmount() { -#if defined(HD_HAS_lightingBlendAmount) - return HdGet_lightingBlendAmount(); -#else - return 1; -#endif -} -vec4 GetViewport() { -#if defined(HD_HAS_viewport) - return HdGet_viewport(); -#else - return vec4(0,0,1,1); -#endif -} -float GetTessLevel() { -#if defined(HD_HAS_tessLevel) - return HdGet_tessLevel(); -#else - return 1; -#endif -} -float GetPointSize() { -#if defined(HD_HAS_pointSize) - return HdGet_pointSize(); -#else - return 3.0; -#endif -} -float GetPointSelectedSize() { -#if defined(HD_HAS_pointSelectedSize) - return HdGet_pointSelectedSize(); -#else - return 5.0; -#endif -} -vec4 GetWireframeColor() { -// Individual prims can specify an alternative wireframe color -// to one specified in the render pass. This is used in cases were -// there is not enough contrast with the normal one. -#if defined(HD_HAS_overrideWireframeColor) - return HdGet_overrideWireframeColor(); -#elif defined(HD_HAS_wireframeColor) - return HdGet_wireframeColor(); -#else - return vec4(0,0,0,0); -#endif -} -vec4 GetMaskColor() { -#if defined(HD_HAS_maskColor) - return HdGet_maskColor(); -#else - return vec4(0.5,0,0,1); -#endif -} -vec4 GetIndicatorColor() { -#if defined(HD_HAS_indicatorColor) - return HdGet_indicatorColor(); -#else - return vec4(0,0.5,0,1); -#endif -} - -bool ShouldDiscardByAlpha(vec4 color) -{ -#if defined(HD_HAS_alphaThreshold) - float alphaThreshold = HdGet_alphaThreshold(); -#else - float alphaThreshold = 0; -#endif - return (color.a < alphaThreshold); -} - -vec2 ApplyAxisAlignedAffineTransform(vec4 t, vec2 pt) -{ - return t.xy * pt + t.zw; -} - - - -void ApplyClipPlanes(vec4 Peye) -{ -#if defined(HD_HAS_numClipPlanes) -#if defined(HD_HAS_clipPlanes) - for (int i=0; i> 2); -} -int GetAggregatedElementID() { - return GetElementID() - + GetDrawingCoord().elementCoord; -} -int HdGet_edgeIndices(int localIndex) { - int index = GetPrimitiveIndex(); - return int(edgeIndices[index]); -} -int HdGet_edgeIndices() { return HdGet_edgeIndices(0); } -int HdGetScalar_edgeIndices(int localIndex) { return HdGet_edgeIndices(localIndex); } -int HdGetScalar_edgeIndices() { return HdGet_edgeIndices(0); } -int GetAuthoredEdgeId(int primitiveEdgeId) { - return primitiveEdgeId; -} -float HdGet_faceVisibility(int localIndex) { - int index = GetAggregatedElementID(); - return float(faceVisibility[index]); -} -float HdGet_faceVisibility() { return HdGet_faceVisibility(0); } -float HdGetScalar_faceVisibility(int localIndex) { return HdGet_faceVisibility(localIndex); } -float HdGetScalar_faceVisibility() { return HdGet_faceVisibility(0); } -vec3 HdGet_points(int localIndex) { - int index = localIndex; - return vec3(inPrimvars[index].points); -} -vec3 HdGet_points() { return HdGet_points(0); } -float HdGetScalar_points(int localIndex) { return HdGet_points(localIndex).x; } -float HdGetScalar_points() { return HdGet_points(0).x; } -vec3 HdGet_normals(int localIndex) { - int index = localIndex; - return vec3(inPrimvars[index].normals); -} -vec3 HdGet_normals() { return HdGet_normals(0); } -float HdGetScalar_normals(int localIndex) { return HdGet_normals(localIndex).x; } -float HdGetScalar_normals() { return HdGet_normals(0).x; } -vec2 HdGet_dispTextureCoord_Coarse(int localIndex) { - int fvarIndex = GetFVarIndex(localIndex); - return vec2(dispTextureCoord[fvarIndex]); -} -vec2 HdGet_dispTextureCoord(int localIndex, vec2 st) { - return (HdGet_dispTextureCoord_Coarse(0) * (1-st.x-st.y) + HdGet_dispTextureCoord_Coarse(1) * st.x + HdGet_dispTextureCoord_Coarse(2) * st.y); -} -FORWARD_DECL(vec4 GetPatchCoord(int index)); -FORWARD_DECL(vec2 GetPatchCoordLocalST()); -vec2 HdGet_dispTextureCoord(int localIndex) { - vec2 localST = GetPatchCoord(localIndex).xy; - return HdGet_dispTextureCoord(localIndex, localST); -} -vec2 HdGet_dispTextureCoord() { return HdGet_dispTextureCoord(0); } -FORWARD_DECL(vec4 GetPatchCoord(int localIndex)); -void ProcessSamplingTransforms(MAT4 instanceModelViewInverse) { -} - -// //////// Codegen Proc GS //////// -FORWARD_DECL(vec4 GetPatchCoord(int index)); -void ProcessPrimvarsOut(int index) { - vec2 localST = GetPatchCoord(index).xy; - const vec3 coords[3] = vec3[]( - vec3(1,0,0), vec3(0,1,0), vec3(0,0,1) - ); - hd_barycentricCoord = coords[index]; - hd_drawingCoord dc = GetDrawingCoord(); - gs_interstageDrawingCoord0[0] = dc.modelCoord; - gs_interstageDrawingCoord0[1] = dc.constantCoord; - gs_interstageDrawingCoord0[2] = dc.elementCoord; - gs_interstageDrawingCoord0[3] = dc.primitiveCoord; - gs_interstageDrawingCoord1[0] = dc.fvarCoord; - gs_interstageDrawingCoord1[1] = dc.shaderCoord; - gs_interstageDrawingCoord1[2] = dc.vertexCoord; - gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; - gs_interstageDrawingCoord2[0] = dc.varyingCoord; - gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; - outPrimvars.points = inPrimvars[index].points; - outPrimvars.normals = inPrimvars[index].normals; - outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); -} - -// --------------------------------------------------------------------------- -// global defines -// --------------------------------------------------------------------------- -// codeGen can override this range (currently not). -// quadro 4000's max is 189. -#ifndef HD_GL_POINT_SIZE_MAX -#define HD_GL_POINT_SIZE_MAX 100.0 -#endif -#ifndef HD_GL_POINT_SIZE_MIN -#define HD_GL_POINT_SIZE_MIN .45 -#endif - -// --------------------------------------------------------------------------- -// render pass states -// --------------------------------------------------------------------------- - -MAT4 GetWorldToViewMatrix() { -#if defined(HD_HAS_worldToViewMatrix) - return MAT4(HdGet_worldToViewMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetWorldToViewInverseMatrix() { -#if defined(HD_HAS_worldToViewInverseMatrix) - return MAT4(HdGet_worldToViewInverseMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetProjectionMatrix() { -#if defined(HD_HAS_projectionMatrix) - return MAT4(HdGet_projectionMatrix()); -#else - return MAT4(1); -#endif -} -vec3 GetPositionInWorldSpace(vec3 windowRelativeCoord) -{ -#if defined(HD_HAS_imageToWorldMatrix) - vec4 pImage = vec4(windowRelativeCoord, 1.0); - vec4 pWorld = vec4(HdGet_imageToWorldMatrix() * pImage); - return (pWorld / pWorld.w).xyz; -#else - return windowRelativeCoord; -#endif -} -float GetLightingBlendAmount() { -#if defined(HD_HAS_lightingBlendAmount) - return HdGet_lightingBlendAmount(); -#else - return 1; -#endif -} -vec4 GetViewport() { -#if defined(HD_HAS_viewport) - return HdGet_viewport(); -#else - return vec4(0,0,1,1); -#endif -} -float GetTessLevel() { -#if defined(HD_HAS_tessLevel) - return HdGet_tessLevel(); -#else - return 1; -#endif -} -float GetPointSize() { -#if defined(HD_HAS_pointSize) - return HdGet_pointSize(); -#else - return 3.0; -#endif -} -float GetPointSelectedSize() { -#if defined(HD_HAS_pointSelectedSize) - return HdGet_pointSelectedSize(); -#else - return 5.0; -#endif -} -vec4 GetWireframeColor() { -// Individual prims can specify an alternative wireframe color -// to one specified in the render pass. This is used in cases were -// there is not enough contrast with the normal one. -#if defined(HD_HAS_overrideWireframeColor) - return HdGet_overrideWireframeColor(); -#elif defined(HD_HAS_wireframeColor) - return HdGet_wireframeColor(); -#else - return vec4(0,0,0,0); -#endif -} -vec4 GetMaskColor() { -#if defined(HD_HAS_maskColor) - return HdGet_maskColor(); -#else - return vec4(0.5,0,0,1); -#endif -} -vec4 GetIndicatorColor() { -#if defined(HD_HAS_indicatorColor) - return HdGet_indicatorColor(); -#else - return vec4(0,0.5,0,1); -#endif -} - -bool ShouldDiscardByAlpha(vec4 color) -{ -#if defined(HD_HAS_alphaThreshold) - float alphaThreshold = HdGet_alphaThreshold(); -#else - float alphaThreshold = 0; -#endif - return (color.a < alphaThreshold); -} - -vec2 ApplyAxisAlignedAffineTransform(vec4 t, vec2 pt) -{ - return t.xy * pt + t.zw; -} - - - -void ApplyClipPlanes(vec4 Peye) -{ -#if defined(HD_HAS_numClipPlanes) -#if defined(HD_HAS_clipPlanes) - for (int i=0; i 0.0) - normal = normalize(normal); - return normal; -} - -vec3 GetNormal(vec3 Neye, int index, vec2 localST) -{ - return GetNormal(Neye, index); -} - - - -vec3 GetTriGeometryNormal(vec3 Neye, vec4 Peye0, vec4 Peye1, vec4 Peye2, - bool isFlipped) -{ - return Neye; -} - -vec3 GetQuadGeometryNormal(vec3 Neye, - vec4 Peye0, vec4 Peye1, vec4 Peye2, vec4 Peye3, - bool isFlipped) -{ - return Neye; -} - - - -vec4 DisplacementTerminal(int index, vec4 Peye, vec3 Neye, vec4 patchCoord) -{ - return Peye; -} - - - -vec4 GetPatchCoord(int index) -{ - vec2 uv[3]; - uv[0] = vec2(0, 0); // (0, 0, 1); - uv[1] = vec2(1, 0); // (1, 0, 0); - uv[2] = vec2(0, 1); // (0, 1, 0); - - ivec3 patchParam = GetPatchParam(); - return InterpolatePatchCoordTriangle(uv[index], patchParam); -} - -void emit(int index, vec4 Peye, vec3 Neye) -{ - outData.Peye = Peye; - outData.Neye = Neye; - - gsPatchCoord = GetPatchCoord(index); - - gl_Position = vec4(GetProjectionMatrix() * outData.Peye); - ApplyClipPlanes(outData.Peye); - - ProcessPrimvarsOut(index); - - EmitVertex(); -} - -void main(void) -{ - gl_PrimitiveID = gl_PrimitiveIDIn; - - bool isFlipped = IsFlipped(); // consider handedness AND negative-scale - - vec3 Neye0 = GetNormal(inData[0].Neye, 0); - Neye0 = GetTriGeometryNormal(Neye0, inData[0].Peye, inData[1].Peye, - inData[2].Peye, isFlipped); - vec3 Neye1 = GetNormal(inData[1].Neye, 1); - Neye1 = GetTriGeometryNormal(Neye1, inData[0].Peye, inData[1].Peye, - inData[2].Peye, isFlipped); - vec3 Neye2 = GetNormal(inData[2].Neye, 2); - Neye2 = GetTriGeometryNormal(Neye2, inData[0].Peye, inData[1].Peye, - inData[2].Peye, isFlipped); - - vec4 Peye0 = DisplacementTerminal( - 0, inData[0].Peye, Neye0, GetPatchCoord(0)); - vec4 Peye1 = DisplacementTerminal( - 1, inData[1].Peye, Neye1, GetPatchCoord(1)); - vec4 Peye2 = DisplacementTerminal( - 2, inData[2].Peye, Neye2, GetPatchCoord(2)); - - // triangle 0: vertices (0,1,2) - emit(0, Peye0, Neye0); - emit(1, Peye1, Neye1); - emit(2, Peye2, Neye2); - - EndPrimitive(); -} - - -======================================================= - FRAGMENT SHADER -======================================================= -#version 450 -#extension GL_NV_shader_buffer_load : require -#extension GL_NV_gpu_shader5 : require -#extension GL_ARB_bindless_texture : require -#define REF(space,type) inout type -#define FORWARD_DECL(func_decl) func_decl; -#define ATOMIC_LOAD(a) (a) -#define ATOMIC_STORE(a, v) (a) = (v) -#define ATOMIC_ADD(a, v) atomicAdd(a, v) -#define ATOMIC_EXCHANGE(a, v) atomicExchange(a, v) -#define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) -#define atomic_int int -#define atomic_uint uint - -#define HGI_HAS_DOUBLE_TYPE 1 - - -struct hgi_ivec3 { int x, y, z; }; -struct hgi_vec3 { float x, y, z; }; -struct hgi_dvec3 { double x, y, z; }; -struct hgi_mat3 { float m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; -struct hgi_dmat3 { double m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; - - - -// //////// Global Includes //////// - -// //////// Global Macros //////// - -// //////// Global Structs //////// - -// //////// Global Member Declarations //////// - -// //////// Global Function Definitions //////// - - -// //////// Codegen Defines //////// -#define HD_SHADER_API 2 -#define MAT4 mat4 -// Alias hgi vec and matrix types to hd. -#define hd_ivec3 hgi_ivec3 -#define hd_vec3 hgi_vec3 -#define hd_dvec3 hgi_dvec3 -#define hd_mat3 hgi_mat3 -#define hd_dmat3 hgi_dmat3 - -ivec3 hd_ivec3_get(hd_ivec3 v) { return ivec3(v.x, v.y, v.z); } -ivec3 hd_ivec3_get(ivec3 v) { return v; } -vec3 hd_vec3_get(hd_vec3 v) { return vec3(v.x, v.y, v.z); } -vec3 hd_vec3_get(vec3 v) { return v; } -dvec3 hd_dvec3_get(hd_dvec3 v) { return dvec3(v.x, v.y, v.z); } -dvec3 hd_dvec3_get(dvec3 v) { return v; } -mat3 hd_mat3_get(hd_mat3 v) { return mat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -mat3 hd_mat3_get(mat3 v) { return v; } -dmat3 hd_dmat3_get(hd_dmat3 v) { return dmat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -dmat3 hd_dmat3_get(dmat3 v) { return v; } -hd_ivec3 hd_ivec3_set(hd_ivec3 v) { return v; } -hd_ivec3 hd_ivec3_set(ivec3 v) { return hd_ivec3(v.x, v.y, v.z); } -hd_vec3 hd_vec3_set(hd_vec3 v) { return v; } -hd_vec3 hd_vec3_set(vec3 v) { return hd_vec3(v.x, v.y, v.z); } -hd_dvec3 hd_dvec3_set(hd_dvec3 v) { return v; } -hd_dvec3 hd_dvec3_set(dvec3 v) { return hd_dvec3(v.x, v.y, v.z); } -hd_mat3 hd_mat3_set(hd_mat3 v) { return v; } -hd_mat3 hd_mat3_set(mat3 v) { return hd_mat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -hd_dmat3 hd_dmat3_set(hd_dmat3 v) { return v; } -hd_dmat3 hd_dmat3_set(dmat3 v) { return hd_dmat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -int hd_int_get(int v) { return v; } -int hd_int_get(ivec2 v) { return v.x; } -int hd_int_get(ivec3 v) { return v.x; } -int hd_int_get(ivec4 v) { return v.x; } -vec3 hd_sample_udim(vec2 v) { -vec2 vf = floor(v); -return vec3(v.x - vf.x, v.y - vf.y, clamp(vf.x, 0.0, 10.0) + 10.0 * vf.y); -} -vec4 hd_vec4_2_10_10_10_get(int v) { - ivec4 unpacked = ivec4((v & 0x3ff) << 22, (v & 0xffc00) << 12, - (v & 0x3ff00000) << 2, (v & 0xc0000000)); - return vec4(unpacked) / 2147483647.0; } -int hd_vec4_2_10_10_10_set(vec4 v) { - return ( (int(v.x * 511.0) & 0x3ff) | - ((int(v.y * 511.0) & 0x3ff) << 10) | - ((int(v.z * 511.0) & 0x3ff) << 20) | - ((int(v.w) & 0x1) << 30)); } -vec2 hd_half2_get(uint v) { - return unpackHalf2x16(v); } -uint hd_half2_set(vec2 v) { - return packHalf2x16(v); } -vec4 hd_half4_get(uvec2 v) { - return vec4(unpackHalf2x16(v.x), unpackHalf2x16(v.y)); } -uvec2 hd_half4_set(vec4 v) { - return uvec2(packHalf2x16(v.xy), packHalf2x16(v.zw)); } -#define HD_NUM_PRIMITIVE_VERTS 3 -#define HD_HAS_transform 1 -#define HD_HAS_transformInverse 1 -#define HD_HAS_color 1 -#define HD_HAS_primID 1 -#define HD_HAS_widths 1 -#define HD_INSTANCER_NUM_LEVELS 0 -#define HD_INSTANCE_INDEX_WIDTH 1 -#define HD_HAS_faceVisibility 1 -#define HD_HAS_dispTextureCoord 1 -#define HD_HAS_points 1 -#define HD_HAS_normals 1 - -// //////// Codegen Decl //////// -struct hd_drawingCoord { - int modelCoord; - int constantCoord; - int elementCoord; - int primitiveCoord; - int fvarCoord; - int shaderCoord; - int vertexCoord; - int topologyVisibilityCoord; - int varyingCoord; - int instanceIndex[HD_INSTANCE_INDEX_WIDTH]; - int instanceCoords[HD_INSTANCE_INDEX_WIDTH]; -}; -FORWARD_DECL(hd_drawingCoord GetDrawingCoord()); -FORWARD_DECL(int HgiGetBaseVertex()); -struct hd_instanceIndex { int indices[HD_INSTANCE_INDEX_WIDTH]; }; -struct ConstantData10 { - mat4 transform; - mat4 transformInverse; - vec4 color; - vec4 primID; - float widths; -}; -FORWARD_DECL(int GetElementID()); -FORWARD_DECL(int GetAggregatedElementID()); -FORWARD_DECL(int GetPrimitiveEdgeId()); -FORWARD_DECL(float GetSelectedEdgeOpacity()); -layout(location = 0) uniform ConstantData10 *constantPrimvars; -layout(location = 1) uniform int *primitiveParam; -layout(location = 2) uniform int *edgeIndices; -layout(location = 3) uniform float *faceVisibility; -in vec4 gsPatchCoord; -in VertexData { - vec4 Peye; - vec3 Neye; -} inData; -layout (location = 0) out vec4 colorOut; -in noperspective vec3 hd_barycentricCoord; -in flat ivec4 gs_interstageDrawingCoord0; -in flat ivec4 gs_interstageDrawingCoord1; -in flat ivec4 gs_interstageDrawingCoord2; -in PrimvarData { - vec3 points; - vec3 normals; - vec2 dispTextureCoord; -} inPrimvars; -layout(location = 4) uniform vec2 *dispTextureCoord; -vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) -{ - // add 0.5 to integer values for more robust interpolation - return vec4(uv.x, uv.y, 0, patchParam.x+0.5f); -} -vec4 InterpolatePatchCoordTriangle(vec2 uv, ivec3 patchParam) -{ - return InterpolatePatchCoord(uv, patchParam); -} - -// //////// Codegen Accessors //////// -mat4 HdGet_transform(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transform); -} -mat4 HdGet_transform() { return HdGet_transform(0); } -mat4 HdGet_transformInverse(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transformInverse); -} -mat4 HdGet_transformInverse() { return HdGet_transformInverse(0); } -vec4 HdGet_color(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].color); -} -vec4 HdGet_color() { return HdGet_color(0); } -float HdGetScalar_color(int localIndex) { return HdGet_color(localIndex).x; } -float HdGetScalar_color() { return HdGet_color(0).x; } -vec4 HdGet_primID(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].primID); -} -vec4 HdGet_primID() { return HdGet_primID(0); } -float HdGetScalar_primID(int localIndex) { return HdGet_primID(localIndex).x; } -float HdGetScalar_primID() { return HdGet_primID(0).x; } -float HdGet_widths(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return float(constantPrimvars[index].widths); -} -float HdGet_widths() { return HdGet_widths(0); } -float HdGetScalar_widths(int localIndex) { return HdGet_widths(localIndex); } -float HdGetScalar_widths() { return HdGet_widths(0); } - -// //////// Codegen FS Source //////// -#define HD_SHADER_SUPPORTS_DOUBLE_PRECISION -#define HD_MINUS_ONE_TO_ONE_DEPTH_RANGE -vec3 GetBarycentricCoord() { - return hd_barycentricCoord; -} -int GetPrimitiveID() { - return gl_PrimitiveID; -} -int GetPrimitiveIndex() { - return GetDrawingCoord().primitiveCoord + GetPrimitiveID(); -} -hd_drawingCoord GetDrawingCoord() { - hd_drawingCoord dc; - dc.modelCoord = gs_interstageDrawingCoord0[0]; - dc.constantCoord = gs_interstageDrawingCoord0[1]; - dc.elementCoord = gs_interstageDrawingCoord0[2]; - dc.primitiveCoord = gs_interstageDrawingCoord0[3]; - dc.fvarCoord = gs_interstageDrawingCoord1[0]; - dc.shaderCoord = gs_interstageDrawingCoord1[1]; - dc.vertexCoord = gs_interstageDrawingCoord1[2]; - dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; - dc.varyingCoord = gs_interstageDrawingCoord2[0]; - dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; - return dc; -} -int HdGet_primitiveParam(int localIndex) { - int index = GetPrimitiveIndex(); - return int(primitiveParam[index]); -} -int HdGet_primitiveParam() { return HdGet_primitiveParam(0); } -int HdGetScalar_primitiveParam(int localIndex) { return HdGet_primitiveParam(localIndex); } -int HdGetScalar_primitiveParam() { return HdGet_primitiveParam(0); } -#if defined(HD_HAS_coarseFaceIndex) -FORWARD_DECL(int HdGetScalar_coarseFaceIndex()); -#endif -ivec3 GetPatchParam() { -#if defined(HD_HAS_coarseFaceIndex) - return ivec3(HdGetScalar_coarseFaceIndex(), 0, 0); -#else - return ivec3(GetPrimitiveID(), 0, 0); -#endif -} -int GetEdgeFlag() { - return (HdGet_primitiveParam() & 3); -} -int GetFVarIndex(int localIndex) { - int fvarCoord = GetDrawingCoord().fvarCoord; - int ptexIndex = GetPatchParam().x & 0xfffffff; - return fvarCoord + ptexIndex * 3 + localIndex; -} -int GetElementID() { - return (hd_int_get(HdGet_primitiveParam()) >> 2); -} -int GetAggregatedElementID() { - return GetElementID() - + GetDrawingCoord().elementCoord; -} -int HdGet_edgeIndices(int localIndex) { - int index = GetPrimitiveIndex(); - return int(edgeIndices[index]); -} -int HdGet_edgeIndices() { return HdGet_edgeIndices(0); } -int HdGetScalar_edgeIndices(int localIndex) { return HdGet_edgeIndices(localIndex); } -int HdGetScalar_edgeIndices() { return HdGet_edgeIndices(0); } -int GetAuthoredEdgeId(int primitiveEdgeId) { - return primitiveEdgeId; -} -float HdGet_faceVisibility(int localIndex) { - int index = GetAggregatedElementID(); - return float(faceVisibility[index]); -} -float HdGet_faceVisibility() { return HdGet_faceVisibility(0); } -float HdGetScalar_faceVisibility(int localIndex) { return HdGet_faceVisibility(localIndex); } -float HdGetScalar_faceVisibility() { return HdGet_faceVisibility(0); } -vec3 HdGet_points(int localIndex) { return vec3(inPrimvars.points);} -vec3 HdGet_points() { return HdGet_points(0); } -float HdGetScalar_points(int localIndex) { return HdGet_points(localIndex).x; } -float HdGetScalar_points() { return HdGet_points(0).x; } -vec3 HdGet_normals(int localIndex) { return vec3(inPrimvars.normals);} -vec3 HdGet_normals() { return HdGet_normals(0); } -float HdGetScalar_normals(int localIndex) { return HdGet_normals(localIndex).x; } -float HdGetScalar_normals() { return HdGet_normals(0).x; } -vec2 HdGet_dispTextureCoord(int localIndex) { return vec2(inPrimvars.dispTextureCoord);} -vec2 HdGet_dispTextureCoord() { return HdGet_dispTextureCoord(0); } -float HdGetScalar_dispTextureCoord(int localIndex) { return HdGet_dispTextureCoord(localIndex).x; } -float HdGetScalar_dispTextureCoord() { return HdGet_dispTextureCoord(0).x; } -FORWARD_DECL(vec4 GetPatchCoord(int index)); -void ProcessSamplingTransforms(MAT4 instanceModelViewInverse) { -} - -// --------------------------------------------------------------------------- -// global defines -// --------------------------------------------------------------------------- -// codeGen can override this range (currently not). -// quadro 4000's max is 189. -#ifndef HD_GL_POINT_SIZE_MAX -#define HD_GL_POINT_SIZE_MAX 100.0 -#endif -#ifndef HD_GL_POINT_SIZE_MIN -#define HD_GL_POINT_SIZE_MIN .45 -#endif - -// --------------------------------------------------------------------------- -// render pass states -// --------------------------------------------------------------------------- - -MAT4 GetWorldToViewMatrix() { -#if defined(HD_HAS_worldToViewMatrix) - return MAT4(HdGet_worldToViewMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetWorldToViewInverseMatrix() { -#if defined(HD_HAS_worldToViewInverseMatrix) - return MAT4(HdGet_worldToViewInverseMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetProjectionMatrix() { -#if defined(HD_HAS_projectionMatrix) - return MAT4(HdGet_projectionMatrix()); -#else - return MAT4(1); -#endif -} -vec3 GetPositionInWorldSpace(vec3 windowRelativeCoord) -{ -#if defined(HD_HAS_imageToWorldMatrix) - vec4 pImage = vec4(windowRelativeCoord, 1.0); - vec4 pWorld = vec4(HdGet_imageToWorldMatrix() * pImage); - return (pWorld / pWorld.w).xyz; -#else - return windowRelativeCoord; -#endif -} -float GetLightingBlendAmount() { -#if defined(HD_HAS_lightingBlendAmount) - return HdGet_lightingBlendAmount(); -#else - return 1; -#endif -} -vec4 GetViewport() { -#if defined(HD_HAS_viewport) - return HdGet_viewport(); -#else - return vec4(0,0,1,1); -#endif -} -float GetTessLevel() { -#if defined(HD_HAS_tessLevel) - return HdGet_tessLevel(); -#else - return 1; -#endif -} -float GetPointSize() { -#if defined(HD_HAS_pointSize) - return HdGet_pointSize(); -#else - return 3.0; -#endif -} -float GetPointSelectedSize() { -#if defined(HD_HAS_pointSelectedSize) - return HdGet_pointSelectedSize(); -#else - return 5.0; -#endif -} -vec4 GetWireframeColor() { -// Individual prims can specify an alternative wireframe color -// to one specified in the render pass. This is used in cases were -// there is not enough contrast with the normal one. -#if defined(HD_HAS_overrideWireframeColor) - return HdGet_overrideWireframeColor(); -#elif defined(HD_HAS_wireframeColor) - return HdGet_wireframeColor(); -#else - return vec4(0,0,0,0); -#endif -} -vec4 GetMaskColor() { -#if defined(HD_HAS_maskColor) - return HdGet_maskColor(); -#else - return vec4(0.5,0,0,1); -#endif -} -vec4 GetIndicatorColor() { -#if defined(HD_HAS_indicatorColor) - return HdGet_indicatorColor(); -#else - return vec4(0,0.5,0,1); -#endif -} - -bool ShouldDiscardByAlpha(vec4 color) -{ -#if defined(HD_HAS_alphaThreshold) - float alphaThreshold = HdGet_alphaThreshold(); -#else - float alphaThreshold = 0; -#endif - return (color.a < alphaThreshold); -} - -vec2 ApplyAxisAlignedAffineTransform(vec4 t, vec2 pt) -{ - return t.xy * pt + t.zw; -} - - - -vec2 HorizontallyNormalizedFilmbackCoordinates() -{ - const vec4 transform = -#ifdef HD_HAS_imageToHorizontallyNormalizedFilmback - HdGet_imageToHorizontallyNormalizedFilmback(); -#else - vec4(vec2(1.0), vec2(0.0)); -#endif - return ApplyAxisAlignedAffineTransform(transform, gl_FragCoord.xy); -} - - - -vec4 ApplySelectionColor(vec4 color) -{ - return color; -} - - - -// Forward declare selection functionality. -// XXX: Currently, the non-empty implementation of this is in hdx. -FORWARD_DECL(vec4 ApplySelectionColor(vec4 color)); - -// XXX: Make sure to update hdx/shaders/renderPass.glslfx when editing these -// color override methods, since they're currently duplicated. This is because -// we don't have a mixin token for color overrides in a render pass yet. -vec4 ApplyColorOverrides(vec4 color) -{ -#if defined(HD_HAS_overrideColor) - // Mix in override color - vec4 overrideColor = HdGet_overrideColor(); - color.rgb = mix(color.rgb, overrideColor.rgb, overrideColor.a); -#endif - return ApplySelectionColor(color); -} - -vec3 ApplyMaskColor(vec3 color, float weight, vec4 maskColor) -{ - float strength = maskColor.a * clamp(weight, 0.0, 1.0); - return mix(color, maskColor.rgb, strength); -} - -vec4 ApplyColorOverridesPostLighting(vec4 color) -{ - #if defined(HD_HAS_maskWeight) - float maskWeight = HdGet_maskWeight(); - vec4 maskColor = GetMaskColor(); - color.rgb = ApplyMaskColor(color.rgb, maskWeight, maskColor); - #endif - #if defined(HD_HAS_indicatorWeight) - float indicatorWeight = HdGet_indicatorWeight(); - vec4 indicatorColor = GetIndicatorColor(); - color.rgb = ApplyMaskColor(color.rgb, indicatorWeight, indicatorColor); - #endif - return color; -} - - - -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - colorOut = color; -} - - -#ifndef HD_HAS_integrateLights -#define HD_HAS_integrateLights -#endif - -struct LightingContribution { - vec3 diffuse; -}; - -struct LightingInterfaceProperties { - float unused; -}; - -LightingContribution -integrateLightsDefault(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - vec3 n = normalize(Neye); - - LightingContribution result; - result.diffuse = vec3(dot(n, vec3(0,0,1))); - - return result; -} - -LightingContribution -integrateLightsConstant(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - LightingContribution result; - //pefectly diffuse white hemisphere contribution - result.diffuse = vec3(1); - - return result; -} - - - -FORWARD_DECL( - LightingContribution integrateLights(vec4 Peye, vec3 Neye, - LightingInterfaceProperties props)); - -vec3 FallbackLighting(in vec3 Peye, in vec3 Neye, in vec3 color) -{ - LightingInterfaceProperties props; - LightingContribution light = integrateLights(vec4(Peye, 1), Neye, props); - return color * light.diffuse; -} - - -vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - // lighting - color.rgb = FallbackLighting(Peye.xyz, Neye, color.rgb); - return color; -} - - -// quaternion to matrix. xyz = imaginary, w = real -MAT4 GetRotationMatrix(vec4 q) -{ - MAT4 r; - r[0].xyzw = vec4(1 - 2 * (q.y * q.y + q.z * q.z), - 2 * (q.x * q.y + q.z * q.w), - 2 * (q.x * q.z - q.y * q.w), - 0); - r[1].xyzw = vec4( 2 * (q.x * q.y - q.z * q.w), - 1 - 2 * (q.x * q.x + q.z * q.z), - 2 * (q.y * q.z + q.x * q.w), - 0); - r[2].xyzw = vec4( 2 * (q.x * q.z + q.y * q.w), - 2 * (q.y * q.z - q.x * q.w), - 1 - 2 * (q.x * q.x + q.y * q.y), - 0); - r[3] = vec4(0, 0, 0, 1); - return r; -} - -// --------------------------------------------------------------------------- - -MAT4 GetInstanceTransform(int level) -{ - MAT4 m = MAT4(1); -#ifdef HD_HAS_INSTANCE_hydra_instanceTransforms - m = HdGetInstance_hydra_instanceTransforms(level, MAT4(1)) * m; -#elif defined(HD_HAS_INSTANCE_instanceTransform) - m = HdGetInstance_instanceTransform(level, MAT4(1)) * m; -#endif - - // instance transform elements are applied: - // scale then rotate then translate - // i.e. (T * R * S) * position - -#ifdef HD_HAS_INSTANCE_hydra_instanceScales - vec3 s = HdGetInstance_hydra_instanceScales(level, /*default=*/vec3(1)); - m = MAT4(s.x, 0, 0, 0, - 0, s.y, 0, 0, - 0, 0, s.z, 0, - 0, 0, 0, 1) * m; -#elif defined(HD_HAS_INSTANCE_instanceScale) - vec3 s = HdGetInstance_scale(level, /*default=*/vec3(1)); - m = MAT4(s.x, 0, 0, 0, - 0, s.y, 0, 0, - 0, 0, s.z, 0, - 0, 0, 0, 1) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceRotations // GfQuat(ix, iy, iz, real) - vec4 q = HdGetInstance_hydra_instanceRotations(level, /*default=*/vec4(0)); - m = GetRotationMatrix(q) * m; -#elif defined(HD_HAS_INSTANCE_rotate) - vec4 q = HdGetInstance_rotate(level, /*default=*/vec4(0)); - m = GetRotationMatrix(q) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceTranslations - vec3 t = HdGetInstance_hydra_instanceTranslations(level, /*default=*/vec3(0)); - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - t.x, t.y, t.z, 1) * m; -#elif defined(HD_HAS_INSTANCE_translate) - vec3 t = HdGetInstance_translate(level, /*default=*/vec3(0)); - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - t.x, t.y, t.z, 1) * m; -#endif - return m; -} - -MAT4 GetInstanceTransformInverse(int level) -{ - MAT4 m = MAT4(1); - -#ifdef HD_HAS_INSTANCE_hydra_instanceTransforms - m = inverse(HdGetInstance_hydra_instanceTransforms(level, MAT4(1))) * m; -#elif defined(HD_HAS_INSTANCE_instanceTransform) - m = inverse(HdGetInstance_instanceTransform(level, MAT4(1))) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceTranslations - vec3 it = -HdGetInstance_hydra_instanceTranslations(level, /*default=*/vec3(0)); // negate - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - it.x, it.y, it.z, 1) * m; -#elif defined(HD_HAS_INSTANCE_translate) - vec3 it = -HdGetInstance_translate(level, /*default=*/vec3(0)); // negate - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - it.x, it.y, it.z, 1) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceRotations - vec4 q = HdGetInstance_hydra_instanceRotations(level, /*default=*/vec4(0)); - q.xyz = -q.xyz; // inverse rotataion axis - m = GetRotationMatrix(q) * m; -#elif defined(HD_HAS_INSTANCE_rotate) - vec4 q = HdGetInstance_rotate(level, /*default=*/vec4(0)); - q.xyz = -q.xyz; // inverse rotataion axis - m = GetRotationMatrix(q) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceScales - vec3 is = 1.0/HdGetInstance_hydra_instanceScales(level, /*default=*/vec3(1)); // inverse scale - m = MAT4(is.x, 0, 0, 0, - 0, is.y, 0, 0, - 0, 0, is.z, 0, - 0, 0, 0, 1) * m; -#elif defined(HD_HAS_INSTANCE_scale) - vec3 is = 1.0/HdGetInstance_scale(level, /*default=*/vec3(1)); // inverse scale - m = MAT4(is.x, 0, 0, 0, - 0, is.y, 0, 0, - 0, 0, is.z, 0, - 0, 0, 0, 1) * m; -#endif - return m; -} - -// --------------------------------------------------------------------------- - -MAT4 GetInstanceTransform() -{ - MAT4 m = MAT4(1); -#ifdef HD_INSTANCER_NUM_LEVELS - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - m = GetInstanceTransform(i) * m; -#ifdef HD_HAS_instancerTransform - m = HdGet_instancerTransform(i) * m; -#endif - } -#endif - return m; -} - -MAT4 GetInstanceTransformInverse() -{ - MAT4 m = MAT4(1); -#ifdef HD_INSTANCER_NUM_LEVELS - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - m = m * GetInstanceTransformInverse(i); -#ifdef HD_HAS_instancerTransformInverse - m = m * HdGet_instancerTransformInverse(i); -#endif - } -#endif - return m; -} - -// --------------------------------------------------------------------------- - -MAT4 ApplyInstanceTransform(MAT4 m) -{ - return GetInstanceTransform() * m; -} - -MAT4 ApplyInstanceTransformInverse(MAT4 m) -{ - return m * GetInstanceTransformInverse(); -} - -bool IsFlipped() -{ -#if defined(HD_HAS_isFlipped) - bool flip = (HdGet_isFlipped() != 0); -#elif defined(HD_HAS_transform) - // The sign of the determinant indicates whether m flips handedness - bool flip = (determinant(HdGet_transform()) < 0.0); -#else - bool flip = false; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceScales - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - vec3 scale = HdGetInstance_hydra_instanceScales(i, /*default=*/vec3(1)); - flip = flip != ((sign(scale.x) * sign(scale.y) * sign(scale.z)) < 0); - } -#elif defined(HD_HAS_INSTANCE_scale) - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - vec3 scale = HdGetInstance_scale(i, /*default=*/vec3(1)); - flip = flip != ((sign(scale.x) * sign(scale.y) * sign(scale.z)) < 0); - } -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceTransforms - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - MAT4 m = HdGetInstance_hydra_instanceTransforms(i, MAT4(1)); - flip = flip != (determinant(m) < 0.0); - } -#elif defined(HD_HAS_INSTANCE_instanceTransform) - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - MAT4 m = HdGetInstance_instanceTransform(i, MAT4(1)); - flip = flip != (determinant(m) < 0.0); - } -#endif - - return flip; -} - - -vec3 GetNormal(vec3 Neye, int index) -{ - return Neye; -} - -vec3 GetNormal(vec3 Neye, int index, vec2 localST) -{ - return GetNormal(Neye, index); -} - - - -vec3 GetShadingNormal(vec3 N, bool isFlipped) -{ - // the fragment shader takes already-flipped-normals. - // no need to flip here. - return N; -} - - - -void DiscardBasedOnShading(bool frontFacing, bool isFlipped) -{ - // Nothing to do since h/w face culling is used. -} - - - -vec4 ApplyEdgeColor(vec4 Cfill, vec4 patchCoord) -{ - return Cfill; -} - -// Return a large value, signifying that the fragment isn't near an edge. -float GetMinEdgeDistance() -{ - return 1000.0; -} - - - -vec3 GetEdgeParamTriangle() -{ - // Expand barycentric coordinates - vec2 param = GetPatchCoord(0).xy; - vec3 barycentric = vec3(param.x, param.y, 1 - param.x - param.y); - - // Match triangle edge order - return barycentric.yzx; -} - -vec3 GetEdgeDistanceTriangle() -{ - vec3 param = GetEdgeParamTriangle(); - return max(vec3(0.0), param / fwidth(param)); -} - -vec4 GetEdgeParamQuad() -{ - // Expand coordinates to opposite corners of quad - vec2 leftBottom = GetPatchCoord(0).xy; - vec2 rightTop = vec2(1.0) - leftBottom; - - // Match quad edge order - return vec4(leftBottom.y, rightTop.x, rightTop.y, leftBottom.x); -} - -vec4 GetEdgeDistanceQuad() -{ - vec4 param = GetEdgeParamQuad(); - return max(vec4(0.0), param / fwidth(param)); -} - - - -struct ReprStyle -{ - vec4 color; - bool usePrimvarColor; - bool usePrimvarAlpha; - bool applyColorOverride; - bool useSurfaceShaderColor; - bool useSurfaceShaderAlpha; -}; - -struct ScalarOverride -{ - bool enabled; - vec3 color; -}; - -FORWARD_DECL(ReprStyle GetReprStyle()); -FORWARD_DECL(ScalarOverride GetScalarOverride()); -FORWARD_DECL( - vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)); -FORWARD_DECL(vec4 postSurfaceShader(vec4 Peye, vec3 Neye, vec4 color)); - -vec4 ShadingTerminal(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - ReprStyle reprStyle = GetReprStyle(); - - // Apply scalar override. - ScalarOverride scalarOverride = GetScalarOverride(); - if (scalarOverride.enabled) { - vec4 result; - - result.rgb = scalarOverride.color; - result.a = reprStyle.usePrimvarAlpha ? color.a: reprStyle.color.a; - - vec4 colorOverride = ApplyColorOverrides(result); - result = reprStyle.applyColorOverride ? colorOverride : result; - - return result; - } - - // Draw mode can override face color - vec4 reprColor; - - reprColor.rgb = reprStyle.usePrimvarColor ? color.rgb : reprStyle.color.rgb; - reprColor.a = reprStyle.usePrimvarAlpha ? color.a : reprStyle.color.a; - - // Compute color overrides - vec4 colorOverride = ApplyColorOverrides(reprColor); - reprColor = reprStyle.applyColorOverride ? colorOverride : reprColor; - - - // Surface shading can be expensive and also can contain undesirable - // side effects (like discards). So only run it for reprs that require it. - - if (reprStyle.useSurfaceShaderColor || - reprStyle.useSurfaceShaderAlpha) { - vec4 shadingColor; - - shadingColor = surfaceShader(Peye, - Neye, - reprColor, - patchCoord); - -#ifdef HD_HAS_postSurfaceShader - shadingColor = postSurfaceShader(Peye, - Neye, - shadingColor); -#endif - - reprColor.rgb = reprStyle.useSurfaceShaderColor ? - shadingColor.rgb : - reprColor.rgb; - - reprColor.a = reprStyle.useSurfaceShaderAlpha ? - shadingColor.a : - reprColor.a; - } - - vec4 baseColor = color; - baseColor = ApplyColorOverrides(baseColor); - - vec4 litColor = mix(baseColor, - reprColor, - GetLightingBlendAmount()); - - // Final overrides. - - return ApplyColorOverridesPostLighting(litColor); -} - - - -#ifdef HD_HAS_integrateLights -#ifndef HD_HAS_definedIntegrateLights -#define HD_HAS_definedIntegrateLights - -LightingContribution -integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - return integrateLightsDefault(Peye, Neye, props); -} - -#endif // HD_HAS_definedIntegrateLights -#endif - -ReprStyle GetReprStyle() -{ - ReprStyle reprStyle; - - reprStyle.color = vec4(0.0, 0.0, 0.0, 1.0); - reprStyle.usePrimvarColor = true; - reprStyle.usePrimvarAlpha = true; - reprStyle.applyColorOverride = true; - reprStyle.useSurfaceShaderColor = true; - reprStyle.useSurfaceShaderAlpha = true; - - return reprStyle; -} - - - -ScalarOverride GetScalarOverride() -{ - ScalarOverride result; - -#if defined(HD_HAS_scalarOverride) - result.enabled = true; - - // Allow a scalar value to override the color from the surface - // for previewing heatmaps. This is useful for editing workflows. -#if defined(HD_HAS_scalarOverrideColorRamp) - int rampCount = constantPrimvars[GetDrawingCoord().constantCoord]. - scalarOverrideColorRamp.length(); - float scalar = HdGet_scalarOverride() * float(rampCount - 1); - float baseIndex = floor(scalar); - float nextIndex = min(float(rampCount - 1), baseIndex + 1.0); - float interp = scalar - baseIndex; - result.color = mix(HdGet_scalarOverrideColorRamp(int(baseIndex)).rgb, - HdGet_scalarOverrideColorRamp(int(nextIndex)).rgb, - interp); -#else - // If no ramp is given just gamma correct the scalar as greyscale. - result.color = vec3(pow(HdGet_scalarOverride(), 2.2)); -#endif // HD_HAS_scalarOverrideColorRamp - -#else // HD_HAS_scalarOverride - result.enabled = false; - result.color = vec3(0.0, 0.0, 0.0); -#endif - - return result; -} - - - -// Determines whether a fragment is on or close to an unhidden triangle edge. -const float edgePickRadius = 2; // in viewport pixels -const float edgePickParametricRadius = 0.02; // in parametric space - -// For smooth looking edges, use an exponential falloff for the opacity. -// Note: We use a slower falloff fn than in meshWire.glslfx to make the -// selected edges stand out. -float SelectedEdgeFalloff(float d) { - return exp2(-1 * d * d); -} - - - -FORWARD_DECL(vec3 GetEdgeDistanceTriangle()); - -vec3 ComputeBaseFaceEdgeDistanceTriangle() -{ - return GetEdgeDistanceTriangle(); -} - -bool SelectWireframeFaceEdges() -{ - return false; -} - - - -float GetSelectedEdgeOpacity() -{ - float closestEdgeDistance = 0.0; - - // The sequence of comparisons should match GetPrimitiveEdgeId() - vec3 dist = ComputeBaseFaceEdgeDistanceTriangle(); - if (dist.x < edgePickRadius) { - closestEdgeDistance = dist.x; - } else if (dist.y < edgePickRadius) { - closestEdgeDistance = dist.y; - } else if (dist.z < edgePickRadius) { - closestEdgeDistance = dist.z; - } else { - return 0; - } - - return SelectedEdgeFalloff(closestEdgeDistance); -} - -// called from hdx/renderPass.glslfx and selection.glslfx -int GetPrimitiveEdgeId() -{ - // 2 (0,1,0) - // ^ - // e2 / \ e1 - // / \' - // (0,0,1) 0 ----- 1 (1,0,0) - // e0 - - int edgeId = -1; - - vec3 dist = ComputeBaseFaceEdgeDistanceTriangle(); - if (dist.x < edgePickRadius) { - edgeId = 0; - } else if (dist.y < edgePickRadius) { - edgeId = 1; - } else if (dist.z < edgePickRadius) { - edgeId = 2; - } else { - return -1; // Not on a mesh edge - } - - const int edgeFlag = GetEdgeFlag(); - const int meshEdgeIndex = HdGetScalar_edgeIndices(); - - // Translate face-edge to authored mesh-edge - if (edgeFlag == 0) { - edgeId = meshEdgeIndex + edgeId; // regular triangle face. - } else if ((bool(edgeFlag & 1) && edgeId == 2) || - (bool(edgeFlag & 2) && edgeId == 0)) { - edgeId = -1; // Not an authored mesh edge - } else { - edgeId = meshEdgeIndex + edgeId - 1; - } - return edgeId; -} - - - -int GetPointId() -{ - return -1; -} - - -void DiscardBasedOnTopologicalVisibility() -{ - // Nothing to do, since there's no authored opinion. -} - - - -vec4 GetInterpolatedPatchCoord() -{ - return gsPatchCoord; -} - - - -#ifndef HD_HAS_ptexFaceOffset -#define HD_HAS_ptexFaceOffset -int HdGet_ptexFaceOffset() -{ - return 0; -} -#endif - -vec4 GetPatchCoord(int localIndex) -{ - vec4 patchCoord = GetInterpolatedPatchCoord(); - return vec4(patchCoord.xyz, patchCoord.w + HdGet_ptexFaceOffset()); -} - -vec4 GetPatchCoord() -{ - return GetPatchCoord(0); -} - -vec3 ComputeScreenSpacePeye() -{ - return inData.Peye.xyz / inData.Peye.w; -} - -vec3 ComputeScreenSpaceNeye() -{ - vec3 Peye = ComputeScreenSpacePeye(); - vec3 Neye = normalize(cross(dFdx(Peye), dFdy(Peye))); - return (gl_FrontFacing ? Neye : -Neye); -} - -void main(void) -{ - bool isFlipped = IsFlipped(); - - DiscardBasedOnShading(gl_FrontFacing, isFlipped); - - DiscardBasedOnTopologicalVisibility(); - - vec4 color = vec4(0.5, 0.5, 0.5, 1); -#ifdef HD_HAS_displayColor - color.rgb = HdGet_displayColor().rgb; -#endif -#ifdef HD_HAS_displayOpacity - color.a = HdGet_displayOpacity(); -#endif - - vec3 Peye = ComputeScreenSpacePeye(); - - vec3 Neye = inData.Neye; - // Normalize Neye after rasterizer interpolation. - if (length(Neye) > 0.0) { - Neye = normalize(Neye); - } - // Give the shader key a chance to override the normal. - Neye = GetNormal(Neye, 0); - // Orient the normal for shading. - Neye = GetShadingNormal(Neye, isFlipped); - - vec4 patchCoord = GetPatchCoord(); - color = ShadingTerminal(vec4(Peye, 1), Neye, color, patchCoord); - - color = ApplyEdgeColor(color, patchCoord); - -#ifdef HD_MATERIAL_TAG_MASKED - if (ShouldDiscardByAlpha(color)) { - discard; - return; - } -#endif - - RenderOutput(vec4(Peye, 1), Neye, color, patchCoord); -} - -------------------------------------------------------- --- glslfx version 0.1 -#import $TOOLS/hdSt/shaders/mesh.glslfx --- configuration -{"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } -, "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } -}}} -------------------------------------------------------- -======================================================= - VERTEX SHADER -======================================================= -#version 450 -#extension GL_NV_shader_buffer_load : require -#extension GL_NV_gpu_shader5 : require -#extension GL_ARB_bindless_texture : require -#extension GL_ARB_shader_draw_parameters : require -int HgiGetBaseVertex() { - return gl_BaseVertexARB; -} -#define REF(space,type) inout type -#define FORWARD_DECL(func_decl) func_decl; -#define ATOMIC_LOAD(a) (a) -#define ATOMIC_STORE(a, v) (a) = (v) -#define ATOMIC_ADD(a, v) atomicAdd(a, v) -#define ATOMIC_EXCHANGE(a, v) atomicExchange(a, v) -#define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) -#define atomic_int int -#define atomic_uint uint - -#define HGI_HAS_DOUBLE_TYPE 1 - - -struct hgi_ivec3 { int x, y, z; }; -struct hgi_vec3 { float x, y, z; }; -struct hgi_dvec3 { double x, y, z; }; -struct hgi_mat3 { float m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; -struct hgi_dmat3 { double m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; - - -// //////// Codegen Defines //////// -#define HD_SHADER_API 2 -#define MAT4 mat4 -// Alias hgi vec and matrix types to hd. -#define hd_ivec3 hgi_ivec3 -#define hd_vec3 hgi_vec3 -#define hd_dvec3 hgi_dvec3 -#define hd_mat3 hgi_mat3 -#define hd_dmat3 hgi_dmat3 - -ivec3 hd_ivec3_get(hd_ivec3 v) { return ivec3(v.x, v.y, v.z); } -ivec3 hd_ivec3_get(ivec3 v) { return v; } -vec3 hd_vec3_get(hd_vec3 v) { return vec3(v.x, v.y, v.z); } -vec3 hd_vec3_get(vec3 v) { return v; } -dvec3 hd_dvec3_get(hd_dvec3 v) { return dvec3(v.x, v.y, v.z); } -dvec3 hd_dvec3_get(dvec3 v) { return v; } -mat3 hd_mat3_get(hd_mat3 v) { return mat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -mat3 hd_mat3_get(mat3 v) { return v; } -dmat3 hd_dmat3_get(hd_dmat3 v) { return dmat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -dmat3 hd_dmat3_get(dmat3 v) { return v; } -hd_ivec3 hd_ivec3_set(hd_ivec3 v) { return v; } -hd_ivec3 hd_ivec3_set(ivec3 v) { return hd_ivec3(v.x, v.y, v.z); } -hd_vec3 hd_vec3_set(hd_vec3 v) { return v; } -hd_vec3 hd_vec3_set(vec3 v) { return hd_vec3(v.x, v.y, v.z); } -hd_dvec3 hd_dvec3_set(hd_dvec3 v) { return v; } -hd_dvec3 hd_dvec3_set(dvec3 v) { return hd_dvec3(v.x, v.y, v.z); } -hd_mat3 hd_mat3_set(hd_mat3 v) { return v; } -hd_mat3 hd_mat3_set(mat3 v) { return hd_mat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -hd_dmat3 hd_dmat3_set(hd_dmat3 v) { return v; } -hd_dmat3 hd_dmat3_set(dmat3 v) { return hd_dmat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -int hd_int_get(int v) { return v; } -int hd_int_get(ivec2 v) { return v.x; } -int hd_int_get(ivec3 v) { return v.x; } -int hd_int_get(ivec4 v) { return v.x; } -vec3 hd_sample_udim(vec2 v) { -vec2 vf = floor(v); -return vec3(v.x - vf.x, v.y - vf.y, clamp(vf.x, 0.0, 10.0) + 10.0 * vf.y); -} -vec4 hd_vec4_2_10_10_10_get(int v) { - ivec4 unpacked = ivec4((v & 0x3ff) << 22, (v & 0xffc00) << 12, - (v & 0x3ff00000) << 2, (v & 0xc0000000)); - return vec4(unpacked) / 2147483647.0; } -int hd_vec4_2_10_10_10_set(vec4 v) { - return ( (int(v.x * 511.0) & 0x3ff) | - ((int(v.y * 511.0) & 0x3ff) << 10) | - ((int(v.z * 511.0) & 0x3ff) << 20) | - ((int(v.w) & 0x1) << 30)); } -vec2 hd_half2_get(uint v) { - return unpackHalf2x16(v); } -uint hd_half2_set(vec2 v) { - return packHalf2x16(v); } -vec4 hd_half4_get(uvec2 v) { - return vec4(unpackHalf2x16(v.x), unpackHalf2x16(v.y)); } -uvec2 hd_half4_set(vec4 v) { - return uvec2(packHalf2x16(v.xy), packHalf2x16(v.zw)); } -#define HD_NUM_PRIMITIVE_VERTS 4 -#define HD_HAS_transform 1 -#define HD_HAS_transformInverse 1 -#define HD_HAS_color 1 -#define HD_HAS_primID 1 -#define HD_HAS_widths 1 -#define HD_INSTANCER_NUM_LEVELS 0 -#define HD_INSTANCE_INDEX_WIDTH 1 -#define HD_HAS_faceVisibility 1 -#define HD_HAS_dispTextureCoord 1 -#define HD_HAS_points 1 -#define HD_HAS_normals 1 - - -// //////// Global Includes //////// - -// //////// Global Macros //////// - -// //////// Global Structs //////// - -// //////// Global Member Declarations //////// -uint hd_VertexID = gl_VertexID; -uint hd_InstanceID = gl_InstanceID; -uint hd_BaseInstance = 0; - -// //////// Global Function Definitions //////// - - -// //////// Codegen Decl //////// -struct hd_drawingCoord { - int modelCoord; - int constantCoord; - int elementCoord; - int primitiveCoord; - int fvarCoord; - int shaderCoord; - int vertexCoord; - int topologyVisibilityCoord; - int varyingCoord; - int instanceIndex[HD_INSTANCE_INDEX_WIDTH]; - int instanceCoords[HD_INSTANCE_INDEX_WIDTH]; -}; -FORWARD_DECL(hd_drawingCoord GetDrawingCoord()); -FORWARD_DECL(int HgiGetBaseVertex()); -struct hd_instanceIndex { int indices[HD_INSTANCE_INDEX_WIDTH]; }; -struct ConstantData10 { - mat4 transform; - mat4 transformInverse; - vec4 color; - vec4 primID; - float widths; -}; -FORWARD_DECL(int GetElementID()); -FORWARD_DECL(int GetAggregatedElementID()); -FORWARD_DECL(int GetPrimitiveEdgeId()); -FORWARD_DECL(float GetSelectedEdgeOpacity()); -out flat ivec4 vs_interstageDrawingCoord0; -out flat ivec4 vs_interstageDrawingCoord1; -out flat ivec4 vs_interstageDrawingCoord2; -layout (location = 2) in ivec4 drawingCoord0; -layout (location = 3) in ivec4 drawingCoord1; -layout (location = 4) in ivec2 drawingCoord2; -layout (location = 0) in vec3 points; -layout (location = 1) in vec3 normals; -layout(location = 0) uniform ConstantData10 *constantPrimvars; -layout(location = 1) uniform int *primitiveParam; -layout(location = 2) uniform ivec2 *edgeIndices; -layout(location = 3) uniform float *faceVisibility; -out VertexData { - vec4 Peye; - vec3 Neye; -} outData; -out PrimvarData { - vec3 points; - vec3 normals; -} outPrimvars; - -// //////// Codegen Accessors //////// -mat4 HdGet_transform(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transform); -} -mat4 HdGet_transform() { return HdGet_transform(0); } -mat4 HdGet_transformInverse(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transformInverse); -} -mat4 HdGet_transformInverse() { return HdGet_transformInverse(0); } -vec4 HdGet_color(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].color); -} -vec4 HdGet_color() { return HdGet_color(0); } -float HdGetScalar_color(int localIndex) { return HdGet_color(localIndex).x; } -float HdGetScalar_color() { return HdGet_color(0).x; } -vec4 HdGet_primID(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].primID); -} -vec4 HdGet_primID() { return HdGet_primID(0); } -float HdGetScalar_primID(int localIndex) { return HdGet_primID(localIndex).x; } -float HdGetScalar_primID() { return HdGet_primID(0).x; } -float HdGet_widths(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return float(constantPrimvars[index].widths); -} -float HdGet_widths() { return HdGet_widths(0); } -float HdGetScalar_widths(int localIndex) { return HdGet_widths(localIndex); } -float HdGetScalar_widths() { return HdGet_widths(0); } - -// //////// Codegen VS Source //////// -#define HD_BINDLESS_BUFFERS_ENABLED -int GetBaseVertexOffset() { - return HgiGetBaseVertex(); -} -hd_instanceIndex GetInstanceIndex() { hd_instanceIndex r; r.indices[0] = 0; return r; } -hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = drawingCoord0.x; - dc.constantCoord = drawingCoord0.y; - dc.elementCoord = drawingCoord0.z; - dc.primitiveCoord = drawingCoord0.w; - dc.fvarCoord = drawingCoord1.x; - dc.shaderCoord = drawingCoord1.z; - dc.vertexCoord = drawingCoord1.w; - dc.topologyVisibilityCoord = drawingCoord2.x; - dc.varyingCoord = drawingCoord2.y; - hd_instanceIndex r = GetInstanceIndex(); - dc.instanceIndex[0] = r.indices[0]; - return dc; -} -vec3 HdGet_points(int localIndex) { return hd_vec3_get(points);} -vec3 HdGet_points() { return HdGet_points(0); } -float HdGetScalar_points(int localIndex) { return HdGet_points(localIndex).x; } -float HdGetScalar_points() { return HdGet_points(0).x; } -vec3 HdGet_normals(int localIndex) { return hd_vec3_get(normals);} -vec3 HdGet_normals() { return HdGet_normals(0); } -float HdGetScalar_normals(int localIndex) { return HdGet_normals(localIndex).x; } -float HdGetScalar_normals() { return HdGet_normals(0).x; } - -// //////// Codegen Proc VS //////// -void ProcessPrimvarsIn() { - hd_drawingCoord dc = GetDrawingCoord(); - vs_interstageDrawingCoord0[0] = dc.modelCoord; - vs_interstageDrawingCoord0[1] = dc.constantCoord; - vs_interstageDrawingCoord0[2] = dc.elementCoord; - vs_interstageDrawingCoord0[3] = dc.primitiveCoord; - vs_interstageDrawingCoord1[0] = dc.fvarCoord; - vs_interstageDrawingCoord1[1] = dc.shaderCoord; - vs_interstageDrawingCoord1[2] = dc.vertexCoord; - vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; - vs_interstageDrawingCoord2[0] = dc.varyingCoord; - vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; - outPrimvars.points = points; - outPrimvars.normals = normals; -} - -// --------------------------------------------------------------------------- -// global defines -// --------------------------------------------------------------------------- -// codeGen can override this range (currently not). -// quadro 4000's max is 189. -#ifndef HD_GL_POINT_SIZE_MAX -#define HD_GL_POINT_SIZE_MAX 100.0 -#endif -#ifndef HD_GL_POINT_SIZE_MIN -#define HD_GL_POINT_SIZE_MIN .45 -#endif - -// --------------------------------------------------------------------------- -// render pass states -// --------------------------------------------------------------------------- - -MAT4 GetWorldToViewMatrix() { -#if defined(HD_HAS_worldToViewMatrix) - return MAT4(HdGet_worldToViewMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetWorldToViewInverseMatrix() { -#if defined(HD_HAS_worldToViewInverseMatrix) - return MAT4(HdGet_worldToViewInverseMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetProjectionMatrix() { -#if defined(HD_HAS_projectionMatrix) - return MAT4(HdGet_projectionMatrix()); -#else - return MAT4(1); -#endif -} -vec3 GetPositionInWorldSpace(vec3 windowRelativeCoord) -{ -#if defined(HD_HAS_imageToWorldMatrix) - vec4 pImage = vec4(windowRelativeCoord, 1.0); - vec4 pWorld = vec4(HdGet_imageToWorldMatrix() * pImage); - return (pWorld / pWorld.w).xyz; -#else - return windowRelativeCoord; -#endif -} -float GetLightingBlendAmount() { -#if defined(HD_HAS_lightingBlendAmount) - return HdGet_lightingBlendAmount(); -#else - return 1; -#endif -} -vec4 GetViewport() { -#if defined(HD_HAS_viewport) - return HdGet_viewport(); -#else - return vec4(0,0,1,1); -#endif -} -float GetTessLevel() { -#if defined(HD_HAS_tessLevel) - return HdGet_tessLevel(); -#else - return 1; -#endif -} -float GetPointSize() { -#if defined(HD_HAS_pointSize) - return HdGet_pointSize(); -#else - return 3.0; -#endif -} -float GetPointSelectedSize() { -#if defined(HD_HAS_pointSelectedSize) - return HdGet_pointSelectedSize(); -#else - return 5.0; -#endif -} -vec4 GetWireframeColor() { -// Individual prims can specify an alternative wireframe color -// to one specified in the render pass. This is used in cases were -// there is not enough contrast with the normal one. -#if defined(HD_HAS_overrideWireframeColor) - return HdGet_overrideWireframeColor(); -#elif defined(HD_HAS_wireframeColor) - return HdGet_wireframeColor(); -#else - return vec4(0,0,0,0); -#endif -} -vec4 GetMaskColor() { -#if defined(HD_HAS_maskColor) - return HdGet_maskColor(); -#else - return vec4(0.5,0,0,1); -#endif -} -vec4 GetIndicatorColor() { -#if defined(HD_HAS_indicatorColor) - return HdGet_indicatorColor(); -#else - return vec4(0,0.5,0,1); -#endif -} - -bool ShouldDiscardByAlpha(vec4 color) -{ -#if defined(HD_HAS_alphaThreshold) - float alphaThreshold = HdGet_alphaThreshold(); -#else - float alphaThreshold = 0; -#endif - return (color.a < alphaThreshold); -} - -vec2 ApplyAxisAlignedAffineTransform(vec4 t, vec2 pt) -{ - return t.xy * pt + t.zw; -} - - - -void ApplyClipPlanes(vec4 Peye) -{ -#if defined(HD_HAS_numClipPlanes) -#if defined(HD_HAS_clipPlanes) - for (int i=0; i> 2); -} -int GetAggregatedElementID() { - return GetElementID() - + GetDrawingCoord().elementCoord; -} -ivec2 HdGet_edgeIndices(int localIndex) { - int index = GetPrimitiveIndex(); - return ivec2(edgeIndices[index]); -} -ivec2 HdGet_edgeIndices() { return HdGet_edgeIndices(0); } -int HdGetScalar_edgeIndices(int localIndex) { return HdGet_edgeIndices(localIndex).x; } -int HdGetScalar_edgeIndices() { return HdGet_edgeIndices(0).x; } -int GetAuthoredEdgeId(int primitiveEdgeId) { - return primitiveEdgeId; -} -float HdGet_faceVisibility(int localIndex) { - int index = GetAggregatedElementID(); - return float(faceVisibility[index]); -} -float HdGet_faceVisibility() { return HdGet_faceVisibility(0); } -float HdGetScalar_faceVisibility(int localIndex) { return HdGet_faceVisibility(localIndex); } -float HdGetScalar_faceVisibility() { return HdGet_faceVisibility(0); } -vec3 HdGet_points(int localIndex) { - int index = localIndex; - return vec3(inPrimvars[index].points); -} -vec3 HdGet_points() { return HdGet_points(0); } -float HdGetScalar_points(int localIndex) { return HdGet_points(localIndex).x; } -float HdGetScalar_points() { return HdGet_points(0).x; } -vec3 HdGet_normals(int localIndex) { - int index = localIndex; - return vec3(inPrimvars[index].normals); -} -vec3 HdGet_normals() { return HdGet_normals(0); } -float HdGetScalar_normals(int localIndex) { return HdGet_normals(localIndex).x; } -float HdGetScalar_normals() { return HdGet_normals(0).x; } -vec2 HdGet_dispTextureCoord_Coarse(int localIndex) { - int fvarIndex = GetFVarIndex(localIndex); - return vec2(dispTextureCoord[fvarIndex]); -} -vec2 HdGet_dispTextureCoord(int localIndex, vec2 st) { - return mix(mix(HdGet_dispTextureCoord_Coarse(0),HdGet_dispTextureCoord_Coarse(1), st.x),mix(HdGet_dispTextureCoord_Coarse(3),HdGet_dispTextureCoord_Coarse(2), st.x), st.y); -} -FORWARD_DECL(vec4 GetPatchCoord(int index)); -FORWARD_DECL(vec2 GetPatchCoordLocalST()); -vec2 HdGet_dispTextureCoord(int localIndex) { - vec2 localST = GetPatchCoord(localIndex).xy; - return HdGet_dispTextureCoord(localIndex, localST); -} -vec2 HdGet_dispTextureCoord() { return HdGet_dispTextureCoord(0); } -FORWARD_DECL(vec4 GetPatchCoord(int localIndex)); -void ProcessSamplingTransforms(MAT4 instanceModelViewInverse) { -} - -// //////// Codegen Proc GS //////// -FORWARD_DECL(vec4 GetPatchCoord(int index)); -void ProcessPrimvarsOut(int index) { - vec2 localST = GetPatchCoord(index).xy; - const vec3 coords[4] = vec3[]( - vec3(1,0,0), vec3(0,1,0), vec3(0,0,1), vec3(0,1,0) - ); - hd_barycentricCoord = coords[index]; - hd_drawingCoord dc = GetDrawingCoord(); - gs_interstageDrawingCoord0[0] = dc.modelCoord; - gs_interstageDrawingCoord0[1] = dc.constantCoord; - gs_interstageDrawingCoord0[2] = dc.elementCoord; - gs_interstageDrawingCoord0[3] = dc.primitiveCoord; - gs_interstageDrawingCoord1[0] = dc.fvarCoord; - gs_interstageDrawingCoord1[1] = dc.shaderCoord; - gs_interstageDrawingCoord1[2] = dc.vertexCoord; - gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; - gs_interstageDrawingCoord2[0] = dc.varyingCoord; - gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; - outPrimvars.points = inPrimvars[index].points; - outPrimvars.normals = inPrimvars[index].normals; - outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); -} - -// --------------------------------------------------------------------------- -// global defines -// --------------------------------------------------------------------------- -// codeGen can override this range (currently not). -// quadro 4000's max is 189. -#ifndef HD_GL_POINT_SIZE_MAX -#define HD_GL_POINT_SIZE_MAX 100.0 -#endif -#ifndef HD_GL_POINT_SIZE_MIN -#define HD_GL_POINT_SIZE_MIN .45 -#endif - -// --------------------------------------------------------------------------- -// render pass states -// --------------------------------------------------------------------------- - -MAT4 GetWorldToViewMatrix() { -#if defined(HD_HAS_worldToViewMatrix) - return MAT4(HdGet_worldToViewMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetWorldToViewInverseMatrix() { -#if defined(HD_HAS_worldToViewInverseMatrix) - return MAT4(HdGet_worldToViewInverseMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetProjectionMatrix() { -#if defined(HD_HAS_projectionMatrix) - return MAT4(HdGet_projectionMatrix()); -#else - return MAT4(1); -#endif -} -vec3 GetPositionInWorldSpace(vec3 windowRelativeCoord) -{ -#if defined(HD_HAS_imageToWorldMatrix) - vec4 pImage = vec4(windowRelativeCoord, 1.0); - vec4 pWorld = vec4(HdGet_imageToWorldMatrix() * pImage); - return (pWorld / pWorld.w).xyz; -#else - return windowRelativeCoord; -#endif -} -float GetLightingBlendAmount() { -#if defined(HD_HAS_lightingBlendAmount) - return HdGet_lightingBlendAmount(); -#else - return 1; -#endif -} -vec4 GetViewport() { -#if defined(HD_HAS_viewport) - return HdGet_viewport(); -#else - return vec4(0,0,1,1); -#endif -} -float GetTessLevel() { -#if defined(HD_HAS_tessLevel) - return HdGet_tessLevel(); -#else - return 1; -#endif -} -float GetPointSize() { -#if defined(HD_HAS_pointSize) - return HdGet_pointSize(); -#else - return 3.0; -#endif -} -float GetPointSelectedSize() { -#if defined(HD_HAS_pointSelectedSize) - return HdGet_pointSelectedSize(); -#else - return 5.0; -#endif -} -vec4 GetWireframeColor() { -// Individual prims can specify an alternative wireframe color -// to one specified in the render pass. This is used in cases were -// there is not enough contrast with the normal one. -#if defined(HD_HAS_overrideWireframeColor) - return HdGet_overrideWireframeColor(); -#elif defined(HD_HAS_wireframeColor) - return HdGet_wireframeColor(); -#else - return vec4(0,0,0,0); -#endif -} -vec4 GetMaskColor() { -#if defined(HD_HAS_maskColor) - return HdGet_maskColor(); -#else - return vec4(0.5,0,0,1); -#endif -} -vec4 GetIndicatorColor() { -#if defined(HD_HAS_indicatorColor) - return HdGet_indicatorColor(); -#else - return vec4(0,0.5,0,1); -#endif -} - -bool ShouldDiscardByAlpha(vec4 color) -{ -#if defined(HD_HAS_alphaThreshold) - float alphaThreshold = HdGet_alphaThreshold(); -#else - float alphaThreshold = 0; -#endif - return (color.a < alphaThreshold); -} - -vec2 ApplyAxisAlignedAffineTransform(vec4 t, vec2 pt) -{ - return t.xy * pt + t.zw; -} - - - -void ApplyClipPlanes(vec4 Peye) -{ -#if defined(HD_HAS_numClipPlanes) -#if defined(HD_HAS_clipPlanes) - for (int i=0; i 0.0) - normal = normalize(normal); - return normal; -} - -vec3 GetNormal(vec3 Neye, int index, vec2 localST) -{ - return GetNormal(Neye, index); -} - - - -vec3 GetTriGeometryNormal(vec3 Neye, vec4 Peye0, vec4 Peye1, vec4 Peye2, - bool isFlipped) -{ - return Neye; -} - -vec3 GetQuadGeometryNormal(vec3 Neye, - vec4 Peye0, vec4 Peye1, vec4 Peye2, vec4 Peye3, - bool isFlipped) -{ - return Neye; -} - - - -vec4 DisplacementTerminal(int index, vec4 Peye, vec3 Neye, vec4 patchCoord) -{ - return Peye; -} - - - -vec4 GetPatchCoord(int index) -{ - vec2 uv[4]; - uv[0] = vec2(0, 0); - uv[1] = vec2(1, 0); - uv[2] = vec2(1, 1); - uv[3] = vec2(0, 1); - - ivec3 patchParam = GetPatchParam(); - return InterpolatePatchCoord(uv[index], patchParam); -} - -void emit(int index, vec4 Peye, vec3 Neye) -{ - outData.Peye = Peye; - outData.Neye = Neye; - - gsPatchCoord = GetPatchCoord(index); - - gl_Position = vec4(GetProjectionMatrix() * outData.Peye); - ApplyClipPlanes(outData.Peye); - - ProcessPrimvarsOut(index); - - EmitVertex(); -} - -void main(void) -{ - gl_PrimitiveID = gl_PrimitiveIDIn; - - bool isFlipped = IsFlipped(); // consider handedness AND negative-scale - - vec3 Neye0 = GetNormal(inData[0].Neye, 0); - Neye0 = GetQuadGeometryNormal(Neye0, inData[0].Peye, inData[1].Peye, - inData[2].Peye, inData[3].Peye, isFlipped); - vec3 Neye1 = GetNormal(inData[1].Neye, 1); - Neye1 = GetQuadGeometryNormal(Neye1, inData[0].Peye, inData[1].Peye, - inData[2].Peye, inData[3].Peye, isFlipped); - vec3 Neye2 = GetNormal(inData[2].Neye, 2); - Neye2 = GetQuadGeometryNormal(Neye2, inData[0].Peye, inData[1].Peye, - inData[2].Peye, inData[3].Peye, isFlipped); - vec3 Neye3 = GetNormal(inData[3].Neye, 3); - Neye3 = GetQuadGeometryNormal(Neye3, inData[0].Peye, inData[1].Peye, - inData[2].Peye, inData[3].Peye, isFlipped); - - vec4 Peye0 = DisplacementTerminal( - 0, inData[0].Peye, Neye0, GetPatchCoord(0)); - vec4 Peye1 = DisplacementTerminal( - 1, inData[1].Peye, Neye1, GetPatchCoord(1)); - vec4 Peye2 = DisplacementTerminal( - 2, inData[2].Peye, Neye2, GetPatchCoord(2)); - vec4 Peye3 = DisplacementTerminal( - 3, inData[3].Peye, Neye3, GetPatchCoord(3)); - - // Generate triangles (0,1,2) and (2,3,0) - // 3---2 - // | .| - // | . | - // |. | - // 0---1 - // The indices post-quadrangulation/subdivision follow the convention: - // 0 -> original (hull) vertex - // 1,3 -> edge vertices - // 2 -> center vertex - // - // By having index 2 in both the triangles, we ensure the pre-quadrangulated - // face's normal (at the center) is part of the rasterizer interpolation, - // which matters when we use smooth/limit normals. - // In the case of flat normals, we use the vertex positions, so it doesn't - // matter. - - // triangle 0: vertices (0,1,2) - emit(0, Peye0, Neye0); - emit(1, Peye1, Neye1); - emit(2, Peye2, Neye2); - EndPrimitive(); - - // triangle 1: vertices (2,3,0) - gl_PrimitiveID = gl_PrimitiveIDIn; - emit(2, Peye2, Neye2); - emit(3, Peye3, Neye3); - emit(0, Peye0, Neye0); - EndPrimitive(); -} - - -======================================================= - FRAGMENT SHADER -======================================================= -#version 450 -#extension GL_NV_shader_buffer_load : require -#extension GL_NV_gpu_shader5 : require -#extension GL_ARB_bindless_texture : require -#define REF(space,type) inout type -#define FORWARD_DECL(func_decl) func_decl; -#define ATOMIC_LOAD(a) (a) -#define ATOMIC_STORE(a, v) (a) = (v) -#define ATOMIC_ADD(a, v) atomicAdd(a, v) -#define ATOMIC_EXCHANGE(a, v) atomicExchange(a, v) -#define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) -#define atomic_int int -#define atomic_uint uint - -#define HGI_HAS_DOUBLE_TYPE 1 - - -struct hgi_ivec3 { int x, y, z; }; -struct hgi_vec3 { float x, y, z; }; -struct hgi_dvec3 { double x, y, z; }; -struct hgi_mat3 { float m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; -struct hgi_dmat3 { double m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; - - - -// //////// Global Includes //////// - -// //////// Global Macros //////// - -// //////// Global Structs //////// - -// //////// Global Member Declarations //////// - -// //////// Global Function Definitions //////// - - -// //////// Codegen Defines //////// -#define HD_SHADER_API 2 -#define MAT4 mat4 -// Alias hgi vec and matrix types to hd. -#define hd_ivec3 hgi_ivec3 -#define hd_vec3 hgi_vec3 -#define hd_dvec3 hgi_dvec3 -#define hd_mat3 hgi_mat3 -#define hd_dmat3 hgi_dmat3 - -ivec3 hd_ivec3_get(hd_ivec3 v) { return ivec3(v.x, v.y, v.z); } -ivec3 hd_ivec3_get(ivec3 v) { return v; } -vec3 hd_vec3_get(hd_vec3 v) { return vec3(v.x, v.y, v.z); } -vec3 hd_vec3_get(vec3 v) { return v; } -dvec3 hd_dvec3_get(hd_dvec3 v) { return dvec3(v.x, v.y, v.z); } -dvec3 hd_dvec3_get(dvec3 v) { return v; } -mat3 hd_mat3_get(hd_mat3 v) { return mat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -mat3 hd_mat3_get(mat3 v) { return v; } -dmat3 hd_dmat3_get(hd_dmat3 v) { return dmat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -dmat3 hd_dmat3_get(dmat3 v) { return v; } -hd_ivec3 hd_ivec3_set(hd_ivec3 v) { return v; } -hd_ivec3 hd_ivec3_set(ivec3 v) { return hd_ivec3(v.x, v.y, v.z); } -hd_vec3 hd_vec3_set(hd_vec3 v) { return v; } -hd_vec3 hd_vec3_set(vec3 v) { return hd_vec3(v.x, v.y, v.z); } -hd_dvec3 hd_dvec3_set(hd_dvec3 v) { return v; } -hd_dvec3 hd_dvec3_set(dvec3 v) { return hd_dvec3(v.x, v.y, v.z); } -hd_mat3 hd_mat3_set(hd_mat3 v) { return v; } -hd_mat3 hd_mat3_set(mat3 v) { return hd_mat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -hd_dmat3 hd_dmat3_set(hd_dmat3 v) { return v; } -hd_dmat3 hd_dmat3_set(dmat3 v) { return hd_dmat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -int hd_int_get(int v) { return v; } -int hd_int_get(ivec2 v) { return v.x; } -int hd_int_get(ivec3 v) { return v.x; } -int hd_int_get(ivec4 v) { return v.x; } -vec3 hd_sample_udim(vec2 v) { -vec2 vf = floor(v); -return vec3(v.x - vf.x, v.y - vf.y, clamp(vf.x, 0.0, 10.0) + 10.0 * vf.y); -} -vec4 hd_vec4_2_10_10_10_get(int v) { - ivec4 unpacked = ivec4((v & 0x3ff) << 22, (v & 0xffc00) << 12, - (v & 0x3ff00000) << 2, (v & 0xc0000000)); - return vec4(unpacked) / 2147483647.0; } -int hd_vec4_2_10_10_10_set(vec4 v) { - return ( (int(v.x * 511.0) & 0x3ff) | - ((int(v.y * 511.0) & 0x3ff) << 10) | - ((int(v.z * 511.0) & 0x3ff) << 20) | - ((int(v.w) & 0x1) << 30)); } -vec2 hd_half2_get(uint v) { - return unpackHalf2x16(v); } -uint hd_half2_set(vec2 v) { - return packHalf2x16(v); } -vec4 hd_half4_get(uvec2 v) { - return vec4(unpackHalf2x16(v.x), unpackHalf2x16(v.y)); } -uvec2 hd_half4_set(vec4 v) { - return uvec2(packHalf2x16(v.xy), packHalf2x16(v.zw)); } -#define HD_NUM_PRIMITIVE_VERTS 4 -#define HD_HAS_transform 1 -#define HD_HAS_transformInverse 1 -#define HD_HAS_color 1 -#define HD_HAS_primID 1 -#define HD_HAS_widths 1 -#define HD_INSTANCER_NUM_LEVELS 0 -#define HD_INSTANCE_INDEX_WIDTH 1 -#define HD_HAS_faceVisibility 1 -#define HD_HAS_dispTextureCoord 1 -#define HD_HAS_points 1 -#define HD_HAS_normals 1 - -// //////// Codegen Decl //////// -struct hd_drawingCoord { - int modelCoord; - int constantCoord; - int elementCoord; - int primitiveCoord; - int fvarCoord; - int shaderCoord; - int vertexCoord; - int topologyVisibilityCoord; - int varyingCoord; - int instanceIndex[HD_INSTANCE_INDEX_WIDTH]; - int instanceCoords[HD_INSTANCE_INDEX_WIDTH]; -}; -FORWARD_DECL(hd_drawingCoord GetDrawingCoord()); -FORWARD_DECL(int HgiGetBaseVertex()); -struct hd_instanceIndex { int indices[HD_INSTANCE_INDEX_WIDTH]; }; -struct ConstantData10 { - mat4 transform; - mat4 transformInverse; - vec4 color; - vec4 primID; - float widths; -}; -FORWARD_DECL(int GetElementID()); -FORWARD_DECL(int GetAggregatedElementID()); -FORWARD_DECL(int GetPrimitiveEdgeId()); -FORWARD_DECL(float GetSelectedEdgeOpacity()); -layout(location = 0) uniform ConstantData10 *constantPrimvars; -layout(location = 1) uniform int *primitiveParam; -layout(location = 2) uniform ivec2 *edgeIndices; -layout(location = 3) uniform float *faceVisibility; -in vec4 gsPatchCoord; -in VertexData { - vec4 Peye; - vec3 Neye; -} inData; -layout (location = 0) out vec4 colorOut; -in noperspective vec3 hd_barycentricCoord; -in flat ivec4 gs_interstageDrawingCoord0; -in flat ivec4 gs_interstageDrawingCoord1; -in flat ivec4 gs_interstageDrawingCoord2; -in PrimvarData { - vec3 points; - vec3 normals; - vec2 dispTextureCoord; -} inPrimvars; -layout(location = 4) uniform vec2 *dispTextureCoord; -vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) -{ - // add 0.5 to integer values for more robust interpolation - return vec4(uv.x, uv.y, 0, patchParam.x+0.5f); -} -vec4 InterpolatePatchCoordTriangle(vec2 uv, ivec3 patchParam) -{ - return InterpolatePatchCoord(uv, patchParam); -} - -// //////// Codegen Accessors //////// -mat4 HdGet_transform(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transform); -} -mat4 HdGet_transform() { return HdGet_transform(0); } -mat4 HdGet_transformInverse(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transformInverse); -} -mat4 HdGet_transformInverse() { return HdGet_transformInverse(0); } -vec4 HdGet_color(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].color); -} -vec4 HdGet_color() { return HdGet_color(0); } -float HdGetScalar_color(int localIndex) { return HdGet_color(localIndex).x; } -float HdGetScalar_color() { return HdGet_color(0).x; } -vec4 HdGet_primID(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].primID); -} -vec4 HdGet_primID() { return HdGet_primID(0); } -float HdGetScalar_primID(int localIndex) { return HdGet_primID(localIndex).x; } -float HdGetScalar_primID() { return HdGet_primID(0).x; } -float HdGet_widths(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return float(constantPrimvars[index].widths); -} -float HdGet_widths() { return HdGet_widths(0); } -float HdGetScalar_widths(int localIndex) { return HdGet_widths(localIndex); } -float HdGetScalar_widths() { return HdGet_widths(0); } - -// //////// Codegen FS Source //////// -#define HD_SHADER_SUPPORTS_DOUBLE_PRECISION -#define HD_MINUS_ONE_TO_ONE_DEPTH_RANGE -vec3 GetBarycentricCoord() { - return hd_barycentricCoord; -} -int GetPrimitiveID() { - return gl_PrimitiveID; -} -int GetPrimitiveIndex() { - return GetDrawingCoord().primitiveCoord + GetPrimitiveID(); -} -hd_drawingCoord GetDrawingCoord() { - hd_drawingCoord dc; - dc.modelCoord = gs_interstageDrawingCoord0[0]; - dc.constantCoord = gs_interstageDrawingCoord0[1]; - dc.elementCoord = gs_interstageDrawingCoord0[2]; - dc.primitiveCoord = gs_interstageDrawingCoord0[3]; - dc.fvarCoord = gs_interstageDrawingCoord1[0]; - dc.shaderCoord = gs_interstageDrawingCoord1[1]; - dc.vertexCoord = gs_interstageDrawingCoord1[2]; - dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; - dc.varyingCoord = gs_interstageDrawingCoord2[0]; - dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; - return dc; -} -int HdGet_primitiveParam(int localIndex) { - int index = GetPrimitiveIndex(); - return int(primitiveParam[index]); -} -int HdGet_primitiveParam() { return HdGet_primitiveParam(0); } -int HdGetScalar_primitiveParam(int localIndex) { return HdGet_primitiveParam(localIndex); } -int HdGetScalar_primitiveParam() { return HdGet_primitiveParam(0); } -#if defined(HD_HAS_coarseFaceIndex) -FORWARD_DECL(int HdGetScalar_coarseFaceIndex()); -#endif -ivec3 GetPatchParam() { -#if defined(HD_HAS_coarseFaceIndex) - return ivec3(HdGetScalar_coarseFaceIndex(), 0, 0); -#else - return ivec3(GetPrimitiveID(), 0, 0); -#endif -} -int GetEdgeFlag() { - return (HdGet_primitiveParam() & 3); -} -int GetFVarIndex(int localIndex) { - int fvarCoord = GetDrawingCoord().fvarCoord; - int ptexIndex = GetPatchParam().x & 0xfffffff; - return fvarCoord + ptexIndex * 4 + localIndex; -} -int GetElementID() { - return (hd_int_get(HdGet_primitiveParam()) >> 2); -} -int GetAggregatedElementID() { - return GetElementID() - + GetDrawingCoord().elementCoord; -} -ivec2 HdGet_edgeIndices(int localIndex) { - int index = GetPrimitiveIndex(); - return ivec2(edgeIndices[index]); -} -ivec2 HdGet_edgeIndices() { return HdGet_edgeIndices(0); } -int HdGetScalar_edgeIndices(int localIndex) { return HdGet_edgeIndices(localIndex).x; } -int HdGetScalar_edgeIndices() { return HdGet_edgeIndices(0).x; } -int GetAuthoredEdgeId(int primitiveEdgeId) { - return primitiveEdgeId; -} -float HdGet_faceVisibility(int localIndex) { - int index = GetAggregatedElementID(); - return float(faceVisibility[index]); -} -float HdGet_faceVisibility() { return HdGet_faceVisibility(0); } -float HdGetScalar_faceVisibility(int localIndex) { return HdGet_faceVisibility(localIndex); } -float HdGetScalar_faceVisibility() { return HdGet_faceVisibility(0); } -vec3 HdGet_points(int localIndex) { return vec3(inPrimvars.points);} -vec3 HdGet_points() { return HdGet_points(0); } -float HdGetScalar_points(int localIndex) { return HdGet_points(localIndex).x; } -float HdGetScalar_points() { return HdGet_points(0).x; } -vec3 HdGet_normals(int localIndex) { return vec3(inPrimvars.normals);} -vec3 HdGet_normals() { return HdGet_normals(0); } -float HdGetScalar_normals(int localIndex) { return HdGet_normals(localIndex).x; } -float HdGetScalar_normals() { return HdGet_normals(0).x; } -vec2 HdGet_dispTextureCoord(int localIndex) { return vec2(inPrimvars.dispTextureCoord);} -vec2 HdGet_dispTextureCoord() { return HdGet_dispTextureCoord(0); } -float HdGetScalar_dispTextureCoord(int localIndex) { return HdGet_dispTextureCoord(localIndex).x; } -float HdGetScalar_dispTextureCoord() { return HdGet_dispTextureCoord(0).x; } -FORWARD_DECL(vec4 GetPatchCoord(int index)); -void ProcessSamplingTransforms(MAT4 instanceModelViewInverse) { -} - -// --------------------------------------------------------------------------- -// global defines -// --------------------------------------------------------------------------- -// codeGen can override this range (currently not). -// quadro 4000's max is 189. -#ifndef HD_GL_POINT_SIZE_MAX -#define HD_GL_POINT_SIZE_MAX 100.0 -#endif -#ifndef HD_GL_POINT_SIZE_MIN -#define HD_GL_POINT_SIZE_MIN .45 -#endif - -// --------------------------------------------------------------------------- -// render pass states -// --------------------------------------------------------------------------- - -MAT4 GetWorldToViewMatrix() { -#if defined(HD_HAS_worldToViewMatrix) - return MAT4(HdGet_worldToViewMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetWorldToViewInverseMatrix() { -#if defined(HD_HAS_worldToViewInverseMatrix) - return MAT4(HdGet_worldToViewInverseMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetProjectionMatrix() { -#if defined(HD_HAS_projectionMatrix) - return MAT4(HdGet_projectionMatrix()); -#else - return MAT4(1); -#endif -} -vec3 GetPositionInWorldSpace(vec3 windowRelativeCoord) -{ -#if defined(HD_HAS_imageToWorldMatrix) - vec4 pImage = vec4(windowRelativeCoord, 1.0); - vec4 pWorld = vec4(HdGet_imageToWorldMatrix() * pImage); - return (pWorld / pWorld.w).xyz; -#else - return windowRelativeCoord; -#endif -} -float GetLightingBlendAmount() { -#if defined(HD_HAS_lightingBlendAmount) - return HdGet_lightingBlendAmount(); -#else - return 1; -#endif -} -vec4 GetViewport() { -#if defined(HD_HAS_viewport) - return HdGet_viewport(); -#else - return vec4(0,0,1,1); -#endif -} -float GetTessLevel() { -#if defined(HD_HAS_tessLevel) - return HdGet_tessLevel(); -#else - return 1; -#endif -} -float GetPointSize() { -#if defined(HD_HAS_pointSize) - return HdGet_pointSize(); -#else - return 3.0; -#endif -} -float GetPointSelectedSize() { -#if defined(HD_HAS_pointSelectedSize) - return HdGet_pointSelectedSize(); -#else - return 5.0; -#endif -} -vec4 GetWireframeColor() { -// Individual prims can specify an alternative wireframe color -// to one specified in the render pass. This is used in cases were -// there is not enough contrast with the normal one. -#if defined(HD_HAS_overrideWireframeColor) - return HdGet_overrideWireframeColor(); -#elif defined(HD_HAS_wireframeColor) - return HdGet_wireframeColor(); -#else - return vec4(0,0,0,0); -#endif -} -vec4 GetMaskColor() { -#if defined(HD_HAS_maskColor) - return HdGet_maskColor(); -#else - return vec4(0.5,0,0,1); -#endif -} -vec4 GetIndicatorColor() { -#if defined(HD_HAS_indicatorColor) - return HdGet_indicatorColor(); -#else - return vec4(0,0.5,0,1); -#endif -} - -bool ShouldDiscardByAlpha(vec4 color) -{ -#if defined(HD_HAS_alphaThreshold) - float alphaThreshold = HdGet_alphaThreshold(); -#else - float alphaThreshold = 0; -#endif - return (color.a < alphaThreshold); -} - -vec2 ApplyAxisAlignedAffineTransform(vec4 t, vec2 pt) -{ - return t.xy * pt + t.zw; -} - - - -vec2 HorizontallyNormalizedFilmbackCoordinates() -{ - const vec4 transform = -#ifdef HD_HAS_imageToHorizontallyNormalizedFilmback - HdGet_imageToHorizontallyNormalizedFilmback(); -#else - vec4(vec2(1.0), vec2(0.0)); -#endif - return ApplyAxisAlignedAffineTransform(transform, gl_FragCoord.xy); -} - - - -vec4 ApplySelectionColor(vec4 color) -{ - return color; -} - - - -// Forward declare selection functionality. -// XXX: Currently, the non-empty implementation of this is in hdx. -FORWARD_DECL(vec4 ApplySelectionColor(vec4 color)); - -// XXX: Make sure to update hdx/shaders/renderPass.glslfx when editing these -// color override methods, since they're currently duplicated. This is because -// we don't have a mixin token for color overrides in a render pass yet. -vec4 ApplyColorOverrides(vec4 color) -{ -#if defined(HD_HAS_overrideColor) - // Mix in override color - vec4 overrideColor = HdGet_overrideColor(); - color.rgb = mix(color.rgb, overrideColor.rgb, overrideColor.a); -#endif - return ApplySelectionColor(color); -} - -vec3 ApplyMaskColor(vec3 color, float weight, vec4 maskColor) -{ - float strength = maskColor.a * clamp(weight, 0.0, 1.0); - return mix(color, maskColor.rgb, strength); -} - -vec4 ApplyColorOverridesPostLighting(vec4 color) -{ - #if defined(HD_HAS_maskWeight) - float maskWeight = HdGet_maskWeight(); - vec4 maskColor = GetMaskColor(); - color.rgb = ApplyMaskColor(color.rgb, maskWeight, maskColor); - #endif - #if defined(HD_HAS_indicatorWeight) - float indicatorWeight = HdGet_indicatorWeight(); - vec4 indicatorColor = GetIndicatorColor(); - color.rgb = ApplyMaskColor(color.rgb, indicatorWeight, indicatorColor); - #endif - return color; -} - - - -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - colorOut = color; -} - - -#ifndef HD_HAS_integrateLights -#define HD_HAS_integrateLights -#endif - -struct LightingContribution { - vec3 diffuse; -}; - -struct LightingInterfaceProperties { - float unused; -}; - -LightingContribution -integrateLightsDefault(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - vec3 n = normalize(Neye); - - LightingContribution result; - result.diffuse = vec3(dot(n, vec3(0,0,1))); - - return result; -} - -LightingContribution -integrateLightsConstant(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - LightingContribution result; - //pefectly diffuse white hemisphere contribution - result.diffuse = vec3(1); - - return result; -} - - - -FORWARD_DECL( - LightingContribution integrateLights(vec4 Peye, vec3 Neye, - LightingInterfaceProperties props)); - -vec3 FallbackLighting(in vec3 Peye, in vec3 Neye, in vec3 color) -{ - LightingInterfaceProperties props; - LightingContribution light = integrateLights(vec4(Peye, 1), Neye, props); - return color * light.diffuse; -} - - -vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - // lighting - color.rgb = FallbackLighting(Peye.xyz, Neye, color.rgb); - return color; -} - - -// quaternion to matrix. xyz = imaginary, w = real -MAT4 GetRotationMatrix(vec4 q) -{ - MAT4 r; - r[0].xyzw = vec4(1 - 2 * (q.y * q.y + q.z * q.z), - 2 * (q.x * q.y + q.z * q.w), - 2 * (q.x * q.z - q.y * q.w), - 0); - r[1].xyzw = vec4( 2 * (q.x * q.y - q.z * q.w), - 1 - 2 * (q.x * q.x + q.z * q.z), - 2 * (q.y * q.z + q.x * q.w), - 0); - r[2].xyzw = vec4( 2 * (q.x * q.z + q.y * q.w), - 2 * (q.y * q.z - q.x * q.w), - 1 - 2 * (q.x * q.x + q.y * q.y), - 0); - r[3] = vec4(0, 0, 0, 1); - return r; -} - -// --------------------------------------------------------------------------- - -MAT4 GetInstanceTransform(int level) -{ - MAT4 m = MAT4(1); -#ifdef HD_HAS_INSTANCE_hydra_instanceTransforms - m = HdGetInstance_hydra_instanceTransforms(level, MAT4(1)) * m; -#elif defined(HD_HAS_INSTANCE_instanceTransform) - m = HdGetInstance_instanceTransform(level, MAT4(1)) * m; -#endif - - // instance transform elements are applied: - // scale then rotate then translate - // i.e. (T * R * S) * position - -#ifdef HD_HAS_INSTANCE_hydra_instanceScales - vec3 s = HdGetInstance_hydra_instanceScales(level, /*default=*/vec3(1)); - m = MAT4(s.x, 0, 0, 0, - 0, s.y, 0, 0, - 0, 0, s.z, 0, - 0, 0, 0, 1) * m; -#elif defined(HD_HAS_INSTANCE_instanceScale) - vec3 s = HdGetInstance_scale(level, /*default=*/vec3(1)); - m = MAT4(s.x, 0, 0, 0, - 0, s.y, 0, 0, - 0, 0, s.z, 0, - 0, 0, 0, 1) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceRotations // GfQuat(ix, iy, iz, real) - vec4 q = HdGetInstance_hydra_instanceRotations(level, /*default=*/vec4(0)); - m = GetRotationMatrix(q) * m; -#elif defined(HD_HAS_INSTANCE_rotate) - vec4 q = HdGetInstance_rotate(level, /*default=*/vec4(0)); - m = GetRotationMatrix(q) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceTranslations - vec3 t = HdGetInstance_hydra_instanceTranslations(level, /*default=*/vec3(0)); - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - t.x, t.y, t.z, 1) * m; -#elif defined(HD_HAS_INSTANCE_translate) - vec3 t = HdGetInstance_translate(level, /*default=*/vec3(0)); - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - t.x, t.y, t.z, 1) * m; -#endif - return m; -} - -MAT4 GetInstanceTransformInverse(int level) -{ - MAT4 m = MAT4(1); - -#ifdef HD_HAS_INSTANCE_hydra_instanceTransforms - m = inverse(HdGetInstance_hydra_instanceTransforms(level, MAT4(1))) * m; -#elif defined(HD_HAS_INSTANCE_instanceTransform) - m = inverse(HdGetInstance_instanceTransform(level, MAT4(1))) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceTranslations - vec3 it = -HdGetInstance_hydra_instanceTranslations(level, /*default=*/vec3(0)); // negate - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - it.x, it.y, it.z, 1) * m; -#elif defined(HD_HAS_INSTANCE_translate) - vec3 it = -HdGetInstance_translate(level, /*default=*/vec3(0)); // negate - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - it.x, it.y, it.z, 1) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceRotations - vec4 q = HdGetInstance_hydra_instanceRotations(level, /*default=*/vec4(0)); - q.xyz = -q.xyz; // inverse rotataion axis - m = GetRotationMatrix(q) * m; -#elif defined(HD_HAS_INSTANCE_rotate) - vec4 q = HdGetInstance_rotate(level, /*default=*/vec4(0)); - q.xyz = -q.xyz; // inverse rotataion axis - m = GetRotationMatrix(q) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceScales - vec3 is = 1.0/HdGetInstance_hydra_instanceScales(level, /*default=*/vec3(1)); // inverse scale - m = MAT4(is.x, 0, 0, 0, - 0, is.y, 0, 0, - 0, 0, is.z, 0, - 0, 0, 0, 1) * m; -#elif defined(HD_HAS_INSTANCE_scale) - vec3 is = 1.0/HdGetInstance_scale(level, /*default=*/vec3(1)); // inverse scale - m = MAT4(is.x, 0, 0, 0, - 0, is.y, 0, 0, - 0, 0, is.z, 0, - 0, 0, 0, 1) * m; -#endif - return m; -} - -// --------------------------------------------------------------------------- - -MAT4 GetInstanceTransform() -{ - MAT4 m = MAT4(1); -#ifdef HD_INSTANCER_NUM_LEVELS - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - m = GetInstanceTransform(i) * m; -#ifdef HD_HAS_instancerTransform - m = HdGet_instancerTransform(i) * m; -#endif - } -#endif - return m; -} - -MAT4 GetInstanceTransformInverse() -{ - MAT4 m = MAT4(1); -#ifdef HD_INSTANCER_NUM_LEVELS - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - m = m * GetInstanceTransformInverse(i); -#ifdef HD_HAS_instancerTransformInverse - m = m * HdGet_instancerTransformInverse(i); -#endif - } -#endif - return m; -} - -// --------------------------------------------------------------------------- - -MAT4 ApplyInstanceTransform(MAT4 m) -{ - return GetInstanceTransform() * m; -} - -MAT4 ApplyInstanceTransformInverse(MAT4 m) -{ - return m * GetInstanceTransformInverse(); -} - -bool IsFlipped() -{ -#if defined(HD_HAS_isFlipped) - bool flip = (HdGet_isFlipped() != 0); -#elif defined(HD_HAS_transform) - // The sign of the determinant indicates whether m flips handedness - bool flip = (determinant(HdGet_transform()) < 0.0); -#else - bool flip = false; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceScales - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - vec3 scale = HdGetInstance_hydra_instanceScales(i, /*default=*/vec3(1)); - flip = flip != ((sign(scale.x) * sign(scale.y) * sign(scale.z)) < 0); - } -#elif defined(HD_HAS_INSTANCE_scale) - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - vec3 scale = HdGetInstance_scale(i, /*default=*/vec3(1)); - flip = flip != ((sign(scale.x) * sign(scale.y) * sign(scale.z)) < 0); - } -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceTransforms - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - MAT4 m = HdGetInstance_hydra_instanceTransforms(i, MAT4(1)); - flip = flip != (determinant(m) < 0.0); - } -#elif defined(HD_HAS_INSTANCE_instanceTransform) - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - MAT4 m = HdGetInstance_instanceTransform(i, MAT4(1)); - flip = flip != (determinant(m) < 0.0); - } -#endif - - return flip; -} - - -vec3 GetNormal(vec3 Neye, int index) -{ - return Neye; -} - -vec3 GetNormal(vec3 Neye, int index, vec2 localST) -{ - return GetNormal(Neye, index); -} - - - -vec3 GetShadingNormal(vec3 N, bool isFlipped) -{ - // the fragment shader takes already-flipped-normals. - // no need to flip here. - return N; -} - - - -void DiscardBasedOnShading(bool frontFacing, bool isFlipped) -{ - // Nothing to do since h/w face culling is used. -} - - - -vec4 ApplyEdgeColor(vec4 Cfill, vec4 patchCoord) -{ - return Cfill; -} - -// Return a large value, signifying that the fragment isn't near an edge. -float GetMinEdgeDistance() -{ - return 1000.0; -} - - - -vec3 GetEdgeParamTriangle() -{ - // Expand barycentric coordinates - vec2 param = GetPatchCoord(0).xy; - vec3 barycentric = vec3(param.x, param.y, 1 - param.x - param.y); - - // Match triangle edge order - return barycentric.yzx; -} - -vec3 GetEdgeDistanceTriangle() -{ - vec3 param = GetEdgeParamTriangle(); - return max(vec3(0.0), param / fwidth(param)); -} - -vec4 GetEdgeParamQuad() -{ - // Expand coordinates to opposite corners of quad - vec2 leftBottom = GetPatchCoord(0).xy; - vec2 rightTop = vec2(1.0) - leftBottom; - - // Match quad edge order - return vec4(leftBottom.y, rightTop.x, rightTop.y, leftBottom.x); -} - -vec4 GetEdgeDistanceQuad() -{ - vec4 param = GetEdgeParamQuad(); - return max(vec4(0.0), param / fwidth(param)); -} - - - -struct ReprStyle -{ - vec4 color; - bool usePrimvarColor; - bool usePrimvarAlpha; - bool applyColorOverride; - bool useSurfaceShaderColor; - bool useSurfaceShaderAlpha; -}; - -struct ScalarOverride -{ - bool enabled; - vec3 color; -}; - -FORWARD_DECL(ReprStyle GetReprStyle()); -FORWARD_DECL(ScalarOverride GetScalarOverride()); -FORWARD_DECL( - vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)); -FORWARD_DECL(vec4 postSurfaceShader(vec4 Peye, vec3 Neye, vec4 color)); - -vec4 ShadingTerminal(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - ReprStyle reprStyle = GetReprStyle(); - - // Apply scalar override. - ScalarOverride scalarOverride = GetScalarOverride(); - if (scalarOverride.enabled) { - vec4 result; - - result.rgb = scalarOverride.color; - result.a = reprStyle.usePrimvarAlpha ? color.a: reprStyle.color.a; - - vec4 colorOverride = ApplyColorOverrides(result); - result = reprStyle.applyColorOverride ? colorOverride : result; - - return result; - } - - // Draw mode can override face color - vec4 reprColor; - - reprColor.rgb = reprStyle.usePrimvarColor ? color.rgb : reprStyle.color.rgb; - reprColor.a = reprStyle.usePrimvarAlpha ? color.a : reprStyle.color.a; - - // Compute color overrides - vec4 colorOverride = ApplyColorOverrides(reprColor); - reprColor = reprStyle.applyColorOverride ? colorOverride : reprColor; - - - // Surface shading can be expensive and also can contain undesirable - // side effects (like discards). So only run it for reprs that require it. - - if (reprStyle.useSurfaceShaderColor || - reprStyle.useSurfaceShaderAlpha) { - vec4 shadingColor; - - shadingColor = surfaceShader(Peye, - Neye, - reprColor, - patchCoord); - -#ifdef HD_HAS_postSurfaceShader - shadingColor = postSurfaceShader(Peye, - Neye, - shadingColor); -#endif - - reprColor.rgb = reprStyle.useSurfaceShaderColor ? - shadingColor.rgb : - reprColor.rgb; - - reprColor.a = reprStyle.useSurfaceShaderAlpha ? - shadingColor.a : - reprColor.a; - } - - vec4 baseColor = color; - baseColor = ApplyColorOverrides(baseColor); - - vec4 litColor = mix(baseColor, - reprColor, - GetLightingBlendAmount()); - - // Final overrides. - - return ApplyColorOverridesPostLighting(litColor); -} - - - -#ifdef HD_HAS_integrateLights -#ifndef HD_HAS_definedIntegrateLights -#define HD_HAS_definedIntegrateLights - -LightingContribution -integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - return integrateLightsDefault(Peye, Neye, props); -} - -#endif // HD_HAS_definedIntegrateLights -#endif - -ReprStyle GetReprStyle() -{ - ReprStyle reprStyle; - - reprStyle.color = vec4(0.0, 0.0, 0.0, 1.0); - reprStyle.usePrimvarColor = true; - reprStyle.usePrimvarAlpha = true; - reprStyle.applyColorOverride = true; - reprStyle.useSurfaceShaderColor = true; - reprStyle.useSurfaceShaderAlpha = true; - - return reprStyle; -} - - - -ScalarOverride GetScalarOverride() -{ - ScalarOverride result; - -#if defined(HD_HAS_scalarOverride) - result.enabled = true; - - // Allow a scalar value to override the color from the surface - // for previewing heatmaps. This is useful for editing workflows. -#if defined(HD_HAS_scalarOverrideColorRamp) - int rampCount = constantPrimvars[GetDrawingCoord().constantCoord]. - scalarOverrideColorRamp.length(); - float scalar = HdGet_scalarOverride() * float(rampCount - 1); - float baseIndex = floor(scalar); - float nextIndex = min(float(rampCount - 1), baseIndex + 1.0); - float interp = scalar - baseIndex; - result.color = mix(HdGet_scalarOverrideColorRamp(int(baseIndex)).rgb, - HdGet_scalarOverrideColorRamp(int(nextIndex)).rgb, - interp); -#else - // If no ramp is given just gamma correct the scalar as greyscale. - result.color = vec3(pow(HdGet_scalarOverride(), 2.2)); -#endif // HD_HAS_scalarOverrideColorRamp - -#else // HD_HAS_scalarOverride - result.enabled = false; - result.color = vec3(0.0, 0.0, 0.0); -#endif - - return result; -} - - - -// Determines whether a fragment is on or close to an unhidden triangle edge. -const float edgePickRadius = 2; // in viewport pixels -const float edgePickParametricRadius = 0.02; // in parametric space - -// For smooth looking edges, use an exponential falloff for the opacity. -// Note: We use a slower falloff fn than in meshWire.glslfx to make the -// selected edges stand out. -float SelectedEdgeFalloff(float d) { - return exp2(-1 * d * d); -} - - - -vec4 ComputeBaseFaceEdgeDistanceQuad() -{ - return GetEdgeDistanceQuad(); -} - -bool SelectWireframeFaceEdges() -{ - return false; -} - - - -float GetSelectedEdgeOpacity() -{ - float closestEdgeDistance = 0.0; - - // The sequence of comparisons should match GetPrimitiveEdgeId() - vec4 dist = ComputeBaseFaceEdgeDistanceQuad(); - if (dist.x < edgePickRadius) { - closestEdgeDistance = dist.x; - } else if (dist.y < edgePickRadius) { - closestEdgeDistance = dist.y; - } else if (dist.z < edgePickRadius) { - closestEdgeDistance = dist.z; - } else if (dist.w < edgePickRadius) { - closestEdgeDistance = dist.w; - } else { - return 0; - } - - return SelectedEdgeFalloff(closestEdgeDistance); -} - -// called from hdx/renderPass.glslfx and selection.glslfx -int GetPrimitiveEdgeId() -{ - // e2 - // (0,1) 3 ------ 2 (1,1) - // | | - // e3 | | e1 - // | | - // (0,0) 0 ------ 1 (1,0) - // e0 - - int edgeId = -1; - - vec4 dist = ComputeBaseFaceEdgeDistanceQuad(); - if (dist.x < edgePickRadius) { - edgeId = 0; - } else if (dist.y < edgePickRadius) { - edgeId = 1; - } else if (dist.z < edgePickRadius) { - edgeId = 2; - } else if (dist.w < edgePickRadius) { - edgeId = 3; - } else { - return -1; // Not on a mesh edge - } - - const int edgeFlag = GetEdgeFlag(); - const ivec2 meshEdgeIndices = HdGet_edgeIndices(); - - // Translate face-edge to authored mesh-edge - if (edgeFlag == 0) { - edgeId = meshEdgeIndices[0] + edgeId; // regular quad face - } else if (edgeId == 0) { - edgeId = meshEdgeIndices[0]; - } else if (edgeId == 3) { - edgeId = meshEdgeIndices[1]; - } else { - edgeId = -1; // Not an authored mesh edge - } - return edgeId; -} - - -int GetPointId() -{ - return -1; -} - - -void DiscardBasedOnTopologicalVisibility() -{ - // Nothing to do, since there's no authored opinion. -} - - - -vec4 GetInterpolatedPatchCoord() -{ - return gsPatchCoord; -} - - - -#ifndef HD_HAS_ptexFaceOffset -#define HD_HAS_ptexFaceOffset -int HdGet_ptexFaceOffset() -{ - return 0; -} -#endif - -vec4 GetPatchCoord(int localIndex) -{ - vec4 patchCoord = GetInterpolatedPatchCoord(); - return vec4(patchCoord.xyz, patchCoord.w + HdGet_ptexFaceOffset()); -} - -vec4 GetPatchCoord() -{ - return GetPatchCoord(0); -} - -vec3 ComputeScreenSpacePeye() -{ - return inData.Peye.xyz / inData.Peye.w; -} - -vec3 ComputeScreenSpaceNeye() -{ - vec3 Peye = ComputeScreenSpacePeye(); - vec3 Neye = normalize(cross(dFdx(Peye), dFdy(Peye))); - return (gl_FrontFacing ? Neye : -Neye); -} - -void main(void) -{ - bool isFlipped = IsFlipped(); - - DiscardBasedOnShading(gl_FrontFacing, isFlipped); - - DiscardBasedOnTopologicalVisibility(); - - vec4 color = vec4(0.5, 0.5, 0.5, 1); -#ifdef HD_HAS_displayColor - color.rgb = HdGet_displayColor().rgb; -#endif -#ifdef HD_HAS_displayOpacity - color.a = HdGet_displayOpacity(); -#endif - - vec3 Peye = ComputeScreenSpacePeye(); - - vec3 Neye = inData.Neye; - // Normalize Neye after rasterizer interpolation. - if (length(Neye) > 0.0) { - Neye = normalize(Neye); - } - // Give the shader key a chance to override the normal. - Neye = GetNormal(Neye, 0); - // Orient the normal for shading. - Neye = GetShadingNormal(Neye, isFlipped); - - vec4 patchCoord = GetPatchCoord(); - color = ShadingTerminal(vec4(Peye, 1), Neye, color, patchCoord); - - color = ApplyEdgeColor(color, patchCoord); - -#ifdef HD_MATERIAL_TAG_MASKED - if (ShouldDiscardByAlpha(color)) { - discard; - return; - } -#endif - - RenderOutput(vec4(Peye, 1), Neye, color, patchCoord); -} - -OK diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_instance.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_instance.out deleted file mode 100644 index 9960bc8fe8..0000000000 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_instance.out +++ /dev/null @@ -1,5531 +0,0 @@ -------------------------------------------------------- --- glslfx version 0.1 -#import $TOOLS/hdSt/shaders/mesh.glslfx --- configuration -{"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } -, "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Triangle"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.TriangleSurface", "EdgeId.Fragment.TriangleParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } -}}} -------------------------------------------------------- -======================================================= - VERTEX SHADER -======================================================= -#version 450 -#extension GL_NV_shader_buffer_load : require -#extension GL_NV_gpu_shader5 : require -#extension GL_ARB_bindless_texture : require -#extension GL_ARB_shader_draw_parameters : require -int HgiGetBaseVertex() { - return gl_BaseVertexARB; -} -#define REF(space,type) inout type -#define FORWARD_DECL(func_decl) func_decl; -#define ATOMIC_LOAD(a) (a) -#define ATOMIC_STORE(a, v) (a) = (v) -#define ATOMIC_ADD(a, v) atomicAdd(a, v) -#define ATOMIC_EXCHANGE(a, v) atomicExchange(a, v) -#define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) -#define atomic_int int -#define atomic_uint uint - -#define HGI_HAS_DOUBLE_TYPE 1 - - -struct hgi_ivec3 { int x, y, z; }; -struct hgi_vec3 { float x, y, z; }; -struct hgi_dvec3 { double x, y, z; }; -struct hgi_mat3 { float m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; -struct hgi_dmat3 { double m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; - - -// //////// Codegen Defines //////// -#define HD_SHADER_API 2 -#define MAT4 mat4 -// Alias hgi vec and matrix types to hd. -#define hd_ivec3 hgi_ivec3 -#define hd_vec3 hgi_vec3 -#define hd_dvec3 hgi_dvec3 -#define hd_mat3 hgi_mat3 -#define hd_dmat3 hgi_dmat3 - -ivec3 hd_ivec3_get(hd_ivec3 v) { return ivec3(v.x, v.y, v.z); } -ivec3 hd_ivec3_get(ivec3 v) { return v; } -vec3 hd_vec3_get(hd_vec3 v) { return vec3(v.x, v.y, v.z); } -vec3 hd_vec3_get(vec3 v) { return v; } -dvec3 hd_dvec3_get(hd_dvec3 v) { return dvec3(v.x, v.y, v.z); } -dvec3 hd_dvec3_get(dvec3 v) { return v; } -mat3 hd_mat3_get(hd_mat3 v) { return mat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -mat3 hd_mat3_get(mat3 v) { return v; } -dmat3 hd_dmat3_get(hd_dmat3 v) { return dmat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -dmat3 hd_dmat3_get(dmat3 v) { return v; } -hd_ivec3 hd_ivec3_set(hd_ivec3 v) { return v; } -hd_ivec3 hd_ivec3_set(ivec3 v) { return hd_ivec3(v.x, v.y, v.z); } -hd_vec3 hd_vec3_set(hd_vec3 v) { return v; } -hd_vec3 hd_vec3_set(vec3 v) { return hd_vec3(v.x, v.y, v.z); } -hd_dvec3 hd_dvec3_set(hd_dvec3 v) { return v; } -hd_dvec3 hd_dvec3_set(dvec3 v) { return hd_dvec3(v.x, v.y, v.z); } -hd_mat3 hd_mat3_set(hd_mat3 v) { return v; } -hd_mat3 hd_mat3_set(mat3 v) { return hd_mat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -hd_dmat3 hd_dmat3_set(hd_dmat3 v) { return v; } -hd_dmat3 hd_dmat3_set(dmat3 v) { return hd_dmat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -int hd_int_get(int v) { return v; } -int hd_int_get(ivec2 v) { return v.x; } -int hd_int_get(ivec3 v) { return v.x; } -int hd_int_get(ivec4 v) { return v.x; } -vec3 hd_sample_udim(vec2 v) { -vec2 vf = floor(v); -return vec3(v.x - vf.x, v.y - vf.y, clamp(vf.x, 0.0, 10.0) + 10.0 * vf.y); -} -vec4 hd_vec4_2_10_10_10_get(int v) { - ivec4 unpacked = ivec4((v & 0x3ff) << 22, (v & 0xffc00) << 12, - (v & 0x3ff00000) << 2, (v & 0xc0000000)); - return vec4(unpacked) / 2147483647.0; } -int hd_vec4_2_10_10_10_set(vec4 v) { - return ( (int(v.x * 511.0) & 0x3ff) | - ((int(v.y * 511.0) & 0x3ff) << 10) | - ((int(v.z * 511.0) & 0x3ff) << 20) | - ((int(v.w) & 0x1) << 30)); } -vec2 hd_half2_get(uint v) { - return unpackHalf2x16(v); } -uint hd_half2_set(vec2 v) { - return packHalf2x16(v); } -vec4 hd_half4_get(uvec2 v) { - return vec4(unpackHalf2x16(v.x), unpackHalf2x16(v.y)); } -uvec2 hd_half4_set(vec4 v) { - return uvec2(packHalf2x16(v.xy), packHalf2x16(v.zw)); } -#define HD_NUM_PRIMITIVE_VERTS 3 -#define HD_HAS_transform 1 -#define HD_HAS_transformInverse 1 -#define HD_HAS_color 1 -#define HD_HAS_primID 1 -#define HD_HAS_widths 1 -#define HD_HAS_INSTANCE_hydra_instanceTranslations 1 -#define HD_HAS_hydra_instanceTranslations_0 1 -#define HD_INSTANCER_NUM_LEVELS 1 -#define HD_INSTANCE_INDEX_WIDTH 2 -#define HD_HAS_faceVisibility 1 -#define HD_HAS_dispTextureCoord 1 -#define HD_HAS_points 1 -#define HD_HAS_normals 1 - - -// //////// Global Includes //////// - -// //////// Global Macros //////// - -// //////// Global Structs //////// - -// //////// Global Member Declarations //////// -uint hd_VertexID = gl_VertexID; -uint hd_InstanceID = gl_InstanceID; -uint hd_BaseInstance = 0; - -// //////// Global Function Definitions //////// - - -// //////// Codegen Decl //////// -struct hd_drawingCoord { - int modelCoord; - int constantCoord; - int elementCoord; - int primitiveCoord; - int fvarCoord; - int shaderCoord; - int vertexCoord; - int topologyVisibilityCoord; - int varyingCoord; - int instanceIndex[HD_INSTANCE_INDEX_WIDTH]; - int instanceCoords[HD_INSTANCE_INDEX_WIDTH]; -}; -FORWARD_DECL(hd_drawingCoord GetDrawingCoord()); -FORWARD_DECL(int HgiGetBaseVertex()); -struct hd_instanceIndex { int indices[HD_INSTANCE_INDEX_WIDTH]; }; -struct ConstantData10 { - mat4 transform; - mat4 transformInverse; - vec4 color; - vec4 primID; - float widths; -}; -FORWARD_DECL(int GetElementID()); -FORWARD_DECL(int GetAggregatedElementID()); -FORWARD_DECL(int GetPrimitiveEdgeId()); -FORWARD_DECL(float GetSelectedEdgeOpacity()); -out flat ivec4 vs_interstageDrawingCoord0; -out flat ivec4 vs_interstageDrawingCoord1; -out flat ivec4 vs_interstageDrawingCoord2; -out flat ivec4 vs_interstageDrawingCoord3; -layout (location = 2) in ivec4 drawingCoord0; -layout (location = 3) in ivec4 drawingCoord1; -layout (location = 4) in ivec2 drawingCoord2; -layout (location = 5) in int drawingCoordI0; -layout (location = 0) in vec3 points; -layout (location = 1) in vec3 normals; -layout(location = 6) uniform int *instanceIndices; -layout(location = 7) uniform int *culledInstanceIndices; -layout(location = 0) uniform ConstantData10 *constantPrimvars; -layout(location = 1) uniform hd_vec3 *hydra_instanceTranslations_0; -layout(location = 2) uniform int *primitiveParam; -layout(location = 3) uniform int *edgeIndices; -layout(location = 4) uniform float *faceVisibility; -out VertexData { - vec4 Peye; - vec3 Neye; -} outData; -out PrimvarData { - vec3 points; - vec3 normals; -} outPrimvars; - -// //////// Codegen Accessors //////// -mat4 HdGet_transform(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transform); -} -mat4 HdGet_transform() { return HdGet_transform(0); } -mat4 HdGet_transformInverse(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transformInverse); -} -mat4 HdGet_transformInverse() { return HdGet_transformInverse(0); } -vec4 HdGet_color(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].color); -} -vec4 HdGet_color() { return HdGet_color(0); } -float HdGetScalar_color(int localIndex) { return HdGet_color(localIndex).x; } -float HdGetScalar_color() { return HdGet_color(0).x; } -vec4 HdGet_primID(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].primID); -} -vec4 HdGet_primID() { return HdGet_primID(0); } -float HdGetScalar_primID(int localIndex) { return HdGet_primID(localIndex).x; } -float HdGetScalar_primID() { return HdGet_primID(0).x; } -float HdGet_widths(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return float(constantPrimvars[index].widths); -} -float HdGet_widths() { return HdGet_widths(0); } -float HdGetScalar_widths(int localIndex) { return HdGet_widths(localIndex); } -float HdGetScalar_widths() { return HdGet_widths(0); } -vec3 HdGet_hydra_instanceTranslations_0(int localIndex) { - int index = GetDrawingCoord().instanceCoords[0]; - return hd_vec3_get(hydra_instanceTranslations_0[index]); -} -vec3 HdGet_hydra_instanceTranslations_0() { return HdGet_hydra_instanceTranslations_0(0); } -float HdGetScalar_hydra_instanceTranslations_0(int localIndex) { return HdGet_hydra_instanceTranslations_0(localIndex).x; } -float HdGetScalar_hydra_instanceTranslations_0() { return HdGet_hydra_instanceTranslations_0(0).x; } -vec3 HdGetInstance_hydra_instanceTranslations(int level, vec3 defaultValue) { - if (level == 0) return HdGet_hydra_instanceTranslations_0(); - return defaultValue; -} -#if !defined(HD_HAS_hydra_instanceTranslations) -#define HD_HAS_hydra_instanceTranslations 1 -vec3 HdGet_hydra_instanceTranslations(int localIndex) { - return HdGet_hydra_instanceTranslations_0(); -} -vec3 HdGet_hydra_instanceTranslations() { return HdGet_hydra_instanceTranslations(0); } -#endif - -// //////// Codegen VS Source //////// -#define HD_BINDLESS_BUFFERS_ENABLED -int GetBaseInstanceIndexCoord() { - return drawingCoord1.y; -} -int GetCurrentInstance() { - return int(hd_InstanceID - hd_BaseInstance); -} -int GetInstanceIndexCoord() { - return GetBaseInstanceIndexCoord() + GetCurrentInstance() * HD_INSTANCE_INDEX_WIDTH; -} -int HdGet_culledInstanceIndices(int localIndex) { - int index = GetInstanceIndexCoord()+localIndex + 1; - return int(culledInstanceIndices[index]); -} -int HdGet_culledInstanceIndices() { return HdGet_culledInstanceIndices(0); } -int HdGetScalar_culledInstanceIndices(int localIndex) { return HdGet_culledInstanceIndices(localIndex); } -int HdGetScalar_culledInstanceIndices() { return HdGet_culledInstanceIndices(0); } -int GetBaseVertexOffset() { - return HgiGetBaseVertex(); -} -hd_instanceIndex GetInstanceIndex() { - hd_instanceIndex r; - for (int i = 0; i < HD_INSTANCE_INDEX_WIDTH; ++i) - r.indices[i] = HdGet_culledInstanceIndices(/*localIndex=*/i); - return r; -} -hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = drawingCoord0.x; - dc.constantCoord = drawingCoord0.y; - dc.elementCoord = drawingCoord0.z; - dc.primitiveCoord = drawingCoord0.w; - dc.fvarCoord = drawingCoord1.x; - dc.shaderCoord = drawingCoord1.z; - dc.vertexCoord = drawingCoord1.w; - dc.topologyVisibilityCoord = drawingCoord2.x; - dc.varyingCoord = drawingCoord2.y; - hd_instanceIndex r = GetInstanceIndex(); - dc.instanceIndex[0] = r.indices[0]; - dc.instanceIndex[1] = r.indices[1]; - dc.instanceCoords[0] = drawingCoordI0 + dc.instanceIndex[1]; - return dc; -} -vec3 HdGet_points(int localIndex) { return hd_vec3_get(points);} -vec3 HdGet_points() { return HdGet_points(0); } -float HdGetScalar_points(int localIndex) { return HdGet_points(localIndex).x; } -float HdGetScalar_points() { return HdGet_points(0).x; } -vec3 HdGet_normals(int localIndex) { return hd_vec3_get(normals);} -vec3 HdGet_normals() { return HdGet_normals(0); } -float HdGetScalar_normals(int localIndex) { return HdGet_normals(localIndex).x; } -float HdGetScalar_normals() { return HdGet_normals(0).x; } - -// //////// Codegen Proc VS //////// -void ProcessPrimvarsIn() { - hd_drawingCoord dc = GetDrawingCoord(); - vs_interstageDrawingCoord0[0] = dc.modelCoord; - vs_interstageDrawingCoord0[1] = dc.constantCoord; - vs_interstageDrawingCoord0[2] = dc.elementCoord; - vs_interstageDrawingCoord0[3] = dc.primitiveCoord; - vs_interstageDrawingCoord1[0] = dc.fvarCoord; - vs_interstageDrawingCoord1[1] = dc.shaderCoord; - vs_interstageDrawingCoord1[2] = dc.vertexCoord; - vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; - vs_interstageDrawingCoord2[0] = dc.varyingCoord; - vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; - vs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; - vs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; - outPrimvars.points = points; - outPrimvars.normals = normals; -} - -// --------------------------------------------------------------------------- -// global defines -// --------------------------------------------------------------------------- -// codeGen can override this range (currently not). -// quadro 4000's max is 189. -#ifndef HD_GL_POINT_SIZE_MAX -#define HD_GL_POINT_SIZE_MAX 100.0 -#endif -#ifndef HD_GL_POINT_SIZE_MIN -#define HD_GL_POINT_SIZE_MIN .45 -#endif - -// --------------------------------------------------------------------------- -// render pass states -// --------------------------------------------------------------------------- - -MAT4 GetWorldToViewMatrix() { -#if defined(HD_HAS_worldToViewMatrix) - return MAT4(HdGet_worldToViewMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetWorldToViewInverseMatrix() { -#if defined(HD_HAS_worldToViewInverseMatrix) - return MAT4(HdGet_worldToViewInverseMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetProjectionMatrix() { -#if defined(HD_HAS_projectionMatrix) - return MAT4(HdGet_projectionMatrix()); -#else - return MAT4(1); -#endif -} -vec3 GetPositionInWorldSpace(vec3 windowRelativeCoord) -{ -#if defined(HD_HAS_imageToWorldMatrix) - vec4 pImage = vec4(windowRelativeCoord, 1.0); - vec4 pWorld = vec4(HdGet_imageToWorldMatrix() * pImage); - return (pWorld / pWorld.w).xyz; -#else - return windowRelativeCoord; -#endif -} -float GetLightingBlendAmount() { -#if defined(HD_HAS_lightingBlendAmount) - return HdGet_lightingBlendAmount(); -#else - return 1; -#endif -} -vec4 GetViewport() { -#if defined(HD_HAS_viewport) - return HdGet_viewport(); -#else - return vec4(0,0,1,1); -#endif -} -float GetTessLevel() { -#if defined(HD_HAS_tessLevel) - return HdGet_tessLevel(); -#else - return 1; -#endif -} -float GetPointSize() { -#if defined(HD_HAS_pointSize) - return HdGet_pointSize(); -#else - return 3.0; -#endif -} -float GetPointSelectedSize() { -#if defined(HD_HAS_pointSelectedSize) - return HdGet_pointSelectedSize(); -#else - return 5.0; -#endif -} -vec4 GetWireframeColor() { -// Individual prims can specify an alternative wireframe color -// to one specified in the render pass. This is used in cases were -// there is not enough contrast with the normal one. -#if defined(HD_HAS_overrideWireframeColor) - return HdGet_overrideWireframeColor(); -#elif defined(HD_HAS_wireframeColor) - return HdGet_wireframeColor(); -#else - return vec4(0,0,0,0); -#endif -} -vec4 GetMaskColor() { -#if defined(HD_HAS_maskColor) - return HdGet_maskColor(); -#else - return vec4(0.5,0,0,1); -#endif -} -vec4 GetIndicatorColor() { -#if defined(HD_HAS_indicatorColor) - return HdGet_indicatorColor(); -#else - return vec4(0,0.5,0,1); -#endif -} - -bool ShouldDiscardByAlpha(vec4 color) -{ -#if defined(HD_HAS_alphaThreshold) - float alphaThreshold = HdGet_alphaThreshold(); -#else - float alphaThreshold = 0; -#endif - return (color.a < alphaThreshold); -} - -vec2 ApplyAxisAlignedAffineTransform(vec4 t, vec2 pt) -{ - return t.xy * pt + t.zw; -} - - - -void ApplyClipPlanes(vec4 Peye) -{ -#if defined(HD_HAS_numClipPlanes) -#if defined(HD_HAS_clipPlanes) - for (int i=0; i> 2); -} -int GetAggregatedElementID() { - return GetElementID() - + GetDrawingCoord().elementCoord; -} -int HdGet_edgeIndices(int localIndex) { - int index = GetPrimitiveIndex(); - return int(edgeIndices[index]); -} -int HdGet_edgeIndices() { return HdGet_edgeIndices(0); } -int HdGetScalar_edgeIndices(int localIndex) { return HdGet_edgeIndices(localIndex); } -int HdGetScalar_edgeIndices() { return HdGet_edgeIndices(0); } -int GetAuthoredEdgeId(int primitiveEdgeId) { - return primitiveEdgeId; -} -float HdGet_faceVisibility(int localIndex) { - int index = GetAggregatedElementID(); - return float(faceVisibility[index]); -} -float HdGet_faceVisibility() { return HdGet_faceVisibility(0); } -float HdGetScalar_faceVisibility(int localIndex) { return HdGet_faceVisibility(localIndex); } -float HdGetScalar_faceVisibility() { return HdGet_faceVisibility(0); } -vec3 HdGet_points(int localIndex) { - int index = localIndex; - return vec3(inPrimvars[index].points); -} -vec3 HdGet_points() { return HdGet_points(0); } -float HdGetScalar_points(int localIndex) { return HdGet_points(localIndex).x; } -float HdGetScalar_points() { return HdGet_points(0).x; } -vec3 HdGet_normals(int localIndex) { - int index = localIndex; - return vec3(inPrimvars[index].normals); -} -vec3 HdGet_normals() { return HdGet_normals(0); } -float HdGetScalar_normals(int localIndex) { return HdGet_normals(localIndex).x; } -float HdGetScalar_normals() { return HdGet_normals(0).x; } -vec2 HdGet_dispTextureCoord_Coarse(int localIndex) { - int fvarIndex = GetFVarIndex(localIndex); - return vec2(dispTextureCoord[fvarIndex]); -} -vec2 HdGet_dispTextureCoord(int localIndex, vec2 st) { - return (HdGet_dispTextureCoord_Coarse(0) * (1-st.x-st.y) + HdGet_dispTextureCoord_Coarse(1) * st.x + HdGet_dispTextureCoord_Coarse(2) * st.y); -} -FORWARD_DECL(vec4 GetPatchCoord(int index)); -FORWARD_DECL(vec2 GetPatchCoordLocalST()); -vec2 HdGet_dispTextureCoord(int localIndex) { - vec2 localST = GetPatchCoord(localIndex).xy; - return HdGet_dispTextureCoord(localIndex, localST); -} -vec2 HdGet_dispTextureCoord() { return HdGet_dispTextureCoord(0); } -FORWARD_DECL(vec4 GetPatchCoord(int localIndex)); -void ProcessSamplingTransforms(MAT4 instanceModelViewInverse) { -} - -// //////// Codegen Proc GS //////// -FORWARD_DECL(vec4 GetPatchCoord(int index)); -void ProcessPrimvarsOut(int index) { - vec2 localST = GetPatchCoord(index).xy; - const vec3 coords[3] = vec3[]( - vec3(1,0,0), vec3(0,1,0), vec3(0,0,1) - ); - hd_barycentricCoord = coords[index]; - hd_drawingCoord dc = GetDrawingCoord(); - gs_interstageDrawingCoord0[0] = dc.modelCoord; - gs_interstageDrawingCoord0[1] = dc.constantCoord; - gs_interstageDrawingCoord0[2] = dc.elementCoord; - gs_interstageDrawingCoord0[3] = dc.primitiveCoord; - gs_interstageDrawingCoord1[0] = dc.fvarCoord; - gs_interstageDrawingCoord1[1] = dc.shaderCoord; - gs_interstageDrawingCoord1[2] = dc.vertexCoord; - gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; - gs_interstageDrawingCoord2[0] = dc.varyingCoord; - gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; - gs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; - gs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; - outPrimvars.points = inPrimvars[index].points; - outPrimvars.normals = inPrimvars[index].normals; - outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); -} - -// --------------------------------------------------------------------------- -// global defines -// --------------------------------------------------------------------------- -// codeGen can override this range (currently not). -// quadro 4000's max is 189. -#ifndef HD_GL_POINT_SIZE_MAX -#define HD_GL_POINT_SIZE_MAX 100.0 -#endif -#ifndef HD_GL_POINT_SIZE_MIN -#define HD_GL_POINT_SIZE_MIN .45 -#endif - -// --------------------------------------------------------------------------- -// render pass states -// --------------------------------------------------------------------------- - -MAT4 GetWorldToViewMatrix() { -#if defined(HD_HAS_worldToViewMatrix) - return MAT4(HdGet_worldToViewMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetWorldToViewInverseMatrix() { -#if defined(HD_HAS_worldToViewInverseMatrix) - return MAT4(HdGet_worldToViewInverseMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetProjectionMatrix() { -#if defined(HD_HAS_projectionMatrix) - return MAT4(HdGet_projectionMatrix()); -#else - return MAT4(1); -#endif -} -vec3 GetPositionInWorldSpace(vec3 windowRelativeCoord) -{ -#if defined(HD_HAS_imageToWorldMatrix) - vec4 pImage = vec4(windowRelativeCoord, 1.0); - vec4 pWorld = vec4(HdGet_imageToWorldMatrix() * pImage); - return (pWorld / pWorld.w).xyz; -#else - return windowRelativeCoord; -#endif -} -float GetLightingBlendAmount() { -#if defined(HD_HAS_lightingBlendAmount) - return HdGet_lightingBlendAmount(); -#else - return 1; -#endif -} -vec4 GetViewport() { -#if defined(HD_HAS_viewport) - return HdGet_viewport(); -#else - return vec4(0,0,1,1); -#endif -} -float GetTessLevel() { -#if defined(HD_HAS_tessLevel) - return HdGet_tessLevel(); -#else - return 1; -#endif -} -float GetPointSize() { -#if defined(HD_HAS_pointSize) - return HdGet_pointSize(); -#else - return 3.0; -#endif -} -float GetPointSelectedSize() { -#if defined(HD_HAS_pointSelectedSize) - return HdGet_pointSelectedSize(); -#else - return 5.0; -#endif -} -vec4 GetWireframeColor() { -// Individual prims can specify an alternative wireframe color -// to one specified in the render pass. This is used in cases were -// there is not enough contrast with the normal one. -#if defined(HD_HAS_overrideWireframeColor) - return HdGet_overrideWireframeColor(); -#elif defined(HD_HAS_wireframeColor) - return HdGet_wireframeColor(); -#else - return vec4(0,0,0,0); -#endif -} -vec4 GetMaskColor() { -#if defined(HD_HAS_maskColor) - return HdGet_maskColor(); -#else - return vec4(0.5,0,0,1); -#endif -} -vec4 GetIndicatorColor() { -#if defined(HD_HAS_indicatorColor) - return HdGet_indicatorColor(); -#else - return vec4(0,0.5,0,1); -#endif -} - -bool ShouldDiscardByAlpha(vec4 color) -{ -#if defined(HD_HAS_alphaThreshold) - float alphaThreshold = HdGet_alphaThreshold(); -#else - float alphaThreshold = 0; -#endif - return (color.a < alphaThreshold); -} - -vec2 ApplyAxisAlignedAffineTransform(vec4 t, vec2 pt) -{ - return t.xy * pt + t.zw; -} - - - -void ApplyClipPlanes(vec4 Peye) -{ -#if defined(HD_HAS_numClipPlanes) -#if defined(HD_HAS_clipPlanes) - for (int i=0; i 0.0) - normal = normalize(normal); - return normal; -} - -vec3 GetNormal(vec3 Neye, int index, vec2 localST) -{ - return GetNormal(Neye, index); -} - - - -vec3 GetTriGeometryNormal(vec3 Neye, vec4 Peye0, vec4 Peye1, vec4 Peye2, - bool isFlipped) -{ - return Neye; -} - -vec3 GetQuadGeometryNormal(vec3 Neye, - vec4 Peye0, vec4 Peye1, vec4 Peye2, vec4 Peye3, - bool isFlipped) -{ - return Neye; -} - - - -vec4 DisplacementTerminal(int index, vec4 Peye, vec3 Neye, vec4 patchCoord) -{ - return Peye; -} - - - -vec4 GetPatchCoord(int index) -{ - vec2 uv[3]; - uv[0] = vec2(0, 0); // (0, 0, 1); - uv[1] = vec2(1, 0); // (1, 0, 0); - uv[2] = vec2(0, 1); // (0, 1, 0); - - ivec3 patchParam = GetPatchParam(); - return InterpolatePatchCoordTriangle(uv[index], patchParam); -} - -void emit(int index, vec4 Peye, vec3 Neye) -{ - outData.Peye = Peye; - outData.Neye = Neye; - - gsPatchCoord = GetPatchCoord(index); - - gl_Position = vec4(GetProjectionMatrix() * outData.Peye); - ApplyClipPlanes(outData.Peye); - - ProcessPrimvarsOut(index); - - EmitVertex(); -} - -void main(void) -{ - gl_PrimitiveID = gl_PrimitiveIDIn; - - bool isFlipped = IsFlipped(); // consider handedness AND negative-scale - - vec3 Neye0 = GetNormal(inData[0].Neye, 0); - Neye0 = GetTriGeometryNormal(Neye0, inData[0].Peye, inData[1].Peye, - inData[2].Peye, isFlipped); - vec3 Neye1 = GetNormal(inData[1].Neye, 1); - Neye1 = GetTriGeometryNormal(Neye1, inData[0].Peye, inData[1].Peye, - inData[2].Peye, isFlipped); - vec3 Neye2 = GetNormal(inData[2].Neye, 2); - Neye2 = GetTriGeometryNormal(Neye2, inData[0].Peye, inData[1].Peye, - inData[2].Peye, isFlipped); - - vec4 Peye0 = DisplacementTerminal( - 0, inData[0].Peye, Neye0, GetPatchCoord(0)); - vec4 Peye1 = DisplacementTerminal( - 1, inData[1].Peye, Neye1, GetPatchCoord(1)); - vec4 Peye2 = DisplacementTerminal( - 2, inData[2].Peye, Neye2, GetPatchCoord(2)); - - // triangle 0: vertices (0,1,2) - emit(0, Peye0, Neye0); - emit(1, Peye1, Neye1); - emit(2, Peye2, Neye2); - - EndPrimitive(); -} - - -======================================================= - FRAGMENT SHADER -======================================================= -#version 450 -#extension GL_NV_shader_buffer_load : require -#extension GL_NV_gpu_shader5 : require -#extension GL_ARB_bindless_texture : require -#define REF(space,type) inout type -#define FORWARD_DECL(func_decl) func_decl; -#define ATOMIC_LOAD(a) (a) -#define ATOMIC_STORE(a, v) (a) = (v) -#define ATOMIC_ADD(a, v) atomicAdd(a, v) -#define ATOMIC_EXCHANGE(a, v) atomicExchange(a, v) -#define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) -#define atomic_int int -#define atomic_uint uint - -#define HGI_HAS_DOUBLE_TYPE 1 - - -struct hgi_ivec3 { int x, y, z; }; -struct hgi_vec3 { float x, y, z; }; -struct hgi_dvec3 { double x, y, z; }; -struct hgi_mat3 { float m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; -struct hgi_dmat3 { double m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; - - - -// //////// Global Includes //////// - -// //////// Global Macros //////// - -// //////// Global Structs //////// - -// //////// Global Member Declarations //////// - -// //////// Global Function Definitions //////// - - -// //////// Codegen Defines //////// -#define HD_SHADER_API 2 -#define MAT4 mat4 -// Alias hgi vec and matrix types to hd. -#define hd_ivec3 hgi_ivec3 -#define hd_vec3 hgi_vec3 -#define hd_dvec3 hgi_dvec3 -#define hd_mat3 hgi_mat3 -#define hd_dmat3 hgi_dmat3 - -ivec3 hd_ivec3_get(hd_ivec3 v) { return ivec3(v.x, v.y, v.z); } -ivec3 hd_ivec3_get(ivec3 v) { return v; } -vec3 hd_vec3_get(hd_vec3 v) { return vec3(v.x, v.y, v.z); } -vec3 hd_vec3_get(vec3 v) { return v; } -dvec3 hd_dvec3_get(hd_dvec3 v) { return dvec3(v.x, v.y, v.z); } -dvec3 hd_dvec3_get(dvec3 v) { return v; } -mat3 hd_mat3_get(hd_mat3 v) { return mat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -mat3 hd_mat3_get(mat3 v) { return v; } -dmat3 hd_dmat3_get(hd_dmat3 v) { return dmat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -dmat3 hd_dmat3_get(dmat3 v) { return v; } -hd_ivec3 hd_ivec3_set(hd_ivec3 v) { return v; } -hd_ivec3 hd_ivec3_set(ivec3 v) { return hd_ivec3(v.x, v.y, v.z); } -hd_vec3 hd_vec3_set(hd_vec3 v) { return v; } -hd_vec3 hd_vec3_set(vec3 v) { return hd_vec3(v.x, v.y, v.z); } -hd_dvec3 hd_dvec3_set(hd_dvec3 v) { return v; } -hd_dvec3 hd_dvec3_set(dvec3 v) { return hd_dvec3(v.x, v.y, v.z); } -hd_mat3 hd_mat3_set(hd_mat3 v) { return v; } -hd_mat3 hd_mat3_set(mat3 v) { return hd_mat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -hd_dmat3 hd_dmat3_set(hd_dmat3 v) { return v; } -hd_dmat3 hd_dmat3_set(dmat3 v) { return hd_dmat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -int hd_int_get(int v) { return v; } -int hd_int_get(ivec2 v) { return v.x; } -int hd_int_get(ivec3 v) { return v.x; } -int hd_int_get(ivec4 v) { return v.x; } -vec3 hd_sample_udim(vec2 v) { -vec2 vf = floor(v); -return vec3(v.x - vf.x, v.y - vf.y, clamp(vf.x, 0.0, 10.0) + 10.0 * vf.y); -} -vec4 hd_vec4_2_10_10_10_get(int v) { - ivec4 unpacked = ivec4((v & 0x3ff) << 22, (v & 0xffc00) << 12, - (v & 0x3ff00000) << 2, (v & 0xc0000000)); - return vec4(unpacked) / 2147483647.0; } -int hd_vec4_2_10_10_10_set(vec4 v) { - return ( (int(v.x * 511.0) & 0x3ff) | - ((int(v.y * 511.0) & 0x3ff) << 10) | - ((int(v.z * 511.0) & 0x3ff) << 20) | - ((int(v.w) & 0x1) << 30)); } -vec2 hd_half2_get(uint v) { - return unpackHalf2x16(v); } -uint hd_half2_set(vec2 v) { - return packHalf2x16(v); } -vec4 hd_half4_get(uvec2 v) { - return vec4(unpackHalf2x16(v.x), unpackHalf2x16(v.y)); } -uvec2 hd_half4_set(vec4 v) { - return uvec2(packHalf2x16(v.xy), packHalf2x16(v.zw)); } -#define HD_NUM_PRIMITIVE_VERTS 3 -#define HD_HAS_transform 1 -#define HD_HAS_transformInverse 1 -#define HD_HAS_color 1 -#define HD_HAS_primID 1 -#define HD_HAS_widths 1 -#define HD_HAS_INSTANCE_hydra_instanceTranslations 1 -#define HD_HAS_hydra_instanceTranslations_0 1 -#define HD_INSTANCER_NUM_LEVELS 1 -#define HD_INSTANCE_INDEX_WIDTH 2 -#define HD_HAS_faceVisibility 1 -#define HD_HAS_dispTextureCoord 1 -#define HD_HAS_points 1 -#define HD_HAS_normals 1 - -// //////// Codegen Decl //////// -struct hd_drawingCoord { - int modelCoord; - int constantCoord; - int elementCoord; - int primitiveCoord; - int fvarCoord; - int shaderCoord; - int vertexCoord; - int topologyVisibilityCoord; - int varyingCoord; - int instanceIndex[HD_INSTANCE_INDEX_WIDTH]; - int instanceCoords[HD_INSTANCE_INDEX_WIDTH]; -}; -FORWARD_DECL(hd_drawingCoord GetDrawingCoord()); -FORWARD_DECL(int HgiGetBaseVertex()); -struct hd_instanceIndex { int indices[HD_INSTANCE_INDEX_WIDTH]; }; -struct ConstantData10 { - mat4 transform; - mat4 transformInverse; - vec4 color; - vec4 primID; - float widths; -}; -FORWARD_DECL(int GetElementID()); -FORWARD_DECL(int GetAggregatedElementID()); -FORWARD_DECL(int GetPrimitiveEdgeId()); -FORWARD_DECL(float GetSelectedEdgeOpacity()); -layout(location = 6) uniform int *instanceIndices; -layout(location = 7) uniform int *culledInstanceIndices; -layout(location = 0) uniform ConstantData10 *constantPrimvars; -layout(location = 1) uniform hd_vec3 *hydra_instanceTranslations_0; -layout(location = 2) uniform int *primitiveParam; -layout(location = 3) uniform int *edgeIndices; -layout(location = 4) uniform float *faceVisibility; -in vec4 gsPatchCoord; -in VertexData { - vec4 Peye; - vec3 Neye; -} inData; -layout (location = 0) out vec4 colorOut; -in noperspective vec3 hd_barycentricCoord; -in flat ivec4 gs_interstageDrawingCoord0; -in flat ivec4 gs_interstageDrawingCoord1; -in flat ivec4 gs_interstageDrawingCoord2; -in flat ivec4 gs_interstageDrawingCoord3; -in PrimvarData { - vec3 points; - vec3 normals; - vec2 dispTextureCoord; -} inPrimvars; -layout(location = 5) uniform vec2 *dispTextureCoord; -vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) -{ - // add 0.5 to integer values for more robust interpolation - return vec4(uv.x, uv.y, 0, patchParam.x+0.5f); -} -vec4 InterpolatePatchCoordTriangle(vec2 uv, ivec3 patchParam) -{ - return InterpolatePatchCoord(uv, patchParam); -} - -// //////// Codegen Accessors //////// -mat4 HdGet_transform(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transform); -} -mat4 HdGet_transform() { return HdGet_transform(0); } -mat4 HdGet_transformInverse(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transformInverse); -} -mat4 HdGet_transformInverse() { return HdGet_transformInverse(0); } -vec4 HdGet_color(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].color); -} -vec4 HdGet_color() { return HdGet_color(0); } -float HdGetScalar_color(int localIndex) { return HdGet_color(localIndex).x; } -float HdGetScalar_color() { return HdGet_color(0).x; } -vec4 HdGet_primID(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].primID); -} -vec4 HdGet_primID() { return HdGet_primID(0); } -float HdGetScalar_primID(int localIndex) { return HdGet_primID(localIndex).x; } -float HdGetScalar_primID() { return HdGet_primID(0).x; } -float HdGet_widths(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return float(constantPrimvars[index].widths); -} -float HdGet_widths() { return HdGet_widths(0); } -float HdGetScalar_widths(int localIndex) { return HdGet_widths(localIndex); } -float HdGetScalar_widths() { return HdGet_widths(0); } -vec3 HdGet_hydra_instanceTranslations_0(int localIndex) { - int index = GetDrawingCoord().instanceCoords[0]; - return hd_vec3_get(hydra_instanceTranslations_0[index]); -} -vec3 HdGet_hydra_instanceTranslations_0() { return HdGet_hydra_instanceTranslations_0(0); } -float HdGetScalar_hydra_instanceTranslations_0(int localIndex) { return HdGet_hydra_instanceTranslations_0(localIndex).x; } -float HdGetScalar_hydra_instanceTranslations_0() { return HdGet_hydra_instanceTranslations_0(0).x; } -vec3 HdGetInstance_hydra_instanceTranslations(int level, vec3 defaultValue) { - if (level == 0) return HdGet_hydra_instanceTranslations_0(); - return defaultValue; -} -#if !defined(HD_HAS_hydra_instanceTranslations) -#define HD_HAS_hydra_instanceTranslations 1 -vec3 HdGet_hydra_instanceTranslations(int localIndex) { - return HdGet_hydra_instanceTranslations_0(); -} -vec3 HdGet_hydra_instanceTranslations() { return HdGet_hydra_instanceTranslations(0); } -#endif - -// //////// Codegen FS Source //////// -#define HD_SHADER_SUPPORTS_DOUBLE_PRECISION -#define HD_MINUS_ONE_TO_ONE_DEPTH_RANGE -vec3 GetBarycentricCoord() { - return hd_barycentricCoord; -} -int GetPrimitiveID() { - return gl_PrimitiveID; -} -int GetPrimitiveIndex() { - return GetDrawingCoord().primitiveCoord + GetPrimitiveID(); -} -hd_drawingCoord GetDrawingCoord() { - hd_drawingCoord dc; - dc.modelCoord = gs_interstageDrawingCoord0[0]; - dc.constantCoord = gs_interstageDrawingCoord0[1]; - dc.elementCoord = gs_interstageDrawingCoord0[2]; - dc.primitiveCoord = gs_interstageDrawingCoord0[3]; - dc.fvarCoord = gs_interstageDrawingCoord1[0]; - dc.shaderCoord = gs_interstageDrawingCoord1[1]; - dc.vertexCoord = gs_interstageDrawingCoord1[2]; - dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; - dc.varyingCoord = gs_interstageDrawingCoord2[0]; - dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; - dc.instanceIndex[1] = gs_interstageDrawingCoord2[2]; - dc.instanceCoords[0] = gs_interstageDrawingCoord2[3]; - return dc; -} -int HdGet_primitiveParam(int localIndex) { - int index = GetPrimitiveIndex(); - return int(primitiveParam[index]); -} -int HdGet_primitiveParam() { return HdGet_primitiveParam(0); } -int HdGetScalar_primitiveParam(int localIndex) { return HdGet_primitiveParam(localIndex); } -int HdGetScalar_primitiveParam() { return HdGet_primitiveParam(0); } -#if defined(HD_HAS_coarseFaceIndex) -FORWARD_DECL(int HdGetScalar_coarseFaceIndex()); -#endif -ivec3 GetPatchParam() { -#if defined(HD_HAS_coarseFaceIndex) - return ivec3(HdGetScalar_coarseFaceIndex(), 0, 0); -#else - return ivec3(GetPrimitiveID(), 0, 0); -#endif -} -int GetEdgeFlag() { - return (HdGet_primitiveParam() & 3); -} -int GetFVarIndex(int localIndex) { - int fvarCoord = GetDrawingCoord().fvarCoord; - int ptexIndex = GetPatchParam().x & 0xfffffff; - return fvarCoord + ptexIndex * 3 + localIndex; -} -int GetElementID() { - return (hd_int_get(HdGet_primitiveParam()) >> 2); -} -int GetAggregatedElementID() { - return GetElementID() - + GetDrawingCoord().elementCoord; -} -int HdGet_edgeIndices(int localIndex) { - int index = GetPrimitiveIndex(); - return int(edgeIndices[index]); -} -int HdGet_edgeIndices() { return HdGet_edgeIndices(0); } -int HdGetScalar_edgeIndices(int localIndex) { return HdGet_edgeIndices(localIndex); } -int HdGetScalar_edgeIndices() { return HdGet_edgeIndices(0); } -int GetAuthoredEdgeId(int primitiveEdgeId) { - return primitiveEdgeId; -} -float HdGet_faceVisibility(int localIndex) { - int index = GetAggregatedElementID(); - return float(faceVisibility[index]); -} -float HdGet_faceVisibility() { return HdGet_faceVisibility(0); } -float HdGetScalar_faceVisibility(int localIndex) { return HdGet_faceVisibility(localIndex); } -float HdGetScalar_faceVisibility() { return HdGet_faceVisibility(0); } -vec3 HdGet_points(int localIndex) { return vec3(inPrimvars.points);} -vec3 HdGet_points() { return HdGet_points(0); } -float HdGetScalar_points(int localIndex) { return HdGet_points(localIndex).x; } -float HdGetScalar_points() { return HdGet_points(0).x; } -vec3 HdGet_normals(int localIndex) { return vec3(inPrimvars.normals);} -vec3 HdGet_normals() { return HdGet_normals(0); } -float HdGetScalar_normals(int localIndex) { return HdGet_normals(localIndex).x; } -float HdGetScalar_normals() { return HdGet_normals(0).x; } -vec2 HdGet_dispTextureCoord(int localIndex) { return vec2(inPrimvars.dispTextureCoord);} -vec2 HdGet_dispTextureCoord() { return HdGet_dispTextureCoord(0); } -float HdGetScalar_dispTextureCoord(int localIndex) { return HdGet_dispTextureCoord(localIndex).x; } -float HdGetScalar_dispTextureCoord() { return HdGet_dispTextureCoord(0).x; } -FORWARD_DECL(vec4 GetPatchCoord(int index)); -void ProcessSamplingTransforms(MAT4 instanceModelViewInverse) { -} - -// --------------------------------------------------------------------------- -// global defines -// --------------------------------------------------------------------------- -// codeGen can override this range (currently not). -// quadro 4000's max is 189. -#ifndef HD_GL_POINT_SIZE_MAX -#define HD_GL_POINT_SIZE_MAX 100.0 -#endif -#ifndef HD_GL_POINT_SIZE_MIN -#define HD_GL_POINT_SIZE_MIN .45 -#endif - -// --------------------------------------------------------------------------- -// render pass states -// --------------------------------------------------------------------------- - -MAT4 GetWorldToViewMatrix() { -#if defined(HD_HAS_worldToViewMatrix) - return MAT4(HdGet_worldToViewMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetWorldToViewInverseMatrix() { -#if defined(HD_HAS_worldToViewInverseMatrix) - return MAT4(HdGet_worldToViewInverseMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetProjectionMatrix() { -#if defined(HD_HAS_projectionMatrix) - return MAT4(HdGet_projectionMatrix()); -#else - return MAT4(1); -#endif -} -vec3 GetPositionInWorldSpace(vec3 windowRelativeCoord) -{ -#if defined(HD_HAS_imageToWorldMatrix) - vec4 pImage = vec4(windowRelativeCoord, 1.0); - vec4 pWorld = vec4(HdGet_imageToWorldMatrix() * pImage); - return (pWorld / pWorld.w).xyz; -#else - return windowRelativeCoord; -#endif -} -float GetLightingBlendAmount() { -#if defined(HD_HAS_lightingBlendAmount) - return HdGet_lightingBlendAmount(); -#else - return 1; -#endif -} -vec4 GetViewport() { -#if defined(HD_HAS_viewport) - return HdGet_viewport(); -#else - return vec4(0,0,1,1); -#endif -} -float GetTessLevel() { -#if defined(HD_HAS_tessLevel) - return HdGet_tessLevel(); -#else - return 1; -#endif -} -float GetPointSize() { -#if defined(HD_HAS_pointSize) - return HdGet_pointSize(); -#else - return 3.0; -#endif -} -float GetPointSelectedSize() { -#if defined(HD_HAS_pointSelectedSize) - return HdGet_pointSelectedSize(); -#else - return 5.0; -#endif -} -vec4 GetWireframeColor() { -// Individual prims can specify an alternative wireframe color -// to one specified in the render pass. This is used in cases were -// there is not enough contrast with the normal one. -#if defined(HD_HAS_overrideWireframeColor) - return HdGet_overrideWireframeColor(); -#elif defined(HD_HAS_wireframeColor) - return HdGet_wireframeColor(); -#else - return vec4(0,0,0,0); -#endif -} -vec4 GetMaskColor() { -#if defined(HD_HAS_maskColor) - return HdGet_maskColor(); -#else - return vec4(0.5,0,0,1); -#endif -} -vec4 GetIndicatorColor() { -#if defined(HD_HAS_indicatorColor) - return HdGet_indicatorColor(); -#else - return vec4(0,0.5,0,1); -#endif -} - -bool ShouldDiscardByAlpha(vec4 color) -{ -#if defined(HD_HAS_alphaThreshold) - float alphaThreshold = HdGet_alphaThreshold(); -#else - float alphaThreshold = 0; -#endif - return (color.a < alphaThreshold); -} - -vec2 ApplyAxisAlignedAffineTransform(vec4 t, vec2 pt) -{ - return t.xy * pt + t.zw; -} - - - -vec2 HorizontallyNormalizedFilmbackCoordinates() -{ - const vec4 transform = -#ifdef HD_HAS_imageToHorizontallyNormalizedFilmback - HdGet_imageToHorizontallyNormalizedFilmback(); -#else - vec4(vec2(1.0), vec2(0.0)); -#endif - return ApplyAxisAlignedAffineTransform(transform, gl_FragCoord.xy); -} - - - -vec4 ApplySelectionColor(vec4 color) -{ - return color; -} - - - -// Forward declare selection functionality. -// XXX: Currently, the non-empty implementation of this is in hdx. -FORWARD_DECL(vec4 ApplySelectionColor(vec4 color)); - -// XXX: Make sure to update hdx/shaders/renderPass.glslfx when editing these -// color override methods, since they're currently duplicated. This is because -// we don't have a mixin token for color overrides in a render pass yet. -vec4 ApplyColorOverrides(vec4 color) -{ -#if defined(HD_HAS_overrideColor) - // Mix in override color - vec4 overrideColor = HdGet_overrideColor(); - color.rgb = mix(color.rgb, overrideColor.rgb, overrideColor.a); -#endif - return ApplySelectionColor(color); -} - -vec3 ApplyMaskColor(vec3 color, float weight, vec4 maskColor) -{ - float strength = maskColor.a * clamp(weight, 0.0, 1.0); - return mix(color, maskColor.rgb, strength); -} - -vec4 ApplyColorOverridesPostLighting(vec4 color) -{ - #if defined(HD_HAS_maskWeight) - float maskWeight = HdGet_maskWeight(); - vec4 maskColor = GetMaskColor(); - color.rgb = ApplyMaskColor(color.rgb, maskWeight, maskColor); - #endif - #if defined(HD_HAS_indicatorWeight) - float indicatorWeight = HdGet_indicatorWeight(); - vec4 indicatorColor = GetIndicatorColor(); - color.rgb = ApplyMaskColor(color.rgb, indicatorWeight, indicatorColor); - #endif - return color; -} - - - -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - colorOut = color; -} - - -#ifndef HD_HAS_integrateLights -#define HD_HAS_integrateLights -#endif - -struct LightingContribution { - vec3 diffuse; -}; - -struct LightingInterfaceProperties { - float unused; -}; - -LightingContribution -integrateLightsDefault(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - vec3 n = normalize(Neye); - - LightingContribution result; - result.diffuse = vec3(dot(n, vec3(0,0,1))); - - return result; -} - -LightingContribution -integrateLightsConstant(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - LightingContribution result; - //pefectly diffuse white hemisphere contribution - result.diffuse = vec3(1); - - return result; -} - - - -FORWARD_DECL( - LightingContribution integrateLights(vec4 Peye, vec3 Neye, - LightingInterfaceProperties props)); - -vec3 FallbackLighting(in vec3 Peye, in vec3 Neye, in vec3 color) -{ - LightingInterfaceProperties props; - LightingContribution light = integrateLights(vec4(Peye, 1), Neye, props); - return color * light.diffuse; -} - - -vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - // lighting - color.rgb = FallbackLighting(Peye.xyz, Neye, color.rgb); - return color; -} - - -// quaternion to matrix. xyz = imaginary, w = real -MAT4 GetRotationMatrix(vec4 q) -{ - MAT4 r; - r[0].xyzw = vec4(1 - 2 * (q.y * q.y + q.z * q.z), - 2 * (q.x * q.y + q.z * q.w), - 2 * (q.x * q.z - q.y * q.w), - 0); - r[1].xyzw = vec4( 2 * (q.x * q.y - q.z * q.w), - 1 - 2 * (q.x * q.x + q.z * q.z), - 2 * (q.y * q.z + q.x * q.w), - 0); - r[2].xyzw = vec4( 2 * (q.x * q.z + q.y * q.w), - 2 * (q.y * q.z - q.x * q.w), - 1 - 2 * (q.x * q.x + q.y * q.y), - 0); - r[3] = vec4(0, 0, 0, 1); - return r; -} - -// --------------------------------------------------------------------------- - -MAT4 GetInstanceTransform(int level) -{ - MAT4 m = MAT4(1); -#ifdef HD_HAS_INSTANCE_hydra_instanceTransforms - m = HdGetInstance_hydra_instanceTransforms(level, MAT4(1)) * m; -#elif defined(HD_HAS_INSTANCE_instanceTransform) - m = HdGetInstance_instanceTransform(level, MAT4(1)) * m; -#endif - - // instance transform elements are applied: - // scale then rotate then translate - // i.e. (T * R * S) * position - -#ifdef HD_HAS_INSTANCE_hydra_instanceScales - vec3 s = HdGetInstance_hydra_instanceScales(level, /*default=*/vec3(1)); - m = MAT4(s.x, 0, 0, 0, - 0, s.y, 0, 0, - 0, 0, s.z, 0, - 0, 0, 0, 1) * m; -#elif defined(HD_HAS_INSTANCE_instanceScale) - vec3 s = HdGetInstance_scale(level, /*default=*/vec3(1)); - m = MAT4(s.x, 0, 0, 0, - 0, s.y, 0, 0, - 0, 0, s.z, 0, - 0, 0, 0, 1) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceRotations // GfQuat(ix, iy, iz, real) - vec4 q = HdGetInstance_hydra_instanceRotations(level, /*default=*/vec4(0)); - m = GetRotationMatrix(q) * m; -#elif defined(HD_HAS_INSTANCE_rotate) - vec4 q = HdGetInstance_rotate(level, /*default=*/vec4(0)); - m = GetRotationMatrix(q) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceTranslations - vec3 t = HdGetInstance_hydra_instanceTranslations(level, /*default=*/vec3(0)); - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - t.x, t.y, t.z, 1) * m; -#elif defined(HD_HAS_INSTANCE_translate) - vec3 t = HdGetInstance_translate(level, /*default=*/vec3(0)); - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - t.x, t.y, t.z, 1) * m; -#endif - return m; -} - -MAT4 GetInstanceTransformInverse(int level) -{ - MAT4 m = MAT4(1); - -#ifdef HD_HAS_INSTANCE_hydra_instanceTransforms - m = inverse(HdGetInstance_hydra_instanceTransforms(level, MAT4(1))) * m; -#elif defined(HD_HAS_INSTANCE_instanceTransform) - m = inverse(HdGetInstance_instanceTransform(level, MAT4(1))) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceTranslations - vec3 it = -HdGetInstance_hydra_instanceTranslations(level, /*default=*/vec3(0)); // negate - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - it.x, it.y, it.z, 1) * m; -#elif defined(HD_HAS_INSTANCE_translate) - vec3 it = -HdGetInstance_translate(level, /*default=*/vec3(0)); // negate - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - it.x, it.y, it.z, 1) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceRotations - vec4 q = HdGetInstance_hydra_instanceRotations(level, /*default=*/vec4(0)); - q.xyz = -q.xyz; // inverse rotataion axis - m = GetRotationMatrix(q) * m; -#elif defined(HD_HAS_INSTANCE_rotate) - vec4 q = HdGetInstance_rotate(level, /*default=*/vec4(0)); - q.xyz = -q.xyz; // inverse rotataion axis - m = GetRotationMatrix(q) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceScales - vec3 is = 1.0/HdGetInstance_hydra_instanceScales(level, /*default=*/vec3(1)); // inverse scale - m = MAT4(is.x, 0, 0, 0, - 0, is.y, 0, 0, - 0, 0, is.z, 0, - 0, 0, 0, 1) * m; -#elif defined(HD_HAS_INSTANCE_scale) - vec3 is = 1.0/HdGetInstance_scale(level, /*default=*/vec3(1)); // inverse scale - m = MAT4(is.x, 0, 0, 0, - 0, is.y, 0, 0, - 0, 0, is.z, 0, - 0, 0, 0, 1) * m; -#endif - return m; -} - -// --------------------------------------------------------------------------- - -MAT4 GetInstanceTransform() -{ - MAT4 m = MAT4(1); -#ifdef HD_INSTANCER_NUM_LEVELS - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - m = GetInstanceTransform(i) * m; -#ifdef HD_HAS_instancerTransform - m = HdGet_instancerTransform(i) * m; -#endif - } -#endif - return m; -} - -MAT4 GetInstanceTransformInverse() -{ - MAT4 m = MAT4(1); -#ifdef HD_INSTANCER_NUM_LEVELS - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - m = m * GetInstanceTransformInverse(i); -#ifdef HD_HAS_instancerTransformInverse - m = m * HdGet_instancerTransformInverse(i); -#endif - } -#endif - return m; -} - -// --------------------------------------------------------------------------- - -MAT4 ApplyInstanceTransform(MAT4 m) -{ - return GetInstanceTransform() * m; -} - -MAT4 ApplyInstanceTransformInverse(MAT4 m) -{ - return m * GetInstanceTransformInverse(); -} - -bool IsFlipped() -{ -#if defined(HD_HAS_isFlipped) - bool flip = (HdGet_isFlipped() != 0); -#elif defined(HD_HAS_transform) - // The sign of the determinant indicates whether m flips handedness - bool flip = (determinant(HdGet_transform()) < 0.0); -#else - bool flip = false; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceScales - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - vec3 scale = HdGetInstance_hydra_instanceScales(i, /*default=*/vec3(1)); - flip = flip != ((sign(scale.x) * sign(scale.y) * sign(scale.z)) < 0); - } -#elif defined(HD_HAS_INSTANCE_scale) - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - vec3 scale = HdGetInstance_scale(i, /*default=*/vec3(1)); - flip = flip != ((sign(scale.x) * sign(scale.y) * sign(scale.z)) < 0); - } -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceTransforms - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - MAT4 m = HdGetInstance_hydra_instanceTransforms(i, MAT4(1)); - flip = flip != (determinant(m) < 0.0); - } -#elif defined(HD_HAS_INSTANCE_instanceTransform) - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - MAT4 m = HdGetInstance_instanceTransform(i, MAT4(1)); - flip = flip != (determinant(m) < 0.0); - } -#endif - - return flip; -} - - -vec3 GetNormal(vec3 Neye, int index) -{ - return Neye; -} - -vec3 GetNormal(vec3 Neye, int index, vec2 localST) -{ - return GetNormal(Neye, index); -} - - - -vec3 GetShadingNormal(vec3 N, bool isFlipped) -{ - // the fragment shader takes already-flipped-normals. - // no need to flip here. - return N; -} - - - -void DiscardBasedOnShading(bool frontFacing, bool isFlipped) -{ - // Nothing to do since h/w face culling is used. -} - - - -vec4 ApplyEdgeColor(vec4 Cfill, vec4 patchCoord) -{ - return Cfill; -} - -// Return a large value, signifying that the fragment isn't near an edge. -float GetMinEdgeDistance() -{ - return 1000.0; -} - - - -vec3 GetEdgeParamTriangle() -{ - // Expand barycentric coordinates - vec2 param = GetPatchCoord(0).xy; - vec3 barycentric = vec3(param.x, param.y, 1 - param.x - param.y); - - // Match triangle edge order - return barycentric.yzx; -} - -vec3 GetEdgeDistanceTriangle() -{ - vec3 param = GetEdgeParamTriangle(); - return max(vec3(0.0), param / fwidth(param)); -} - -vec4 GetEdgeParamQuad() -{ - // Expand coordinates to opposite corners of quad - vec2 leftBottom = GetPatchCoord(0).xy; - vec2 rightTop = vec2(1.0) - leftBottom; - - // Match quad edge order - return vec4(leftBottom.y, rightTop.x, rightTop.y, leftBottom.x); -} - -vec4 GetEdgeDistanceQuad() -{ - vec4 param = GetEdgeParamQuad(); - return max(vec4(0.0), param / fwidth(param)); -} - - - -struct ReprStyle -{ - vec4 color; - bool usePrimvarColor; - bool usePrimvarAlpha; - bool applyColorOverride; - bool useSurfaceShaderColor; - bool useSurfaceShaderAlpha; -}; - -struct ScalarOverride -{ - bool enabled; - vec3 color; -}; - -FORWARD_DECL(ReprStyle GetReprStyle()); -FORWARD_DECL(ScalarOverride GetScalarOverride()); -FORWARD_DECL( - vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)); -FORWARD_DECL(vec4 postSurfaceShader(vec4 Peye, vec3 Neye, vec4 color)); - -vec4 ShadingTerminal(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - ReprStyle reprStyle = GetReprStyle(); - - // Apply scalar override. - ScalarOverride scalarOverride = GetScalarOverride(); - if (scalarOverride.enabled) { - vec4 result; - - result.rgb = scalarOverride.color; - result.a = reprStyle.usePrimvarAlpha ? color.a: reprStyle.color.a; - - vec4 colorOverride = ApplyColorOverrides(result); - result = reprStyle.applyColorOverride ? colorOverride : result; - - return result; - } - - // Draw mode can override face color - vec4 reprColor; - - reprColor.rgb = reprStyle.usePrimvarColor ? color.rgb : reprStyle.color.rgb; - reprColor.a = reprStyle.usePrimvarAlpha ? color.a : reprStyle.color.a; - - // Compute color overrides - vec4 colorOverride = ApplyColorOverrides(reprColor); - reprColor = reprStyle.applyColorOverride ? colorOverride : reprColor; - - - // Surface shading can be expensive and also can contain undesirable - // side effects (like discards). So only run it for reprs that require it. - - if (reprStyle.useSurfaceShaderColor || - reprStyle.useSurfaceShaderAlpha) { - vec4 shadingColor; - - shadingColor = surfaceShader(Peye, - Neye, - reprColor, - patchCoord); - -#ifdef HD_HAS_postSurfaceShader - shadingColor = postSurfaceShader(Peye, - Neye, - shadingColor); -#endif - - reprColor.rgb = reprStyle.useSurfaceShaderColor ? - shadingColor.rgb : - reprColor.rgb; - - reprColor.a = reprStyle.useSurfaceShaderAlpha ? - shadingColor.a : - reprColor.a; - } - - vec4 baseColor = color; - baseColor = ApplyColorOverrides(baseColor); - - vec4 litColor = mix(baseColor, - reprColor, - GetLightingBlendAmount()); - - // Final overrides. - - return ApplyColorOverridesPostLighting(litColor); -} - - - -#ifdef HD_HAS_integrateLights -#ifndef HD_HAS_definedIntegrateLights -#define HD_HAS_definedIntegrateLights - -LightingContribution -integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - return integrateLightsDefault(Peye, Neye, props); -} - -#endif // HD_HAS_definedIntegrateLights -#endif - -ReprStyle GetReprStyle() -{ - ReprStyle reprStyle; - - reprStyle.color = vec4(0.0, 0.0, 0.0, 1.0); - reprStyle.usePrimvarColor = true; - reprStyle.usePrimvarAlpha = true; - reprStyle.applyColorOverride = true; - reprStyle.useSurfaceShaderColor = true; - reprStyle.useSurfaceShaderAlpha = true; - - return reprStyle; -} - - - -ScalarOverride GetScalarOverride() -{ - ScalarOverride result; - -#if defined(HD_HAS_scalarOverride) - result.enabled = true; - - // Allow a scalar value to override the color from the surface - // for previewing heatmaps. This is useful for editing workflows. -#if defined(HD_HAS_scalarOverrideColorRamp) - int rampCount = constantPrimvars[GetDrawingCoord().constantCoord]. - scalarOverrideColorRamp.length(); - float scalar = HdGet_scalarOverride() * float(rampCount - 1); - float baseIndex = floor(scalar); - float nextIndex = min(float(rampCount - 1), baseIndex + 1.0); - float interp = scalar - baseIndex; - result.color = mix(HdGet_scalarOverrideColorRamp(int(baseIndex)).rgb, - HdGet_scalarOverrideColorRamp(int(nextIndex)).rgb, - interp); -#else - // If no ramp is given just gamma correct the scalar as greyscale. - result.color = vec3(pow(HdGet_scalarOverride(), 2.2)); -#endif // HD_HAS_scalarOverrideColorRamp - -#else // HD_HAS_scalarOverride - result.enabled = false; - result.color = vec3(0.0, 0.0, 0.0); -#endif - - return result; -} - - - -// Determines whether a fragment is on or close to an unhidden triangle edge. -const float edgePickRadius = 2; // in viewport pixels -const float edgePickParametricRadius = 0.02; // in parametric space - -// For smooth looking edges, use an exponential falloff for the opacity. -// Note: We use a slower falloff fn than in meshWire.glslfx to make the -// selected edges stand out. -float SelectedEdgeFalloff(float d) { - return exp2(-1 * d * d); -} - - - -FORWARD_DECL(vec3 GetEdgeDistanceTriangle()); - -vec3 ComputeBaseFaceEdgeDistanceTriangle() -{ - return GetEdgeDistanceTriangle(); -} - -bool SelectWireframeFaceEdges() -{ - return false; -} - - - -float GetSelectedEdgeOpacity() -{ - float closestEdgeDistance = 0.0; - - // The sequence of comparisons should match GetPrimitiveEdgeId() - vec3 dist = ComputeBaseFaceEdgeDistanceTriangle(); - if (dist.x < edgePickRadius) { - closestEdgeDistance = dist.x; - } else if (dist.y < edgePickRadius) { - closestEdgeDistance = dist.y; - } else if (dist.z < edgePickRadius) { - closestEdgeDistance = dist.z; - } else { - return 0; - } - - return SelectedEdgeFalloff(closestEdgeDistance); -} - -// called from hdx/renderPass.glslfx and selection.glslfx -int GetPrimitiveEdgeId() -{ - // 2 (0,1,0) - // ^ - // e2 / \ e1 - // / \' - // (0,0,1) 0 ----- 1 (1,0,0) - // e0 - - int edgeId = -1; - - vec3 dist = ComputeBaseFaceEdgeDistanceTriangle(); - if (dist.x < edgePickRadius) { - edgeId = 0; - } else if (dist.y < edgePickRadius) { - edgeId = 1; - } else if (dist.z < edgePickRadius) { - edgeId = 2; - } else { - return -1; // Not on a mesh edge - } - - const int edgeFlag = GetEdgeFlag(); - const int meshEdgeIndex = HdGetScalar_edgeIndices(); - - // Translate face-edge to authored mesh-edge - if (edgeFlag == 0) { - edgeId = meshEdgeIndex + edgeId; // regular triangle face. - } else if ((bool(edgeFlag & 1) && edgeId == 2) || - (bool(edgeFlag & 2) && edgeId == 0)) { - edgeId = -1; // Not an authored mesh edge - } else { - edgeId = meshEdgeIndex + edgeId - 1; - } - return edgeId; -} - - - -int GetPointId() -{ - return -1; -} - - -void DiscardBasedOnTopologicalVisibility() -{ - // Nothing to do, since there's no authored opinion. -} - - - -vec4 GetInterpolatedPatchCoord() -{ - return gsPatchCoord; -} - - - -#ifndef HD_HAS_ptexFaceOffset -#define HD_HAS_ptexFaceOffset -int HdGet_ptexFaceOffset() -{ - return 0; -} -#endif - -vec4 GetPatchCoord(int localIndex) -{ - vec4 patchCoord = GetInterpolatedPatchCoord(); - return vec4(patchCoord.xyz, patchCoord.w + HdGet_ptexFaceOffset()); -} - -vec4 GetPatchCoord() -{ - return GetPatchCoord(0); -} - -vec3 ComputeScreenSpacePeye() -{ - return inData.Peye.xyz / inData.Peye.w; -} - -vec3 ComputeScreenSpaceNeye() -{ - vec3 Peye = ComputeScreenSpacePeye(); - vec3 Neye = normalize(cross(dFdx(Peye), dFdy(Peye))); - return (gl_FrontFacing ? Neye : -Neye); -} - -void main(void) -{ - bool isFlipped = IsFlipped(); - - DiscardBasedOnShading(gl_FrontFacing, isFlipped); - - DiscardBasedOnTopologicalVisibility(); - - vec4 color = vec4(0.5, 0.5, 0.5, 1); -#ifdef HD_HAS_displayColor - color.rgb = HdGet_displayColor().rgb; -#endif -#ifdef HD_HAS_displayOpacity - color.a = HdGet_displayOpacity(); -#endif - - vec3 Peye = ComputeScreenSpacePeye(); - - vec3 Neye = inData.Neye; - // Normalize Neye after rasterizer interpolation. - if (length(Neye) > 0.0) { - Neye = normalize(Neye); - } - // Give the shader key a chance to override the normal. - Neye = GetNormal(Neye, 0); - // Orient the normal for shading. - Neye = GetShadingNormal(Neye, isFlipped); - - vec4 patchCoord = GetPatchCoord(); - color = ShadingTerminal(vec4(Peye, 1), Neye, color, patchCoord); - - color = ApplyEdgeColor(color, patchCoord); - -#ifdef HD_MATERIAL_TAG_MASKED - if (ShouldDiscardByAlpha(color)) { - discard; - return; - } -#endif - - RenderOutput(vec4(Peye, 1), Neye, color, patchCoord); -} - -------------------------------------------------------- --- glslfx version 0.1 -#import $TOOLS/hdSt/shaders/mesh.glslfx --- configuration -{"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "PointId.Vertex.None", "Mesh.Vertex"] } -, "geometryShader" : { "source" : ["Instancing.Transform", "MeshNormal.Flat", "MeshNormal.Geometry.NoFlat", "Geometry.NoCustomDisplacement", "Mesh.Geometry.Quad"] } -, "fragmentShader" : { "source" : ["Instancing.Transform", "MeshNormal.Pass", "MeshNormal.Fragment.SingleSided", "MeshFaceCull.Fragment.None", "MeshWire.Fragment.NoEdge", "MeshWire.Fragment.EdgeParam", "Fragment.CommonTerminals", "Fragment.Surface", "Fragment.ScalarOverride", "EdgeId.Fragment.Common", "EdgeId.Fragment.QuadSurface", "EdgeId.Fragment.QuadParam", "PointId.Fragment.Fallback", "Visibility.Fragment.Fallback", "Mesh.Fragment.PatchCoord", "Mesh.Fragment"] } -}}} -------------------------------------------------------- -======================================================= - VERTEX SHADER -======================================================= -#version 450 -#extension GL_NV_shader_buffer_load : require -#extension GL_NV_gpu_shader5 : require -#extension GL_ARB_bindless_texture : require -#extension GL_ARB_shader_draw_parameters : require -int HgiGetBaseVertex() { - return gl_BaseVertexARB; -} -#define REF(space,type) inout type -#define FORWARD_DECL(func_decl) func_decl; -#define ATOMIC_LOAD(a) (a) -#define ATOMIC_STORE(a, v) (a) = (v) -#define ATOMIC_ADD(a, v) atomicAdd(a, v) -#define ATOMIC_EXCHANGE(a, v) atomicExchange(a, v) -#define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) -#define atomic_int int -#define atomic_uint uint - -#define HGI_HAS_DOUBLE_TYPE 1 - - -struct hgi_ivec3 { int x, y, z; }; -struct hgi_vec3 { float x, y, z; }; -struct hgi_dvec3 { double x, y, z; }; -struct hgi_mat3 { float m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; -struct hgi_dmat3 { double m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; - - -// //////// Codegen Defines //////// -#define HD_SHADER_API 2 -#define MAT4 mat4 -// Alias hgi vec and matrix types to hd. -#define hd_ivec3 hgi_ivec3 -#define hd_vec3 hgi_vec3 -#define hd_dvec3 hgi_dvec3 -#define hd_mat3 hgi_mat3 -#define hd_dmat3 hgi_dmat3 - -ivec3 hd_ivec3_get(hd_ivec3 v) { return ivec3(v.x, v.y, v.z); } -ivec3 hd_ivec3_get(ivec3 v) { return v; } -vec3 hd_vec3_get(hd_vec3 v) { return vec3(v.x, v.y, v.z); } -vec3 hd_vec3_get(vec3 v) { return v; } -dvec3 hd_dvec3_get(hd_dvec3 v) { return dvec3(v.x, v.y, v.z); } -dvec3 hd_dvec3_get(dvec3 v) { return v; } -mat3 hd_mat3_get(hd_mat3 v) { return mat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -mat3 hd_mat3_get(mat3 v) { return v; } -dmat3 hd_dmat3_get(hd_dmat3 v) { return dmat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -dmat3 hd_dmat3_get(dmat3 v) { return v; } -hd_ivec3 hd_ivec3_set(hd_ivec3 v) { return v; } -hd_ivec3 hd_ivec3_set(ivec3 v) { return hd_ivec3(v.x, v.y, v.z); } -hd_vec3 hd_vec3_set(hd_vec3 v) { return v; } -hd_vec3 hd_vec3_set(vec3 v) { return hd_vec3(v.x, v.y, v.z); } -hd_dvec3 hd_dvec3_set(hd_dvec3 v) { return v; } -hd_dvec3 hd_dvec3_set(dvec3 v) { return hd_dvec3(v.x, v.y, v.z); } -hd_mat3 hd_mat3_set(hd_mat3 v) { return v; } -hd_mat3 hd_mat3_set(mat3 v) { return hd_mat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -hd_dmat3 hd_dmat3_set(hd_dmat3 v) { return v; } -hd_dmat3 hd_dmat3_set(dmat3 v) { return hd_dmat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -int hd_int_get(int v) { return v; } -int hd_int_get(ivec2 v) { return v.x; } -int hd_int_get(ivec3 v) { return v.x; } -int hd_int_get(ivec4 v) { return v.x; } -vec3 hd_sample_udim(vec2 v) { -vec2 vf = floor(v); -return vec3(v.x - vf.x, v.y - vf.y, clamp(vf.x, 0.0, 10.0) + 10.0 * vf.y); -} -vec4 hd_vec4_2_10_10_10_get(int v) { - ivec4 unpacked = ivec4((v & 0x3ff) << 22, (v & 0xffc00) << 12, - (v & 0x3ff00000) << 2, (v & 0xc0000000)); - return vec4(unpacked) / 2147483647.0; } -int hd_vec4_2_10_10_10_set(vec4 v) { - return ( (int(v.x * 511.0) & 0x3ff) | - ((int(v.y * 511.0) & 0x3ff) << 10) | - ((int(v.z * 511.0) & 0x3ff) << 20) | - ((int(v.w) & 0x1) << 30)); } -vec2 hd_half2_get(uint v) { - return unpackHalf2x16(v); } -uint hd_half2_set(vec2 v) { - return packHalf2x16(v); } -vec4 hd_half4_get(uvec2 v) { - return vec4(unpackHalf2x16(v.x), unpackHalf2x16(v.y)); } -uvec2 hd_half4_set(vec4 v) { - return uvec2(packHalf2x16(v.xy), packHalf2x16(v.zw)); } -#define HD_NUM_PRIMITIVE_VERTS 4 -#define HD_HAS_transform 1 -#define HD_HAS_transformInverse 1 -#define HD_HAS_color 1 -#define HD_HAS_primID 1 -#define HD_HAS_widths 1 -#define HD_HAS_INSTANCE_hydra_instanceTranslations 1 -#define HD_HAS_hydra_instanceTranslations_0 1 -#define HD_INSTANCER_NUM_LEVELS 1 -#define HD_INSTANCE_INDEX_WIDTH 2 -#define HD_HAS_faceVisibility 1 -#define HD_HAS_dispTextureCoord 1 -#define HD_HAS_points 1 -#define HD_HAS_normals 1 - - -// //////// Global Includes //////// - -// //////// Global Macros //////// - -// //////// Global Structs //////// - -// //////// Global Member Declarations //////// -uint hd_VertexID = gl_VertexID; -uint hd_InstanceID = gl_InstanceID; -uint hd_BaseInstance = 0; - -// //////// Global Function Definitions //////// - - -// //////// Codegen Decl //////// -struct hd_drawingCoord { - int modelCoord; - int constantCoord; - int elementCoord; - int primitiveCoord; - int fvarCoord; - int shaderCoord; - int vertexCoord; - int topologyVisibilityCoord; - int varyingCoord; - int instanceIndex[HD_INSTANCE_INDEX_WIDTH]; - int instanceCoords[HD_INSTANCE_INDEX_WIDTH]; -}; -FORWARD_DECL(hd_drawingCoord GetDrawingCoord()); -FORWARD_DECL(int HgiGetBaseVertex()); -struct hd_instanceIndex { int indices[HD_INSTANCE_INDEX_WIDTH]; }; -struct ConstantData10 { - mat4 transform; - mat4 transformInverse; - vec4 color; - vec4 primID; - float widths; -}; -FORWARD_DECL(int GetElementID()); -FORWARD_DECL(int GetAggregatedElementID()); -FORWARD_DECL(int GetPrimitiveEdgeId()); -FORWARD_DECL(float GetSelectedEdgeOpacity()); -out flat ivec4 vs_interstageDrawingCoord0; -out flat ivec4 vs_interstageDrawingCoord1; -out flat ivec4 vs_interstageDrawingCoord2; -out flat ivec4 vs_interstageDrawingCoord3; -layout (location = 2) in ivec4 drawingCoord0; -layout (location = 3) in ivec4 drawingCoord1; -layout (location = 4) in ivec2 drawingCoord2; -layout (location = 5) in int drawingCoordI0; -layout (location = 0) in vec3 points; -layout (location = 1) in vec3 normals; -layout(location = 6) uniform int *instanceIndices; -layout(location = 7) uniform int *culledInstanceIndices; -layout(location = 0) uniform ConstantData10 *constantPrimvars; -layout(location = 1) uniform hd_vec3 *hydra_instanceTranslations_0; -layout(location = 2) uniform int *primitiveParam; -layout(location = 3) uniform ivec2 *edgeIndices; -layout(location = 4) uniform float *faceVisibility; -out VertexData { - vec4 Peye; - vec3 Neye; -} outData; -out PrimvarData { - vec3 points; - vec3 normals; -} outPrimvars; - -// //////// Codegen Accessors //////// -mat4 HdGet_transform(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transform); -} -mat4 HdGet_transform() { return HdGet_transform(0); } -mat4 HdGet_transformInverse(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transformInverse); -} -mat4 HdGet_transformInverse() { return HdGet_transformInverse(0); } -vec4 HdGet_color(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].color); -} -vec4 HdGet_color() { return HdGet_color(0); } -float HdGetScalar_color(int localIndex) { return HdGet_color(localIndex).x; } -float HdGetScalar_color() { return HdGet_color(0).x; } -vec4 HdGet_primID(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].primID); -} -vec4 HdGet_primID() { return HdGet_primID(0); } -float HdGetScalar_primID(int localIndex) { return HdGet_primID(localIndex).x; } -float HdGetScalar_primID() { return HdGet_primID(0).x; } -float HdGet_widths(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return float(constantPrimvars[index].widths); -} -float HdGet_widths() { return HdGet_widths(0); } -float HdGetScalar_widths(int localIndex) { return HdGet_widths(localIndex); } -float HdGetScalar_widths() { return HdGet_widths(0); } -vec3 HdGet_hydra_instanceTranslations_0(int localIndex) { - int index = GetDrawingCoord().instanceCoords[0]; - return hd_vec3_get(hydra_instanceTranslations_0[index]); -} -vec3 HdGet_hydra_instanceTranslations_0() { return HdGet_hydra_instanceTranslations_0(0); } -float HdGetScalar_hydra_instanceTranslations_0(int localIndex) { return HdGet_hydra_instanceTranslations_0(localIndex).x; } -float HdGetScalar_hydra_instanceTranslations_0() { return HdGet_hydra_instanceTranslations_0(0).x; } -vec3 HdGetInstance_hydra_instanceTranslations(int level, vec3 defaultValue) { - if (level == 0) return HdGet_hydra_instanceTranslations_0(); - return defaultValue; -} -#if !defined(HD_HAS_hydra_instanceTranslations) -#define HD_HAS_hydra_instanceTranslations 1 -vec3 HdGet_hydra_instanceTranslations(int localIndex) { - return HdGet_hydra_instanceTranslations_0(); -} -vec3 HdGet_hydra_instanceTranslations() { return HdGet_hydra_instanceTranslations(0); } -#endif - -// //////// Codegen VS Source //////// -#define HD_BINDLESS_BUFFERS_ENABLED -int GetBaseInstanceIndexCoord() { - return drawingCoord1.y; -} -int GetCurrentInstance() { - return int(hd_InstanceID - hd_BaseInstance); -} -int GetInstanceIndexCoord() { - return GetBaseInstanceIndexCoord() + GetCurrentInstance() * HD_INSTANCE_INDEX_WIDTH; -} -int HdGet_culledInstanceIndices(int localIndex) { - int index = GetInstanceIndexCoord()+localIndex + 1; - return int(culledInstanceIndices[index]); -} -int HdGet_culledInstanceIndices() { return HdGet_culledInstanceIndices(0); } -int HdGetScalar_culledInstanceIndices(int localIndex) { return HdGet_culledInstanceIndices(localIndex); } -int HdGetScalar_culledInstanceIndices() { return HdGet_culledInstanceIndices(0); } -int GetBaseVertexOffset() { - return HgiGetBaseVertex(); -} -hd_instanceIndex GetInstanceIndex() { - hd_instanceIndex r; - for (int i = 0; i < HD_INSTANCE_INDEX_WIDTH; ++i) - r.indices[i] = HdGet_culledInstanceIndices(/*localIndex=*/i); - return r; -} -hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = drawingCoord0.x; - dc.constantCoord = drawingCoord0.y; - dc.elementCoord = drawingCoord0.z; - dc.primitiveCoord = drawingCoord0.w; - dc.fvarCoord = drawingCoord1.x; - dc.shaderCoord = drawingCoord1.z; - dc.vertexCoord = drawingCoord1.w; - dc.topologyVisibilityCoord = drawingCoord2.x; - dc.varyingCoord = drawingCoord2.y; - hd_instanceIndex r = GetInstanceIndex(); - dc.instanceIndex[0] = r.indices[0]; - dc.instanceIndex[1] = r.indices[1]; - dc.instanceCoords[0] = drawingCoordI0 + dc.instanceIndex[1]; - return dc; -} -vec3 HdGet_points(int localIndex) { return hd_vec3_get(points);} -vec3 HdGet_points() { return HdGet_points(0); } -float HdGetScalar_points(int localIndex) { return HdGet_points(localIndex).x; } -float HdGetScalar_points() { return HdGet_points(0).x; } -vec3 HdGet_normals(int localIndex) { return hd_vec3_get(normals);} -vec3 HdGet_normals() { return HdGet_normals(0); } -float HdGetScalar_normals(int localIndex) { return HdGet_normals(localIndex).x; } -float HdGetScalar_normals() { return HdGet_normals(0).x; } - -// //////// Codegen Proc VS //////// -void ProcessPrimvarsIn() { - hd_drawingCoord dc = GetDrawingCoord(); - vs_interstageDrawingCoord0[0] = dc.modelCoord; - vs_interstageDrawingCoord0[1] = dc.constantCoord; - vs_interstageDrawingCoord0[2] = dc.elementCoord; - vs_interstageDrawingCoord0[3] = dc.primitiveCoord; - vs_interstageDrawingCoord1[0] = dc.fvarCoord; - vs_interstageDrawingCoord1[1] = dc.shaderCoord; - vs_interstageDrawingCoord1[2] = dc.vertexCoord; - vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; - vs_interstageDrawingCoord2[0] = dc.varyingCoord; - vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; - vs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; - vs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; - outPrimvars.points = points; - outPrimvars.normals = normals; -} - -// --------------------------------------------------------------------------- -// global defines -// --------------------------------------------------------------------------- -// codeGen can override this range (currently not). -// quadro 4000's max is 189. -#ifndef HD_GL_POINT_SIZE_MAX -#define HD_GL_POINT_SIZE_MAX 100.0 -#endif -#ifndef HD_GL_POINT_SIZE_MIN -#define HD_GL_POINT_SIZE_MIN .45 -#endif - -// --------------------------------------------------------------------------- -// render pass states -// --------------------------------------------------------------------------- - -MAT4 GetWorldToViewMatrix() { -#if defined(HD_HAS_worldToViewMatrix) - return MAT4(HdGet_worldToViewMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetWorldToViewInverseMatrix() { -#if defined(HD_HAS_worldToViewInverseMatrix) - return MAT4(HdGet_worldToViewInverseMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetProjectionMatrix() { -#if defined(HD_HAS_projectionMatrix) - return MAT4(HdGet_projectionMatrix()); -#else - return MAT4(1); -#endif -} -vec3 GetPositionInWorldSpace(vec3 windowRelativeCoord) -{ -#if defined(HD_HAS_imageToWorldMatrix) - vec4 pImage = vec4(windowRelativeCoord, 1.0); - vec4 pWorld = vec4(HdGet_imageToWorldMatrix() * pImage); - return (pWorld / pWorld.w).xyz; -#else - return windowRelativeCoord; -#endif -} -float GetLightingBlendAmount() { -#if defined(HD_HAS_lightingBlendAmount) - return HdGet_lightingBlendAmount(); -#else - return 1; -#endif -} -vec4 GetViewport() { -#if defined(HD_HAS_viewport) - return HdGet_viewport(); -#else - return vec4(0,0,1,1); -#endif -} -float GetTessLevel() { -#if defined(HD_HAS_tessLevel) - return HdGet_tessLevel(); -#else - return 1; -#endif -} -float GetPointSize() { -#if defined(HD_HAS_pointSize) - return HdGet_pointSize(); -#else - return 3.0; -#endif -} -float GetPointSelectedSize() { -#if defined(HD_HAS_pointSelectedSize) - return HdGet_pointSelectedSize(); -#else - return 5.0; -#endif -} -vec4 GetWireframeColor() { -// Individual prims can specify an alternative wireframe color -// to one specified in the render pass. This is used in cases were -// there is not enough contrast with the normal one. -#if defined(HD_HAS_overrideWireframeColor) - return HdGet_overrideWireframeColor(); -#elif defined(HD_HAS_wireframeColor) - return HdGet_wireframeColor(); -#else - return vec4(0,0,0,0); -#endif -} -vec4 GetMaskColor() { -#if defined(HD_HAS_maskColor) - return HdGet_maskColor(); -#else - return vec4(0.5,0,0,1); -#endif -} -vec4 GetIndicatorColor() { -#if defined(HD_HAS_indicatorColor) - return HdGet_indicatorColor(); -#else - return vec4(0,0.5,0,1); -#endif -} - -bool ShouldDiscardByAlpha(vec4 color) -{ -#if defined(HD_HAS_alphaThreshold) - float alphaThreshold = HdGet_alphaThreshold(); -#else - float alphaThreshold = 0; -#endif - return (color.a < alphaThreshold); -} - -vec2 ApplyAxisAlignedAffineTransform(vec4 t, vec2 pt) -{ - return t.xy * pt + t.zw; -} - - - -void ApplyClipPlanes(vec4 Peye) -{ -#if defined(HD_HAS_numClipPlanes) -#if defined(HD_HAS_clipPlanes) - for (int i=0; i> 2); -} -int GetAggregatedElementID() { - return GetElementID() - + GetDrawingCoord().elementCoord; -} -ivec2 HdGet_edgeIndices(int localIndex) { - int index = GetPrimitiveIndex(); - return ivec2(edgeIndices[index]); -} -ivec2 HdGet_edgeIndices() { return HdGet_edgeIndices(0); } -int HdGetScalar_edgeIndices(int localIndex) { return HdGet_edgeIndices(localIndex).x; } -int HdGetScalar_edgeIndices() { return HdGet_edgeIndices(0).x; } -int GetAuthoredEdgeId(int primitiveEdgeId) { - return primitiveEdgeId; -} -float HdGet_faceVisibility(int localIndex) { - int index = GetAggregatedElementID(); - return float(faceVisibility[index]); -} -float HdGet_faceVisibility() { return HdGet_faceVisibility(0); } -float HdGetScalar_faceVisibility(int localIndex) { return HdGet_faceVisibility(localIndex); } -float HdGetScalar_faceVisibility() { return HdGet_faceVisibility(0); } -vec3 HdGet_points(int localIndex) { - int index = localIndex; - return vec3(inPrimvars[index].points); -} -vec3 HdGet_points() { return HdGet_points(0); } -float HdGetScalar_points(int localIndex) { return HdGet_points(localIndex).x; } -float HdGetScalar_points() { return HdGet_points(0).x; } -vec3 HdGet_normals(int localIndex) { - int index = localIndex; - return vec3(inPrimvars[index].normals); -} -vec3 HdGet_normals() { return HdGet_normals(0); } -float HdGetScalar_normals(int localIndex) { return HdGet_normals(localIndex).x; } -float HdGetScalar_normals() { return HdGet_normals(0).x; } -vec2 HdGet_dispTextureCoord_Coarse(int localIndex) { - int fvarIndex = GetFVarIndex(localIndex); - return vec2(dispTextureCoord[fvarIndex]); -} -vec2 HdGet_dispTextureCoord(int localIndex, vec2 st) { - return mix(mix(HdGet_dispTextureCoord_Coarse(0),HdGet_dispTextureCoord_Coarse(1), st.x),mix(HdGet_dispTextureCoord_Coarse(3),HdGet_dispTextureCoord_Coarse(2), st.x), st.y); -} -FORWARD_DECL(vec4 GetPatchCoord(int index)); -FORWARD_DECL(vec2 GetPatchCoordLocalST()); -vec2 HdGet_dispTextureCoord(int localIndex) { - vec2 localST = GetPatchCoord(localIndex).xy; - return HdGet_dispTextureCoord(localIndex, localST); -} -vec2 HdGet_dispTextureCoord() { return HdGet_dispTextureCoord(0); } -FORWARD_DECL(vec4 GetPatchCoord(int localIndex)); -void ProcessSamplingTransforms(MAT4 instanceModelViewInverse) { -} - -// //////// Codegen Proc GS //////// -FORWARD_DECL(vec4 GetPatchCoord(int index)); -void ProcessPrimvarsOut(int index) { - vec2 localST = GetPatchCoord(index).xy; - const vec3 coords[4] = vec3[]( - vec3(1,0,0), vec3(0,1,0), vec3(0,0,1), vec3(0,1,0) - ); - hd_barycentricCoord = coords[index]; - hd_drawingCoord dc = GetDrawingCoord(); - gs_interstageDrawingCoord0[0] = dc.modelCoord; - gs_interstageDrawingCoord0[1] = dc.constantCoord; - gs_interstageDrawingCoord0[2] = dc.elementCoord; - gs_interstageDrawingCoord0[3] = dc.primitiveCoord; - gs_interstageDrawingCoord1[0] = dc.fvarCoord; - gs_interstageDrawingCoord1[1] = dc.shaderCoord; - gs_interstageDrawingCoord1[2] = dc.vertexCoord; - gs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; - gs_interstageDrawingCoord2[0] = dc.varyingCoord; - gs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; - gs_interstageDrawingCoord2[2] = dc.instanceIndex[1]; - gs_interstageDrawingCoord2[3] = dc.instanceCoords[0]; - outPrimvars.points = inPrimvars[index].points; - outPrimvars.normals = inPrimvars[index].normals; - outPrimvars.dispTextureCoord = HdGet_dispTextureCoord(index); -} - -// --------------------------------------------------------------------------- -// global defines -// --------------------------------------------------------------------------- -// codeGen can override this range (currently not). -// quadro 4000's max is 189. -#ifndef HD_GL_POINT_SIZE_MAX -#define HD_GL_POINT_SIZE_MAX 100.0 -#endif -#ifndef HD_GL_POINT_SIZE_MIN -#define HD_GL_POINT_SIZE_MIN .45 -#endif - -// --------------------------------------------------------------------------- -// render pass states -// --------------------------------------------------------------------------- - -MAT4 GetWorldToViewMatrix() { -#if defined(HD_HAS_worldToViewMatrix) - return MAT4(HdGet_worldToViewMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetWorldToViewInverseMatrix() { -#if defined(HD_HAS_worldToViewInverseMatrix) - return MAT4(HdGet_worldToViewInverseMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetProjectionMatrix() { -#if defined(HD_HAS_projectionMatrix) - return MAT4(HdGet_projectionMatrix()); -#else - return MAT4(1); -#endif -} -vec3 GetPositionInWorldSpace(vec3 windowRelativeCoord) -{ -#if defined(HD_HAS_imageToWorldMatrix) - vec4 pImage = vec4(windowRelativeCoord, 1.0); - vec4 pWorld = vec4(HdGet_imageToWorldMatrix() * pImage); - return (pWorld / pWorld.w).xyz; -#else - return windowRelativeCoord; -#endif -} -float GetLightingBlendAmount() { -#if defined(HD_HAS_lightingBlendAmount) - return HdGet_lightingBlendAmount(); -#else - return 1; -#endif -} -vec4 GetViewport() { -#if defined(HD_HAS_viewport) - return HdGet_viewport(); -#else - return vec4(0,0,1,1); -#endif -} -float GetTessLevel() { -#if defined(HD_HAS_tessLevel) - return HdGet_tessLevel(); -#else - return 1; -#endif -} -float GetPointSize() { -#if defined(HD_HAS_pointSize) - return HdGet_pointSize(); -#else - return 3.0; -#endif -} -float GetPointSelectedSize() { -#if defined(HD_HAS_pointSelectedSize) - return HdGet_pointSelectedSize(); -#else - return 5.0; -#endif -} -vec4 GetWireframeColor() { -// Individual prims can specify an alternative wireframe color -// to one specified in the render pass. This is used in cases were -// there is not enough contrast with the normal one. -#if defined(HD_HAS_overrideWireframeColor) - return HdGet_overrideWireframeColor(); -#elif defined(HD_HAS_wireframeColor) - return HdGet_wireframeColor(); -#else - return vec4(0,0,0,0); -#endif -} -vec4 GetMaskColor() { -#if defined(HD_HAS_maskColor) - return HdGet_maskColor(); -#else - return vec4(0.5,0,0,1); -#endif -} -vec4 GetIndicatorColor() { -#if defined(HD_HAS_indicatorColor) - return HdGet_indicatorColor(); -#else - return vec4(0,0.5,0,1); -#endif -} - -bool ShouldDiscardByAlpha(vec4 color) -{ -#if defined(HD_HAS_alphaThreshold) - float alphaThreshold = HdGet_alphaThreshold(); -#else - float alphaThreshold = 0; -#endif - return (color.a < alphaThreshold); -} - -vec2 ApplyAxisAlignedAffineTransform(vec4 t, vec2 pt) -{ - return t.xy * pt + t.zw; -} - - - -void ApplyClipPlanes(vec4 Peye) -{ -#if defined(HD_HAS_numClipPlanes) -#if defined(HD_HAS_clipPlanes) - for (int i=0; i 0.0) - normal = normalize(normal); - return normal; -} - -vec3 GetNormal(vec3 Neye, int index, vec2 localST) -{ - return GetNormal(Neye, index); -} - - - -vec3 GetTriGeometryNormal(vec3 Neye, vec4 Peye0, vec4 Peye1, vec4 Peye2, - bool isFlipped) -{ - return Neye; -} - -vec3 GetQuadGeometryNormal(vec3 Neye, - vec4 Peye0, vec4 Peye1, vec4 Peye2, vec4 Peye3, - bool isFlipped) -{ - return Neye; -} - - - -vec4 DisplacementTerminal(int index, vec4 Peye, vec3 Neye, vec4 patchCoord) -{ - return Peye; -} - - - -vec4 GetPatchCoord(int index) -{ - vec2 uv[4]; - uv[0] = vec2(0, 0); - uv[1] = vec2(1, 0); - uv[2] = vec2(1, 1); - uv[3] = vec2(0, 1); - - ivec3 patchParam = GetPatchParam(); - return InterpolatePatchCoord(uv[index], patchParam); -} - -void emit(int index, vec4 Peye, vec3 Neye) -{ - outData.Peye = Peye; - outData.Neye = Neye; - - gsPatchCoord = GetPatchCoord(index); - - gl_Position = vec4(GetProjectionMatrix() * outData.Peye); - ApplyClipPlanes(outData.Peye); - - ProcessPrimvarsOut(index); - - EmitVertex(); -} - -void main(void) -{ - gl_PrimitiveID = gl_PrimitiveIDIn; - - bool isFlipped = IsFlipped(); // consider handedness AND negative-scale - - vec3 Neye0 = GetNormal(inData[0].Neye, 0); - Neye0 = GetQuadGeometryNormal(Neye0, inData[0].Peye, inData[1].Peye, - inData[2].Peye, inData[3].Peye, isFlipped); - vec3 Neye1 = GetNormal(inData[1].Neye, 1); - Neye1 = GetQuadGeometryNormal(Neye1, inData[0].Peye, inData[1].Peye, - inData[2].Peye, inData[3].Peye, isFlipped); - vec3 Neye2 = GetNormal(inData[2].Neye, 2); - Neye2 = GetQuadGeometryNormal(Neye2, inData[0].Peye, inData[1].Peye, - inData[2].Peye, inData[3].Peye, isFlipped); - vec3 Neye3 = GetNormal(inData[3].Neye, 3); - Neye3 = GetQuadGeometryNormal(Neye3, inData[0].Peye, inData[1].Peye, - inData[2].Peye, inData[3].Peye, isFlipped); - - vec4 Peye0 = DisplacementTerminal( - 0, inData[0].Peye, Neye0, GetPatchCoord(0)); - vec4 Peye1 = DisplacementTerminal( - 1, inData[1].Peye, Neye1, GetPatchCoord(1)); - vec4 Peye2 = DisplacementTerminal( - 2, inData[2].Peye, Neye2, GetPatchCoord(2)); - vec4 Peye3 = DisplacementTerminal( - 3, inData[3].Peye, Neye3, GetPatchCoord(3)); - - // Generate triangles (0,1,2) and (2,3,0) - // 3---2 - // | .| - // | . | - // |. | - // 0---1 - // The indices post-quadrangulation/subdivision follow the convention: - // 0 -> original (hull) vertex - // 1,3 -> edge vertices - // 2 -> center vertex - // - // By having index 2 in both the triangles, we ensure the pre-quadrangulated - // face's normal (at the center) is part of the rasterizer interpolation, - // which matters when we use smooth/limit normals. - // In the case of flat normals, we use the vertex positions, so it doesn't - // matter. - - // triangle 0: vertices (0,1,2) - emit(0, Peye0, Neye0); - emit(1, Peye1, Neye1); - emit(2, Peye2, Neye2); - EndPrimitive(); - - // triangle 1: vertices (2,3,0) - gl_PrimitiveID = gl_PrimitiveIDIn; - emit(2, Peye2, Neye2); - emit(3, Peye3, Neye3); - emit(0, Peye0, Neye0); - EndPrimitive(); -} - - -======================================================= - FRAGMENT SHADER -======================================================= -#version 450 -#extension GL_NV_shader_buffer_load : require -#extension GL_NV_gpu_shader5 : require -#extension GL_ARB_bindless_texture : require -#define REF(space,type) inout type -#define FORWARD_DECL(func_decl) func_decl; -#define ATOMIC_LOAD(a) (a) -#define ATOMIC_STORE(a, v) (a) = (v) -#define ATOMIC_ADD(a, v) atomicAdd(a, v) -#define ATOMIC_EXCHANGE(a, v) atomicExchange(a, v) -#define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) -#define atomic_int int -#define atomic_uint uint - -#define HGI_HAS_DOUBLE_TYPE 1 - - -struct hgi_ivec3 { int x, y, z; }; -struct hgi_vec3 { float x, y, z; }; -struct hgi_dvec3 { double x, y, z; }; -struct hgi_mat3 { float m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; -struct hgi_dmat3 { double m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; - - - -// //////// Global Includes //////// - -// //////// Global Macros //////// - -// //////// Global Structs //////// - -// //////// Global Member Declarations //////// - -// //////// Global Function Definitions //////// - - -// //////// Codegen Defines //////// -#define HD_SHADER_API 2 -#define MAT4 mat4 -// Alias hgi vec and matrix types to hd. -#define hd_ivec3 hgi_ivec3 -#define hd_vec3 hgi_vec3 -#define hd_dvec3 hgi_dvec3 -#define hd_mat3 hgi_mat3 -#define hd_dmat3 hgi_dmat3 - -ivec3 hd_ivec3_get(hd_ivec3 v) { return ivec3(v.x, v.y, v.z); } -ivec3 hd_ivec3_get(ivec3 v) { return v; } -vec3 hd_vec3_get(hd_vec3 v) { return vec3(v.x, v.y, v.z); } -vec3 hd_vec3_get(vec3 v) { return v; } -dvec3 hd_dvec3_get(hd_dvec3 v) { return dvec3(v.x, v.y, v.z); } -dvec3 hd_dvec3_get(dvec3 v) { return v; } -mat3 hd_mat3_get(hd_mat3 v) { return mat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -mat3 hd_mat3_get(mat3 v) { return v; } -dmat3 hd_dmat3_get(hd_dmat3 v) { return dmat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -dmat3 hd_dmat3_get(dmat3 v) { return v; } -hd_ivec3 hd_ivec3_set(hd_ivec3 v) { return v; } -hd_ivec3 hd_ivec3_set(ivec3 v) { return hd_ivec3(v.x, v.y, v.z); } -hd_vec3 hd_vec3_set(hd_vec3 v) { return v; } -hd_vec3 hd_vec3_set(vec3 v) { return hd_vec3(v.x, v.y, v.z); } -hd_dvec3 hd_dvec3_set(hd_dvec3 v) { return v; } -hd_dvec3 hd_dvec3_set(dvec3 v) { return hd_dvec3(v.x, v.y, v.z); } -hd_mat3 hd_mat3_set(hd_mat3 v) { return v; } -hd_mat3 hd_mat3_set(mat3 v) { return hd_mat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -hd_dmat3 hd_dmat3_set(hd_dmat3 v) { return v; } -hd_dmat3 hd_dmat3_set(dmat3 v) { return hd_dmat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -int hd_int_get(int v) { return v; } -int hd_int_get(ivec2 v) { return v.x; } -int hd_int_get(ivec3 v) { return v.x; } -int hd_int_get(ivec4 v) { return v.x; } -vec3 hd_sample_udim(vec2 v) { -vec2 vf = floor(v); -return vec3(v.x - vf.x, v.y - vf.y, clamp(vf.x, 0.0, 10.0) + 10.0 * vf.y); -} -vec4 hd_vec4_2_10_10_10_get(int v) { - ivec4 unpacked = ivec4((v & 0x3ff) << 22, (v & 0xffc00) << 12, - (v & 0x3ff00000) << 2, (v & 0xc0000000)); - return vec4(unpacked) / 2147483647.0; } -int hd_vec4_2_10_10_10_set(vec4 v) { - return ( (int(v.x * 511.0) & 0x3ff) | - ((int(v.y * 511.0) & 0x3ff) << 10) | - ((int(v.z * 511.0) & 0x3ff) << 20) | - ((int(v.w) & 0x1) << 30)); } -vec2 hd_half2_get(uint v) { - return unpackHalf2x16(v); } -uint hd_half2_set(vec2 v) { - return packHalf2x16(v); } -vec4 hd_half4_get(uvec2 v) { - return vec4(unpackHalf2x16(v.x), unpackHalf2x16(v.y)); } -uvec2 hd_half4_set(vec4 v) { - return uvec2(packHalf2x16(v.xy), packHalf2x16(v.zw)); } -#define HD_NUM_PRIMITIVE_VERTS 4 -#define HD_HAS_transform 1 -#define HD_HAS_transformInverse 1 -#define HD_HAS_color 1 -#define HD_HAS_primID 1 -#define HD_HAS_widths 1 -#define HD_HAS_INSTANCE_hydra_instanceTranslations 1 -#define HD_HAS_hydra_instanceTranslations_0 1 -#define HD_INSTANCER_NUM_LEVELS 1 -#define HD_INSTANCE_INDEX_WIDTH 2 -#define HD_HAS_faceVisibility 1 -#define HD_HAS_dispTextureCoord 1 -#define HD_HAS_points 1 -#define HD_HAS_normals 1 - -// //////// Codegen Decl //////// -struct hd_drawingCoord { - int modelCoord; - int constantCoord; - int elementCoord; - int primitiveCoord; - int fvarCoord; - int shaderCoord; - int vertexCoord; - int topologyVisibilityCoord; - int varyingCoord; - int instanceIndex[HD_INSTANCE_INDEX_WIDTH]; - int instanceCoords[HD_INSTANCE_INDEX_WIDTH]; -}; -FORWARD_DECL(hd_drawingCoord GetDrawingCoord()); -FORWARD_DECL(int HgiGetBaseVertex()); -struct hd_instanceIndex { int indices[HD_INSTANCE_INDEX_WIDTH]; }; -struct ConstantData10 { - mat4 transform; - mat4 transformInverse; - vec4 color; - vec4 primID; - float widths; -}; -FORWARD_DECL(int GetElementID()); -FORWARD_DECL(int GetAggregatedElementID()); -FORWARD_DECL(int GetPrimitiveEdgeId()); -FORWARD_DECL(float GetSelectedEdgeOpacity()); -layout(location = 6) uniform int *instanceIndices; -layout(location = 7) uniform int *culledInstanceIndices; -layout(location = 0) uniform ConstantData10 *constantPrimvars; -layout(location = 1) uniform hd_vec3 *hydra_instanceTranslations_0; -layout(location = 2) uniform int *primitiveParam; -layout(location = 3) uniform ivec2 *edgeIndices; -layout(location = 4) uniform float *faceVisibility; -in vec4 gsPatchCoord; -in VertexData { - vec4 Peye; - vec3 Neye; -} inData; -layout (location = 0) out vec4 colorOut; -in noperspective vec3 hd_barycentricCoord; -in flat ivec4 gs_interstageDrawingCoord0; -in flat ivec4 gs_interstageDrawingCoord1; -in flat ivec4 gs_interstageDrawingCoord2; -in flat ivec4 gs_interstageDrawingCoord3; -in PrimvarData { - vec3 points; - vec3 normals; - vec2 dispTextureCoord; -} inPrimvars; -layout(location = 5) uniform vec2 *dispTextureCoord; -vec4 InterpolatePatchCoord(vec2 uv, ivec3 patchParam) -{ - // add 0.5 to integer values for more robust interpolation - return vec4(uv.x, uv.y, 0, patchParam.x+0.5f); -} -vec4 InterpolatePatchCoordTriangle(vec2 uv, ivec3 patchParam) -{ - return InterpolatePatchCoord(uv, patchParam); -} - -// //////// Codegen Accessors //////// -mat4 HdGet_transform(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transform); -} -mat4 HdGet_transform() { return HdGet_transform(0); } -mat4 HdGet_transformInverse(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transformInverse); -} -mat4 HdGet_transformInverse() { return HdGet_transformInverse(0); } -vec4 HdGet_color(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].color); -} -vec4 HdGet_color() { return HdGet_color(0); } -float HdGetScalar_color(int localIndex) { return HdGet_color(localIndex).x; } -float HdGetScalar_color() { return HdGet_color(0).x; } -vec4 HdGet_primID(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].primID); -} -vec4 HdGet_primID() { return HdGet_primID(0); } -float HdGetScalar_primID(int localIndex) { return HdGet_primID(localIndex).x; } -float HdGetScalar_primID() { return HdGet_primID(0).x; } -float HdGet_widths(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return float(constantPrimvars[index].widths); -} -float HdGet_widths() { return HdGet_widths(0); } -float HdGetScalar_widths(int localIndex) { return HdGet_widths(localIndex); } -float HdGetScalar_widths() { return HdGet_widths(0); } -vec3 HdGet_hydra_instanceTranslations_0(int localIndex) { - int index = GetDrawingCoord().instanceCoords[0]; - return hd_vec3_get(hydra_instanceTranslations_0[index]); -} -vec3 HdGet_hydra_instanceTranslations_0() { return HdGet_hydra_instanceTranslations_0(0); } -float HdGetScalar_hydra_instanceTranslations_0(int localIndex) { return HdGet_hydra_instanceTranslations_0(localIndex).x; } -float HdGetScalar_hydra_instanceTranslations_0() { return HdGet_hydra_instanceTranslations_0(0).x; } -vec3 HdGetInstance_hydra_instanceTranslations(int level, vec3 defaultValue) { - if (level == 0) return HdGet_hydra_instanceTranslations_0(); - return defaultValue; -} -#if !defined(HD_HAS_hydra_instanceTranslations) -#define HD_HAS_hydra_instanceTranslations 1 -vec3 HdGet_hydra_instanceTranslations(int localIndex) { - return HdGet_hydra_instanceTranslations_0(); -} -vec3 HdGet_hydra_instanceTranslations() { return HdGet_hydra_instanceTranslations(0); } -#endif - -// //////// Codegen FS Source //////// -#define HD_SHADER_SUPPORTS_DOUBLE_PRECISION -#define HD_MINUS_ONE_TO_ONE_DEPTH_RANGE -vec3 GetBarycentricCoord() { - return hd_barycentricCoord; -} -int GetPrimitiveID() { - return gl_PrimitiveID; -} -int GetPrimitiveIndex() { - return GetDrawingCoord().primitiveCoord + GetPrimitiveID(); -} -hd_drawingCoord GetDrawingCoord() { - hd_drawingCoord dc; - dc.modelCoord = gs_interstageDrawingCoord0[0]; - dc.constantCoord = gs_interstageDrawingCoord0[1]; - dc.elementCoord = gs_interstageDrawingCoord0[2]; - dc.primitiveCoord = gs_interstageDrawingCoord0[3]; - dc.fvarCoord = gs_interstageDrawingCoord1[0]; - dc.shaderCoord = gs_interstageDrawingCoord1[1]; - dc.vertexCoord = gs_interstageDrawingCoord1[2]; - dc.topologyVisibilityCoord = gs_interstageDrawingCoord1[3]; - dc.varyingCoord = gs_interstageDrawingCoord2[0]; - dc.instanceIndex[0] = gs_interstageDrawingCoord2[1]; - dc.instanceIndex[1] = gs_interstageDrawingCoord2[2]; - dc.instanceCoords[0] = gs_interstageDrawingCoord2[3]; - return dc; -} -int HdGet_primitiveParam(int localIndex) { - int index = GetPrimitiveIndex(); - return int(primitiveParam[index]); -} -int HdGet_primitiveParam() { return HdGet_primitiveParam(0); } -int HdGetScalar_primitiveParam(int localIndex) { return HdGet_primitiveParam(localIndex); } -int HdGetScalar_primitiveParam() { return HdGet_primitiveParam(0); } -#if defined(HD_HAS_coarseFaceIndex) -FORWARD_DECL(int HdGetScalar_coarseFaceIndex()); -#endif -ivec3 GetPatchParam() { -#if defined(HD_HAS_coarseFaceIndex) - return ivec3(HdGetScalar_coarseFaceIndex(), 0, 0); -#else - return ivec3(GetPrimitiveID(), 0, 0); -#endif -} -int GetEdgeFlag() { - return (HdGet_primitiveParam() & 3); -} -int GetFVarIndex(int localIndex) { - int fvarCoord = GetDrawingCoord().fvarCoord; - int ptexIndex = GetPatchParam().x & 0xfffffff; - return fvarCoord + ptexIndex * 4 + localIndex; -} -int GetElementID() { - return (hd_int_get(HdGet_primitiveParam()) >> 2); -} -int GetAggregatedElementID() { - return GetElementID() - + GetDrawingCoord().elementCoord; -} -ivec2 HdGet_edgeIndices(int localIndex) { - int index = GetPrimitiveIndex(); - return ivec2(edgeIndices[index]); -} -ivec2 HdGet_edgeIndices() { return HdGet_edgeIndices(0); } -int HdGetScalar_edgeIndices(int localIndex) { return HdGet_edgeIndices(localIndex).x; } -int HdGetScalar_edgeIndices() { return HdGet_edgeIndices(0).x; } -int GetAuthoredEdgeId(int primitiveEdgeId) { - return primitiveEdgeId; -} -float HdGet_faceVisibility(int localIndex) { - int index = GetAggregatedElementID(); - return float(faceVisibility[index]); -} -float HdGet_faceVisibility() { return HdGet_faceVisibility(0); } -float HdGetScalar_faceVisibility(int localIndex) { return HdGet_faceVisibility(localIndex); } -float HdGetScalar_faceVisibility() { return HdGet_faceVisibility(0); } -vec3 HdGet_points(int localIndex) { return vec3(inPrimvars.points);} -vec3 HdGet_points() { return HdGet_points(0); } -float HdGetScalar_points(int localIndex) { return HdGet_points(localIndex).x; } -float HdGetScalar_points() { return HdGet_points(0).x; } -vec3 HdGet_normals(int localIndex) { return vec3(inPrimvars.normals);} -vec3 HdGet_normals() { return HdGet_normals(0); } -float HdGetScalar_normals(int localIndex) { return HdGet_normals(localIndex).x; } -float HdGetScalar_normals() { return HdGet_normals(0).x; } -vec2 HdGet_dispTextureCoord(int localIndex) { return vec2(inPrimvars.dispTextureCoord);} -vec2 HdGet_dispTextureCoord() { return HdGet_dispTextureCoord(0); } -float HdGetScalar_dispTextureCoord(int localIndex) { return HdGet_dispTextureCoord(localIndex).x; } -float HdGetScalar_dispTextureCoord() { return HdGet_dispTextureCoord(0).x; } -FORWARD_DECL(vec4 GetPatchCoord(int index)); -void ProcessSamplingTransforms(MAT4 instanceModelViewInverse) { -} - -// --------------------------------------------------------------------------- -// global defines -// --------------------------------------------------------------------------- -// codeGen can override this range (currently not). -// quadro 4000's max is 189. -#ifndef HD_GL_POINT_SIZE_MAX -#define HD_GL_POINT_SIZE_MAX 100.0 -#endif -#ifndef HD_GL_POINT_SIZE_MIN -#define HD_GL_POINT_SIZE_MIN .45 -#endif - -// --------------------------------------------------------------------------- -// render pass states -// --------------------------------------------------------------------------- - -MAT4 GetWorldToViewMatrix() { -#if defined(HD_HAS_worldToViewMatrix) - return MAT4(HdGet_worldToViewMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetWorldToViewInverseMatrix() { -#if defined(HD_HAS_worldToViewInverseMatrix) - return MAT4(HdGet_worldToViewInverseMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetProjectionMatrix() { -#if defined(HD_HAS_projectionMatrix) - return MAT4(HdGet_projectionMatrix()); -#else - return MAT4(1); -#endif -} -vec3 GetPositionInWorldSpace(vec3 windowRelativeCoord) -{ -#if defined(HD_HAS_imageToWorldMatrix) - vec4 pImage = vec4(windowRelativeCoord, 1.0); - vec4 pWorld = vec4(HdGet_imageToWorldMatrix() * pImage); - return (pWorld / pWorld.w).xyz; -#else - return windowRelativeCoord; -#endif -} -float GetLightingBlendAmount() { -#if defined(HD_HAS_lightingBlendAmount) - return HdGet_lightingBlendAmount(); -#else - return 1; -#endif -} -vec4 GetViewport() { -#if defined(HD_HAS_viewport) - return HdGet_viewport(); -#else - return vec4(0,0,1,1); -#endif -} -float GetTessLevel() { -#if defined(HD_HAS_tessLevel) - return HdGet_tessLevel(); -#else - return 1; -#endif -} -float GetPointSize() { -#if defined(HD_HAS_pointSize) - return HdGet_pointSize(); -#else - return 3.0; -#endif -} -float GetPointSelectedSize() { -#if defined(HD_HAS_pointSelectedSize) - return HdGet_pointSelectedSize(); -#else - return 5.0; -#endif -} -vec4 GetWireframeColor() { -// Individual prims can specify an alternative wireframe color -// to one specified in the render pass. This is used in cases were -// there is not enough contrast with the normal one. -#if defined(HD_HAS_overrideWireframeColor) - return HdGet_overrideWireframeColor(); -#elif defined(HD_HAS_wireframeColor) - return HdGet_wireframeColor(); -#else - return vec4(0,0,0,0); -#endif -} -vec4 GetMaskColor() { -#if defined(HD_HAS_maskColor) - return HdGet_maskColor(); -#else - return vec4(0.5,0,0,1); -#endif -} -vec4 GetIndicatorColor() { -#if defined(HD_HAS_indicatorColor) - return HdGet_indicatorColor(); -#else - return vec4(0,0.5,0,1); -#endif -} - -bool ShouldDiscardByAlpha(vec4 color) -{ -#if defined(HD_HAS_alphaThreshold) - float alphaThreshold = HdGet_alphaThreshold(); -#else - float alphaThreshold = 0; -#endif - return (color.a < alphaThreshold); -} - -vec2 ApplyAxisAlignedAffineTransform(vec4 t, vec2 pt) -{ - return t.xy * pt + t.zw; -} - - - -vec2 HorizontallyNormalizedFilmbackCoordinates() -{ - const vec4 transform = -#ifdef HD_HAS_imageToHorizontallyNormalizedFilmback - HdGet_imageToHorizontallyNormalizedFilmback(); -#else - vec4(vec2(1.0), vec2(0.0)); -#endif - return ApplyAxisAlignedAffineTransform(transform, gl_FragCoord.xy); -} - - - -vec4 ApplySelectionColor(vec4 color) -{ - return color; -} - - - -// Forward declare selection functionality. -// XXX: Currently, the non-empty implementation of this is in hdx. -FORWARD_DECL(vec4 ApplySelectionColor(vec4 color)); - -// XXX: Make sure to update hdx/shaders/renderPass.glslfx when editing these -// color override methods, since they're currently duplicated. This is because -// we don't have a mixin token for color overrides in a render pass yet. -vec4 ApplyColorOverrides(vec4 color) -{ -#if defined(HD_HAS_overrideColor) - // Mix in override color - vec4 overrideColor = HdGet_overrideColor(); - color.rgb = mix(color.rgb, overrideColor.rgb, overrideColor.a); -#endif - return ApplySelectionColor(color); -} - -vec3 ApplyMaskColor(vec3 color, float weight, vec4 maskColor) -{ - float strength = maskColor.a * clamp(weight, 0.0, 1.0); - return mix(color, maskColor.rgb, strength); -} - -vec4 ApplyColorOverridesPostLighting(vec4 color) -{ - #if defined(HD_HAS_maskWeight) - float maskWeight = HdGet_maskWeight(); - vec4 maskColor = GetMaskColor(); - color.rgb = ApplyMaskColor(color.rgb, maskWeight, maskColor); - #endif - #if defined(HD_HAS_indicatorWeight) - float indicatorWeight = HdGet_indicatorWeight(); - vec4 indicatorColor = GetIndicatorColor(); - color.rgb = ApplyMaskColor(color.rgb, indicatorWeight, indicatorColor); - #endif - return color; -} - - - -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - colorOut = color; -} - - -#ifndef HD_HAS_integrateLights -#define HD_HAS_integrateLights -#endif - -struct LightingContribution { - vec3 diffuse; -}; - -struct LightingInterfaceProperties { - float unused; -}; - -LightingContribution -integrateLightsDefault(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - vec3 n = normalize(Neye); - - LightingContribution result; - result.diffuse = vec3(dot(n, vec3(0,0,1))); - - return result; -} - -LightingContribution -integrateLightsConstant(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - LightingContribution result; - //pefectly diffuse white hemisphere contribution - result.diffuse = vec3(1); - - return result; -} - - - -FORWARD_DECL( - LightingContribution integrateLights(vec4 Peye, vec3 Neye, - LightingInterfaceProperties props)); - -vec3 FallbackLighting(in vec3 Peye, in vec3 Neye, in vec3 color) -{ - LightingInterfaceProperties props; - LightingContribution light = integrateLights(vec4(Peye, 1), Neye, props); - return color * light.diffuse; -} - - -vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - // lighting - color.rgb = FallbackLighting(Peye.xyz, Neye, color.rgb); - return color; -} - - -// quaternion to matrix. xyz = imaginary, w = real -MAT4 GetRotationMatrix(vec4 q) -{ - MAT4 r; - r[0].xyzw = vec4(1 - 2 * (q.y * q.y + q.z * q.z), - 2 * (q.x * q.y + q.z * q.w), - 2 * (q.x * q.z - q.y * q.w), - 0); - r[1].xyzw = vec4( 2 * (q.x * q.y - q.z * q.w), - 1 - 2 * (q.x * q.x + q.z * q.z), - 2 * (q.y * q.z + q.x * q.w), - 0); - r[2].xyzw = vec4( 2 * (q.x * q.z + q.y * q.w), - 2 * (q.y * q.z - q.x * q.w), - 1 - 2 * (q.x * q.x + q.y * q.y), - 0); - r[3] = vec4(0, 0, 0, 1); - return r; -} - -// --------------------------------------------------------------------------- - -MAT4 GetInstanceTransform(int level) -{ - MAT4 m = MAT4(1); -#ifdef HD_HAS_INSTANCE_hydra_instanceTransforms - m = HdGetInstance_hydra_instanceTransforms(level, MAT4(1)) * m; -#elif defined(HD_HAS_INSTANCE_instanceTransform) - m = HdGetInstance_instanceTransform(level, MAT4(1)) * m; -#endif - - // instance transform elements are applied: - // scale then rotate then translate - // i.e. (T * R * S) * position - -#ifdef HD_HAS_INSTANCE_hydra_instanceScales - vec3 s = HdGetInstance_hydra_instanceScales(level, /*default=*/vec3(1)); - m = MAT4(s.x, 0, 0, 0, - 0, s.y, 0, 0, - 0, 0, s.z, 0, - 0, 0, 0, 1) * m; -#elif defined(HD_HAS_INSTANCE_instanceScale) - vec3 s = HdGetInstance_scale(level, /*default=*/vec3(1)); - m = MAT4(s.x, 0, 0, 0, - 0, s.y, 0, 0, - 0, 0, s.z, 0, - 0, 0, 0, 1) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceRotations // GfQuat(ix, iy, iz, real) - vec4 q = HdGetInstance_hydra_instanceRotations(level, /*default=*/vec4(0)); - m = GetRotationMatrix(q) * m; -#elif defined(HD_HAS_INSTANCE_rotate) - vec4 q = HdGetInstance_rotate(level, /*default=*/vec4(0)); - m = GetRotationMatrix(q) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceTranslations - vec3 t = HdGetInstance_hydra_instanceTranslations(level, /*default=*/vec3(0)); - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - t.x, t.y, t.z, 1) * m; -#elif defined(HD_HAS_INSTANCE_translate) - vec3 t = HdGetInstance_translate(level, /*default=*/vec3(0)); - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - t.x, t.y, t.z, 1) * m; -#endif - return m; -} - -MAT4 GetInstanceTransformInverse(int level) -{ - MAT4 m = MAT4(1); - -#ifdef HD_HAS_INSTANCE_hydra_instanceTransforms - m = inverse(HdGetInstance_hydra_instanceTransforms(level, MAT4(1))) * m; -#elif defined(HD_HAS_INSTANCE_instanceTransform) - m = inverse(HdGetInstance_instanceTransform(level, MAT4(1))) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceTranslations - vec3 it = -HdGetInstance_hydra_instanceTranslations(level, /*default=*/vec3(0)); // negate - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - it.x, it.y, it.z, 1) * m; -#elif defined(HD_HAS_INSTANCE_translate) - vec3 it = -HdGetInstance_translate(level, /*default=*/vec3(0)); // negate - m = MAT4( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - it.x, it.y, it.z, 1) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceRotations - vec4 q = HdGetInstance_hydra_instanceRotations(level, /*default=*/vec4(0)); - q.xyz = -q.xyz; // inverse rotataion axis - m = GetRotationMatrix(q) * m; -#elif defined(HD_HAS_INSTANCE_rotate) - vec4 q = HdGetInstance_rotate(level, /*default=*/vec4(0)); - q.xyz = -q.xyz; // inverse rotataion axis - m = GetRotationMatrix(q) * m; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceScales - vec3 is = 1.0/HdGetInstance_hydra_instanceScales(level, /*default=*/vec3(1)); // inverse scale - m = MAT4(is.x, 0, 0, 0, - 0, is.y, 0, 0, - 0, 0, is.z, 0, - 0, 0, 0, 1) * m; -#elif defined(HD_HAS_INSTANCE_scale) - vec3 is = 1.0/HdGetInstance_scale(level, /*default=*/vec3(1)); // inverse scale - m = MAT4(is.x, 0, 0, 0, - 0, is.y, 0, 0, - 0, 0, is.z, 0, - 0, 0, 0, 1) * m; -#endif - return m; -} - -// --------------------------------------------------------------------------- - -MAT4 GetInstanceTransform() -{ - MAT4 m = MAT4(1); -#ifdef HD_INSTANCER_NUM_LEVELS - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - m = GetInstanceTransform(i) * m; -#ifdef HD_HAS_instancerTransform - m = HdGet_instancerTransform(i) * m; -#endif - } -#endif - return m; -} - -MAT4 GetInstanceTransformInverse() -{ - MAT4 m = MAT4(1); -#ifdef HD_INSTANCER_NUM_LEVELS - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - m = m * GetInstanceTransformInverse(i); -#ifdef HD_HAS_instancerTransformInverse - m = m * HdGet_instancerTransformInverse(i); -#endif - } -#endif - return m; -} - -// --------------------------------------------------------------------------- - -MAT4 ApplyInstanceTransform(MAT4 m) -{ - return GetInstanceTransform() * m; -} - -MAT4 ApplyInstanceTransformInverse(MAT4 m) -{ - return m * GetInstanceTransformInverse(); -} - -bool IsFlipped() -{ -#if defined(HD_HAS_isFlipped) - bool flip = (HdGet_isFlipped() != 0); -#elif defined(HD_HAS_transform) - // The sign of the determinant indicates whether m flips handedness - bool flip = (determinant(HdGet_transform()) < 0.0); -#else - bool flip = false; -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceScales - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - vec3 scale = HdGetInstance_hydra_instanceScales(i, /*default=*/vec3(1)); - flip = flip != ((sign(scale.x) * sign(scale.y) * sign(scale.z)) < 0); - } -#elif defined(HD_HAS_INSTANCE_scale) - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - vec3 scale = HdGetInstance_scale(i, /*default=*/vec3(1)); - flip = flip != ((sign(scale.x) * sign(scale.y) * sign(scale.z)) < 0); - } -#endif - -#ifdef HD_HAS_INSTANCE_hydra_instanceTransforms - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - MAT4 m = HdGetInstance_hydra_instanceTransforms(i, MAT4(1)); - flip = flip != (determinant(m) < 0.0); - } -#elif defined(HD_HAS_INSTANCE_instanceTransform) - for (int i = 0; i < HD_INSTANCER_NUM_LEVELS; ++i) { - MAT4 m = HdGetInstance_instanceTransform(i, MAT4(1)); - flip = flip != (determinant(m) < 0.0); - } -#endif - - return flip; -} - - -vec3 GetNormal(vec3 Neye, int index) -{ - return Neye; -} - -vec3 GetNormal(vec3 Neye, int index, vec2 localST) -{ - return GetNormal(Neye, index); -} - - - -vec3 GetShadingNormal(vec3 N, bool isFlipped) -{ - // the fragment shader takes already-flipped-normals. - // no need to flip here. - return N; -} - - - -void DiscardBasedOnShading(bool frontFacing, bool isFlipped) -{ - // Nothing to do since h/w face culling is used. -} - - - -vec4 ApplyEdgeColor(vec4 Cfill, vec4 patchCoord) -{ - return Cfill; -} - -// Return a large value, signifying that the fragment isn't near an edge. -float GetMinEdgeDistance() -{ - return 1000.0; -} - - - -vec3 GetEdgeParamTriangle() -{ - // Expand barycentric coordinates - vec2 param = GetPatchCoord(0).xy; - vec3 barycentric = vec3(param.x, param.y, 1 - param.x - param.y); - - // Match triangle edge order - return barycentric.yzx; -} - -vec3 GetEdgeDistanceTriangle() -{ - vec3 param = GetEdgeParamTriangle(); - return max(vec3(0.0), param / fwidth(param)); -} - -vec4 GetEdgeParamQuad() -{ - // Expand coordinates to opposite corners of quad - vec2 leftBottom = GetPatchCoord(0).xy; - vec2 rightTop = vec2(1.0) - leftBottom; - - // Match quad edge order - return vec4(leftBottom.y, rightTop.x, rightTop.y, leftBottom.x); -} - -vec4 GetEdgeDistanceQuad() -{ - vec4 param = GetEdgeParamQuad(); - return max(vec4(0.0), param / fwidth(param)); -} - - - -struct ReprStyle -{ - vec4 color; - bool usePrimvarColor; - bool usePrimvarAlpha; - bool applyColorOverride; - bool useSurfaceShaderColor; - bool useSurfaceShaderAlpha; -}; - -struct ScalarOverride -{ - bool enabled; - vec3 color; -}; - -FORWARD_DECL(ReprStyle GetReprStyle()); -FORWARD_DECL(ScalarOverride GetScalarOverride()); -FORWARD_DECL( - vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)); -FORWARD_DECL(vec4 postSurfaceShader(vec4 Peye, vec3 Neye, vec4 color)); - -vec4 ShadingTerminal(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - ReprStyle reprStyle = GetReprStyle(); - - // Apply scalar override. - ScalarOverride scalarOverride = GetScalarOverride(); - if (scalarOverride.enabled) { - vec4 result; - - result.rgb = scalarOverride.color; - result.a = reprStyle.usePrimvarAlpha ? color.a: reprStyle.color.a; - - vec4 colorOverride = ApplyColorOverrides(result); - result = reprStyle.applyColorOverride ? colorOverride : result; - - return result; - } - - // Draw mode can override face color - vec4 reprColor; - - reprColor.rgb = reprStyle.usePrimvarColor ? color.rgb : reprStyle.color.rgb; - reprColor.a = reprStyle.usePrimvarAlpha ? color.a : reprStyle.color.a; - - // Compute color overrides - vec4 colorOverride = ApplyColorOverrides(reprColor); - reprColor = reprStyle.applyColorOverride ? colorOverride : reprColor; - - - // Surface shading can be expensive and also can contain undesirable - // side effects (like discards). So only run it for reprs that require it. - - if (reprStyle.useSurfaceShaderColor || - reprStyle.useSurfaceShaderAlpha) { - vec4 shadingColor; - - shadingColor = surfaceShader(Peye, - Neye, - reprColor, - patchCoord); - -#ifdef HD_HAS_postSurfaceShader - shadingColor = postSurfaceShader(Peye, - Neye, - shadingColor); -#endif - - reprColor.rgb = reprStyle.useSurfaceShaderColor ? - shadingColor.rgb : - reprColor.rgb; - - reprColor.a = reprStyle.useSurfaceShaderAlpha ? - shadingColor.a : - reprColor.a; - } - - vec4 baseColor = color; - baseColor = ApplyColorOverrides(baseColor); - - vec4 litColor = mix(baseColor, - reprColor, - GetLightingBlendAmount()); - - // Final overrides. - - return ApplyColorOverridesPostLighting(litColor); -} - - - -#ifdef HD_HAS_integrateLights -#ifndef HD_HAS_definedIntegrateLights -#define HD_HAS_definedIntegrateLights - -LightingContribution -integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - return integrateLightsDefault(Peye, Neye, props); -} - -#endif // HD_HAS_definedIntegrateLights -#endif - -ReprStyle GetReprStyle() -{ - ReprStyle reprStyle; - - reprStyle.color = vec4(0.0, 0.0, 0.0, 1.0); - reprStyle.usePrimvarColor = true; - reprStyle.usePrimvarAlpha = true; - reprStyle.applyColorOverride = true; - reprStyle.useSurfaceShaderColor = true; - reprStyle.useSurfaceShaderAlpha = true; - - return reprStyle; -} - - - -ScalarOverride GetScalarOverride() -{ - ScalarOverride result; - -#if defined(HD_HAS_scalarOverride) - result.enabled = true; - - // Allow a scalar value to override the color from the surface - // for previewing heatmaps. This is useful for editing workflows. -#if defined(HD_HAS_scalarOverrideColorRamp) - int rampCount = constantPrimvars[GetDrawingCoord().constantCoord]. - scalarOverrideColorRamp.length(); - float scalar = HdGet_scalarOverride() * float(rampCount - 1); - float baseIndex = floor(scalar); - float nextIndex = min(float(rampCount - 1), baseIndex + 1.0); - float interp = scalar - baseIndex; - result.color = mix(HdGet_scalarOverrideColorRamp(int(baseIndex)).rgb, - HdGet_scalarOverrideColorRamp(int(nextIndex)).rgb, - interp); -#else - // If no ramp is given just gamma correct the scalar as greyscale. - result.color = vec3(pow(HdGet_scalarOverride(), 2.2)); -#endif // HD_HAS_scalarOverrideColorRamp - -#else // HD_HAS_scalarOverride - result.enabled = false; - result.color = vec3(0.0, 0.0, 0.0); -#endif - - return result; -} - - - -// Determines whether a fragment is on or close to an unhidden triangle edge. -const float edgePickRadius = 2; // in viewport pixels -const float edgePickParametricRadius = 0.02; // in parametric space - -// For smooth looking edges, use an exponential falloff for the opacity. -// Note: We use a slower falloff fn than in meshWire.glslfx to make the -// selected edges stand out. -float SelectedEdgeFalloff(float d) { - return exp2(-1 * d * d); -} - - - -vec4 ComputeBaseFaceEdgeDistanceQuad() -{ - return GetEdgeDistanceQuad(); -} - -bool SelectWireframeFaceEdges() -{ - return false; -} - - - -float GetSelectedEdgeOpacity() -{ - float closestEdgeDistance = 0.0; - - // The sequence of comparisons should match GetPrimitiveEdgeId() - vec4 dist = ComputeBaseFaceEdgeDistanceQuad(); - if (dist.x < edgePickRadius) { - closestEdgeDistance = dist.x; - } else if (dist.y < edgePickRadius) { - closestEdgeDistance = dist.y; - } else if (dist.z < edgePickRadius) { - closestEdgeDistance = dist.z; - } else if (dist.w < edgePickRadius) { - closestEdgeDistance = dist.w; - } else { - return 0; - } - - return SelectedEdgeFalloff(closestEdgeDistance); -} - -// called from hdx/renderPass.glslfx and selection.glslfx -int GetPrimitiveEdgeId() -{ - // e2 - // (0,1) 3 ------ 2 (1,1) - // | | - // e3 | | e1 - // | | - // (0,0) 0 ------ 1 (1,0) - // e0 - - int edgeId = -1; - - vec4 dist = ComputeBaseFaceEdgeDistanceQuad(); - if (dist.x < edgePickRadius) { - edgeId = 0; - } else if (dist.y < edgePickRadius) { - edgeId = 1; - } else if (dist.z < edgePickRadius) { - edgeId = 2; - } else if (dist.w < edgePickRadius) { - edgeId = 3; - } else { - return -1; // Not on a mesh edge - } - - const int edgeFlag = GetEdgeFlag(); - const ivec2 meshEdgeIndices = HdGet_edgeIndices(); - - // Translate face-edge to authored mesh-edge - if (edgeFlag == 0) { - edgeId = meshEdgeIndices[0] + edgeId; // regular quad face - } else if (edgeId == 0) { - edgeId = meshEdgeIndices[0]; - } else if (edgeId == 3) { - edgeId = meshEdgeIndices[1]; - } else { - edgeId = -1; // Not an authored mesh edge - } - return edgeId; -} - - -int GetPointId() -{ - return -1; -} - - -void DiscardBasedOnTopologicalVisibility() -{ - // Nothing to do, since there's no authored opinion. -} - - - -vec4 GetInterpolatedPatchCoord() -{ - return gsPatchCoord; -} - - - -#ifndef HD_HAS_ptexFaceOffset -#define HD_HAS_ptexFaceOffset -int HdGet_ptexFaceOffset() -{ - return 0; -} -#endif - -vec4 GetPatchCoord(int localIndex) -{ - vec4 patchCoord = GetInterpolatedPatchCoord(); - return vec4(patchCoord.xyz, patchCoord.w + HdGet_ptexFaceOffset()); -} - -vec4 GetPatchCoord() -{ - return GetPatchCoord(0); -} - -vec3 ComputeScreenSpacePeye() -{ - return inData.Peye.xyz / inData.Peye.w; -} - -vec3 ComputeScreenSpaceNeye() -{ - vec3 Peye = ComputeScreenSpacePeye(); - vec3 Neye = normalize(cross(dFdx(Peye), dFdy(Peye))); - return (gl_FrontFacing ? Neye : -Neye); -} - -void main(void) -{ - bool isFlipped = IsFlipped(); - - DiscardBasedOnShading(gl_FrontFacing, isFlipped); - - DiscardBasedOnTopologicalVisibility(); - - vec4 color = vec4(0.5, 0.5, 0.5, 1); -#ifdef HD_HAS_displayColor - color.rgb = HdGet_displayColor().rgb; -#endif -#ifdef HD_HAS_displayOpacity - color.a = HdGet_displayOpacity(); -#endif - - vec3 Peye = ComputeScreenSpacePeye(); - - vec3 Neye = inData.Neye; - // Normalize Neye after rasterizer interpolation. - if (length(Neye) > 0.0) { - Neye = normalize(Neye); - } - // Give the shader key a chance to override the normal. - Neye = GetNormal(Neye, 0); - // Orient the normal for shading. - Neye = GetShadingNormal(Neye, isFlipped); - - vec4 patchCoord = GetPatchCoord(); - color = ShadingTerminal(vec4(Peye, 1), Neye, color, patchCoord); - - color = ApplyEdgeColor(color, patchCoord); - -#ifdef HD_MATERIAL_TAG_MASKED - if (ShouldDiscardByAlpha(color)) { - discard; - return; - } -#endif - - RenderOutput(vec4(Peye, 1), Neye, color, patchCoord); -} - -OK diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_doubleSided.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out similarity index 100% rename from pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_doubleSided.out rename to pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out similarity index 100% rename from pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect.out rename to pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_smoothNormals.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out similarity index 100% rename from pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_bindless_indirect_smoothNormals.out rename to pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_bindless.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_bindless.out deleted file mode 100644 index ebd462d16f..0000000000 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_bindless.out +++ /dev/null @@ -1,1760 +0,0 @@ -------------------------------------------------------- --- glslfx version 0.1 -#import $TOOLS/hdSt/shaders/points.glslfx --- configuration -{"techniques": {"default": { -"vertexShader" : { "source" : ["Instancing.Transform", "Point.Vertex", "PointId.Vertex.PointParam", "Selection.DecodeUtils", "Selection.Vertex.PointSel"] } -, "fragmentShader" : { "source" : ["Fragment.CommonTerminals", "Fragment.Surface", "Fragment.NoScalarOverride", "Point.Fragment", "PointId.Fragment.PointParam"] } -}}} -------------------------------------------------------- -======================================================= - VERTEX SHADER -======================================================= -#version 450 -#extension GL_NV_shader_buffer_load : require -#extension GL_NV_gpu_shader5 : require -#extension GL_ARB_bindless_texture : require -#extension GL_ARB_shader_draw_parameters : require -int HgiGetBaseVertex() { - return gl_BaseVertexARB; -} -#define REF(space,type) inout type -#define FORWARD_DECL(func_decl) func_decl; -#define ATOMIC_LOAD(a) (a) -#define ATOMIC_STORE(a, v) (a) = (v) -#define ATOMIC_ADD(a, v) atomicAdd(a, v) -#define ATOMIC_EXCHANGE(a, v) atomicExchange(a, v) -#define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) -#define atomic_int int -#define atomic_uint uint - -#define HGI_HAS_DOUBLE_TYPE 1 - - -struct hgi_ivec3 { int x, y, z; }; -struct hgi_vec3 { float x, y, z; }; -struct hgi_dvec3 { double x, y, z; }; -struct hgi_mat3 { float m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; -struct hgi_dmat3 { double m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; - - -// //////// Codegen Defines //////// -#define HD_SHADER_API 2 -#define MAT4 mat4 -// Alias hgi vec and matrix types to hd. -#define hd_ivec3 hgi_ivec3 -#define hd_vec3 hgi_vec3 -#define hd_dvec3 hgi_dvec3 -#define hd_mat3 hgi_mat3 -#define hd_dmat3 hgi_dmat3 - -ivec3 hd_ivec3_get(hd_ivec3 v) { return ivec3(v.x, v.y, v.z); } -ivec3 hd_ivec3_get(ivec3 v) { return v; } -vec3 hd_vec3_get(hd_vec3 v) { return vec3(v.x, v.y, v.z); } -vec3 hd_vec3_get(vec3 v) { return v; } -dvec3 hd_dvec3_get(hd_dvec3 v) { return dvec3(v.x, v.y, v.z); } -dvec3 hd_dvec3_get(dvec3 v) { return v; } -mat3 hd_mat3_get(hd_mat3 v) { return mat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -mat3 hd_mat3_get(mat3 v) { return v; } -dmat3 hd_dmat3_get(hd_dmat3 v) { return dmat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -dmat3 hd_dmat3_get(dmat3 v) { return v; } -hd_ivec3 hd_ivec3_set(hd_ivec3 v) { return v; } -hd_ivec3 hd_ivec3_set(ivec3 v) { return hd_ivec3(v.x, v.y, v.z); } -hd_vec3 hd_vec3_set(hd_vec3 v) { return v; } -hd_vec3 hd_vec3_set(vec3 v) { return hd_vec3(v.x, v.y, v.z); } -hd_dvec3 hd_dvec3_set(hd_dvec3 v) { return v; } -hd_dvec3 hd_dvec3_set(dvec3 v) { return hd_dvec3(v.x, v.y, v.z); } -hd_mat3 hd_mat3_set(hd_mat3 v) { return v; } -hd_mat3 hd_mat3_set(mat3 v) { return hd_mat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -hd_dmat3 hd_dmat3_set(hd_dmat3 v) { return v; } -hd_dmat3 hd_dmat3_set(dmat3 v) { return hd_dmat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -int hd_int_get(int v) { return v; } -int hd_int_get(ivec2 v) { return v.x; } -int hd_int_get(ivec3 v) { return v.x; } -int hd_int_get(ivec4 v) { return v.x; } -vec3 hd_sample_udim(vec2 v) { -vec2 vf = floor(v); -return vec3(v.x - vf.x, v.y - vf.y, clamp(vf.x, 0.0, 10.0) + 10.0 * vf.y); -} -vec4 hd_vec4_2_10_10_10_get(int v) { - ivec4 unpacked = ivec4((v & 0x3ff) << 22, (v & 0xffc00) << 12, - (v & 0x3ff00000) << 2, (v & 0xc0000000)); - return vec4(unpacked) / 2147483647.0; } -int hd_vec4_2_10_10_10_set(vec4 v) { - return ( (int(v.x * 511.0) & 0x3ff) | - ((int(v.y * 511.0) & 0x3ff) << 10) | - ((int(v.z * 511.0) & 0x3ff) << 20) | - ((int(v.w) & 0x1) << 30)); } -vec2 hd_half2_get(uint v) { - return unpackHalf2x16(v); } -uint hd_half2_set(vec2 v) { - return packHalf2x16(v); } -vec4 hd_half4_get(uvec2 v) { - return vec4(unpackHalf2x16(v.x), unpackHalf2x16(v.y)); } -uvec2 hd_half4_set(vec4 v) { - return uvec2(packHalf2x16(v.xy), packHalf2x16(v.zw)); } -#define HD_NUM_PRIMITIVE_VERTS 1 -#define HD_HAS_transform 1 -#define HD_HAS_transformInverse 1 -#define HD_HAS_color 1 -#define HD_HAS_primID 1 -#define HD_HAS_widths 1 -#define HD_INSTANCER_NUM_LEVELS 0 -#define HD_INSTANCE_INDEX_WIDTH 1 -#define HD_HAS_points 1 -#define HD_HAS_normals 1 - - -// //////// Global Includes //////// - -// //////// Global Macros //////// - -// //////// Global Structs //////// - -// //////// Global Member Declarations //////// -uint hd_VertexID = gl_VertexID; -uint hd_InstanceID = gl_InstanceID; -uint hd_BaseInstance = 0; - -// //////// Global Function Definitions //////// - - -// //////// Codegen Decl //////// -struct hd_drawingCoord { - int modelCoord; - int constantCoord; - int elementCoord; - int primitiveCoord; - int fvarCoord; - int shaderCoord; - int vertexCoord; - int topologyVisibilityCoord; - int varyingCoord; - int instanceIndex[HD_INSTANCE_INDEX_WIDTH]; - int instanceCoords[HD_INSTANCE_INDEX_WIDTH]; -}; -FORWARD_DECL(hd_drawingCoord GetDrawingCoord()); -FORWARD_DECL(int HgiGetBaseVertex()); -struct hd_instanceIndex { int indices[HD_INSTANCE_INDEX_WIDTH]; }; -struct ConstantData10 { - mat4 transform; - mat4 transformInverse; - vec4 color; - vec4 primID; - float widths; -}; -FORWARD_DECL(int GetElementID()); -FORWARD_DECL(int GetAggregatedElementID()); -FORWARD_DECL(int GetPrimitiveEdgeId()); -FORWARD_DECL(float GetSelectedEdgeOpacity()); -out flat ivec4 vs_interstageDrawingCoord0; -out flat ivec4 vs_interstageDrawingCoord1; -out flat ivec4 vs_interstageDrawingCoord2; -layout (location = 2) in ivec4 drawingCoord0; -layout (location = 3) in ivec4 drawingCoord1; -layout (location = 4) in ivec2 drawingCoord2; -layout (location = 0) in vec3 points; -layout (location = 1) in vec3 normals; -layout(location = 0) uniform ConstantData10 *constantPrimvars; -out VertexData { - vec4 Peye; -} outData; -out flat int vsPointId; -out PrimvarData { - vec3 points; - vec3 normals; -} outPrimvars; - -// //////// Codegen Accessors //////// -mat4 HdGet_transform(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transform); -} -mat4 HdGet_transform() { return HdGet_transform(0); } -mat4 HdGet_transformInverse(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transformInverse); -} -mat4 HdGet_transformInverse() { return HdGet_transformInverse(0); } -vec4 HdGet_color(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].color); -} -vec4 HdGet_color() { return HdGet_color(0); } -float HdGetScalar_color(int localIndex) { return HdGet_color(localIndex).x; } -float HdGetScalar_color() { return HdGet_color(0).x; } -vec4 HdGet_primID(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].primID); -} -vec4 HdGet_primID() { return HdGet_primID(0); } -float HdGetScalar_primID(int localIndex) { return HdGet_primID(localIndex).x; } -float HdGetScalar_primID() { return HdGet_primID(0).x; } -float HdGet_widths(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return float(constantPrimvars[index].widths); -} -float HdGet_widths() { return HdGet_widths(0); } -float HdGetScalar_widths(int localIndex) { return HdGet_widths(localIndex); } -float HdGetScalar_widths() { return HdGet_widths(0); } - -// //////// Codegen VS Source //////// -#define HD_BINDLESS_BUFFERS_ENABLED -int GetBaseVertexOffset() { - return HgiGetBaseVertex(); -} -hd_instanceIndex GetInstanceIndex() { hd_instanceIndex r; r.indices[0] = 0; return r; } -hd_drawingCoord GetDrawingCoord() { hd_drawingCoord dc; - dc.modelCoord = drawingCoord0.x; - dc.constantCoord = drawingCoord0.y; - dc.elementCoord = drawingCoord0.z; - dc.primitiveCoord = drawingCoord0.w; - dc.fvarCoord = drawingCoord1.x; - dc.shaderCoord = drawingCoord1.z; - dc.vertexCoord = drawingCoord1.w; - dc.topologyVisibilityCoord = drawingCoord2.x; - dc.varyingCoord = drawingCoord2.y; - hd_instanceIndex r = GetInstanceIndex(); - dc.instanceIndex[0] = r.indices[0]; - return dc; -} -vec3 HdGet_points(int localIndex) { return hd_vec3_get(points);} -vec3 HdGet_points() { return HdGet_points(0); } -float HdGetScalar_points(int localIndex) { return HdGet_points(localIndex).x; } -float HdGetScalar_points() { return HdGet_points(0).x; } -vec3 HdGet_normals(int localIndex) { return hd_vec3_get(normals);} -vec3 HdGet_normals() { return HdGet_normals(0); } -float HdGetScalar_normals(int localIndex) { return HdGet_normals(localIndex).x; } -float HdGetScalar_normals() { return HdGet_normals(0).x; } - -// //////// Codegen Proc VS //////// -void ProcessPrimvarsIn() { - hd_drawingCoord dc = GetDrawingCoord(); - vs_interstageDrawingCoord0[0] = dc.modelCoord; - vs_interstageDrawingCoord0[1] = dc.constantCoord; - vs_interstageDrawingCoord0[2] = dc.elementCoord; - vs_interstageDrawingCoord0[3] = dc.primitiveCoord; - vs_interstageDrawingCoord1[0] = dc.fvarCoord; - vs_interstageDrawingCoord1[1] = dc.shaderCoord; - vs_interstageDrawingCoord1[2] = dc.vertexCoord; - vs_interstageDrawingCoord1[3] = dc.topologyVisibilityCoord; - vs_interstageDrawingCoord2[0] = dc.varyingCoord; - vs_interstageDrawingCoord2[1] = dc.instanceIndex[0]; - outPrimvars.points = points; - outPrimvars.normals = normals; -} - -// --------------------------------------------------------------------------- -// global defines -// --------------------------------------------------------------------------- -// codeGen can override this range (currently not). -// quadro 4000's max is 189. -#ifndef HD_GL_POINT_SIZE_MAX -#define HD_GL_POINT_SIZE_MAX 100.0 -#endif -#ifndef HD_GL_POINT_SIZE_MIN -#define HD_GL_POINT_SIZE_MIN .45 -#endif - -// --------------------------------------------------------------------------- -// render pass states -// --------------------------------------------------------------------------- - -MAT4 GetWorldToViewMatrix() { -#if defined(HD_HAS_worldToViewMatrix) - return MAT4(HdGet_worldToViewMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetWorldToViewInverseMatrix() { -#if defined(HD_HAS_worldToViewInverseMatrix) - return MAT4(HdGet_worldToViewInverseMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetProjectionMatrix() { -#if defined(HD_HAS_projectionMatrix) - return MAT4(HdGet_projectionMatrix()); -#else - return MAT4(1); -#endif -} -vec3 GetPositionInWorldSpace(vec3 windowRelativeCoord) -{ -#if defined(HD_HAS_imageToWorldMatrix) - vec4 pImage = vec4(windowRelativeCoord, 1.0); - vec4 pWorld = vec4(HdGet_imageToWorldMatrix() * pImage); - return (pWorld / pWorld.w).xyz; -#else - return windowRelativeCoord; -#endif -} -float GetLightingBlendAmount() { -#if defined(HD_HAS_lightingBlendAmount) - return HdGet_lightingBlendAmount(); -#else - return 1; -#endif -} -vec4 GetViewport() { -#if defined(HD_HAS_viewport) - return HdGet_viewport(); -#else - return vec4(0,0,1,1); -#endif -} -float GetTessLevel() { -#if defined(HD_HAS_tessLevel) - return HdGet_tessLevel(); -#else - return 1; -#endif -} -float GetPointSize() { -#if defined(HD_HAS_pointSize) - return HdGet_pointSize(); -#else - return 3.0; -#endif -} -float GetPointSelectedSize() { -#if defined(HD_HAS_pointSelectedSize) - return HdGet_pointSelectedSize(); -#else - return 5.0; -#endif -} -vec4 GetWireframeColor() { -// Individual prims can specify an alternative wireframe color -// to one specified in the render pass. This is used in cases were -// there is not enough contrast with the normal one. -#if defined(HD_HAS_overrideWireframeColor) - return HdGet_overrideWireframeColor(); -#elif defined(HD_HAS_wireframeColor) - return HdGet_wireframeColor(); -#else - return vec4(0,0,0,0); -#endif -} -vec4 GetMaskColor() { -#if defined(HD_HAS_maskColor) - return HdGet_maskColor(); -#else - return vec4(0.5,0,0,1); -#endif -} -vec4 GetIndicatorColor() { -#if defined(HD_HAS_indicatorColor) - return HdGet_indicatorColor(); -#else - return vec4(0,0.5,0,1); -#endif -} - -bool ShouldDiscardByAlpha(vec4 color) -{ -#if defined(HD_HAS_alphaThreshold) - float alphaThreshold = HdGet_alphaThreshold(); -#else - float alphaThreshold = 0; -#endif - return (color.a < alphaThreshold); -} - -vec2 ApplyAxisAlignedAffineTransform(vec4 t, vec2 pt) -{ - return t.xy * pt + t.zw; -} - - - -void ApplyClipPlanes(vec4 Peye) -{ -#if defined(HD_HAS_numClipPlanes) -#if defined(HD_HAS_clipPlanes) - for (int i=0; i> 1; // bits 31:1 -} - -// --------- subprim decoding ---------- -// Each subprims offsets' buffer encoding is: -// [subprim-type][min][max][ selOffsets ] -// <----------3 ----------><--- max - min + 1 --> -struct SubprimHeader { - int type; - int min; - int max; -}; -SubprimHeader DecodeSubprimHeader(int offset) -{ - SubprimHeader header; - header.type = HdGet_hdxSelectionBuffer(offset ); - header.min = HdGet_hdxSelectionBuffer(offset + 1); - header.max = HdGet_hdxSelectionBuffer(offset + 2); - return header; -} - -bool IsSubprimSelected(int id, int min, int max, int headerStart, - REF(thread, int) nextSubprimOffset) -{ - const int SUBPRIM_SELOFFSETS_HEADER_SIZE = 3; - - nextSubprimOffset = 0; // initialize - bool isSelected = false; - - if (id >= min && id < max) { - int netSubprimIndex = - headerStart + SUBPRIM_SELOFFSETS_HEADER_SIZE + id - min; - int selOffset = HdGet_hdxSelectionBuffer(netSubprimIndex); - - DecodeSelOffset(selOffset, /*out*/isSelected, /*out*/nextSubprimOffset); - } else { - // The subprim id does not fall in the selected id range, so the subprim - // in question isn't selected. However, we can still have other - // subprim(s) selected. To get the offset to jump to, we mimic decoding - // the "min" subprim id. - int minSubprimIndex = headerStart + SUBPRIM_SELOFFSETS_HEADER_SIZE; - DecodeSelOffset(HdGet_hdxSelectionBuffer(minSubprimIndex), - /*out*/isSelected, /*out*/nextSubprimOffset); - isSelected = false; - } - - return isSelected; -} -#endif // HD_HAS_hdxSelectionBuffer - -// Keep the result struct definition outside guards. -struct SubprimSelectionResult { - bool elementSelected; - bool elementEdgeSelected; - bool edgeSelected; - bool pointSelected; - int pointColorId; -}; - -SubprimSelectionResult InitSubprimSelectionResult( - bool elementSelected, - bool elementEdgeSelected, - bool edgeSelected, - bool pointSelected, - int pointColorId) -{ - SubprimSelectionResult res; - - res.elementSelected = elementSelected; - res.elementEdgeSelected = elementEdgeSelected; - res.edgeSelected = edgeSelected; - res.pointSelected = pointSelected; - res.pointColorId = pointColorId; - - return res; -} - -bool IsAnySubprimSelected(SubprimSelectionResult s) -{ - return (s.elementSelected || - s.elementEdgeSelected || - s.edgeSelected || - s.pointSelected); -} - -bool HasCustomizedPointColor(SubprimSelectionResult s) -{ - // Use -1 to encode selected points that don't have a custom point color. - return (s.pointColorId != -1); -} - -#if defined(HD_HAS_hdxSelectionBuffer) -// Note: These should match the SubprimType enum in hdx/SelectionTracker.cpp -#define SUBPRIM_TYPE_ELEMENT 0 -#define SUBPRIM_TYPE_ELEMENT_EDGE 1 -#define SUBPRIM_TYPE_EDGE 2 -#define SUBPRIM_TYPE_POINT 3 -#define SUBPRIM_TYPE_INSTANCE 4 - -SubprimSelectionResult GetSubprimSel(int offset, - int elementId, int edgeId, int pointId) -{ - SubprimSelectionResult s = - InitSubprimSelectionResult(false, false, false, false, 0); - - int nextSubprimOffset = 0; - SubprimHeader header = DecodeSubprimHeader(offset); - - if (header.type == SUBPRIM_TYPE_ELEMENT) { - s.elementSelected = - IsSubprimSelected(elementId, header.min, header.max, - offset, /*out*/nextSubprimOffset); - - if (nextSubprimOffset != 0) { - // fragment has additional subprim(s) selected. update header. - header = DecodeSubprimHeader(nextSubprimOffset); - offset = nextSubprimOffset; - } - } - - if (header.type == SUBPRIM_TYPE_ELEMENT_EDGE) { - s.elementEdgeSelected = - IsSubprimSelected(edgeId, header.min, header.max, - offset, /*out*/nextSubprimOffset); - - if (nextSubprimOffset != 0) { - // fragment has additional subprim(s) selected. update header. - header = DecodeSubprimHeader(nextSubprimOffset); - offset = nextSubprimOffset; - } - } - if (header.type == SUBPRIM_TYPE_EDGE) { - s.edgeSelected = - IsSubprimSelected(edgeId, header.min, header.max, - offset, /*out*/nextSubprimOffset); - - if (nextSubprimOffset != 0) { - // fragment has points selected. update header. - header = DecodeSubprimHeader(nextSubprimOffset); - offset = nextSubprimOffset; - } - } - - if (header.type == SUBPRIM_TYPE_POINT) { - s.pointSelected = - IsSubprimSelected(pointId, header.min, header.max, - offset, /*unused*/nextSubprimOffset); - // For points alone, since there isn't any subprim to follow it, the - // offset field is overriden to represent the index into the - // selectedPointColors buffer to support customized coloring of a set of - // selected points. - s.pointColorId = nextSubprimOffset; - } - - return s; -} - -// --------- instance decoding ---------- -bool IsInstanceSelected(int offset, REF(thread, int) nextOffset) -{ - // If we don't find an instance subprim block, pass the same offset to - // GetSubprimSel. - nextOffset = offset; - bool sel = false; - - int instanceId = GetDrawingCoord().instanceIndex[0]; - - SubprimHeader header = DecodeSubprimHeader(offset); - if (header.type == SUBPRIM_TYPE_INSTANCE) { - sel = - IsSubprimSelected(instanceId, header.min, header.max, - offset, /*out*/nextOffset); - } - - return sel; -} -#endif // HD_HAS_hdxSelectionBuffer - -// --------- selection buffer decoding entry point ---------- -struct SelectionResult { - bool primOrInstanceSel; - SubprimSelectionResult subprimSel; -}; - -SelectionResult InitSelectionResult( - bool primOrInstanceSel, - bool elementSelected, - bool elementEdgeSelected, - bool edgeSelected, - bool pointSelected, - int pointColorId) -{ - SelectionResult res; - - res.primOrInstanceSel = primOrInstanceSel; - res.subprimSel = InitSubprimSelectionResult( - elementSelected, - elementEdgeSelected, - edgeSelected, - pointSelected, - pointColorId); - - return res; -} - - -// Decodes the selection buffer encoding scheme for a given mode, and returns -// the selection result. -SelectionResult GetSelectionResult(int mode, - int elementId, int edgeId, int pointId) -{ - SelectionResult res = - InitSelectionResult(false, false, false, false, false, 0); - -#if defined(HD_HAS_hdxSelectionBuffer) - // The hdxSelectionBuffer layout is: - // [#modes] [per-mode offset] [data mode0] ... [data modeM] - // [---------header---------] - // Each mode's data is laid out as: - // [ prims | points | edges | elementEdges | elements | instances ] - // <----------- subprims -------------------> - // <------------------ per prim ------------------------> - // See hdx/SelectionTracker.cpp for details on the encoding scheme. - int modeOffset = GetIndexOffsetForHighlightMode(mode); - if (!HighlightModeHasSelection(modeOffset)) { - // highlight mode has no selected objects (prims/instances/elements) - return res; - } - - const int PRIM_SELOFFSETS_HEADER_SIZE = 2; - const int primId = HdGet_primID(); - int smin = HdGet_hdxSelectionBuffer(modeOffset); - int smax = HdGet_hdxSelectionBuffer(modeOffset + 1); - - if (primId >= smin && primId < smax) { - int offset = modeOffset + PRIM_SELOFFSETS_HEADER_SIZE + primId - smin; - int nextOffset = 0; - bool sel = false; - DecodeSelOffset(HdGet_hdxSelectionBuffer(offset), - /*out*/sel, /*out*/nextOffset); - - // At this point, sel indicates whether the fragment corresponds to - // a prim that needs to be fully highlighted, while a non-zero - // nextOffset indicates whether additional decoding may be done. - - // We don't currently differentiate between prim, instance and - // subprim selection highlighting (i.e., visually, they look the - // same), and thus can skip additional decoding if sel is true. - // We choose not to, for ease of future customization. - if (nextOffset != 0) { - // check if instance (or) subprim(s) are selected - offset = nextOffset; - sel = sel || IsInstanceSelected(offset, /*out*/nextOffset); - - if (nextOffset != 0) { - res.subprimSel = - GetSubprimSel(nextOffset, elementId, edgeId, pointId); - } - } - res.primOrInstanceSel = sel; - } -#endif // HD_HAS_hdxSelectionBuffer - - return res; -} - -// Returns the logical OR of the inputs -SelectionResult -_CombineWithOr(SelectionResult a, SelectionResult b) -{ - SelectionResult res = - InitSelectionResult(false, false, false, false, false, 0); - - res.primOrInstanceSel = a.primOrInstanceSel || b.primOrInstanceSel; - res.subprimSel.elementSelected = a.subprimSel.elementSelected || - b.subprimSel.elementSelected; - res.subprimSel.elementEdgeSelected = a.subprimSel.elementEdgeSelected || - b.subprimSel.elementEdgeSelected; - res.subprimSel.edgeSelected = a.subprimSel.edgeSelected || - b.subprimSel.edgeSelected; - res.subprimSel.pointSelected = a.subprimSel.pointSelected || - b.subprimSel.pointSelected; - // pointColorIndex is ignored. - return res; -} - -// Returns the net selection result aggregating the result of each selection -// mode. -SelectionResult GetNetSelectionResult(int elementId, int edgeId, int pointId) -{ - SelectionResult netResult = - InitSelectionResult(false, false, false, false, false, 0); - -#if defined(HD_HAS_hdxSelectionBuffer) - const int numSelectionModes = GetNumSelectionHighlightModes(); - for (int mode = 0; mode < numSelectionModes; mode++) { - SelectionResult modeResult = - GetSelectionResult(mode, elementId, edgeId, pointId); - netResult = _CombineWithOr(modeResult, netResult); - } -#endif - return netResult; -} - - -// Mixin for use in the vertex shader stage. -// Decodes the selection buffer to find out if the current vertex (point) is -// selected. This is called from hdSt/shaders/pointId.glslfx -bool IsPointSelected(int pointId) -{ - bool sel = false; - #if defined(HD_HAS_hdxSelectionBuffer) - const int numSelectionModes = GetNumSelectionHighlightModes(); - for (int mode = 0; mode < numSelectionModes; mode++) { - // At the VS stage, we don't carry enough state to determine the - // elementId and edgeId. So, use fallback values instead. - SelectionResult res = - GetSelectionResult(mode, /*elementId*/-1, /*edgeId*/-1, pointId); - if (res.subprimSel.pointSelected && - !HasCustomizedPointColor(res.subprimSel)) { - sel = true; - break; - } - } // for each highlight mode - #endif - return sel; -} - - -======================================================= - TESS CONTROL SHADER -======================================================= -======================================================= - TESS EVAL SHADER -======================================================= -======================================================= - GEOMETRY SHADER -======================================================= -======================================================= - FRAGMENT SHADER -======================================================= -#version 450 -#extension GL_NV_shader_buffer_load : require -#extension GL_NV_gpu_shader5 : require -#extension GL_ARB_bindless_texture : require -#define REF(space,type) inout type -#define FORWARD_DECL(func_decl) func_decl; -#define ATOMIC_LOAD(a) (a) -#define ATOMIC_STORE(a, v) (a) = (v) -#define ATOMIC_ADD(a, v) atomicAdd(a, v) -#define ATOMIC_EXCHANGE(a, v) atomicExchange(a, v) -#define ATOMIC_COMP_SWAP(a, expected, desired) atomicCompSwap(a, expected, desired) -#define atomic_int int -#define atomic_uint uint - -#define HGI_HAS_DOUBLE_TYPE 1 - - -struct hgi_ivec3 { int x, y, z; }; -struct hgi_vec3 { float x, y, z; }; -struct hgi_dvec3 { double x, y, z; }; -struct hgi_mat3 { float m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; -struct hgi_dmat3 { double m00, m01, m02, - m10, m11, m12, - m20, m21, m22; }; - - - -// //////// Global Includes //////// - -// //////// Global Macros //////// - -// //////// Global Structs //////// - -// //////// Global Member Declarations //////// - -// //////// Global Function Definitions //////// - - -// //////// Codegen Defines //////// -#define HD_SHADER_API 2 -#define MAT4 mat4 -// Alias hgi vec and matrix types to hd. -#define hd_ivec3 hgi_ivec3 -#define hd_vec3 hgi_vec3 -#define hd_dvec3 hgi_dvec3 -#define hd_mat3 hgi_mat3 -#define hd_dmat3 hgi_dmat3 - -ivec3 hd_ivec3_get(hd_ivec3 v) { return ivec3(v.x, v.y, v.z); } -ivec3 hd_ivec3_get(ivec3 v) { return v; } -vec3 hd_vec3_get(hd_vec3 v) { return vec3(v.x, v.y, v.z); } -vec3 hd_vec3_get(vec3 v) { return v; } -dvec3 hd_dvec3_get(hd_dvec3 v) { return dvec3(v.x, v.y, v.z); } -dvec3 hd_dvec3_get(dvec3 v) { return v; } -mat3 hd_mat3_get(hd_mat3 v) { return mat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -mat3 hd_mat3_get(mat3 v) { return v; } -dmat3 hd_dmat3_get(hd_dmat3 v) { return dmat3(v.m00, v.m01, v.m02, - v.m10, v.m11, v.m12, - v.m20, v.m21, v.m22); } -dmat3 hd_dmat3_get(dmat3 v) { return v; } -hd_ivec3 hd_ivec3_set(hd_ivec3 v) { return v; } -hd_ivec3 hd_ivec3_set(ivec3 v) { return hd_ivec3(v.x, v.y, v.z); } -hd_vec3 hd_vec3_set(hd_vec3 v) { return v; } -hd_vec3 hd_vec3_set(vec3 v) { return hd_vec3(v.x, v.y, v.z); } -hd_dvec3 hd_dvec3_set(hd_dvec3 v) { return v; } -hd_dvec3 hd_dvec3_set(dvec3 v) { return hd_dvec3(v.x, v.y, v.z); } -hd_mat3 hd_mat3_set(hd_mat3 v) { return v; } -hd_mat3 hd_mat3_set(mat3 v) { return hd_mat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -hd_dmat3 hd_dmat3_set(hd_dmat3 v) { return v; } -hd_dmat3 hd_dmat3_set(dmat3 v) { return hd_dmat3(v[0][0], v[0][1], v[0][2], - v[1][0], v[1][1], v[1][2], - v[2][0], v[2][1], v[2][2]); } -int hd_int_get(int v) { return v; } -int hd_int_get(ivec2 v) { return v.x; } -int hd_int_get(ivec3 v) { return v.x; } -int hd_int_get(ivec4 v) { return v.x; } -vec3 hd_sample_udim(vec2 v) { -vec2 vf = floor(v); -return vec3(v.x - vf.x, v.y - vf.y, clamp(vf.x, 0.0, 10.0) + 10.0 * vf.y); -} -vec4 hd_vec4_2_10_10_10_get(int v) { - ivec4 unpacked = ivec4((v & 0x3ff) << 22, (v & 0xffc00) << 12, - (v & 0x3ff00000) << 2, (v & 0xc0000000)); - return vec4(unpacked) / 2147483647.0; } -int hd_vec4_2_10_10_10_set(vec4 v) { - return ( (int(v.x * 511.0) & 0x3ff) | - ((int(v.y * 511.0) & 0x3ff) << 10) | - ((int(v.z * 511.0) & 0x3ff) << 20) | - ((int(v.w) & 0x1) << 30)); } -vec2 hd_half2_get(uint v) { - return unpackHalf2x16(v); } -uint hd_half2_set(vec2 v) { - return packHalf2x16(v); } -vec4 hd_half4_get(uvec2 v) { - return vec4(unpackHalf2x16(v.x), unpackHalf2x16(v.y)); } -uvec2 hd_half4_set(vec4 v) { - return uvec2(packHalf2x16(v.xy), packHalf2x16(v.zw)); } -#define HD_NUM_PRIMITIVE_VERTS 1 -#define HD_HAS_transform 1 -#define HD_HAS_transformInverse 1 -#define HD_HAS_color 1 -#define HD_HAS_primID 1 -#define HD_HAS_widths 1 -#define HD_INSTANCER_NUM_LEVELS 0 -#define HD_INSTANCE_INDEX_WIDTH 1 -#define HD_HAS_points 1 -#define HD_HAS_normals 1 - -// //////// Codegen Decl //////// -struct hd_drawingCoord { - int modelCoord; - int constantCoord; - int elementCoord; - int primitiveCoord; - int fvarCoord; - int shaderCoord; - int vertexCoord; - int topologyVisibilityCoord; - int varyingCoord; - int instanceIndex[HD_INSTANCE_INDEX_WIDTH]; - int instanceCoords[HD_INSTANCE_INDEX_WIDTH]; -}; -FORWARD_DECL(hd_drawingCoord GetDrawingCoord()); -FORWARD_DECL(int HgiGetBaseVertex()); -struct hd_instanceIndex { int indices[HD_INSTANCE_INDEX_WIDTH]; }; -struct ConstantData10 { - mat4 transform; - mat4 transformInverse; - vec4 color; - vec4 primID; - float widths; -}; -FORWARD_DECL(int GetElementID()); -FORWARD_DECL(int GetAggregatedElementID()); -FORWARD_DECL(int GetPrimitiveEdgeId()); -FORWARD_DECL(float GetSelectedEdgeOpacity()); -layout(location = 0) uniform ConstantData10 *constantPrimvars; -in VertexData { - vec4 Peye; -} inData; -in flat int vsPointId; -layout (location = 0) out vec4 colorOut; -in flat ivec4 vs_interstageDrawingCoord0; -in flat ivec4 vs_interstageDrawingCoord1; -in flat ivec4 vs_interstageDrawingCoord2; -in PrimvarData { - vec3 points; - vec3 normals; -} inPrimvars; - -// //////// Codegen Accessors //////// -mat4 HdGet_transform(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transform); -} -mat4 HdGet_transform() { return HdGet_transform(0); } -mat4 HdGet_transformInverse(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return mat4(constantPrimvars[index].transformInverse); -} -mat4 HdGet_transformInverse() { return HdGet_transformInverse(0); } -vec4 HdGet_color(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].color); -} -vec4 HdGet_color() { return HdGet_color(0); } -float HdGetScalar_color(int localIndex) { return HdGet_color(localIndex).x; } -float HdGetScalar_color() { return HdGet_color(0).x; } -vec4 HdGet_primID(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return vec4(constantPrimvars[index].primID); -} -vec4 HdGet_primID() { return HdGet_primID(0); } -float HdGetScalar_primID(int localIndex) { return HdGet_primID(localIndex).x; } -float HdGetScalar_primID() { return HdGet_primID(0).x; } -float HdGet_widths(int localIndex) { - int index = GetDrawingCoord().constantCoord; - return float(constantPrimvars[index].widths); -} -float HdGet_widths() { return HdGet_widths(0); } -float HdGetScalar_widths(int localIndex) { return HdGet_widths(localIndex); } -float HdGetScalar_widths() { return HdGet_widths(0); } - -// //////// Codegen FS Source //////// -#define HD_SHADER_SUPPORTS_DOUBLE_PRECISION -#define HD_MINUS_ONE_TO_ONE_DEPTH_RANGE -vec3 GetBarycentricCoord() { - return vec3(0); -} -int GetPrimitiveID() { - return gl_PrimitiveID; -} -int GetPrimitiveIndex() { - return GetDrawingCoord().primitiveCoord + GetPrimitiveID(); -} -hd_drawingCoord GetDrawingCoord() { - hd_drawingCoord dc; - dc.modelCoord = vs_interstageDrawingCoord0[0]; - dc.constantCoord = vs_interstageDrawingCoord0[1]; - dc.elementCoord = vs_interstageDrawingCoord0[2]; - dc.primitiveCoord = vs_interstageDrawingCoord0[3]; - dc.fvarCoord = vs_interstageDrawingCoord1[0]; - dc.shaderCoord = vs_interstageDrawingCoord1[1]; - dc.vertexCoord = vs_interstageDrawingCoord1[2]; - dc.topologyVisibilityCoord = vs_interstageDrawingCoord1[3]; - dc.varyingCoord = vs_interstageDrawingCoord2[0]; - dc.instanceIndex[0] = vs_interstageDrawingCoord2[1]; - return dc; -} -int GetElementID() { - return -1; -} -int GetAggregatedElementID() { - return GetElementID(); -} -int GetEdgeFlag() { - return 0; -} -ivec3 GetPatchParam() { - return ivec3(0, 0, 0); -} -int GetFVarIndex(int localIndex) { - return 0; -} -int GetAuthoredEdgeId(int primitiveEdgeId) { - return -1; -} -int GetPrimitiveEdgeId() { - return -1; -} -float GetSelectedEdgeOpacity() { - return 0.0; -} -bool SelectWireframeFaceEdges() { - return false; -} -vec3 HdGet_points(int localIndex) { return vec3(inPrimvars.points);} -vec3 HdGet_points() { return HdGet_points(0); } -float HdGetScalar_points(int localIndex) { return HdGet_points(localIndex).x; } -float HdGetScalar_points() { return HdGet_points(0).x; } -vec3 HdGet_normals(int localIndex) { return vec3(inPrimvars.normals);} -vec3 HdGet_normals() { return HdGet_normals(0); } -float HdGetScalar_normals(int localIndex) { return HdGet_normals(localIndex).x; } -float HdGetScalar_normals() { return HdGet_normals(0).x; } -FORWARD_DECL(vec4 GetPatchCoord(int index)); -void ProcessSamplingTransforms(MAT4 instanceModelViewInverse) { -} - -// --------------------------------------------------------------------------- -// global defines -// --------------------------------------------------------------------------- -// codeGen can override this range (currently not). -// quadro 4000's max is 189. -#ifndef HD_GL_POINT_SIZE_MAX -#define HD_GL_POINT_SIZE_MAX 100.0 -#endif -#ifndef HD_GL_POINT_SIZE_MIN -#define HD_GL_POINT_SIZE_MIN .45 -#endif - -// --------------------------------------------------------------------------- -// render pass states -// --------------------------------------------------------------------------- - -MAT4 GetWorldToViewMatrix() { -#if defined(HD_HAS_worldToViewMatrix) - return MAT4(HdGet_worldToViewMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetWorldToViewInverseMatrix() { -#if defined(HD_HAS_worldToViewInverseMatrix) - return MAT4(HdGet_worldToViewInverseMatrix()); -#else - return MAT4(1); -#endif -} -MAT4 GetProjectionMatrix() { -#if defined(HD_HAS_projectionMatrix) - return MAT4(HdGet_projectionMatrix()); -#else - return MAT4(1); -#endif -} -vec3 GetPositionInWorldSpace(vec3 windowRelativeCoord) -{ -#if defined(HD_HAS_imageToWorldMatrix) - vec4 pImage = vec4(windowRelativeCoord, 1.0); - vec4 pWorld = vec4(HdGet_imageToWorldMatrix() * pImage); - return (pWorld / pWorld.w).xyz; -#else - return windowRelativeCoord; -#endif -} -float GetLightingBlendAmount() { -#if defined(HD_HAS_lightingBlendAmount) - return HdGet_lightingBlendAmount(); -#else - return 1; -#endif -} -vec4 GetViewport() { -#if defined(HD_HAS_viewport) - return HdGet_viewport(); -#else - return vec4(0,0,1,1); -#endif -} -float GetTessLevel() { -#if defined(HD_HAS_tessLevel) - return HdGet_tessLevel(); -#else - return 1; -#endif -} -float GetPointSize() { -#if defined(HD_HAS_pointSize) - return HdGet_pointSize(); -#else - return 3.0; -#endif -} -float GetPointSelectedSize() { -#if defined(HD_HAS_pointSelectedSize) - return HdGet_pointSelectedSize(); -#else - return 5.0; -#endif -} -vec4 GetWireframeColor() { -// Individual prims can specify an alternative wireframe color -// to one specified in the render pass. This is used in cases were -// there is not enough contrast with the normal one. -#if defined(HD_HAS_overrideWireframeColor) - return HdGet_overrideWireframeColor(); -#elif defined(HD_HAS_wireframeColor) - return HdGet_wireframeColor(); -#else - return vec4(0,0,0,0); -#endif -} -vec4 GetMaskColor() { -#if defined(HD_HAS_maskColor) - return HdGet_maskColor(); -#else - return vec4(0.5,0,0,1); -#endif -} -vec4 GetIndicatorColor() { -#if defined(HD_HAS_indicatorColor) - return HdGet_indicatorColor(); -#else - return vec4(0,0.5,0,1); -#endif -} - -bool ShouldDiscardByAlpha(vec4 color) -{ -#if defined(HD_HAS_alphaThreshold) - float alphaThreshold = HdGet_alphaThreshold(); -#else - float alphaThreshold = 0; -#endif - return (color.a < alphaThreshold); -} - -vec2 ApplyAxisAlignedAffineTransform(vec4 t, vec2 pt) -{ - return t.xy * pt + t.zw; -} - - - -vec2 HorizontallyNormalizedFilmbackCoordinates() -{ - const vec4 transform = -#ifdef HD_HAS_imageToHorizontallyNormalizedFilmback - HdGet_imageToHorizontallyNormalizedFilmback(); -#else - vec4(vec2(1.0), vec2(0.0)); -#endif - return ApplyAxisAlignedAffineTransform(transform, gl_FragCoord.xy); -} - - - -vec4 ApplySelectionColor(vec4 color) -{ - return color; -} - - - -// Forward declare selection functionality. -// XXX: Currently, the non-empty implementation of this is in hdx. -FORWARD_DECL(vec4 ApplySelectionColor(vec4 color)); - -// XXX: Make sure to update hdx/shaders/renderPass.glslfx when editing these -// color override methods, since they're currently duplicated. This is because -// we don't have a mixin token for color overrides in a render pass yet. -vec4 ApplyColorOverrides(vec4 color) -{ -#if defined(HD_HAS_overrideColor) - // Mix in override color - vec4 overrideColor = HdGet_overrideColor(); - color.rgb = mix(color.rgb, overrideColor.rgb, overrideColor.a); -#endif - return ApplySelectionColor(color); -} - -vec3 ApplyMaskColor(vec3 color, float weight, vec4 maskColor) -{ - float strength = maskColor.a * clamp(weight, 0.0, 1.0); - return mix(color, maskColor.rgb, strength); -} - -vec4 ApplyColorOverridesPostLighting(vec4 color) -{ - #if defined(HD_HAS_maskWeight) - float maskWeight = HdGet_maskWeight(); - vec4 maskColor = GetMaskColor(); - color.rgb = ApplyMaskColor(color.rgb, maskWeight, maskColor); - #endif - #if defined(HD_HAS_indicatorWeight) - float indicatorWeight = HdGet_indicatorWeight(); - vec4 indicatorColor = GetIndicatorColor(); - color.rgb = ApplyMaskColor(color.rgb, indicatorWeight, indicatorColor); - #endif - return color; -} - - - -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - colorOut = color; -} - - -#ifndef HD_HAS_integrateLights -#define HD_HAS_integrateLights -#endif - -struct LightingContribution { - vec3 diffuse; -}; - -struct LightingInterfaceProperties { - float unused; -}; - -LightingContribution -integrateLightsDefault(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - vec3 n = normalize(Neye); - - LightingContribution result; - result.diffuse = vec3(dot(n, vec3(0,0,1))); - - return result; -} - -LightingContribution -integrateLightsConstant(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - LightingContribution result; - //pefectly diffuse white hemisphere contribution - result.diffuse = vec3(1); - - return result; -} - - - -FORWARD_DECL( - LightingContribution integrateLights(vec4 Peye, vec3 Neye, - LightingInterfaceProperties props)); - -vec3 FallbackLighting(in vec3 Peye, in vec3 Neye, in vec3 color) -{ - LightingInterfaceProperties props; - LightingContribution light = integrateLights(vec4(Peye, 1), Neye, props); - return color * light.diffuse; -} - - -vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - // lighting - color.rgb = FallbackLighting(Peye.xyz, Neye, color.rgb); - return color; -} - - -struct ReprStyle -{ - vec4 color; - bool usePrimvarColor; - bool usePrimvarAlpha; - bool applyColorOverride; - bool useSurfaceShaderColor; - bool useSurfaceShaderAlpha; -}; - -struct ScalarOverride -{ - bool enabled; - vec3 color; -}; - -FORWARD_DECL(ReprStyle GetReprStyle()); -FORWARD_DECL(ScalarOverride GetScalarOverride()); -FORWARD_DECL( - vec4 surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord)); -FORWARD_DECL(vec4 postSurfaceShader(vec4 Peye, vec3 Neye, vec4 color)); - -vec4 ShadingTerminal(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -{ - ReprStyle reprStyle = GetReprStyle(); - - // Apply scalar override. - ScalarOverride scalarOverride = GetScalarOverride(); - if (scalarOverride.enabled) { - vec4 result; - - result.rgb = scalarOverride.color; - result.a = reprStyle.usePrimvarAlpha ? color.a: reprStyle.color.a; - - vec4 colorOverride = ApplyColorOverrides(result); - result = reprStyle.applyColorOverride ? colorOverride : result; - - return result; - } - - // Draw mode can override face color - vec4 reprColor; - - reprColor.rgb = reprStyle.usePrimvarColor ? color.rgb : reprStyle.color.rgb; - reprColor.a = reprStyle.usePrimvarAlpha ? color.a : reprStyle.color.a; - - // Compute color overrides - vec4 colorOverride = ApplyColorOverrides(reprColor); - reprColor = reprStyle.applyColorOverride ? colorOverride : reprColor; - - - // Surface shading can be expensive and also can contain undesirable - // side effects (like discards). So only run it for reprs that require it. - - if (reprStyle.useSurfaceShaderColor || - reprStyle.useSurfaceShaderAlpha) { - vec4 shadingColor; - - shadingColor = surfaceShader(Peye, - Neye, - reprColor, - patchCoord); - -#ifdef HD_HAS_postSurfaceShader - shadingColor = postSurfaceShader(Peye, - Neye, - shadingColor); -#endif - - reprColor.rgb = reprStyle.useSurfaceShaderColor ? - shadingColor.rgb : - reprColor.rgb; - - reprColor.a = reprStyle.useSurfaceShaderAlpha ? - shadingColor.a : - reprColor.a; - } - - vec4 baseColor = color; - baseColor = ApplyColorOverrides(baseColor); - - vec4 litColor = mix(baseColor, - reprColor, - GetLightingBlendAmount()); - - // Final overrides. - - return ApplyColorOverridesPostLighting(litColor); -} - - - -#ifdef HD_HAS_integrateLights -#ifndef HD_HAS_definedIntegrateLights -#define HD_HAS_definedIntegrateLights - -LightingContribution -integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props) -{ - return integrateLightsDefault(Peye, Neye, props); -} - -#endif // HD_HAS_definedIntegrateLights -#endif - -ReprStyle GetReprStyle() -{ - ReprStyle reprStyle; - - reprStyle.color = vec4(0.0, 0.0, 0.0, 1.0); - reprStyle.usePrimvarColor = true; - reprStyle.usePrimvarAlpha = true; - reprStyle.applyColorOverride = true; - reprStyle.useSurfaceShaderColor = true; - reprStyle.useSurfaceShaderAlpha = true; - - return reprStyle; -} - - - -ScalarOverride GetScalarOverride() -{ - ScalarOverride result; - - result.enabled = false; - result.color = vec3(0.0, 0.0, 0.0); - - return result; -} - - -void main(void) -{ - vec3 Peye = inData.Peye.xyz / inData.Peye.w; - // camera facing. - vec3 Neye = vec3(0, 0, 1); - - vec4 color = vec4(0.5, 0.5, 0.5, 1); -#ifdef HD_HAS_displayColor - color.rgb = HdGet_displayColor().rgb; -#endif -#ifdef HD_HAS_displayOpacity - color.a = HdGet_displayOpacity(); -#endif - - vec4 patchCoord = vec4(0); - color = ShadingTerminal(vec4(Peye, 1), Neye, color, patchCoord); - -#ifdef HD_MATERIAL_TAG_MASKED - if (ShouldDiscardByAlpha(color)) { - discard; - } -#endif - - RenderOutput(vec4(Peye, 1), Neye, color, patchCoord); -} - - -int GetPointId() -{ - return vsPointId; -} - -OK From e1966fe2b325d92f75d397612238f7e7ccc8c75b Mon Sep 17 00:00:00 2001 From: pixar-oss Date: Mon, 14 Oct 2024 13:10:24 -0700 Subject: [PATCH 034/300] Updated our CMake pxr_test_scripts macro to allow us to install test files using a specified destination name so that python test files can be installed with their .py extension to be importable as modules for other tests. An explicit destination is specified by appending ':' to the file in the pxr_test_scripts entry like: pxr_test_scripts( testenv/test1.py testenv/test2.py:explicitDestinationName.py ) (Internal change: 2344517) --- cmake/macros/Public.cmake | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cmake/macros/Public.cmake b/cmake/macros/Public.cmake index 1b809e738d..da4b0e2cb0 100644 --- a/cmake/macros/Public.cmake +++ b/cmake/macros/Public.cmake @@ -658,7 +658,24 @@ function(pxr_test_scripts) endif() foreach(file ${ARGN}) - get_filename_component(destFile ${file} NAME_WE) + # Perform regex match to extract both source resource path and + # destination resource path. + # Regex match appropriately takes care of windows drive letter followed + # by a ":", which is also the token we use to separate the source and + # destination resource paths. + string(REGEX MATCHALL "([A-Za-z]:)?([^:]+)" file "${file}") + + list(LENGTH file n) + if (n EQUAL 1) + get_filename_component(destFile ${file} NAME_WE) + elseif (n EQUAL 2) + list(GET file 1 destFile) + list(GET file 0 file) + else() + message(FATAL_ERROR + "Failed to parse test file path ${file}") + endif() + # XXX -- We shouldn't have to install to run tests. install( PROGRAMS ${file} From d1a5807cb1196469dbaedc03f4977c752b08cab8 Mon Sep 17 00:00:00 2001 From: pixar-oss Date: Mon, 14 Oct 2024 13:10:43 -0700 Subject: [PATCH 035/300] Adding missing test testUsdNamespaceEditorTargetPathFixup to CMakelist (Internal change: 2344522) --- pxr/usd/usd/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pxr/usd/usd/CMakeLists.txt b/pxr/usd/usd/CMakeLists.txt index 87c8a01bba..df3c383bf2 100644 --- a/pxr/usd/usd/CMakeLists.txt +++ b/pxr/usd/usd/CMakeLists.txt @@ -235,6 +235,7 @@ pxr_test_scripts( testenv/testUsdModel.py testenv/testUsdNamespaceEditor.py testenv/testUsdNamespaceEditorProperties.py + testenv/testUsdNamespaceEditorTargetPathFixup.py testenv/testUsdNotices.py testenv/testUsdObjectsChangedNotices.py testenv/testUsdOpaqueAttributes.py @@ -662,6 +663,11 @@ pxr_install_test_dir( DEST testUsdNamespaceEditorProperties ) +pxr_install_test_dir( + SRC testenv/testUsdNamespaceEditorTargetPathFixup + DEST testUsdNamespaceEditorTargetPathFixup +) + pxr_install_test_dir( SRC testenv/testUsdPrims.testenv DEST testUsdPrims @@ -1280,6 +1286,12 @@ pxr_register_test(testUsdNamespaceEditorProperties EXPECTED_RETURN_CODE 0 ) +pxr_register_test(testUsdNamespaceEditorTargetPathFixup + PYTHON + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdNamespaceEditorTargetPathFixup" + EXPECTED_RETURN_CODE 0 +) + pxr_register_test(testUsdReadOutOfBounds PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdReadOutOfBounds" From 94b0c792f5d157ec0c90d017c05f64345c0ef310 Mon Sep 17 00:00:00 2001 From: unhyperbolic Date: Mon, 14 Oct 2024 13:11:11 -0700 Subject: [PATCH 036/300] Changing the hydra schema template to not include the api.h if the respective library does not require symbol visibility attributes for its functions. (Internal change: 2344572) --- pxr/imaging/hd/codegenTemplates/schemaClass.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pxr/imaging/hd/codegenTemplates/schemaClass.h b/pxr/imaging/hd/codegenTemplates/schemaClass.h index aff00a12fe..15254941e5 100644 --- a/pxr/imaging/hd/codegenTemplates/schemaClass.h +++ b/pxr/imaging/hd/codegenTemplates/schemaClass.h @@ -19,11 +19,12 @@ #define {{ HEADER_GUARD|snake }}_{{ FILE_NAME|snake }}_H /// \file - +{% if LIBRARY_API %} #include "{{ INCLUDE_PATH }}/api.h" +{%- endif -%} {%- if SCHEMA_INCLUDES is defined -%} -{%- for t in SCHEMA_INCLUDES %} +{% for t in SCHEMA_INCLUDES %} #include "{{ t | expand }}.h" {%- endfor -%} {%- endif %} @@ -75,7 +76,7 @@ PXR_NAMESPACE_OPEN_SCOPE {%- endfor -%} {%- endif %} -TF_DECLARE_PUBLIC_TOKENS({{SCHEMA_CLASS_NAME}}Tokens, {{ LIBRARY_API }}, +TF_DECLARE_PUBLIC_TOKENS({{SCHEMA_CLASS_NAME}}Tokens,{% if LIBRARY_API%} {{ LIBRARY_API }},{% endif %} {{ SCHEMA_CLASS_NAME|snake }}_TOKENS); //----------------------------------------------------------------------------- From eb7c7c6bd7b9570a20025cf21583ca16106a1911 Mon Sep 17 00:00:00 2001 From: rajabala Date: Mon, 14 Oct 2024 15:59:20 -0700 Subject: [PATCH 037/300] [usdImaging] Transport additional USD prim info to Hydra. (Internal change: 2344616) --- .../usdImaging/dataSourceUsdPrimInfo.cpp | 37 +++- pxr/usdImaging/usdImaging/hdSchemaDefs.py | 13 +- .../baseline/basic.txt | 16 ++ .../usdImaging/usdPrimInfoSchema.cpp | 160 +++++++++++++----- pxr/usdImaging/usdImaging/usdPrimInfoSchema.h | 63 +++++-- 5 files changed, 215 insertions(+), 74 deletions(-) diff --git a/pxr/usdImaging/usdImaging/dataSourceUsdPrimInfo.cpp b/pxr/usdImaging/usdImaging/dataSourceUsdPrimInfo.cpp index f74b2186e1..63e2351de8 100644 --- a/pxr/usdImaging/usdImaging/dataSourceUsdPrimInfo.cpp +++ b/pxr/usdImaging/usdImaging/dataSourceUsdPrimInfo.cpp @@ -59,8 +59,11 @@ TfTokenVector UsdImagingDataSourceUsdPrimInfo::GetNames() { TfTokenVector result = { + UsdImagingUsdPrimInfoSchemaTokens->specifier, + UsdImagingUsdPrimInfoSchemaTokens->typeName, UsdImagingUsdPrimInfoSchemaTokens->isLoaded, - UsdImagingUsdPrimInfoSchemaTokens->specifier + UsdImagingUsdPrimInfoSchemaTokens->apiSchemas, + UsdImagingUsdPrimInfoSchemaTokens->kind, }; if (_usdPrim.IsInstance()) { @@ -77,13 +80,35 @@ UsdImagingDataSourceUsdPrimInfo::GetNames() HdDataSourceBaseHandle UsdImagingDataSourceUsdPrimInfo::Get(const TfToken &name) { - if (name == UsdImagingUsdPrimInfoSchemaTokens->isLoaded) { - return HdRetainedTypedSampledDataSource::New( - _usdPrim.IsLoaded()); - } + using BoolDataSource = HdRetainedTypedSampledDataSource; + using TokenDataSource = HdRetainedTypedSampledDataSource; + using TokenArrayDataSource = + HdRetainedTypedSampledDataSource>; + if (name == UsdImagingUsdPrimInfoSchemaTokens->specifier) { return _SpecifierToDataSource(_usdPrim.GetSpecifier()); } + if (name == UsdImagingUsdPrimInfoSchemaTokens->typeName) { + return TokenDataSource::New(_usdPrim.GetTypeName()); + } + if (name == UsdImagingUsdPrimInfoSchemaTokens->isLoaded) { + return BoolDataSource::New(_usdPrim.IsLoaded()); + } + if (name == UsdImagingUsdPrimInfoSchemaTokens->apiSchemas) { + const TfTokenVector appliedSchemas = _usdPrim.GetAppliedSchemas(); + if (!appliedSchemas.empty()) { + return TokenArrayDataSource::New( + VtArray(appliedSchemas.begin(), appliedSchemas.end())); + } + return nullptr; + } + if (name == UsdImagingUsdPrimInfoSchemaTokens->kind) { + TfToken kind; + if (_usdPrim.GetKind(&kind)) { + return TokenDataSource::New(kind); + } + return nullptr; + } if (name == UsdImagingUsdPrimInfoSchemaTokens->niPrototypePath) { if (!_usdPrim.IsInstance()) { return nullptr; @@ -99,7 +124,7 @@ UsdImagingDataSourceUsdPrimInfo::Get(const TfToken &name) if (!_usdPrim.IsPrototype()) { return nullptr; } - return HdRetainedTypedSampledDataSource::New(true); + return BoolDataSource::New(true); } return nullptr; } diff --git a/pxr/usdImaging/usdImaging/hdSchemaDefs.py b/pxr/usdImaging/usdImaging/hdSchemaDefs.py index df0160f3d1..c7e5417a8a 100644 --- a/pxr/usdImaging/usdImaging/hdSchemaDefs.py +++ b/pxr/usdImaging/usdImaging/hdSchemaDefs.py @@ -17,11 +17,18 @@ SCHEMA_TOKEN = '__usdPrimInfo', ADD_DEFAULT_LOCATOR = True, MEMBERS = [ + ('specifier', T_TOKEN, {}), + ('typeName', T_TOKEN, {}), + ('isLoaded', T_BOOL, {}), + # Skipping isModel and isGroup, which can be inferred from 'kind'. + ('apiSchemas', T_TOKENARRAY, {}), + ('kind', T_TOKEN, {}), + # XXX Add variantSets. Is it a token array, or a container of token + # to token array? ('niPrototypePath', T_PATH, dict(ADD_LOCATOR=True)), ('isNiPrototype', T_BOOL, {}), - ('specifier', T_TOKEN, {}), ('piPropagatedPrototypes', T_CONTAINER, {}), - ('isLoaded', T_BOOL, {}), + ], STATIC_TOKEN_DATASOURCE_BUILDERS = [ ('specifier', ['def', 'over', '(class_, "class")']), @@ -196,4 +203,4 @@ ('namespacedSettings', T_CONTAINER, dict(ADD_LOCATOR=True)), ], ), -] +] diff --git a/pxr/usdImaging/usdImaging/testenv/testUsdImagingStageSceneIndexContents/baseline/basic.txt b/pxr/usdImaging/usdImaging/testenv/testUsdImagingStageSceneIndexContents/baseline/basic.txt index febc141946..3240de58f7 100644 --- a/pxr/usdImaging/usdImaging/testenv/testUsdImagingStageSceneIndexContents/baseline/basic.txt +++ b/pxr/usdImaging/usdImaging/testenv/testUsdImagingStageSceneIndexContents/baseline/basic.txt @@ -14,6 +14,8 @@ 1 [specifier] def + [typeName] + Xform [primOrigin] [scenePath] HdPrimOriginSchema::OriginPath(/CoordSys) @@ -24,6 +26,8 @@ 1 [specifier] def + [typeName] + Xform [primOrigin] [scenePath] HdPrimOriginSchema::OriginPath(/CoordSys/modelSpace) @@ -34,6 +38,8 @@ 1 [specifier] def + [typeName] + Xform [primOrigin] [scenePath] HdPrimOriginSchema::OriginPath(/CoordSys/worldSpace) @@ -49,16 +55,22 @@ 1 [specifier] def + [typeName] + Xform [primOrigin] [scenePath] HdPrimOriginSchema::OriginPath(/Geom) [primvars] type = mesh [__usdPrimInfo] + [apiSchemas] + [MaterialBindingAPI, CoordSysAPI:worldSpace, CoordSysAPI:modelSpace] [isLoaded] 1 [specifier] def + [typeName] + Mesh [coordSysBinding] [modelSpace] /CoordSys/modelSpace @@ -137,6 +149,8 @@ 1 [specifier] def + [typeName] + Scope [primOrigin] [scenePath] HdPrimOriginSchema::OriginPath(/Materials) @@ -147,6 +161,8 @@ 1 [specifier] def + [typeName] + Material [material] [] [interfaceMappings] diff --git a/pxr/usdImaging/usdImaging/usdPrimInfoSchema.cpp b/pxr/usdImaging/usdImaging/usdPrimInfoSchema.cpp index aa75095fdc..a575d84452 100644 --- a/pxr/usdImaging/usdImaging/usdPrimInfoSchema.cpp +++ b/pxr/usdImaging/usdImaging/usdPrimInfoSchema.cpp @@ -32,56 +32,105 @@ TF_DEFINE_PUBLIC_TOKENS(UsdImagingUsdPrimInfoSchemaTokens, // --(BEGIN CUSTOM CODE: Schema Methods)-- // --(END CUSTOM CODE: Schema Methods)-- -HdPathDataSourceHandle -UsdImagingUsdPrimInfoSchema::GetNiPrototypePath() const +HdTokenDataSourceHandle +UsdImagingUsdPrimInfoSchema::GetSpecifier() const { - return _GetTypedDataSource( - UsdImagingUsdPrimInfoSchemaTokens->niPrototypePath); + return _GetTypedDataSource( + UsdImagingUsdPrimInfoSchemaTokens->specifier); +} + +HdTokenDataSourceHandle +UsdImagingUsdPrimInfoSchema::GetTypeName() const +{ + return _GetTypedDataSource( + UsdImagingUsdPrimInfoSchemaTokens->typeName); } HdBoolDataSourceHandle -UsdImagingUsdPrimInfoSchema::GetIsNiPrototype() const +UsdImagingUsdPrimInfoSchema::GetIsLoaded() const { return _GetTypedDataSource( - UsdImagingUsdPrimInfoSchemaTokens->isNiPrototype); + UsdImagingUsdPrimInfoSchemaTokens->isLoaded); +} + +HdTokenArrayDataSourceHandle +UsdImagingUsdPrimInfoSchema::GetApiSchemas() const +{ + return _GetTypedDataSource( + UsdImagingUsdPrimInfoSchemaTokens->apiSchemas); } HdTokenDataSourceHandle -UsdImagingUsdPrimInfoSchema::GetSpecifier() const +UsdImagingUsdPrimInfoSchema::GetKind() const { return _GetTypedDataSource( - UsdImagingUsdPrimInfoSchemaTokens->specifier); + UsdImagingUsdPrimInfoSchemaTokens->kind); } -HdContainerDataSourceHandle -UsdImagingUsdPrimInfoSchema::GetPiPropagatedPrototypes() const +HdPathDataSourceHandle +UsdImagingUsdPrimInfoSchema::GetNiPrototypePath() const { - return _GetTypedDataSource( - UsdImagingUsdPrimInfoSchemaTokens->piPropagatedPrototypes); + return _GetTypedDataSource( + UsdImagingUsdPrimInfoSchemaTokens->niPrototypePath); } HdBoolDataSourceHandle -UsdImagingUsdPrimInfoSchema::GetIsLoaded() const +UsdImagingUsdPrimInfoSchema::GetIsNiPrototype() const { return _GetTypedDataSource( - UsdImagingUsdPrimInfoSchemaTokens->isLoaded); + UsdImagingUsdPrimInfoSchemaTokens->isNiPrototype); +} + +HdContainerDataSourceHandle +UsdImagingUsdPrimInfoSchema::GetPiPropagatedPrototypes() const +{ + return _GetTypedDataSource( + UsdImagingUsdPrimInfoSchemaTokens->piPropagatedPrototypes); } /*static*/ HdContainerDataSourceHandle UsdImagingUsdPrimInfoSchema::BuildRetained( + const HdTokenDataSourceHandle &specifier, + const HdTokenDataSourceHandle &typeName, + const HdBoolDataSourceHandle &isLoaded, + const HdTokenArrayDataSourceHandle &apiSchemas, + const HdTokenDataSourceHandle &kind, const HdPathDataSourceHandle &niPrototypePath, const HdBoolDataSourceHandle &isNiPrototype, - const HdTokenDataSourceHandle &specifier, - const HdContainerDataSourceHandle &piPropagatedPrototypes, - const HdBoolDataSourceHandle &isLoaded + const HdContainerDataSourceHandle &piPropagatedPrototypes ) { - TfToken _names[5]; - HdDataSourceBaseHandle _values[5]; + TfToken _names[8]; + HdDataSourceBaseHandle _values[8]; size_t _count = 0; + if (specifier) { + _names[_count] = UsdImagingUsdPrimInfoSchemaTokens->specifier; + _values[_count++] = specifier; + } + + if (typeName) { + _names[_count] = UsdImagingUsdPrimInfoSchemaTokens->typeName; + _values[_count++] = typeName; + } + + if (isLoaded) { + _names[_count] = UsdImagingUsdPrimInfoSchemaTokens->isLoaded; + _values[_count++] = isLoaded; + } + + if (apiSchemas) { + _names[_count] = UsdImagingUsdPrimInfoSchemaTokens->apiSchemas; + _values[_count++] = apiSchemas; + } + + if (kind) { + _names[_count] = UsdImagingUsdPrimInfoSchemaTokens->kind; + _values[_count++] = kind; + } + if (niPrototypePath) { _names[_count] = UsdImagingUsdPrimInfoSchemaTokens->niPrototypePath; _values[_count++] = niPrototypePath; @@ -92,60 +141,74 @@ UsdImagingUsdPrimInfoSchema::BuildRetained( _values[_count++] = isNiPrototype; } - if (specifier) { - _names[_count] = UsdImagingUsdPrimInfoSchemaTokens->specifier; - _values[_count++] = specifier; - } - if (piPropagatedPrototypes) { _names[_count] = UsdImagingUsdPrimInfoSchemaTokens->piPropagatedPrototypes; _values[_count++] = piPropagatedPrototypes; } - - if (isLoaded) { - _names[_count] = UsdImagingUsdPrimInfoSchemaTokens->isLoaded; - _values[_count++] = isLoaded; - } return HdRetainedContainerDataSource::New(_count, _names, _values); } UsdImagingUsdPrimInfoSchema::Builder & -UsdImagingUsdPrimInfoSchema::Builder::SetNiPrototypePath( - const HdPathDataSourceHandle &niPrototypePath) +UsdImagingUsdPrimInfoSchema::Builder::SetSpecifier( + const HdTokenDataSourceHandle &specifier) { - _niPrototypePath = niPrototypePath; + _specifier = specifier; return *this; } UsdImagingUsdPrimInfoSchema::Builder & -UsdImagingUsdPrimInfoSchema::Builder::SetIsNiPrototype( - const HdBoolDataSourceHandle &isNiPrototype) +UsdImagingUsdPrimInfoSchema::Builder::SetTypeName( + const HdTokenDataSourceHandle &typeName) { - _isNiPrototype = isNiPrototype; + _typeName = typeName; return *this; } UsdImagingUsdPrimInfoSchema::Builder & -UsdImagingUsdPrimInfoSchema::Builder::SetSpecifier( - const HdTokenDataSourceHandle &specifier) +UsdImagingUsdPrimInfoSchema::Builder::SetIsLoaded( + const HdBoolDataSourceHandle &isLoaded) { - _specifier = specifier; + _isLoaded = isLoaded; return *this; } UsdImagingUsdPrimInfoSchema::Builder & -UsdImagingUsdPrimInfoSchema::Builder::SetPiPropagatedPrototypes( - const HdContainerDataSourceHandle &piPropagatedPrototypes) +UsdImagingUsdPrimInfoSchema::Builder::SetApiSchemas( + const HdTokenArrayDataSourceHandle &apiSchemas) { - _piPropagatedPrototypes = piPropagatedPrototypes; + _apiSchemas = apiSchemas; return *this; } UsdImagingUsdPrimInfoSchema::Builder & -UsdImagingUsdPrimInfoSchema::Builder::SetIsLoaded( - const HdBoolDataSourceHandle &isLoaded) +UsdImagingUsdPrimInfoSchema::Builder::SetKind( + const HdTokenDataSourceHandle &kind) { - _isLoaded = isLoaded; + _kind = kind; + return *this; +} + +UsdImagingUsdPrimInfoSchema::Builder & +UsdImagingUsdPrimInfoSchema::Builder::SetNiPrototypePath( + const HdPathDataSourceHandle &niPrototypePath) +{ + _niPrototypePath = niPrototypePath; + return *this; +} + +UsdImagingUsdPrimInfoSchema::Builder & +UsdImagingUsdPrimInfoSchema::Builder::SetIsNiPrototype( + const HdBoolDataSourceHandle &isNiPrototype) +{ + _isNiPrototype = isNiPrototype; + return *this; +} + +UsdImagingUsdPrimInfoSchema::Builder & +UsdImagingUsdPrimInfoSchema::Builder::SetPiPropagatedPrototypes( + const HdContainerDataSourceHandle &piPropagatedPrototypes) +{ + _piPropagatedPrototypes = piPropagatedPrototypes; return *this; } @@ -153,11 +216,14 @@ HdContainerDataSourceHandle UsdImagingUsdPrimInfoSchema::Builder::Build() { return UsdImagingUsdPrimInfoSchema::BuildRetained( + _specifier, + _typeName, + _isLoaded, + _apiSchemas, + _kind, _niPrototypePath, _isNiPrototype, - _specifier, - _piPropagatedPrototypes, - _isLoaded + _piPropagatedPrototypes ); } diff --git a/pxr/usdImaging/usdImaging/usdPrimInfoSchema.h b/pxr/usdImaging/usdImaging/usdPrimInfoSchema.h index 4b98f599bb..e9afbb476b 100644 --- a/pxr/usdImaging/usdImaging/usdPrimInfoSchema.h +++ b/pxr/usdImaging/usdImaging/usdPrimInfoSchema.h @@ -34,11 +34,14 @@ PXR_NAMESPACE_OPEN_SCOPE #define USD_IMAGING_USD_PRIM_INFO_SCHEMA_TOKENS \ (__usdPrimInfo) \ + (specifier) \ + (typeName) \ + (isLoaded) \ + (apiSchemas) \ + (kind) \ (niPrototypePath) \ (isNiPrototype) \ - (specifier) \ (piPropagatedPrototypes) \ - (isLoaded) \ (def) \ (over) \ ((class_, "class")) \ @@ -76,19 +79,28 @@ class UsdImagingUsdPrimInfoSchema : public HdSchema /// @{ USDIMAGING_API - HdPathDataSourceHandle GetNiPrototypePath() const; + HdTokenDataSourceHandle GetSpecifier() const; USDIMAGING_API - HdBoolDataSourceHandle GetIsNiPrototype() const; + HdTokenDataSourceHandle GetTypeName() const; USDIMAGING_API - HdTokenDataSourceHandle GetSpecifier() const; + HdBoolDataSourceHandle GetIsLoaded() const; USDIMAGING_API - HdContainerDataSourceHandle GetPiPropagatedPrototypes() const; + HdTokenArrayDataSourceHandle GetApiSchemas() const; USDIMAGING_API - HdBoolDataSourceHandle GetIsLoaded() const; + HdTokenDataSourceHandle GetKind() const; + + USDIMAGING_API + HdPathDataSourceHandle GetNiPrototypePath() const; + + USDIMAGING_API + HdBoolDataSourceHandle GetIsNiPrototype() const; + + USDIMAGING_API + HdContainerDataSourceHandle GetPiPropagatedPrototypes() const; /// @} @@ -134,11 +146,14 @@ class UsdImagingUsdPrimInfoSchema : public HdSchema USDIMAGING_API static HdContainerDataSourceHandle BuildRetained( + const HdTokenDataSourceHandle &specifier, + const HdTokenDataSourceHandle &typeName, + const HdBoolDataSourceHandle &isLoaded, + const HdTokenArrayDataSourceHandle &apiSchemas, + const HdTokenDataSourceHandle &kind, const HdPathDataSourceHandle &niPrototypePath, const HdBoolDataSourceHandle &isNiPrototype, - const HdTokenDataSourceHandle &specifier, - const HdContainerDataSourceHandle &piPropagatedPrototypes, - const HdBoolDataSourceHandle &isLoaded + const HdContainerDataSourceHandle &piPropagatedPrototypes ); /// \class UsdImagingUsdPrimInfoSchema::Builder @@ -151,31 +166,43 @@ class UsdImagingUsdPrimInfoSchema : public HdSchema { public: USDIMAGING_API + Builder &SetSpecifier( + const HdTokenDataSourceHandle &specifier); + USDIMAGING_API + Builder &SetTypeName( + const HdTokenDataSourceHandle &typeName); + USDIMAGING_API + Builder &SetIsLoaded( + const HdBoolDataSourceHandle &isLoaded); + USDIMAGING_API + Builder &SetApiSchemas( + const HdTokenArrayDataSourceHandle &apiSchemas); + USDIMAGING_API + Builder &SetKind( + const HdTokenDataSourceHandle &kind); + USDIMAGING_API Builder &SetNiPrototypePath( const HdPathDataSourceHandle &niPrototypePath); USDIMAGING_API Builder &SetIsNiPrototype( const HdBoolDataSourceHandle &isNiPrototype); USDIMAGING_API - Builder &SetSpecifier( - const HdTokenDataSourceHandle &specifier); - USDIMAGING_API Builder &SetPiPropagatedPrototypes( const HdContainerDataSourceHandle &piPropagatedPrototypes); - USDIMAGING_API - Builder &SetIsLoaded( - const HdBoolDataSourceHandle &isLoaded); /// Returns a container data source containing the members set thus far. USDIMAGING_API HdContainerDataSourceHandle Build(); private: + HdTokenDataSourceHandle _specifier; + HdTokenDataSourceHandle _typeName; + HdBoolDataSourceHandle _isLoaded; + HdTokenArrayDataSourceHandle _apiSchemas; + HdTokenDataSourceHandle _kind; HdPathDataSourceHandle _niPrototypePath; HdBoolDataSourceHandle _isNiPrototype; - HdTokenDataSourceHandle _specifier; HdContainerDataSourceHandle _piPropagatedPrototypes; - HdBoolDataSourceHandle _isLoaded; }; From 329bda16be896716b43491eb70d0b060267d3ad0 Mon Sep 17 00:00:00 2001 From: pixar-oss Date: Tue, 15 Oct 2024 10:12:57 -0700 Subject: [PATCH 038/300] Adding basic reference and payload tests for dependent namespace edits in UsdNamespaceEditor. (Internal change: 2344687) --- pxr/usd/usd/CMakeLists.txt | 8 + ...estUsdNamespaceEditorDependentEditsBase.py | 155 ++ ...ependentEditsBasicReferencesAndPayloads.py | 1611 +++++++++++++++++ 3 files changed, 1774 insertions(+) create mode 100644 pxr/usd/usd/testenv/testUsdNamespaceEditorDependentEditsBase.py create mode 100644 pxr/usd/usd/testenv/testUsdNamespaceEditorDependentEditsBasicReferencesAndPayloads.py diff --git a/pxr/usd/usd/CMakeLists.txt b/pxr/usd/usd/CMakeLists.txt index df3c383bf2..2efc40ffd4 100644 --- a/pxr/usd/usd/CMakeLists.txt +++ b/pxr/usd/usd/CMakeLists.txt @@ -234,6 +234,8 @@ pxr_test_scripts( testenv/testUsdMetadata.py testenv/testUsdModel.py testenv/testUsdNamespaceEditor.py + testenv/testUsdNamespaceEditorDependentEditsBase.py:testUsdNamespaceEditorDependentEditsBase.py + testenv/testUsdNamespaceEditorDependentEditsBasicReferencesAndPayloads.py testenv/testUsdNamespaceEditorProperties.py testenv/testUsdNamespaceEditorTargetPathFixup.py testenv/testUsdNotices.py @@ -1280,6 +1282,12 @@ pxr_register_test(testUsdNamespaceEditor EXPECTED_RETURN_CODE 0 ) +pxr_register_test(testUsdNamespaceEditorDependentEditsBasicReferencesAndPayloads + PYTHON + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdNamespaceEditorDependentEditsBasicReferencesAndPayloads" + EXPECTED_RETURN_CODE 0 +) + pxr_register_test(testUsdNamespaceEditorProperties PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdNamespaceEditorProperties" diff --git a/pxr/usd/usd/testenv/testUsdNamespaceEditorDependentEditsBase.py b/pxr/usd/usd/testenv/testUsdNamespaceEditorDependentEditsBase.py new file mode 100644 index 0000000000..7d86d3d73d --- /dev/null +++ b/pxr/usd/usd/testenv/testUsdNamespaceEditorDependentEditsBase.py @@ -0,0 +1,155 @@ +#!/pxrpythonsubst +# +# Copyright 2024 Pixar +# +# Licensed under the terms set forth in the LICENSE.txt file available at +# https://openusd.org/license. + +import contextlib, inspect, sys, unittest +from pxr import Sdf, Usd + +class TestUsdNamespaceEditorDependentEditsBase(unittest.TestCase): + '''Base class for testUsdNamespaceEditDependentEditsXXX tests which + provides share utilities for verifying outcomes of edits. + ''' + + @contextlib.contextmanager + def ApplyEdits(self, editor, label, expectWarnings = False): + '''Context manager for adding a namespace edit on a Usd.NameespaceEditor + that will automatically verify that it can be applied and will apply it + verifying a successful apply. It also prints out useful information to + help keep test output organized. + + Example Usage: + editor = Usd.NamespaceEditor(stage) + with self.ApplyEdits(editor, "Move /Foo to /Bar"): + self.assertTrue(editor.MovePrimAtPath('/Foo', '/Bar')) + ''' + + # The enclosing test case function name to output with the begin and + # end messages. + testFunctionName = next((x.function for x in inspect.stack() + if x.function.startswith("test_")), "") + msg = testFunctionName + " : " + label + print("\n==== Begin ApplyEdits : {} ====".format(msg)) + print("\n==== Begin ApplyEdits : {} ====".format(msg), file=sys.stderr) + + yield + + if expectWarnings: + print("\n=== EXPECT WARNINGS ===", file=sys.stderr) + self.assertTrue(editor.CanApplyEdits()) + self.assertTrue(editor.ApplyEdits()) + if expectWarnings: + print("\n=== END EXPECTED WARNINGS ===", file=sys.stderr) + + print("==== End ApplyEdits : {} ====".format(msg)) + print("==== End ApplyEdits : {} ====".format(msg), file=sys.stderr) + + def _VerifyPrimContents(self, prim, expectedContentsDict): + '''Helper that verifies the contents of a USD prim, specifically its + child prims and properties, match the given expected contents. + + A prims expected contents are expressed as a dictionary of the form + + { + '.' : ['propName1', 'propName2'], + 'Child1' : {...child prim expected contents...}, + 'Child2' : {...child prim expected contents...} + } + ''' + + # '.' is used to key the list of expected property names for the prim + expectedPropertyNameSet = set(expectedContentsDict.get('.', [])) + + # Get the actual property names and compare against the expected set. + propertyNameSet = set(prim.GetPropertyNames()) + self.assertEqual(propertyNameSet, expectedPropertyNameSet, + "The actual property set {} does not match the expected property " + "set {} for the prim at path {}".format( + list(propertyNameSet), + list(expectedPropertyNameSet), + prim.GetPath())) + + # Expected children names are all the expected contents keys except '.' + expectedChildNameSet = set( + [k for k in expectedContentsDict.keys() if k != '.']) + + # Get the actual child prim names and compare against the expected set. + # We specifically want all children so we get unloaded prims and prims + # that aren't defined (they are just overs) + childrenNameSet = set(prim.GetAllChildrenNames()) + self.assertEqual(childrenNameSet, expectedChildNameSet, + "The actual child prim set {} does not match the expected children " + "set {} for the prim at path {}".format( + list(childrenNameSet), + list(expectedChildNameSet), + prim.GetPath())) + + # Verify the expected contents of each expected child prim. + for childName in expectedChildNameSet: + childPath = prim.GetPath().AppendChild(childName) + primChild = prim.GetPrimAtPath(childPath) + self._VerifyPrimContents(primChild, expectedContentsDict[childName]) + + def _VerifyStageContents(self, stage, expectedContentsDict): + '''Helper that verifies the contents of every USD prim on the given + stage, specifically each's child prims and properties, match the given + expected contents dictionary.''' + + self._VerifyPrimContents(stage.GetPseudoRoot(), expectedContentsDict) + + def _GetCompositionFieldsInLayer(self, layer): + '''Helper that finds all prims specs with composition fields set in the + given layer and returns a dictionary of prim paths to the fields and + their values. + + Example output: + + { + '/' : { + relocates : (('/Prim/Foo', '/Prim/Bar), ) + }, + '/Prim' : { + references : [Sdf.Refence(layer, '/RefPath')], + payload : [Sdf.Payload(layer, '/PayloadPath)] + }, + '/PrimA/ChildA' : { + inherits : ['/GlobalClass', '/PrimA/LocalClass'] + } + } + ''' + + compositionFields = {} + + # Relocates are only in layer metadata so add them as belonging to the + # pseudoroot if there are any. + if layer.HasRelocates(): + compositionFields ['/'] = {'relocates' : layer.relocates} + + def _GetCompositonFieldsForPrimAtPath(path) : + if not path.IsPrimPath() and not path.IsPrimVariantSelectionPath(): + return + + def _AddListOpValueForField(fieldName, listOp): + if not path in compositionFields: + compositionFields[str(path)] = {} + compositionFields[str(path)][fieldName] = listOp.GetAppliedItems() + + prim = layer.GetPrimAtPath(path) + if prim is None: + return + if prim.hasReferences: + _AddListOpValueForField('references', prim.referenceList) + if prim.hasPayloads: + _AddListOpValueForField('payload', prim.payloadList) + if prim.hasInheritPaths: + _AddListOpValueForField('inherits', prim.inheritPathList) + if prim.hasSpecializes: + _AddListOpValueForField('specializes', prim.specializesList) + + layer.Traverse("/", _GetCompositonFieldsForPrimAtPath) + return compositionFields + +if __name__ == '__main__': + unittest.main() diff --git a/pxr/usd/usd/testenv/testUsdNamespaceEditorDependentEditsBasicReferencesAndPayloads.py b/pxr/usd/usd/testenv/testUsdNamespaceEditorDependentEditsBasicReferencesAndPayloads.py new file mode 100644 index 0000000000..59372709ec --- /dev/null +++ b/pxr/usd/usd/testenv/testUsdNamespaceEditorDependentEditsBasicReferencesAndPayloads.py @@ -0,0 +1,1611 @@ +#!/pxrpythonsubst +# +# Copyright 2024 Pixar +# +# Licensed under the terms set forth in the LICENSE.txt file available at +# https://openusd.org/license. + +import sys, unittest +from pxr import Sdf, Usd +from testUsdNamespaceEditorDependentEditsBase \ + import TestUsdNamespaceEditorDependentEditsBase + +class TestUsdNamespaceEditorDependentEditsBasicReferencesAndPayloads( + TestUsdNamespaceEditorDependentEditsBase): + '''Tests downstream dependency namespace edits across references and + payloads.''' + + def test_BasicDependentReferences(self): + """Test downstream dependency namespace edits across basic single + references, both internal and in separate layers """ + + # Setup: + # Layer 1 has simple hierarchy of /Ref, Child, and GrandChild that is + # referenced and will be namespace edited. It also has three prims + # that internally reference /Ref, /Ref/Child, and /Ref/Child/GrandChild + # respectively. These internally referencing prims will be affected by + # downstream dependency edits. + layer1 = Sdf.Layer.CreateAnonymous("layer1.usda") + layer1ImportString = '''#usda 1.0 + def "Ref" { + int refAttr + + def "Child" { + int childAttr + + def "GrandChild" { + int grandChildAttr + } + } + } + + def "InternalRef1" ( + references = + ) { + over "Child" { + int overChildAttr + over "GrandChild" { + int overGrandChildAttr + } + } + def "LocalChild" {} + int localAttr + } + + def "InternalRef2" ( + references = + ) { + over "GrandChild" { + int overGrandChildAttr + } + def "LocalChild" {} + int localAttr + } + + def "InternalRef3" ( + references = + ) { + def "LocalChild" {} + int localAttr + } + ''' + layer1.ImportFromString(layer1ImportString) + + # Layer 2 has three prims that reference /Ref, /Ref/Child, and + # /Ref/Child/GrandChild from layer 1 respectively. These prims will be + # affected by downstream dependency edits. + layer2 = Sdf.Layer.CreateAnonymous("layer2.usda") + layer2ImportString = '''#usda 1.0 + def "Prim1" ( + references = @''' + layer1.identifier + '''@ + ) { + over "Child" { + int overChildAttr + over "GrandChild" { + int overGrandChildAttr + } + } + def "LocalChild" {} + int localAttr + } + + def "Prim2" ( + references = @''' + layer1.identifier + '''@ + ) { + over "GrandChild" { + int overGrandChildAttr + } + def "LocalChild" {} + int localAttr + } + + def "Prim3" ( + references = @''' + layer1.identifier + '''@ + ) { + def "LocalChild" {} + int localAttr + } + ''' + layer2.ImportFromString(layer2ImportString) + + # Open both layers as stages. + stage1 = Usd.Stage.Open(layer1, Usd.Stage.LoadAll) + stage2 = Usd.Stage.Open(layer2, Usd.Stage.LoadAll) + + # Create an editor for stage 1 with stage 2 as an addtional dependent + # stage. + editor = Usd.NamespaceEditor(stage1) + editor.AddDependentStage(stage2) + + # Verify the initial composition fields for both layers. + self.assertEqual(self._GetCompositionFieldsInLayer(layer1), { + '/InternalRef1' : { + 'references' : (Sdf.Reference(primPath='/Ref'),) + }, + '/InternalRef2' : { + 'references' : (Sdf.Reference(primPath='/Ref/Child'),) + }, + '/InternalRef3' : { + 'references' : (Sdf.Reference(primPath='/Ref/Child/GrandChild'),) + }, + }) + + self.assertEqual(self._GetCompositionFieldsInLayer(layer2), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer1.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : (Sdf.Reference(layer1.identifier, '/Ref/Child'),) + }, + '/Prim3' : { + 'references' : (Sdf.Reference(layer1.identifier, + '/Ref/Child/GrandChild'),) + }, + }) + + # Both the internal reference prims in stage 1 and the "regular" + # reference prims in stage 2 will have same contents since they + # reference the same prims and define identical local specs. So, + # we create expected contents dictionaries that we can share for + # verification. + refToRefContents = { + '.' : ['refAttr', 'localAttr'], + 'Child' : { + '.' : ['childAttr', 'overChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'overGrandChildAttr'], + }, + }, + 'LocalChild' : {} + } + + refToChildContents = { + '.' : ['childAttr', 'localAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'overGrandChildAttr'], + }, + 'LocalChild' : {}, + } + + refToGrandChildContents = { + '.' : ['grandChildAttr', 'localAttr'], + 'LocalChild' : {}, + } + + # Verify the expected contents of stage 1 + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'Child' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'], + } + } + }, + 'InternalRef1' : refToRefContents, + 'InternalRef2' : refToChildContents, + 'InternalRef3' : refToGrandChildContents + }) + + # Verify the expected contents of stage 2. + self._VerifyStageContents(stage2, { + 'Prim1' : refToRefContents, + 'Prim2' : refToChildContents, + 'Prim3' : refToGrandChildContents + }) + + # Edit: Rename /Ref/Child to /Ref/RenamedChild + with self.ApplyEdits(editor, "Move /Ref/Child -> /Ref/RenamedChild"): + self.assertTrue(editor.MovePrimAtPath( + '/Ref/Child', '/Ref/RenamedChild')) + + # Verify the updated composition fields in layer1. The internal + # reference fields to /Ref/Child and its descendant + # /Ref/Child/GrandChild have been updated to use the renamed paths. + self.assertEqual(self._GetCompositionFieldsInLayer(layer1), { + '/InternalRef1' : { + 'references' : (Sdf.Reference(primPath='/Ref'),) + }, + '/InternalRef2' : { + 'references' : (Sdf.Reference(primPath='/Ref/RenamedChild'),) + }, + '/InternalRef3' : { + 'references' : (Sdf.Reference( + primPath='/Ref/RenamedChild/GrandChild'),) + }, + }) + + # Verify the udpated composition fields in layer2. The reference fields + # to /Ref/Child and its descendant /Ref/Child/GrandChild have been + # similarly updated to use the renamed paths. + self.assertEqual(self._GetCompositionFieldsInLayer(layer2), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer1.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : (Sdf.Reference(layer1.identifier, + '/Ref/RenamedChild'),) + }, + '/Prim3' : { + 'references' : (Sdf.Reference(layer1.identifier, + '/Ref/RenamedChild/GrandChild'),) + }, + }) + + # Verify the updated stage contents for both stages. + # + # For the both prims that directly reference /Ref, the child prim is + # renamed to RenamedChild. Note that this means the local override specs + # for the referencing prims have been renamed to RenamedChild too which + # is why the composed RenamedChild prim still has both childAttr and + # overChildAttr and the composed GrandChild remains unchanged + # + # The contents of the other two prims in each stage remain unchanged + # as the update to the reference fields allow those prims to remain the + # same. + refToRefContents = { + '.' : ['refAttr', 'localAttr'], + 'RenamedChild' : { + '.' : ['childAttr', 'overChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'overGrandChildAttr'], + }, + }, + 'LocalChild' : {}, + } + + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'RenamedChild' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'], + } + } + }, + 'InternalRef1' : refToRefContents, + 'InternalRef2' : refToChildContents, + 'InternalRef3' : refToGrandChildContents + }) + + self._VerifyStageContents(stage2, { + 'Prim1' : refToRefContents, + 'Prim2' : refToChildContents, + 'Prim3' : refToGrandChildContents + }) + + # Edit: Reparent and rename /Ref/RenamedChild to /MovedChild + with self.ApplyEdits(editor, "Move /Ref/RenamedChild -> /MovedChild"): + self.assertTrue(editor.MovePrimAtPath( + '/Ref/RenamedChild', '/MovedChild')) + + # Verify the udpated composition fields in layer1. The internal + # reference fields to /Ref/RenamedChild and its descendant + # /Ref/RenamedChild/GrandChild have been updated to use the moved paths. + self.assertEqual(self._GetCompositionFieldsInLayer(layer1), { + '/InternalRef1' : { + 'references' : (Sdf.Reference(primPath='/Ref'),) + }, + '/InternalRef2' : { + 'references' : (Sdf.Reference(primPath='/MovedChild'),) + }, + '/InternalRef3' : { + 'references' : (Sdf.Reference(primPath='/MovedChild/GrandChild'),) + }, + }) + + # Verify the udpated composition fields in layer2. The reference fields + # to /Ref/RenamedChild and its descendant /Ref/RenamedChild/GrandChild + # have been similarly updated to use the moved paths. + self.assertEqual(self._GetCompositionFieldsInLayer(layer2), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer1.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : (Sdf.Reference(layer1.identifier, '/MovedChild'),) + }, + '/Prim3' : { + 'references' : (Sdf.Reference(layer1.identifier, + '/MovedChild/GrandChild'),) + }, + }) + + # Verify the updated stage contents for both stages. + # + # For both prims that directly reference /Ref, since RenamedChild has + # been moved out of /Ref, it is no longer a composed child of the + # referencing prims. Note that the over to RenamedChild (which brought + # in the attributes overChildAttr and GrandChild.overChildAttr) has been + # deleted to prevent the reintroduction of a partially specced + # RenamedChild. + # + # The contents of the other two prims in each stage remain unchanged + # as the update to the reference fields allow those prims to remain the + # same. + refToRefContents = { + '.' : ['refAttr', 'localAttr'], + 'LocalChild' : {}, + } + + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + }, + 'MovedChild' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'], + } + }, + 'InternalRef1' : refToRefContents, + 'InternalRef2' : refToChildContents, + 'InternalRef3' : refToGrandChildContents + }) + + self._VerifyStageContents(stage2, { + 'Prim1' : refToRefContents, + 'Prim2' : refToChildContents, + 'Prim3' : refToGrandChildContents + }) + + # Edit: Reparent and rename /MovedChild back to its original path + # /Ref/Child + with self.ApplyEdits(editor, "Move /MovedChild -> /Ref/Child"): + self.assertTrue(editor.MovePrimAtPath('/MovedChild', '/Ref/Child')) + + # Verify the udpated composition fields in layer1 and layer2. All the + # reference fields have been updated to their original paths. + self.assertEqual(self._GetCompositionFieldsInLayer(layer1), { + '/InternalRef1' : { + 'references' : (Sdf.Reference(primPath='/Ref'),) + }, + '/InternalRef2' : { + 'references' : (Sdf.Reference(primPath='/Ref/Child'),) + }, + '/InternalRef3' : { + 'references' : (Sdf.Reference(primPath='/Ref/Child/GrandChild'),) + }, + }) + + self.assertEqual(self._GetCompositionFieldsInLayer(layer2), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer1.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : (Sdf.Reference(layer1.identifier, '/Ref/Child'),) + }, + '/Prim3' : { + 'references' : (Sdf.Reference(layer1.identifier, + '/Ref/Child/GrandChild'),) + }, + }) + + # Verify the updated stage contents for both stages. + # + # For both prims that directly reference /Ref, they are returned to + # their original contents with one notable exception: the overs on + # Child that introduced overChildAttr and GrandChild.overGrandChildAttr + # are NOT restored from being deleted so these attributes are not + # present like they were in the initial state of the stages. + # + # The contents of the other two prims in each stage remain unchanged + # (which matches their initial state) as the update to the reference + # fields allow those prims to remain the same. + refToRefContents = { + '.' : ['refAttr', 'localAttr'], + 'Child' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'] + } + }, + 'LocalChild' : {}, + } + + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'Child' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'], + } + } + }, + 'InternalRef1' : refToRefContents, + 'InternalRef2' : refToChildContents, + 'InternalRef3' : refToGrandChildContents + }) + + self._VerifyStageContents(stage2, { + 'Prim1' : refToRefContents, + 'Prim2' : refToChildContents, + 'Prim3' : refToGrandChildContents + }) + + # Reset both layers before the next operation to return the overs on the + # prims that reference /Ref + layer1.ImportFromString(layer1ImportString) + layer2.ImportFromString(layer2ImportString) + + # Verify the stage contents which again have the initial overs. + refToRefContents = { + '.' : ['refAttr', 'localAttr'], + 'Child' : { + '.' : ['childAttr', 'overChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'overGrandChildAttr'] + } + }, + 'LocalChild' : {}, + } + + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'Child' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'], + } + } + }, + 'InternalRef1' : refToRefContents, + 'InternalRef2' : refToChildContents, + 'InternalRef3' : refToGrandChildContents + }) + + self._VerifyStageContents(stage2, { + 'Prim1' : refToRefContents, + 'Prim2' : refToChildContents, + 'Prim3' : refToGrandChildContents + }) + + # Edit: Delete the prim at /Ref/Child + with self.ApplyEdits(editor, "Delete /Ref/Child"): + self.assertTrue(editor.DeletePrimAtPath('/Ref/Child')) + + # Verify the udpated composition fields in layer1 and layer2. All the + # reference fields that reference /Ref/Child or its descendants have + # had those references removed. Note the reference fields remain but the + # values are empty. + self.assertEqual(self._GetCompositionFieldsInLayer(layer1), { + '/InternalRef1' : { + 'references' : (Sdf.Reference(primPath='/Ref'),) + }, + '/InternalRef2' : { + 'references' : () + }, + '/InternalRef3' : { + 'references' : () + }, + }) + + self.assertEqual(self._GetCompositionFieldsInLayer(layer2), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer1.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : () + }, + '/Prim3' : { + 'references' : () + }, + }) + + # Verify the updated stage contents for both stages. + # + # For both prims that directly reference /Ref, since Child has been + # deleted as a child of from /Ref, it is no longer a composed child of + # these referencing prims. Note that the overs to Child (which brought + # in the attributes overChildAttr and GrandChild.overChildAttr) have + # been deleted to prevent the reintroduction of a partially specced + # Child. + # + # Unlike all the prior edits in this test case, the contents of the + # other two prims in each stage DO change because the references have + # been deleted and can no longer compose contents from across them. + # Addtionally any child specs in the referencing prims that would've + # comosed over the now deleted referenced prim's children are also + # deleted to "truly delete" all composed prims from the deleted + # reference. + # + # XXX: There is an open question as to whether this is the correct + # behavior or if we should go a step further and delete the specs that + # introduced the now deleted reference prims (instead of just removing + # the reference but not the referencing prim itself like we do now). + # This expanded approach would result in the InternalRef2, InternalRef3, + # Prim2, and Prim3 prims being completely deleted from their stages. + refToRefContents = { + '.' : ['refAttr', 'localAttr'], + 'LocalChild' : {}, + } + + refToChildContents = { + '.' : ['localAttr'], + 'LocalChild' : {}, + } + + refToGrandChildContents = { + '.' : ['localAttr'], + 'LocalChild' : {}, + } + + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + }, + 'InternalRef1' : refToRefContents, + 'InternalRef2' : refToChildContents, + 'InternalRef3' : refToGrandChildContents + }) + + self._VerifyStageContents(stage2, { + 'Prim1' : refToRefContents, + 'Prim2' : refToChildContents, + 'Prim3' : refToGrandChildContents + }) + + def test_BasicDependentPayloads(self): + """Test downstream dependency namespace edits across basic single + payloads.""" + + # Setup: + # Layer 1 has simple hierarchy of /Ref, Child, GrandChild that is + # referenced and will be namespace edited. + layer1 = Sdf.Layer.CreateAnonymous("layer1.usda") + layer1.ImportFromString('''#usda 1.0 + def "Ref" { + int refAttr + + def "Child" { + int childAttr + + def "GrandChild" { + int grandChildAttr + } + } + } + ''') + + # Layer 2 has three prims that payload /Ref, /Ref/Child, and + # /Ref/Child/GrandChild from layer 1 respectively. These will be + # affected by downstream dependency edits. + layer2 = Sdf.Layer.CreateAnonymous("layer2.usda") + layer2.ImportFromString('''#usda 1.0 + def "Prim1" ( + payload = @''' + layer1.identifier + '''@ + ) { + over "Child" { + int overChildAttr + over "GrandChild" { + int overGrandChildAttr + } + } + def "LocalChild" {} + int localAttr + } + + def "Prim2" ( + payload = @''' + layer1.identifier + '''@ + ) { + int overChildAttr + over "GrandChild" { + int overGrandChildAttr + } + def "LocalChild" {} + int localAttr + } + + def "Prim3" ( + payload = @''' + layer1.identifier + '''@ + ) { + def "LocalChild" {} + int localAttr + } + ''') + + # Open both layers as stages. + stage1 = Usd.Stage.Open(layer1, Usd.Stage.LoadAll) + stage2 = Usd.Stage.Open(layer2, Usd.Stage.LoadAll) + + # Create an editor for stage 1 with stage 2 as an addtional dependent + # stage. + editor = Usd.NamespaceEditor(stage1) + editor.AddDependentStage(stage2) + + # Verify the initial composition fields for both layer 2 (layer 1 has + # no composition fields). + self.assertEqual(self._GetCompositionFieldsInLayer(layer1), {}) + self.assertEqual(self._GetCompositionFieldsInLayer(layer2), { + '/Prim1' : { + 'payload' : (Sdf.Payload(layer1.identifier, '/Ref'),) + }, + '/Prim2' : { + 'payload' : (Sdf.Payload(layer1.identifier, '/Ref/Child'),) + }, + '/Prim3' : { + 'payload' : (Sdf.Payload(layer1.identifier, + '/Ref/Child/GrandChild'),) + }, + }) + + # Verify the initial simple hierarchy in stage 1. + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'Child' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'] + } + } + } + }) + + # Verify the initial composed prim contents for each prim in stage 2. + # Note that all prims are loaded at the start so all payload contents + # are composed with local prim specs. + prim1Contents = { + '.' : ['refAttr', 'localAttr'], + 'Child' : { + '.' : ['childAttr', 'overChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'overGrandChildAttr'] + }, + }, + 'LocalChild' : {}, + } + + prim2Contents = { + '.' : ['childAttr', 'overChildAttr', 'localAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'overGrandChildAttr'] + }, + 'LocalChild' : {}, + } + + prim3Contents = { + '.' : ['grandChildAttr', 'localAttr'], + 'LocalChild' : {}, + } + + self._VerifyStageContents(stage2, { + 'Prim1' : prim1Contents, + 'Prim2' : prim2Contents, + 'Prim3' : prim3Contents + }) + + # Edit: Rename /Ref/Child to /Ref/RenamedChild + with self.ApplyEdits(editor, "Move /Ref/Child -> /Ref/RenamedChild"): + self.assertTrue(editor.MovePrimAtPath( + '/Ref/Child', '/Ref/RenamedChild')) + + # Verify the udpated composition fields in layer2. The payload fields to + # /Ref/Child and its descendant /Ref/Child/GrandChild have been updated + # to use the renamed paths because all prims are currently loaded. + self.assertEqual(self._GetCompositionFieldsInLayer(layer2), { + '/Prim1' : { + 'payload' : (Sdf.Payload(layer1.identifier, '/Ref'),) + }, + '/Prim2' : { + 'payload' : (Sdf.Payload(layer1.identifier, '/Ref/RenamedChild'),) + }, + '/Prim3' : { + 'payload' : (Sdf.Payload(layer1.identifier, + '/Ref/RenamedChild/GrandChild'),) + }, + }) + + # Verify the expected simple rename in stage 1. + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'RenamedChild' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'] + } + } + }, + }) + + # Verify the updated contents for stage 2. + # + # For /Prim1 which directly references /Ref, the child prim is renamed + # to RenamedChild. And just like with references, this means the local + # override specs for the prims introducing the payloads have been + # renamed to RenamedChild. + # + # The contents of the other two prims in each stage remain unchanged + # as the update to the payload fields allow those prims to remain the + # same. + prim1Contents = { + '.' : ['refAttr', 'localAttr'], + 'RenamedChild' : { + '.' : ['childAttr', 'overChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'overGrandChildAttr'] + }, + }, + 'LocalChild' : {}, + } + + self._VerifyStageContents(stage2, { + 'Prim1' : prim1Contents, + 'Prim2' : prim2Contents, + 'Prim3' : prim3Contents + }) + + # Now unload /Prim1 and /Prim3 so that we can demonstrate the one way + # that payload dependencies deviate from references. + stage2.Unload('/Prim1') + stage2.Unload('/Prim3') + + # Verify the contents of stage 2 with the prims unloaded. + # + # /Prim1 and /Prim3 are only composed from the their local opinions + # without the opinions from their payloads in layer 1 + prim1Contents = { + '.' : ['localAttr'], + 'RenamedChild' : { + '.' : ['overChildAttr'], + 'GrandChild' : { + '.' : ['overGrandChildAttr'], + }, + }, + 'LocalChild' : {}, + } + + prim3Contents = { + '.' : ['localAttr'], + 'LocalChild' : {}, + } + + self._VerifyStageContents(stage2, { + 'Prim1' : prim1Contents, + 'Prim2' : prim2Contents, + 'Prim3' : prim3Contents + }) + + # Edit: Rename /Ref/RenamedChild back to /Ref/Child + with self.ApplyEdits(editor, "Move /Ref/RenamedChild -> /Ref/Child"): + self.assertTrue(editor.MovePrimAtPath( + '/Ref/RenamedChild', '/Ref/Child')) + + # Verify the udpated composition fields in layer2. ONLY the payload for + # the still loaded /Prim2 is updated. The payload for /Prim1 would've + # been unaffected regardless of the load state, but /Prim3's payload + # can't be updated solely because it is unloaded. + self.assertEqual(self._GetCompositionFieldsInLayer(layer2), { + '/Prim1' : { + 'payload' : (Sdf.Payload(layer1.identifier, '/Ref'),) + }, + '/Prim2' : { + 'payload' : (Sdf.Payload(layer1.identifier, '/Ref/Child'),) + }, + '/Prim3' : { + 'payload' : (Sdf.Payload(layer1.identifier, + '/Ref/RenamedChild/GrandChild'),) + }, + }) + + # Verify the contents for stage 2 + # + # NONE of the prim contents have changed but for a different reasons. + # /Prim1 and /Prim3 have not changed because the payloads are unloaded + # and there is no dependency on the payload path for which to propagate + # dependent edits. + # /Prim2 is unchanged because the loaded payload's path has been updated + # to the new path. + self._VerifyStageContents(stage2, { + 'Prim1' : prim1Contents, + 'Prim2' : prim2Contents, + 'Prim3' : prim3Contents + }) + + # Now load /Prim1 and /Prim3 again. Loading /Prim3 will emit warnings + # because of the payload points to path that no longer exists in layer1. + stage2.Load('/Prim1') + print("\n=== EXPECT WARNINGS ===", file=sys.stderr) + stage2.Load('/Prim3') + print("\n=== END EXPECTED WARNINGS ===", file=sys.stderr) + + # Verify the post-edit contents for stage 2 now with all prims loaded. + # + # The contents of /Prim1 and /Prim3 with payloads loaded show how we + # couldn't correctly update the dependent paths for the unloaded + # payloads when doing the prior rename back. + # + # The now loaded /Prim1 is in a partially edited state as we weren't + # able to move the the local RenamedChild specs back to Child while the + # prim was unloaded. + # + # The now loaded /Prim3 is unchanged from its unloaded state as the + # payload path still points to /Ref/RenamedChild/GrandChild which no + # longer exists at that path (and we have an unresolved payload + # composition error on this prim now). + prim1Contents = { + '.' : ['refAttr', 'localAttr'], + 'Child' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'] + }, + }, + 'RenamedChild' : { + '.' : ['overChildAttr'], + 'GrandChild' : { + '.' : ['overGrandChildAttr'], + }, + }, + 'LocalChild' : {}, + } + + self._VerifyStageContents(stage2, { + 'Prim1' : prim1Contents, + 'Prim2' : prim2Contents, + 'Prim3' : prim3Contents + }) + + def test_BasicNestedReferences(self): + """Test downstream dependency name space edits across chains of + references.""" + + # Setup: + # Layer 1 has simple hierarchy of /Ref, Child, GrandChild that is + # referenced and will be namespace edited. + layer1 = Sdf.Layer.CreateAnonymous("layer1.usda") + layer1.ImportFromString('''#usda 1.0 + def "Ref" { + int refAttr + + def "Child" { + int childAttr + + def "GrandChild" { + int grandChildAttr + } + } + } + ''') + + # Layer 2 has three prims that reference /Ref, /Ref/Child, and + # /Ref/Child/GrandChild from layer 1 respectively. These will be + # affected by downstream dependency edits. + layer2 = Sdf.Layer.CreateAnonymous("layer2.usda") + layer2.ImportFromString('''#usda 1.0 + def "Prim1" ( + references = @''' + layer1.identifier + '''@ + ) { + over "Child" { + int over1ChildAttr + over "GrandChild" { + int over1GrandChildAttr + } + } + def "Prim1_LocalChild" {} + int prim1_localAttr + } + + def "Prim2" ( + references = @''' + layer1.identifier + '''@ + ) { + over "GrandChild" { + int over2GrandChildAttr + } + def "Prim2_LocalChild" {} + int prim2_localAttr + } + + def "Prim3" ( + references = @''' + layer1.identifier + '''@ + ) { + def "Prim3_LocalChild" {} + int prim3_LocalAttr + } + ''') + + # Layer3 has multiple prims that each reference the possible + # prims in layer2 in order to test the various permutations of direct + # and ancestral reference chains. + # /Prim4 : References /Prim1 which directly references /Ref + # /Prim4_A : References /Prim1/Child which ancestrally references + # /Ref/Child + # /Prim4_B : References /Prim1/Child/GrandChild which ancestrally + # references /Ref/Child/GrandChild + # /Prim5 : References /Prim2 which directly references /Ref/Child + # /Prim5_A : References /Prim2/GrandChild which ancestrally references + # /Ref/Child/GrandChild + # /Prim6 : References /Prim3 which directly references + # /Ref/Child/GrandChild + layer3 = Sdf.Layer.CreateAnonymous("layer3.usda") + layer3.ImportFromString('''#usda 1.0 + def "Prim4" ( + references = @''' + layer2.identifier + '''@ + ) { + over "Child" { + int over4ChildAttr + over "GrandChild" { + int over4GrandChildAttr + } + } + def "LocalChild" {} + int localAttr + } + + def "Prim4_A" ( + references = @''' + layer2.identifier + '''@ + ) { + over "GrandChild" { + int over4_AGrandChildAttr + } + def "LocalChild" {} + int localAttr + } + + def "Prim4_B" ( + references = @''' + layer2.identifier + '''@ + ) { + def "LocalChild" {} + int localAttr + } + + def "Prim5" ( + references = @''' + layer2.identifier + '''@ + ) { + over "GrandChild" { + int over5GrandChildAttr + } + def "LocalChild" {} + int localAttr + } + + def "Prim5_A" ( + references = @''' + layer2.identifier + '''@ + ) { + def "LocalChild" {} + int localAttr + } + + def "Prim6" ( + references = @''' + layer2.identifier + '''@ + ) { + def "LocalChild" {} + int localAttr + } + ''') + + # Open all three layers as stages. + stage1 = Usd.Stage.Open(layer1, Usd.Stage.LoadAll) + stage2 = Usd.Stage.Open(layer2, Usd.Stage.LoadAll) + stage3 = Usd.Stage.Open(layer3, Usd.Stage.LoadAll) + + # Create an editor for stage1 with ONLY stage 3 as a dependent stage + # (i.e. excluding stage 2). This will still cause edits to layer2 when + # layer1 is edited as stage3 has dependencies on layer 2 and thus, these + # changes will be reflected in stage 2. + editor = Usd.NamespaceEditor(stage1) + editor.AddDependentStage(stage3) + + # Verify the initial composition fields for each layer. + self.assertEqual(self._GetCompositionFieldsInLayer(layer1), {}) + + self.assertEqual(self._GetCompositionFieldsInLayer(layer2), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer1.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : (Sdf.Reference(layer1.identifier, '/Ref/Child'),) + }, + '/Prim3' : { + 'references' : (Sdf.Reference(layer1.identifier, + '/Ref/Child/GrandChild'),) + }, + }) + + self.assertEqual(self._GetCompositionFieldsInLayer(layer3), { + '/Prim4' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim1'),) + }, + '/Prim4_A' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim1/Child'),) + }, + '/Prim4_B' : { + 'references' : (Sdf.Reference(layer2.identifier, + '/Prim1/Child/GrandChild'),) + }, + '/Prim5' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim2'),) + }, + '/Prim5_A' : { + 'references' : (Sdf.Reference(layer2.identifier, + '/Prim2/GrandChild'),) + }, + '/Prim6' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim3'),) + }, + }) + + # Verify the initial contents of stage 1. + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'Child' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'] + } + } + }, + }) + + # Verify the initial contents of stage 2 with its three single + # reference composed prims + prim1Contents = { + '.' : ['refAttr', 'prim1_localAttr'], + 'Child' : { + '.' : ['childAttr', 'over1ChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over1GrandChildAttr'] + }, + }, + 'Prim1_LocalChild' : {}, + } + + prim2Contents = { + '.' : ['childAttr', 'prim2_localAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over2GrandChildAttr'] + }, + 'Prim2_LocalChild' : {}, + } + + prim3Contents = { + '.' : ['grandChildAttr', 'prim3_LocalAttr'], + 'Prim3_LocalChild' : {}, + } + + self._VerifyStageContents(stage2, { + 'Prim1' : prim1Contents, + 'Prim2' : prim2Contents, + 'Prim3' : prim3Contents + }) + + # Verify the initial contents of stage 3 with its all its prims composed + # from 2-chain references + prim4Contents = { + '.' : ['refAttr', 'prim1_localAttr', 'localAttr'], + 'Child' : { + '.' : ['childAttr', 'over1ChildAttr', 'over4ChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over1GrandChildAttr', + 'over4GrandChildAttr'] + }, + }, + 'Prim1_LocalChild' : {}, + 'LocalChild' : {}, + } + + prim4_AContents = { + '.' : ['childAttr', 'over1ChildAttr', 'localAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over1GrandChildAttr', + 'over4_AGrandChildAttr'] + }, + 'LocalChild' : {}, + } + + prim4_BContents = { + '.' : ['grandChildAttr', 'over1GrandChildAttr', 'localAttr'], + 'LocalChild' : {}, + } + + prim5Contents = { + '.' : ['childAttr', 'prim2_localAttr', 'localAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over2GrandChildAttr', + 'over5GrandChildAttr'] + }, + 'Prim2_LocalChild' : {}, + 'LocalChild' : {}, + } + + prim5_AContents = { + '.' : ['grandChildAttr', 'over2GrandChildAttr', 'localAttr'], + 'LocalChild' : {}, + } + + prim6Contents = { + '.' : ['grandChildAttr', 'prim3_LocalAttr', 'localAttr'], + 'Prim3_LocalChild' : {}, + 'LocalChild' : {}, + } + + self._VerifyStageContents(stage3, { + 'Prim4' : prim4Contents, + 'Prim4_A' : prim4_AContents, + 'Prim4_B' : prim4_BContents, + 'Prim5' : prim5Contents, + 'Prim5_A' : prim5_AContents, + 'Prim6' : prim6Contents + }) + + # Edit: Rename /Ref/Child to /Ref/RenamedChild on stage 1. + with self.ApplyEdits(editor, "Move /Ref/Child -> /Ref/RenamedChild"): + self.assertTrue(editor.MovePrimAtPath( + '/Ref/Child', '/Ref/RenamedChild')) + + # Verify the udpated composition fields in layer2. The reference fields + # to /Ref/Child and its descendant /Ref/Child/GrandChild have been + # updated to use the renamed paths. + self.assertEqual(self._GetCompositionFieldsInLayer(layer2), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer1.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : (Sdf.Reference(layer1.identifier, + '/Ref/RenamedChild'),) + }, + '/Prim3' : { + 'references' : (Sdf.Reference(layer1.identifier, + '/Ref/RenamedChild/GrandChild'),) + }, + }) + + # Verify the udpated composition fields in layer3. The reference + # fields to /Prim1/Child and its descendant /Prim1/Child/GrandChild have + # to be updated as all the specs composing /Prim1/Child are renamed to + # RenamedChild by the dependent edits. + self.assertEqual(self._GetCompositionFieldsInLayer(layer3), { + '/Prim4' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim1'),) + }, + '/Prim4_A' : { + 'references' : (Sdf.Reference(layer2.identifier, + '/Prim1/RenamedChild'),) + }, + '/Prim4_B' : { + 'references' : (Sdf.Reference(layer2.identifier, + '/Prim1/RenamedChild/GrandChild'),) + }, + '/Prim5' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim2'),) + }, + '/Prim5_A' : { + 'references' : (Sdf.Reference(layer2.identifier, + '/Prim2/GrandChild'),) + }, + '/Prim6' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim3'),) + }, + }) + + # Verify the simple prim rename is reflected in contents of stage 1. + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'RenamedChild' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'] + } + } + }, + }) + + # Verify the udpated contents of stage 2. + # + # There are prims in stage 3 that reference /Prim1/Child on layer2 so + # which ancestrally references /Ref/Child. So the specs for /Prim1/Child + # on layer 2 are renamed to RenamedChild for this dependency. This + # change is reflected in the contents of stage 2. + # + # Stage 3 also has prims with dependencies on /Prim2 and /Prim3, but + # the contents of those two prims remain the same as the reference paths + # are just updated to /Ref/RenamedChild and /Ref/RenamedChild/GrandChild. + prim1Contents = { + '.' : ['refAttr', 'prim1_localAttr'], + 'RenamedChild' : { + '.' : ['childAttr', 'over1ChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over1GrandChildAttr'] + }, + }, + 'Prim1_LocalChild' : {}, + } + + self._VerifyStageContents(stage2, { + 'Prim1' : prim1Contents, + 'Prim2' : prim2Contents, + 'Prim3' : prim3Contents + }) + + # Verify the updated contents of stage 3. + # + # /Prim4 references /Prim1 which references /Ref so /Prim4/Child is also + # renamed to /Prim4/RenamedChild. + # No other prims' contents change as they each had one of their nested + # references arcs updated to the new path. + prim4Contents = { + '.' : ['refAttr', 'prim1_localAttr', 'localAttr'], + 'RenamedChild' : { + '.' : ['childAttr', 'over1ChildAttr', 'over4ChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over1GrandChildAttr', + 'over4GrandChildAttr'] + }, + }, + 'Prim1_LocalChild' : {}, + 'LocalChild' : {}, + } + + self._VerifyStageContents(stage3, { + 'Prim4' : prim4Contents, + 'Prim4_A' : prim4_AContents, + 'Prim4_B' : prim4_BContents, + 'Prim5' : prim5Contents, + 'Prim5_A' : prim5_AContents, + 'Prim6' : prim6Contents + }) + + # Edit: Reparent and rename /Ref/RenamedChild to /MovedChild + with self.ApplyEdits(editor, "Move /Ref/RenamedChild -> /MovedChild"): + self.assertTrue(editor.MovePrimAtPath( + '/Ref/RenamedChild', '/MovedChild')) + + # Verify the udpated composition fields in layer2. The reference fields + # to /Ref/RenamedChild and its descendant /Ref/RenamedChild/GrandChild + # have been updated to use the moved paths. + self.assertEqual(self._GetCompositionFieldsInLayer(layer2), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer1.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : (Sdf.Reference(layer1.identifier, '/MovedChild'),) + }, + '/Prim3' : { + 'references' : (Sdf.Reference(layer1.identifier, + '/MovedChild/GrandChild'),) + }, + }) + + # Verify the udpated composition fields in layer3. Like with the + # previous edit, the reference fields to /Prim1/RenamedChild and + # its descendant /Prim1/RenamedChild/GrandChild have to be updated as + # all the specs composing /Prim1/RenameChild have been moved by the + # dependent edits. However, since RenamedChild was moved out /Ref, it no + # longer maps across the reference to /Prim1 which results in the + # deletion of the composed /Prim1/RenamedChild. So the reference fields + # for /Prim4_A and /Prim4_B are updated to delete these references to + # prims that no longer exist in layer2. + self.assertEqual(self._GetCompositionFieldsInLayer(layer3), { + '/Prim4' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim1'),) + }, + '/Prim4_A' : { + 'references' : () + }, + '/Prim4_B' : { + 'references' : () + }, + '/Prim5' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim2'),) + }, + '/Prim5_A' : { + 'references' : (Sdf.Reference(layer2.identifier, + '/Prim2/GrandChild'),) + }, + '/Prim6' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim3'),) + }, + }) + + # Verify the simple reparent and rename is reflected in contents of + # stage 1. + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + }, + 'MovedChild' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'] + } + } + }) + + # Verify the udpated contents of stage 2. + # + # There are prims in stage 3 that reference /Prim1/RenamedChild on + # layer2 which ancestrally references /Ref/RenamedChild. So the specs + # for /Prim1/RenamedChild on layer 2 are deleted for this dependency + # (since the RenamedChild was moved out of the reference). This change + # is reflected in the contents of stage 2. + # + # Stage 3 also has prims with dependencies on /Prim2 and /Prim3, but + # these contents remain the same as the reference paths are + # just updated to /MovedChild and /MovedChild/GrandChild. + prim1Contents = { + '.' : ['refAttr', 'prim1_localAttr'], + 'Prim1_LocalChild' : {}, + } + + self._VerifyStageContents(stage2, { + 'Prim1' : prim1Contents, + 'Prim2' : prim2Contents, + 'Prim3' : prim3Contents + }) + + # Verify the updated contents of stage 3. + # + # /Prim4 references /Prim1 which references /Ref so /Prim4/RenamedChild + # is also deleted. /Prim4_A and /Prim4_B have lost their references so + # these also only have the contents of their local specs. + # + # The rest of the prims have no contents change as they each had one of + # their nested references arcs updated to the new path. + prim4Contents = { + '.' : ['refAttr', 'prim1_localAttr', 'localAttr'], + 'Prim1_LocalChild' : {}, + 'LocalChild' : {}, + } + + prim4_AContents = { + '.' : ['localAttr'], + 'LocalChild' : {}, + } + + prim4_BContents = { + '.' : ['localAttr'], + 'LocalChild' : {}, + } + + self._VerifyStageContents(stage3, { + 'Prim4' : prim4Contents, + 'Prim4_A' : prim4_AContents, + 'Prim4_B' : prim4_BContents, + 'Prim5' : prim5Contents, + 'Prim5_A' : prim5_AContents, + 'Prim6' : prim6Contents + }) + + # Edit: Reparent and rename /MovedChild back to its original path + # /Ref/Child + with self.ApplyEdits(editor, "Move /MovedChild -> /Ref/Child"): + self.assertTrue(editor.MovePrimAtPath('/MovedChild', '/Ref/Child')) + + # Verify the udpated composition fields in layer2. The reference fields + # have all been updated to their original paths. + self.assertEqual(self._GetCompositionFieldsInLayer(layer2), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer1.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : (Sdf.Reference(layer1.identifier, '/Ref/Child'),) + }, + '/Prim3' : { + 'references' : (Sdf.Reference(layer1.identifier, + '/Ref/Child/GrandChild'),) + }, + }) + + # Verify the udpated composition fields in layer3 which have NOT changed + # because the prior edit deleted both references that initially + # referred to /Prim1/Child. + self.assertEqual(self._GetCompositionFieldsInLayer(layer3), { + '/Prim4' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim1'),) + }, + '/Prim4_A' : { + 'references' : () + }, + '/Prim4_B' : { + 'references' : () + }, + '/Prim5' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim2'),) + }, + '/Prim5_A' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim2/GrandChild'),) + }, + '/Prim6' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim3'),) + }, + }) + + # Verify the return to the the original contents in stage 1. + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'Child' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'] + } + } + }, + }) + + # Verify the udpated contents of stage 2. + # + # The contents of /Prim1 have returned to the original contents with + # the exception that the local opinions for Child and GrandChild in + # layer2 were deleted in the prior edit and cannot be restored. + # + # /Prim2 and /Prim3 remain unchanged. + prim1Contents = { + '.' : ['refAttr', 'prim1_localAttr'], + 'Child' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'] + }, + }, + 'Prim1_LocalChild' : {}, + } + + self._VerifyStageContents(stage2, { + 'Prim1' : prim1Contents, + 'Prim2' : prim2Contents, + 'Prim3' : prim3Contents + }) + + # Verify the updated contents of stage 3. + # + # /Prim4 returns to its original contents with the exception that + # deleted local opinions on layer3 for Child and the deleted opinions + # from /Prim1/Child on layer2 cannot be restored. + # + # /Prim4_A and /Prim4_B remain unchanged (and therefore unrestored) + # because their references were deleted by the previous edit. + # + # The rest of the prims continue to have no contents change as they each + # had one of their nested references arcs updated to the original path. + prim4Contents = { + '.' : ['refAttr', 'prim1_localAttr', 'localAttr'], + 'Child' : { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'] + }, + }, + 'Prim1_LocalChild' : {}, + 'LocalChild' : {}, + } + + self._VerifyStageContents(stage3, { + 'Prim4' : prim4Contents, + 'Prim4_A' : prim4_AContents, + 'Prim4_B' : prim4_BContents, + 'Prim5' : prim5Contents, + 'Prim5_A' : prim5_AContents, + 'Prim6' : prim6Contents + }) + + # Edit: Delete /Ref/Child + with self.ApplyEdits(editor, "Delete /Ref/Child"): + self.assertTrue(editor.DeletePrimAtPath('/Ref/Child')) + + # Verify the udpated composition fields in layer2. The reference fields + # to /Ref/Child and its descendant /Ref/Child/GrandChild have been + # set to empty now that those prims don't exist on layer1 + self.assertEqual(self._GetCompositionFieldsInLayer(layer2), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer1.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : () + }, + '/Prim3' : { + 'references' : () + }, + }) + + # Verify the udpated composition fields in layer3. The only change now + # is that /Prim5_A's reference to /Prim2/GrandChild has been deleted as + # /Prim2/GrandChild is no a valid composed prim of layer2. + self.assertEqual(self._GetCompositionFieldsInLayer(layer3), { + '/Prim4' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim1'),) + }, + '/Prim4_A' : { + 'references' : () + }, + '/Prim4_B' : { + 'references' : () + }, + '/Prim5' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim2'),) + }, + '/Prim5_A' : { + 'references' : () + }, + '/Prim6' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Prim3'),) + }, + }) + + # Verify the deletion of Child on stage 1. + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + }, + }) + + # Verify the udpated contents of stage 2. + # + # The contents of /Prim1 no longer have the child Child. + # + # /Prim2 and /Prim3 have lost their references so only have local + # opinions from layer2. + prim1Contents = { + '.' : ['refAttr', 'prim1_localAttr'], + 'Prim1_LocalChild' : {}, + } + + prim2Contents = { + '.' : ['prim2_localAttr'], + 'Prim2_LocalChild' : {}, + } + + prim3Contents = { + '.' : ['prim3_LocalAttr'], + 'Prim3_LocalChild' : {}, + } + + self._VerifyStageContents(stage2, { + 'Prim1' : prim1Contents, + 'Prim2' : prim2Contents, + 'Prim3' : prim3Contents + }) + + # Verify the updated contents of stage 3. + # + # /Prim4 loses all opinions about Child. + # + # /Prim4_A and /Prim4_B remain unchanged still because of the prior + # deleted references. + # + # /Prim5 and /Prim6 are affected by the deletion of the references on + # /Prim2 and /Prim3 respectively, but they still composed the layer2 + # local opinions from /Prim2 and /Prim3 + # + # /Prim5_A only has its own local opinions because its own reference + # has also been deleted. + prim4Contents = { + '.' : ['refAttr', 'prim1_localAttr', 'localAttr'], + 'Prim1_LocalChild' : {}, + 'LocalChild' : {}, + } + + prim5Contents = { + '.' : ['prim2_localAttr', 'localAttr'], + 'Prim2_LocalChild' : {}, + 'LocalChild' : {}, + } + + prim5_AContents = { + '.' : ['localAttr'], + 'LocalChild' : {}, + } + + prim6Contents = { + '.' : ['prim3_LocalAttr', 'localAttr'], + 'Prim3_LocalChild' : {}, + 'LocalChild' : {}, + } + + self._VerifyStageContents(stage3, { + 'Prim4' : prim4Contents, + 'Prim4_A' : prim4_AContents, + 'Prim4_B' : prim4_BContents, + 'Prim5' : prim5Contents, + 'Prim5_A' : prim5_AContents, + 'Prim6' : prim6Contents + }) + +if __name__ == '__main__': + unittest.main() From 7596547caf00f96ece963a6d72d0efd57010159c Mon Sep 17 00:00:00 2001 From: matthewcpp Date: Tue, 15 Oct 2024 13:17:44 -0700 Subject: [PATCH 039/300] This changes addresses a behavorial difference that appeared in 23.11 relating to UsdUtils.ExtractExternalReferences. In previous versions, udim paths would not be resolved during this function call. This change restores that behavior by disabling udim resolution for ExtractExternalReferences. Fixes #3173 (Internal change: 2344689) --- pxr/usd/usdUtils/CMakeLists.txt | 24 +++++++++++++++++ pxr/usd/usdUtils/assetLocalization.cpp | 6 +++-- pxr/usd/usdUtils/assetLocalization.h | 17 +++++++++--- pxr/usd/usdUtils/dependencies.cpp | 5 ++-- pxr/usd/usdUtils/dependencies.h | 26 ++++++++++++++++++- .../testUsdUtilsDependencyExtractor.py | 7 ++++- .../baseline/udims-resolved.txt | 4 +++ .../baseline/udims.txt | 3 +++ .../udims/root.usda | 5 ++++ .../udims/test.1001.txt | 1 + .../udims/test.1002.txt | 1 + pxr/usd/usdUtils/usdzPackage.cpp | 10 ++++++- pxr/usd/usdUtils/wrapDependencies.cpp | 14 +++++++--- 13 files changed, 110 insertions(+), 13 deletions(-) create mode 100644 pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/baseline/udims-resolved.txt create mode 100644 pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/baseline/udims.txt create mode 100644 pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/udims/root.usda create mode 100644 pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/udims/test.1001.txt create mode 100644 pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/udims/test.1002.txt diff --git a/pxr/usd/usdUtils/CMakeLists.txt b/pxr/usd/usdUtils/CMakeLists.txt index dd0605106f..e358361d5d 100644 --- a/pxr/usd/usdUtils/CMakeLists.txt +++ b/pxr/usd/usdUtils/CMakeLists.txt @@ -246,6 +246,16 @@ pxr_install_test_dir( DEST testUsdUtilsDependencyExtractor5 ) +pxr_install_test_dir( + SRC testenv/testUsdUtilsDependencyExtractor + DEST testUsdUtilsDependencyExtractor6 +) + +pxr_install_test_dir( + SRC testenv/testUsdUtilsDependencyExtractor + DEST testUsdUtilsDependencyExtractor7 +) + pxr_install_test_dir( SRC testenv/testUsdUtilsFlattenLayerStack DEST testUsdUtilsFlattenLayerStack @@ -590,6 +600,20 @@ pxr_register_test(testUsdUtilsDependencyExtractor5 EXPECTED_RETURN_CODE 0 ) +pxr_register_test(testUsdUtilsDependencyExtractor6 + PYTHON + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdUtilsDependencyExtractor udims/root.usda udims.txt" + DIFF_COMPARE udims.txt + EXPECTED_RETURN_CODE 0 +) + +pxr_register_test(testUsdUtilsDependencyExtractor7 + PYTHON + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdUtilsDependencyExtractor --resolve-udim-paths udims/root.usda udims-resolved.txt" + DIFF_COMPARE udims-resolved.txt + EXPECTED_RETURN_CODE 0 +) + pxr_register_test(testUsdUtilsFlattenLayerStack PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdUtilsFlattenLayerStack" diff --git a/pxr/usd/usdUtils/assetLocalization.cpp b/pxr/usd/usdUtils/assetLocalization.cpp index 1df66c4fdb..9e830681cd 100644 --- a/pxr/usd/usdUtils/assetLocalization.cpp +++ b/pxr/usd/usdUtils/assetLocalization.cpp @@ -527,7 +527,7 @@ UsdUtils_LocalizationContext::_GetUdimTiles( { std::vector additionalPaths; - if (!UsdShadeUdimUtils::IsUdimIdentifier(assetPath)) { + if (!_resolveUdimPaths || !UsdShadeUdimUtils::IsUdimIdentifier(assetPath)) { return additionalPaths; } @@ -631,7 +631,8 @@ void UsdUtils_ExtractExternalReferences( const UsdUtils_LocalizationContext::ReferenceType refTypesToInclude, std::vector* outSublayers, std::vector* outReferences, - std::vector* outPayloads) + std::vector* outPayloads, + const UsdUtilsExtractExternalReferencesParams& params) { TRACE_FUNCTION(); @@ -643,6 +644,7 @@ void UsdUtils_ExtractExternalReferences( UsdUtils_LocalizationContext context(&delegate); context.SetRefTypesToInclude(refTypesToInclude); context.SetRecurseLayerDependencies(false); + context.SetResolveUdimPaths(params.GetResolveUdimPaths()); context.Process(SdfLayer::FindOrOpen(filePath)); client.SortAndRemoveDuplicates(); diff --git a/pxr/usd/usdUtils/assetLocalization.h b/pxr/usd/usdUtils/assetLocalization.h index 4150879698..d579fbfdbd 100644 --- a/pxr/usd/usdUtils/assetLocalization.h +++ b/pxr/usd/usdUtils/assetLocalization.h @@ -88,6 +88,13 @@ class UsdUtils_LocalizationContext { dependenciesToSkip.end()); } + // Controls udim path resolution. + // If this value is set to false, asset paths containing udim patterns + // be re returned untouched. + inline void SetResolveUdimPaths(bool resolveUdimPaths) { + _resolveUdimPaths = resolveUdimPaths; + } + private: void _ProcessLayer(const SdfLayerRefPtr& layer); void _ProcessSublayers(const SdfLayerRefPtr& layer); @@ -111,11 +118,11 @@ class UsdUtils_LocalizationContext { bool processingMetadata = false); // Searches for udim tiles associated with the given asset path. - static std::vector _GetUdimTiles(const SdfLayerRefPtr& layer, + std::vector _GetUdimTiles(const SdfLayerRefPtr& layer, const std::string &assetPath); // Discovers all dependencies for the supplied asset path - static std::vector _GetDependencies(const SdfLayerRefPtr& layer, + std::vector _GetDependencies(const SdfLayerRefPtr& layer, const std::string &assetPath); // Searches for the clips of a given templated string @@ -158,6 +165,9 @@ class UsdUtils_LocalizationContext { // Specifies if metadata filtering should be enabled bool _metadataFilteringEnabled = false; + // Specifies if udim paths should be resolved during processing. + bool _resolveUdimPaths = true; + // user supplied list of dependencies that will be skipped when // processing the asset std::unordered_set _dependenciesToSkip; @@ -168,7 +178,8 @@ void UsdUtils_ExtractExternalReferences( const UsdUtils_LocalizationContext::ReferenceType refTypesToInclude, std::vector* subLayers, std::vector* references, - std::vector* payloads); + std::vector* payloads, + const UsdUtilsExtractExternalReferencesParams& params = {}); PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usd/usdUtils/dependencies.cpp b/pxr/usd/usdUtils/dependencies.cpp index 56c92f8e60..0eec2a94a5 100644 --- a/pxr/usd/usdUtils/dependencies.cpp +++ b/pxr/usd/usdUtils/dependencies.cpp @@ -34,11 +34,12 @@ UsdUtilsExtractExternalReferences( const std::string& filePath, std::vector* subLayers, std::vector* references, - std::vector* payloads) + std::vector* payloads, + const UsdUtilsExtractExternalReferencesParams& params) { UsdUtils_ExtractExternalReferences(filePath, UsdUtils_LocalizationContext::ReferenceType::All, - subLayers, references, payloads); + subLayers, references, payloads, params); } struct UsdUtils_ComputeAllDependenciesClient diff --git a/pxr/usd/usdUtils/dependencies.h b/pxr/usd/usdUtils/dependencies.h index 648dbffed4..3ddf40ca37 100644 --- a/pxr/usd/usdUtils/dependencies.h +++ b/pxr/usd/usdUtils/dependencies.h @@ -28,11 +28,34 @@ PXR_NAMESPACE_OPEN_SCOPE +/// Structure which controls aspects of the +/// \ref UsdUtilsExtractExternalReferences function. +class UsdUtilsExtractExternalReferencesParams { +public: + /// Specifies whether UDIM template paths should be resolved when extracting + /// references. If true, the resolved paths for all discovered UDIM tiles + /// will be included in the references bucket and the template path will be + /// discarded. If false, no resolution will take place and the template path + /// will appear in the references bucket. + inline void SetResolveUdimPaths(bool resolveUdimPaths) { + _resolveUdimPaths = resolveUdimPaths; + } + + + inline bool GetResolveUdimPaths() const { return _resolveUdimPaths; } + +private: + bool _resolveUdimPaths = false; +}; + /// Parses the file at \p filePath, identifying external references, and /// sorting them into separate type-based buckets. Sublayers are returned in /// the \p sublayers vector, references, whether prim references, value clip /// references or values from asset path attributes, are returned in the /// \p references vector. Payload paths are returned in \p payloads. +/// The \p params parameter controls various settings that affect the +/// extraction process. See \ref UsdUtilsExtractExternalReferencesParams for +/// additional details. /// /// \note No recursive chasing of dependencies is performed; that is the /// client's responsibility, if desired. @@ -45,7 +68,8 @@ void UsdUtilsExtractExternalReferences( const std::string& filePath, std::vector* subLayers, std::vector* references, - std::vector* payloads); + std::vector* payloads, + const UsdUtilsExtractExternalReferencesParams& params = {}); /// Recursively computes all the dependencies of the given asset and populates /// \p layers with all the dependencies that can be opened as an SdfLayer. diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor.py b/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor.py index 95a9e27320..f421accfb4 100644 --- a/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor.py +++ b/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor.py @@ -28,6 +28,7 @@ def presult(ostr, fileName, refType, refs): parser.add_argument('infile') parser.add_argument('outfile', default='-') parser.add_argument('--open-as-anon', dest='openAsAnon', action='store_true') + parser.add_argument('--resolve-udim-paths', dest="resolveUdimPaths", action='store_true') args = parser.parse_args() if not os.path.exists(args.infile): @@ -46,8 +47,12 @@ def presult(ostr, fileName, refType, refs): layer.SetPermissionToEdit(False) identifier = args.infile + extractionParams = UsdUtils.ExtractExternalReferencesParams() + if (args.resolveUdimPaths): + extractionParams.SetResolveUdimPaths(True) + sublayers, references, payloads = \ - UsdUtils.ExtractExternalReferences(identifier) + UsdUtils.ExtractExternalReferences(identifier, extractionParams) with stream(args.outfile, 'w') as ofp: presult(ofp, args.infile, 'sublayers', sublayers) diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/baseline/udims-resolved.txt b/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/baseline/udims-resolved.txt new file mode 100644 index 0000000000..2606fd2a8f --- /dev/null +++ b/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/baseline/udims-resolved.txt @@ -0,0 +1,4 @@ +udims/root.usda no sublayers +udims/root.usda references[001]: ./test.1001.txt +udims/root.usda references[002]: ./test.1002.txt +udims/root.usda no payloads diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/baseline/udims.txt b/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/baseline/udims.txt new file mode 100644 index 0000000000..d5a5bec0e2 --- /dev/null +++ b/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/baseline/udims.txt @@ -0,0 +1,3 @@ +udims/root.usda no sublayers +udims/root.usda references[001]: ./test..txt +udims/root.usda no payloads diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/udims/root.usda b/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/udims/root.usda new file mode 100644 index 0000000000..181d94d03f --- /dev/null +++ b/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/udims/root.usda @@ -0,0 +1,5 @@ +#usda 1.0 + +def "Test" { + asset udims = @./test..txt@ +} \ No newline at end of file diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/udims/test.1001.txt b/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/udims/test.1001.txt new file mode 100644 index 0000000000..7cebf7db5f --- /dev/null +++ b/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/udims/test.1001.txt @@ -0,0 +1 @@ +1001 \ No newline at end of file diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/udims/test.1002.txt b/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/udims/test.1002.txt new file mode 100644 index 0000000000..5ed13cbaef --- /dev/null +++ b/pxr/usd/usdUtils/testenv/testUsdUtilsDependencyExtractor/udims/test.1002.txt @@ -0,0 +1 @@ +1002 \ No newline at end of file diff --git a/pxr/usd/usdUtils/usdzPackage.cpp b/pxr/usd/usdUtils/usdzPackage.cpp index f53cb45153..a3c7031147 100644 --- a/pxr/usd/usdUtils/usdzPackage.cpp +++ b/pxr/usd/usdUtils/usdzPackage.cpp @@ -117,9 +117,17 @@ UsdUtilsCreateNewARKitUsdzPackage( // the composition of the stage. std::vector sublayers, references, payloads; + // We are explicitly setting the UDIM path resolution option to false + // here because the following logic only cares if the root layer contains + // any external references and does reason about the contents of the + // results. UDIM path resolution has the potential to be expensive, for + // example in the case of network filesystem paths. + UsdUtilsExtractExternalReferencesParams params; + params.SetResolveUdimPaths(false); + UsdUtils_ExtractExternalReferences(resolvedPath, UsdUtils_LocalizationContext::ReferenceType::CompositionOnly, - &sublayers, &references, &payloads); + &sublayers, &references, &payloads, params); // Ensure that the root layer has the ".usdc" extension. std::string targetBaseName = firstLayerName.empty() ? diff --git a/pxr/usd/usdUtils/wrapDependencies.cpp b/pxr/usd/usdUtils/wrapDependencies.cpp index 4fc906f26a..fefed2c59f 100644 --- a/pxr/usd/usdUtils/wrapDependencies.cpp +++ b/pxr/usd/usdUtils/wrapDependencies.cpp @@ -27,11 +27,12 @@ namespace { static bp::tuple _ExtractExternalReferences( - const std::string& filePath) + const std::string& filePath, + const UsdUtilsExtractExternalReferencesParams& params = {}) { std::vector subLayers, references, payloads; UsdUtilsExtractExternalReferences(filePath, - &subLayers, &references, &payloads); + &subLayers, &references, &payloads, params); return bp::make_tuple(subLayers, references, payloads); } @@ -65,8 +66,15 @@ _ComputeAllDependencies( void wrapDependencies() { + typedef UsdUtilsExtractExternalReferencesParams ExtractRefParams; + bp::class_("ExtractExternalReferencesParams") + .def("SetResolveUdimPaths", &ExtractRefParams::SetResolveUdimPaths) + .def("GetResolveUdimPaths", &ExtractRefParams::GetResolveUdimPaths) + ; + bp::def("ExtractExternalReferences", _ExtractExternalReferences, - bp::arg("filePath")); + (bp::arg("filePath"), + bp::arg("parameters") = ExtractRefParams())); bp::def("CreateNewUsdzPackage", UsdUtilsCreateNewUsdzPackage, (bp::arg("assetPath"), From c89138d79caebe76958d5dcc28e5bcc3a6c4725f Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Tue, 15 Oct 2024 21:53:34 -0700 Subject: [PATCH 040/300] UsdValidatonContext::Validate(stage) should also validate instance proxy prims, when it traverses the stage for prims to validate. The Validate(stage) API now validates all prims, including instance proxies, by default. Clients can also use the overload that takes a traversal predicate to be used for stage traversal when validating the stage. The default behavior matches the behavior we currently have in usdchecker / UsdUtils.ComplianceChecker. (Internal change: 2344766) --- pxr/usd/usd/validationContext.cpp | 30 ++++++++++++++++++++---------- pxr/usd/usd/validationContext.h | 19 +++++++++++++++++-- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/pxr/usd/usd/validationContext.cpp b/pxr/usd/usd/validationContext.cpp index f93da721a8..b515b6a419 100644 --- a/pxr/usd/usd/validationContext.cpp +++ b/pxr/usd/usd/validationContext.cpp @@ -8,9 +8,10 @@ #include "pxr/base/tf/type.h" #include "pxr/base/work/dispatcher.h" #include "pxr/base/work/withScopedParallelism.h" -#include "pxr/usd/usd/validationContext.h" +#include "pxr/usd/usd/primFlags.h" #include "pxr/usd/usd/schemaRegistry.h" #include "pxr/usd/usd/stage.h" +#include "pxr/usd/usd/validationContext.h" #include "pxr/usd/usd/validator.h" #include "pxr/usd/usd/validationRegistry.h" @@ -298,7 +299,8 @@ UsdValidationContext::Validate(const SdfLayerHandle &layer) const } UsdValidationErrorVector -UsdValidationContext::Validate(const UsdStagePtr &stage) const +UsdValidationContext::Validate(const UsdStagePtr &stage, + const Usd_PrimFlagsPredicate &predicate) const { if (!stage) { TF_CODING_ERROR("Invalid stage provided to validate."); @@ -308,12 +310,20 @@ UsdValidationContext::Validate(const UsdStagePtr &stage) const UsdValidationErrorVector errors; std::mutex errorsMutex; WorkWithScopedDispatcher( - [this, &stage, &errors, &errorsMutex](WorkDispatcher &dispatcher) { - _ValidateStage(dispatcher, stage, &errors, &errorsMutex); - }); + [this, &stage, &errors, &errorsMutex, &predicate]( + WorkDispatcher &dispatcher) { + _ValidateStage(dispatcher, stage, &errors, &errorsMutex, + predicate); + }); return errors; } +UsdValidationErrorVector +UsdValidationContext::Validate(const UsdStagePtr &stage) const +{ + return Validate(stage, UsdTraverseInstanceProxies(UsdPrimDefaultPredicate)); +} + UsdValidationErrorVector UsdValidationContext::Validate(const std::vector &prims) const { @@ -373,10 +383,10 @@ UsdValidationContext::_ValidateLayer(WorkDispatcher &dispatcher, } void -UsdValidationContext::_ValidateStage(WorkDispatcher &dispatcher, - const UsdStagePtr &stage, - UsdValidationErrorVector *errors, - std::mutex *errorsMutex) const +UsdValidationContext::_ValidateStage( + WorkDispatcher &dispatcher, const UsdStagePtr &stage, + UsdValidationErrorVector *errors, std::mutex *errorsMutex, + const Usd_PrimFlagsPredicate &predicate) const { // If we reached here via Validate(const UsdStagePtr&), then the stage // must be valid. @@ -393,7 +403,7 @@ UsdValidationContext::_ValidateStage(WorkDispatcher &dispatcher, _AddErrors(validator->Validate(stage), errors, errorsMutex); }); } - _ValidatePrims(dispatcher, stage->Traverse(), errors, errorsMutex); + _ValidatePrims(dispatcher, stage->Traverse(predicate), errors, errorsMutex); } template diff --git a/pxr/usd/usd/validationContext.h b/pxr/usd/usd/validationContext.h index 47157b097f..46ca8bce06 100644 --- a/pxr/usd/usd/validationContext.h +++ b/pxr/usd/usd/validationContext.h @@ -25,6 +25,7 @@ PXR_NAMESPACE_OPEN_SCOPE class TfType; class WorkDispatcher; +class Usd_PrimFlagsPredicate; /// \class UsdValidationContext /// @@ -181,7 +182,7 @@ class UsdValidationContext /// the layers reachable from the stage. In addition to that any Stage /// validators will also be run on the given stage. The stage will also be /// traversed to run prim and schema type validators on all the prims in the - /// stage. + /// stage. \p predicate will be used to traverse the prims to be validated. /// /// All the validators run in parallel. Any resulting errors are collected /// in the returned vector. @@ -193,6 +194,19 @@ class UsdValidationContext /// /// A coding error is issued if the stage being validated is not valid. USD_API + UsdValidationErrorVector Validate( + const UsdStageWeakPtr &stage, + const Usd_PrimFlagsPredicate &predicate) const; + + /// Run validation on the given valid \p stage by executing the selected + /// validators for this UsdValidationContext; Returns a vector of errors + /// + /// \ref UsdTraverseInstanceProxies "Instance Proxy predicate" is used to + /// traverse the prims to be validated in this overload. + /// + /// \sa UsdValidationContext::Validate(const UsdStageWeakPtr &stage, + /// const Usd_PrimFlagsPredicate &predicate) const + USD_API UsdValidationErrorVector Validate(const UsdStagePtr &stage) const; /// Run validation on the given valid \p prims by executing the selected @@ -253,7 +267,8 @@ class UsdValidationContext void _ValidateStage(WorkDispatcher &dispatcher, const UsdStagePtr &stage, UsdValidationErrorVector *errors, - std::mutex *errorsMutex) const; + std::mutex *errorsMutex, + const Usd_PrimFlagsPredicate &predicate) const; // Helper function to validate prims. Generalized for UsdPrimRange and // vector of UsdPrims. From af65a82ab111cd3615c23188f2e837940b713dad Mon Sep 17 00:00:00 2001 From: diyajoy Date: Wed, 16 Oct 2024 21:35:46 -0700 Subject: [PATCH 041/300] Throw a coding error in the USD schema registry if a schema is registered without an identifier. USD uses aliases under UsdSchemaBase as identifiers if no "schemaIdentifier" field is defined in the metadata to be backwards compatible with external USD users with their own schema libraries. (Internal change: 2344778) --- pxr/usd/usd/schemaRegistry.cpp | 16 ++++++++++++---- pxr/usd/usd/testenv/testUsdSchemaRegistry.py | 10 ++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/pxr/usd/usd/schemaRegistry.cpp b/pxr/usd/usd/schemaRegistry.cpp index cf88e580c9..d3238e9447 100644 --- a/pxr/usd/usd/schemaRegistry.cpp +++ b/pxr/usd/usd/schemaRegistry.cpp @@ -163,14 +163,22 @@ struct _TypeMapCache { } // The schema's identifier is the "schemaIdentifier" field. - // If not present, we use the type's alias under UsdSchemaBase. + // If not present, we use the type's alias under UsdSchemaBase + // to maintain backwards compatibility. string identifier = _GetSchemaIdentifierFromMetadata(metadata); if(identifier.empty()) { const vector aliases = schemaBaseType.GetAliases(type); - if (aliases.size() != 1) { - continue; + if (aliases.size() == 1) { + identifier = aliases.front(); } - identifier = aliases.front(); + } + + // Check if a valid identifier was found + if (identifier.empty()) { + TF_CODING_ERROR("Registration failed for schema type %s. " + "Schema types must have a single valid identifier.", + type.GetTypeName().c_str()); + continue; } // Generate all the components of the schema info. diff --git a/pxr/usd/usd/testenv/testUsdSchemaRegistry.py b/pxr/usd/usd/testenv/testUsdSchemaRegistry.py index fb67de2f56..8ae941e633 100644 --- a/pxr/usd/usd/testenv/testUsdSchemaRegistry.py +++ b/pxr/usd/usd/testenv/testUsdSchemaRegistry.py @@ -18,6 +18,16 @@ def setUpClass(cls): assert testPlugins[0].name == "testUsdSchemaRegistry", \ "Failed to load expected test plugin" + # This checks an invalid case for test_SchemaIdentifier that throws a + # coding error on schema registry construction + try: + Usd.SchemaRegistry() + assert False, "Coding error expected on schema registry initialization." + except Tf.ErrorException as e: + assert 'Registration failed for schema type ' \ + 'TestUsdSchemaRegistryNoIdentifierAndNoAlias.' in str(e) + assert len(str(e).strip().split('\n')) == 1 + def test_PrimMetadata(self): primDef = Usd.SchemaRegistry().FindConcretePrimDefinition( "MetadataTest") From 937443364a8c5089e74cea7776bd977820a3da24 Mon Sep 17 00:00:00 2001 From: sunyab Date: Wed, 16 Oct 2024 21:40:09 -0700 Subject: [PATCH 042/300] pcp: Reenable incremental changes for layer operations This was disabled by default for the OpenUSD 24.11 release in change 2344776. This change reenables the optimization to continue development and pick up additional testing. (Internal change: 2344802) --- pxr/usd/pcp/changes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pxr/usd/pcp/changes.cpp b/pxr/usd/pcp/changes.cpp index 016edbb9df..99528bc1b5 100644 --- a/pxr/usd/pcp/changes.cpp +++ b/pxr/usd/pcp/changes.cpp @@ -26,7 +26,7 @@ PXR_NAMESPACE_OPEN_SCOPE TF_DEFINE_ENV_SETTING( - PCP_ENABLE_MINIMAL_CHANGES_FOR_LAYER_OPERATIONS, false, + PCP_ENABLE_MINIMAL_CHANGES_FOR_LAYER_OPERATIONS, true, "If enabled, pcp will compute a minimal amount of targeted change entries " "for layer operations. This can result in a significant performance " "improvement when muting/unmuting layer or adding/removing sublayers."); From 36264902bf969bc5fd05c59083d20b8a9c91047a Mon Sep 17 00:00:00 2001 From: katpet Date: Thu, 17 Oct 2024 12:34:26 -0700 Subject: [PATCH 043/300] The rileyGlobalsSceneIndexPlugin has the effect of applying render settings from the schema early enough that non-editable settings like hider:incremental are applied in time to affect the render. This causes hider:incremental to be set to false, since that is the default in the schema. Interactive renders need incremental to be enabled, so added a conditional in UpdateLegacySettings which forces incrmental to be enabled for interactive renders. (Internal change: 2344936) --- third_party/renderman-26/plugin/hdPrman/renderParam.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/third_party/renderman-26/plugin/hdPrman/renderParam.cpp b/third_party/renderman-26/plugin/hdPrman/renderParam.cpp index f8f3a68ce2..6ee733ea10 100644 --- a/third_party/renderman-26/plugin/hdPrman/renderParam.cpp +++ b/third_party/renderman-26/plugin/hdPrman/renderParam.cpp @@ -1211,6 +1211,12 @@ HdPrman_RenderParam::UpdateLegacyOptions() // SetRileyShutterIntervalFromCameraContextCameraPath. } } + + // Force incremental to be enabled for interacive renders + if (_renderDelegate->IsInteractive() && !_usingHusk) { + options.SetInteger(RixStr.k_hider_incremental, 1); + } + // Apply the batch command line settings last, so that they can // either intentionally override render settings, or sometimes be skipped // if the equivalent render setting exists, like for checkpointinterval. From cb467553369f9af45e0e0c67ff7aa673434bf4bf Mon Sep 17 00:00:00 2001 From: unhyperbolic Date: Thu, 17 Oct 2024 15:51:31 -0700 Subject: [PATCH 044/300] Adding emulation support for tasks to HdSceneIndexAdapterSceneDelegate. The scene index uses the HdLegacyTaskSchema to specify a task. The primitive type is always task and the schema includes a task factory, in lieu of the templated HdRenderIndex::InsertTask. (Internal change: 2344995) --- pxr/imaging/hd/CMakeLists.txt | 2 + pxr/imaging/hd/dirtyBitsTranslator.cpp | 39 ++++ pxr/imaging/hd/dirtyBitsTranslator.h | 5 +- pxr/imaging/hd/hdSchemaDefs.py | 20 ++ pxr/imaging/hd/legacyTaskFactory.cpp | 14 ++ pxr/imaging/hd/legacyTaskFactory.h | 59 +++++ pxr/imaging/hd/legacyTaskSchema.cpp | 209 ++++++++++++++++++ pxr/imaging/hd/legacyTaskSchema.h | 207 +++++++++++++++++ pxr/imaging/hd/renderIndex.cpp | 21 +- pxr/imaging/hd/renderIndex.h | 3 + .../hd/sceneIndexAdapterSceneDelegate.cpp | 88 +++++++- .../hd/sceneIndexAdapterSceneDelegate.h | 3 +- pxr/imaging/hd/tokens.h | 3 +- 13 files changed, 665 insertions(+), 8 deletions(-) create mode 100644 pxr/imaging/hd/legacyTaskFactory.cpp create mode 100644 pxr/imaging/hd/legacyTaskFactory.h create mode 100644 pxr/imaging/hd/legacyTaskSchema.cpp create mode 100644 pxr/imaging/hd/legacyTaskSchema.h diff --git a/pxr/imaging/hd/CMakeLists.txt b/pxr/imaging/hd/CMakeLists.txt index 84bd7f4afa..a79becac8c 100644 --- a/pxr/imaging/hd/CMakeLists.txt +++ b/pxr/imaging/hd/CMakeLists.txt @@ -103,6 +103,8 @@ pxr_library(hd legacyDisplayStyleSchema legacyGeomSubsetSceneIndex legacyPrimSceneIndex + legacyTaskFactory + legacyTaskSchema lensDistortionSchema light lightSchema diff --git a/pxr/imaging/hd/dirtyBitsTranslator.cpp b/pxr/imaging/hd/dirtyBitsTranslator.cpp index 6bffdebe75..7be39fe128 100644 --- a/pxr/imaging/hd/dirtyBitsTranslator.cpp +++ b/pxr/imaging/hd/dirtyBitsTranslator.cpp @@ -44,6 +44,7 @@ #include "pxr/imaging/hd/instanceSchema.h" #include "pxr/imaging/hd/integratorSchema.h" #include "pxr/imaging/hd/legacyDisplayStyleSchema.h" +#include "pxr/imaging/hd/legacyTaskSchema.h" #include "pxr/imaging/hd/lightSchema.h" #include "pxr/imaging/hd/materialBindingsSchema.h" #include "pxr/imaging/hd/materialConnectionSchema.h" @@ -954,6 +955,44 @@ HdDirtyBitsTranslator::InstancerLocatorSetToDirtyBits( return bits; } +/*static*/ +HdDirtyBits +HdDirtyBitsTranslator::TaskLocatorSetToDirtyBits( + HdDataSourceLocatorSet const& set) +{ + HdDataSourceLocatorSet::const_iterator it = set.begin(); + + const HdDataSourceLocatorSet::const_iterator end = set.end(); + + if (it == end) { + return HdChangeTracker::Clean; + } + + // Note, for efficiency we search for locators in the set in order, so that + // we only end up making one trip through the set. If you add to this + // function, make sure you sort the addition by locator name, or + // _FindLocator won't work. + // Also note, this should match InstancerDirtyBitsToLocatorSet + + if (*it == HdDataSourceLocator::EmptyLocator()) { + return HdChangeTracker::AllDirty; + } + + HdDirtyBits bits = HdChangeTracker::Clean; + + if (_FindLocator(HdLegacyTaskSchema::GetCollectionLocator(), end, &it)) { + bits |= HdChangeTracker::DirtyCollection; + } + if (_FindLocator(HdLegacyTaskSchema::GetParametersLocator(), end, &it)) { + bits |= HdChangeTracker::DirtyParams; + } + if (_FindLocator(HdLegacyTaskSchema::GetRenderTagsLocator(), end, &it)) { + bits |= HdChangeTracker::DirtyRenderTags; + } + + return bits; +} + /*static*/ HdDirtyBits HdDirtyBitsTranslator::BprimLocatorSetToDirtyBits( diff --git a/pxr/imaging/hd/dirtyBitsTranslator.h b/pxr/imaging/hd/dirtyBitsTranslator.h index 22e2bd19af..e9a6f2a744 100644 --- a/pxr/imaging/hd/dirtyBitsTranslator.h +++ b/pxr/imaging/hd/dirtyBitsTranslator.h @@ -48,7 +48,10 @@ class HdDirtyBitsTranslator HD_API static HdDirtyBits InstancerLocatorSetToDirtyBits(TfToken const& primType, HdDataSourceLocatorSet const& set); - + HD_API + static HdDirtyBits TaskLocatorSetToDirtyBits( + HdDataSourceLocatorSet const& set); + using LocatorSetToDirtyBitsFnc = std::function; diff --git a/pxr/imaging/hd/hdSchemaDefs.py b/pxr/imaging/hd/hdSchemaDefs.py index 3bdb4aeefc..a4cc0ebfda 100644 --- a/pxr/imaging/hd/hdSchemaDefs.py +++ b/pxr/imaging/hd/hdSchemaDefs.py @@ -1383,5 +1383,25 @@ ], ADD_DEFAULT_LOCATOR = True, ), + #-------------------------------------------------------------------------- + # legacyTask + dict( + SCHEMA_NAME = 'LegacyTask', + DOC = '''The {{ SCHEMA_CLASS_NAME }} specifies a Hydra task by providing + a task factory and data.''', + SCHEMA_TOKEN = 'task', + ADD_DEFAULT_LOCATOR = True, + MEMBERS = [ + ('ALL_MEMBERS', '', dict(ADD_LOCATOR = True)), + ('factory', 'HdLegacyTaskFactoryDataSource', {}), + ('parameters', T_SAMPLED, + dict(DOC = ''' + Parameters for task. Type depends on task type. + E.g. HdxRenderTaskParams if the factory produces HdxRenderTask + instances.''')), + ('collection', 'HdRprimCollectionDataSource', {}), + ('renderTags', 'HdTokenVectorDataSource', {}), + ], + ), ] diff --git a/pxr/imaging/hd/legacyTaskFactory.cpp b/pxr/imaging/hd/legacyTaskFactory.cpp new file mode 100644 index 0000000000..cec97b37d8 --- /dev/null +++ b/pxr/imaging/hd/legacyTaskFactory.cpp @@ -0,0 +1,14 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// + +#include "pxr/imaging/hd/legacyTaskFactory.h" + +PXR_NAMESPACE_OPEN_SCOPE + +HdLegacyTaskFactory::~HdLegacyTaskFactory() = default; + +PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/imaging/hd/legacyTaskFactory.h b/pxr/imaging/hd/legacyTaskFactory.h new file mode 100644 index 0000000000..ad07f9469a --- /dev/null +++ b/pxr/imaging/hd/legacyTaskFactory.h @@ -0,0 +1,59 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +#ifndef PXR_IMAGING_HD_LEGACY_TASK_FACTORY_H +#define PXR_IMAGING_HD_LEGACY_TASK_FACTORY_H + +#include "pxr/pxr.h" +#include "pxr/imaging/hd/api.h" + +#include "pxr/usd/sdf/path.h" + +#include + +PXR_NAMESPACE_OPEN_SCOPE + +class HdSceneDelegate; +using HdTaskSharedPtr = std::shared_ptr; +using HdLegacyTaskFactorySharedPtr = std::shared_ptr; + +/// +/// \class HdLegacyTaskFactory +/// +/// An abstract base class to create implementations of HdTask. +/// +class HdLegacyTaskFactory +{ +public: + virtual HdTaskSharedPtr Create( + HdSceneDelegate * delegate, const SdfPath &id) = 0; + + HD_API + virtual ~HdLegacyTaskFactory(); +}; + +template +class HdLegacyTaskFactory_Impl : public HdLegacyTaskFactory +{ +public: + HdTaskSharedPtr Create( + HdSceneDelegate * const delegate, const SdfPath &id) override + { + return std::make_shared(delegate, id); + } +}; + +/// Given a subclass implementing HdTask, create a factory for that +/// subclass. +template +HdLegacyTaskFactorySharedPtr HdMakeLegacyTaskFactory() +{ + return std::make_shared>(); +} + +PXR_NAMESPACE_CLOSE_SCOPE + +#endif diff --git a/pxr/imaging/hd/legacyTaskSchema.cpp b/pxr/imaging/hd/legacyTaskSchema.cpp new file mode 100644 index 0000000000..55e6abcaa0 --- /dev/null +++ b/pxr/imaging/hd/legacyTaskSchema.cpp @@ -0,0 +1,209 @@ +// +// Copyright 2023 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +//////////////////////////////////////////////////////////////////////// + +/* ************************************************************************** */ +/* ** ** */ +/* ** This file is generated by a script. ** */ +/* ** ** */ +/* ** Do not edit it directly (unless it is within a CUSTOM CODE section)! ** */ +/* ** Edit hdSchemaDefs.py instead to make changes. ** */ +/* ** ** */ +/* ************************************************************************** */ + +#include "pxr/imaging/hd/legacyTaskSchema.h" + +#include "pxr/imaging/hd/retainedDataSource.h" + +#include "pxr/base/trace/trace.h" + +// --(BEGIN CUSTOM CODE: Includes)-- +// --(END CUSTOM CODE: Includes)-- + +PXR_NAMESPACE_OPEN_SCOPE + +TF_DEFINE_PUBLIC_TOKENS(HdLegacyTaskSchemaTokens, + HD_LEGACY_TASK_SCHEMA_TOKENS); + +// --(BEGIN CUSTOM CODE: Schema Methods)-- +// --(END CUSTOM CODE: Schema Methods)-- + +HdLegacyTaskFactoryDataSourceHandle +HdLegacyTaskSchema::GetFactory() const +{ + return _GetTypedDataSource( + HdLegacyTaskSchemaTokens->factory); +} + +HdSampledDataSourceHandle +HdLegacyTaskSchema::GetParameters() const +{ + return _GetTypedDataSource( + HdLegacyTaskSchemaTokens->parameters); +} + +HdRprimCollectionDataSourceHandle +HdLegacyTaskSchema::GetCollection() const +{ + return _GetTypedDataSource( + HdLegacyTaskSchemaTokens->collection); +} + +HdTokenVectorDataSourceHandle +HdLegacyTaskSchema::GetRenderTags() const +{ + return _GetTypedDataSource( + HdLegacyTaskSchemaTokens->renderTags); +} + +/*static*/ +HdContainerDataSourceHandle +HdLegacyTaskSchema::BuildRetained( + const HdLegacyTaskFactoryDataSourceHandle &factory, + const HdSampledDataSourceHandle ¶meters, + const HdRprimCollectionDataSourceHandle &collection, + const HdTokenVectorDataSourceHandle &renderTags +) +{ + TfToken _names[4]; + HdDataSourceBaseHandle _values[4]; + + size_t _count = 0; + + if (factory) { + _names[_count] = HdLegacyTaskSchemaTokens->factory; + _values[_count++] = factory; + } + + if (parameters) { + _names[_count] = HdLegacyTaskSchemaTokens->parameters; + _values[_count++] = parameters; + } + + if (collection) { + _names[_count] = HdLegacyTaskSchemaTokens->collection; + _values[_count++] = collection; + } + + if (renderTags) { + _names[_count] = HdLegacyTaskSchemaTokens->renderTags; + _values[_count++] = renderTags; + } + return HdRetainedContainerDataSource::New(_count, _names, _values); +} + +HdLegacyTaskSchema::Builder & +HdLegacyTaskSchema::Builder::SetFactory( + const HdLegacyTaskFactoryDataSourceHandle &factory) +{ + _factory = factory; + return *this; +} + +HdLegacyTaskSchema::Builder & +HdLegacyTaskSchema::Builder::SetParameters( + const HdSampledDataSourceHandle ¶meters) +{ + _parameters = parameters; + return *this; +} + +HdLegacyTaskSchema::Builder & +HdLegacyTaskSchema::Builder::SetCollection( + const HdRprimCollectionDataSourceHandle &collection) +{ + _collection = collection; + return *this; +} + +HdLegacyTaskSchema::Builder & +HdLegacyTaskSchema::Builder::SetRenderTags( + const HdTokenVectorDataSourceHandle &renderTags) +{ + _renderTags = renderTags; + return *this; +} + +HdContainerDataSourceHandle +HdLegacyTaskSchema::Builder::Build() +{ + return HdLegacyTaskSchema::BuildRetained( + _factory, + _parameters, + _collection, + _renderTags + ); +} + +/*static*/ +HdLegacyTaskSchema +HdLegacyTaskSchema::GetFromParent( + const HdContainerDataSourceHandle &fromParentContainer) +{ + return HdLegacyTaskSchema( + fromParentContainer + ? HdContainerDataSource::Cast(fromParentContainer->Get( + HdLegacyTaskSchemaTokens->task)) + : nullptr); +} + +/*static*/ +const TfToken & +HdLegacyTaskSchema::GetSchemaToken() +{ + return HdLegacyTaskSchemaTokens->task; +} + +/*static*/ +const HdDataSourceLocator & +HdLegacyTaskSchema::GetDefaultLocator() +{ + static const HdDataSourceLocator locator(GetSchemaToken()); + return locator; +} + +/* static */ +const HdDataSourceLocator & +HdLegacyTaskSchema::GetFactoryLocator() +{ + static const HdDataSourceLocator locator = + GetDefaultLocator().Append( + HdLegacyTaskSchemaTokens->factory); + return locator; +} + +/* static */ +const HdDataSourceLocator & +HdLegacyTaskSchema::GetParametersLocator() +{ + static const HdDataSourceLocator locator = + GetDefaultLocator().Append( + HdLegacyTaskSchemaTokens->parameters); + return locator; +} + +/* static */ +const HdDataSourceLocator & +HdLegacyTaskSchema::GetCollectionLocator() +{ + static const HdDataSourceLocator locator = + GetDefaultLocator().Append( + HdLegacyTaskSchemaTokens->collection); + return locator; +} + +/* static */ +const HdDataSourceLocator & +HdLegacyTaskSchema::GetRenderTagsLocator() +{ + static const HdDataSourceLocator locator = + GetDefaultLocator().Append( + HdLegacyTaskSchemaTokens->renderTags); + return locator; +} + +PXR_NAMESPACE_CLOSE_SCOPE \ No newline at end of file diff --git a/pxr/imaging/hd/legacyTaskSchema.h b/pxr/imaging/hd/legacyTaskSchema.h new file mode 100644 index 0000000000..acd2f53edb --- /dev/null +++ b/pxr/imaging/hd/legacyTaskSchema.h @@ -0,0 +1,207 @@ +// +// Copyright 2023 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +//////////////////////////////////////////////////////////////////////// + +/* ************************************************************************** */ +/* ** ** */ +/* ** This file is generated by a script. ** */ +/* ** ** */ +/* ** Do not edit it directly (unless it is within a CUSTOM CODE section)! ** */ +/* ** Edit hdSchemaDefs.py instead to make changes. ** */ +/* ** ** */ +/* ************************************************************************** */ + +#ifndef PXR_IMAGING_HD_LEGACY_TASK_SCHEMA_H +#define PXR_IMAGING_HD_LEGACY_TASK_SCHEMA_H + +/// \file + +#include "pxr/imaging/hd/api.h" + +#include "pxr/imaging/hd/schema.h" + +// --(BEGIN CUSTOM CODE: Includes)-- +#include "pxr/imaging/hd/rprimCollection.h" +// --(END CUSTOM CODE: Includes)-- + +PXR_NAMESPACE_OPEN_SCOPE + +// --(BEGIN CUSTOM CODE: Declares)-- + +using HdRprimCollectionDataSource = HdTypedSampledDataSource; +using HdRprimCollectionDataSourceHandle = HdRprimCollectionDataSource::Handle; + +using HdTokenVectorDataSource = HdTypedSampledDataSource; +using HdTokenVectorDataSourceHandle = HdTokenVectorDataSource::Handle; + +using HdLegacyTaskFactorySharedPtr = std::shared_ptr; +using HdLegacyTaskFactoryDataSource = + HdTypedSampledDataSource; +using HdLegacyTaskFactoryDataSourceHandle = + HdLegacyTaskFactoryDataSource::Handle; + + +// --(END CUSTOM CODE: Declares)-- + +#define HD_LEGACY_TASK_SCHEMA_TOKENS \ + (task) \ + (factory) \ + (parameters) \ + (collection) \ + (renderTags) \ + +TF_DECLARE_PUBLIC_TOKENS(HdLegacyTaskSchemaTokens, HD_API, + HD_LEGACY_TASK_SCHEMA_TOKENS); + +//----------------------------------------------------------------------------- + +// The HdLegacyTaskSchema specifies a Hydra task by providing a task factory +// and data. +// + +class HdLegacyTaskSchema : public HdSchema +{ +public: + /// \name Schema retrieval + /// @{ + + HdLegacyTaskSchema(HdContainerDataSourceHandle container) + : HdSchema(container) {} + + /// Retrieves a container data source with the schema's default name token + /// "task" from the parent container and constructs a + /// HdLegacyTaskSchema instance. + /// Because the requested container data source may not exist, the result + /// should be checked with IsDefined() or a bool comparison before use. + HD_API + static HdLegacyTaskSchema GetFromParent( + const HdContainerDataSourceHandle &fromParentContainer); + + /// @} + +// --(BEGIN CUSTOM CODE: Schema Methods)-- +// --(END CUSTOM CODE: Schema Methods)-- + + /// \name Member accessor + /// @{ + + HD_API + HdLegacyTaskFactoryDataSourceHandle GetFactory() const; + + /// Parameters for task. Type depends on task type. E.g. + /// HdxRenderTaskParams if the factory produces HdxRenderTask instances. + HD_API + HdSampledDataSourceHandle GetParameters() const; + + HD_API + HdRprimCollectionDataSourceHandle GetCollection() const; + + HD_API + HdTokenVectorDataSourceHandle GetRenderTags() const; + + /// @} + + /// \name Schema location + /// @{ + + /// Returns a token where the container representing this schema is found in + /// a container by default. + HD_API + static const TfToken &GetSchemaToken(); + + /// Returns an HdDataSourceLocator (relative to the prim-level data source) + /// where the container representing this schema is found by default. + HD_API + static const HdDataSourceLocator &GetDefaultLocator(); + + /// @} + + /// \name Data source locators for members + /// + /// The following methods return an HdDataSourceLocator (relative to the + /// prim-level data source) where the data source for a member can be found. + /// + /// This is often useful for checking intersection against the + /// HdDataSourceLocatorSet sent with HdDataSourceObserver::PrimsDirtied. + /// @{ + + /// Prim-level relative data source locator to locate factory. + HD_API + static const HdDataSourceLocator &GetFactoryLocator(); + + /// Prim-level relative data source locator to locate parameters. + HD_API + static const HdDataSourceLocator &GetParametersLocator(); + + /// Prim-level relative data source locator to locate collection. + HD_API + static const HdDataSourceLocator &GetCollectionLocator(); + + /// Prim-level relative data source locator to locate renderTags. + HD_API + static const HdDataSourceLocator &GetRenderTagsLocator(); + /// @} + + /// \name Schema construction + /// @{ + + /// \deprecated Use Builder instead. + /// + /// Builds a container data source which includes the provided child data + /// sources. Parameters with nullptr values are excluded. This is a + /// low-level interface. For cases in which it's desired to define + /// the container with a sparse set of child fields, the Builder class + /// is often more convenient and readable. + HD_API + static HdContainerDataSourceHandle + BuildRetained( + const HdLegacyTaskFactoryDataSourceHandle &factory, + const HdSampledDataSourceHandle ¶meters, + const HdRprimCollectionDataSourceHandle &collection, + const HdTokenVectorDataSourceHandle &renderTags + ); + + /// \class HdLegacyTaskSchema::Builder + /// + /// Utility class for setting sparse sets of child data source fields to be + /// filled as arguments into BuildRetained. Because all setter methods + /// return a reference to the instance, this can be used in the "builder + /// pattern" form. + class Builder + { + public: + HD_API + Builder &SetFactory( + const HdLegacyTaskFactoryDataSourceHandle &factory); + HD_API + Builder &SetParameters( + const HdSampledDataSourceHandle ¶meters); + HD_API + Builder &SetCollection( + const HdRprimCollectionDataSourceHandle &collection); + HD_API + Builder &SetRenderTags( + const HdTokenVectorDataSourceHandle &renderTags); + + /// Returns a container data source containing the members set thus far. + HD_API + HdContainerDataSourceHandle Build(); + + private: + HdLegacyTaskFactoryDataSourceHandle _factory; + HdSampledDataSourceHandle _parameters; + HdRprimCollectionDataSourceHandle _collection; + HdTokenVectorDataSourceHandle _renderTags; + + }; + + /// @} +}; + +PXR_NAMESPACE_CLOSE_SCOPE + +#endif \ No newline at end of file diff --git a/pxr/imaging/hd/renderIndex.cpp b/pxr/imaging/hd/renderIndex.cpp index 503a8fc27e..dea05765bc 100644 --- a/pxr/imaging/hd/renderIndex.cpp +++ b/pxr/imaging/hd/renderIndex.cpp @@ -348,6 +348,7 @@ HdRenderIndex::_RemoveSubtree( _sprimIndex.RemoveSubtree(root, sceneDelegate, _tracker, _renderDelegate); _bprimIndex.RemoveSubtree(root, sceneDelegate, _tracker, _renderDelegate); _RemoveInstancerSubtree(root, sceneDelegate); + _RemoveTaskSubtree(root, sceneDelegate); } @@ -587,6 +588,7 @@ HdRenderIndex::_Clear() // Clear instancers. _RemoveInstancerSubtree(SdfPath::AbsoluteRootPath(), nullptr); + _RemoveTaskSubtree(SdfPath::AbsoluteRootPath(), nullptr); _instancerMap.clear(); } @@ -606,9 +608,20 @@ HdRenderIndex::_TrackDelegateTask(HdSceneDelegate* delegate, return; } - HdTaskSharedPtr task = taskCreateFnc(delegate, taskId); - _tracker.TaskInserted(taskId, task->GetInitialDirtyBitsMask()); - _taskMap.emplace(taskId, _TaskInfo{delegate, task}); + HdTaskSharedPtr const task = taskCreateFnc(delegate, taskId); + _InsertTask(delegate, taskId, task); +} + +void +HdRenderIndex::_InsertTask(HdSceneDelegate* delegate, + SdfPath const &id, + HdTaskSharedPtr const &task) +{ + HD_TRACE_FUNCTION(); + HF_MALLOC_TAG_FUNCTION(); + + _tracker.TaskInserted(id, task->GetInitialDirtyBitsMask()); + _taskMap.emplace(id, _TaskInfo{delegate, task}); } HdTaskSharedPtr const& @@ -650,7 +663,7 @@ HdRenderIndex::_RemoveTaskSubtree(const SdfPath &root, const SdfPath &id = it->first; const _TaskInfo &taskInfo = it->second; - if ((taskInfo.sceneDelegate == sceneDelegate) && + if ((sceneDelegate == nullptr || taskInfo.sceneDelegate == sceneDelegate ) && (id.HasPrefix(root))) { _tracker.TaskRemoved(id); diff --git a/pxr/imaging/hd/renderIndex.h b/pxr/imaging/hd/renderIndex.h index a718c77269..97b85d82b1 100644 --- a/pxr/imaging/hd/renderIndex.h +++ b/pxr/imaging/hd/renderIndex.h @@ -485,6 +485,9 @@ class HdRenderIndex final SdfPath const& bprimId); void _InsertInstancer(HdSceneDelegate* delegate, SdfPath const &id); + void _InsertTask(HdSceneDelegate* delegate, + SdfPath const &id, + HdTaskSharedPtr const &task); void _RemoveRprim(SdfPath const& id); void _RemoveSprim(TfToken const& typeId, SdfPath const& id); diff --git a/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp b/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp index 85915b9cd7..ec00c7a70a 100644 --- a/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp +++ b/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp @@ -19,6 +19,8 @@ #include "pxr/imaging/hd/extComputationCpuCallback.h" #include "pxr/imaging/hd/field.h" #include "pxr/imaging/hd/geomSubset.h" +#include "pxr/imaging/hd/legacyTaskFactory.h" +#include "pxr/imaging/hd/legacyTaskSchema.h" #include "pxr/imaging/hd/light.h" #include "pxr/imaging/hd/material.h" #include "pxr/imaging/hd/meshTopology.h" @@ -194,6 +196,40 @@ HdSceneIndexAdapterSceneDelegate::_GetInputPrim(SdfPath const& id) // ---------------------------------------------------------------------------- // HdSceneIndexObserver interfaces +static +HdTaskSharedPtr _CreateTask(const HdSceneIndexPrim &prim, + HdSceneDelegate * const delegate, + const SdfPath &indexPath) +{ + const HdLegacyTaskSchema taskSchema = + HdLegacyTaskSchema::GetFromParent(prim.dataSource); + HdLegacyTaskFactoryDataSourceHandle const ds = + taskSchema.GetFactory(); + if (!ds) { + TF_CODING_ERROR( + "When adding task %s in HdSceneIndexAdapterSceneDelegate: " + "No factory data source in HdLegacyTaskSchema.", + indexPath.GetText()); + return nullptr; + } + HdLegacyTaskFactorySharedPtr const factory = ds->GetTypedValue(0.0f); + if (!factory) { + TF_CODING_ERROR( + "When adding task %s in HdSceneIndexAdapterSceneDelegate: " + "No factory in HdLegacyTaskSchema.", + indexPath.GetText()); + return nullptr; + } + HdTaskSharedPtr const task = factory->Create(delegate, indexPath); + if (!task) { + TF_CODING_ERROR( + "When adding task %s in HdSceneIndexAdapterSceneDelegate: " + "No task from factory in HdLegacyTaskSchema.", + indexPath.GetText()); + } + return task; +} + void HdSceneIndexAdapterSceneDelegate::_PrimAdded( const SdfPath &primPath, @@ -208,12 +244,13 @@ HdSceneIndexAdapterSceneDelegate::_PrimAdded( // and re-insert with the correct type. // (3) The prim exists, and has the right type; in this case, we don't // remove the prim but we should invalidate all of its properties. + // Note that we make an exception for tasks - which we handle like (2). bool isResync = false; if (it != _primCache.end()) { _PrimCacheEntry &entry = (*it).second; const TfToken &existingType = entry.primType; - if (primType != existingType) { + if (primType != existingType || primType == HdPrimTypeTokens->task) { if (GetRenderIndex().IsRprimTypeSupported(existingType)) { GetRenderIndex()._RemoveRprim(indexPath); } else if (GetRenderIndex().IsSprimTypeSupported(existingType)) { @@ -243,6 +280,11 @@ HdSceneIndexAdapterSceneDelegate::_PrimAdded( } else if (primType == HdPrimTypeTokens->geomSubset) { GetRenderIndex().GetChangeTracker()._MarkRprimDirty( indexPath.GetParentPath(), HdChangeTracker::DirtyTopology); + } else if (primType == HdPrimTypeTokens->task) { + if (HdTaskSharedPtr const task = + _CreateTask(_GetInputPrim(indexPath), this, indexPath)) { + GetRenderIndex()._InsertTask(this, indexPath, task); + } } } @@ -362,6 +404,8 @@ HdSceneIndexAdapterSceneDelegate::PrimsRemoved( GetRenderIndex().GetChangeTracker()._MarkRprimDirty( entry.primPath.GetParentPath(), HdChangeTracker::DirtyTopology); + } else if (primType == HdPrimTypeTokens->task) { + GetRenderIndex().RemoveTask(entry.primPath); } } else { // Otherwise, there's a subtree and we need to call _RemoveSubtree. @@ -439,6 +483,14 @@ HdSceneIndexAdapterSceneDelegate::PrimsDirtied( } else if (primType == HdPrimTypeTokens->geomSubset) { GetRenderIndex().GetChangeTracker()._MarkRprimDirty( indexPath.GetParentPath(), HdChangeTracker::DirtyTopology); + } else if (primType == HdPrimTypeTokens->task) { + const HdDirtyBits dirtyBits = + HdDirtyBitsTranslator::TaskLocatorSetToDirtyBits( + entry.dirtyLocators); + if (dirtyBits != HdChangeTracker::Clean) { + GetRenderIndex().GetChangeTracker().MarkTaskDirty( + indexPath, dirtyBits); + } } if (entry.dirtyLocators.Intersects( @@ -2043,6 +2095,26 @@ HdSceneIndexAdapterSceneDelegate::Get(SdfPath const &id, TfToken const &key) } } + // For tasks. + if (const HdLegacyTaskSchema task = + HdLegacyTaskSchema::GetFromParent(prim.dataSource)) { + if (key == HdTokens->params) { + if (HdSampledDataSourceHandle const ds = task.GetParameters()) { + return ds->GetValue(0.0f); + } + } + if (key == HdTokens->collection) { + if (HdRprimCollectionDataSourceHandle const ds = task.GetCollection()) { + return ds->GetValue(0.0f); + } + } + if (key == HdTokens->renderTags) { + if (HdTokenVectorDataSourceHandle const ds = task.GetRenderTags()) { + return ds->GetValue(0.0f); + } + } + } + // Fallback for unknown prim conventions provided by emulated scene // delegate. if (HdTypedSampledDataSource::Handle sdDs = @@ -2732,6 +2804,20 @@ HdSceneIndexAdapterSceneDelegate::InvokeExtComputation( callback->Compute(context); } +TfTokenVector +HdSceneIndexAdapterSceneDelegate::GetTaskRenderTags(SdfPath const &taskId) +{ + TRACE_FUNCTION(); + HF_MALLOC_TAG_FUNCTION(); + const HdSceneIndexPrim prim = _GetInputPrim(taskId); + const HdLegacyTaskSchema task = HdLegacyTaskSchema::GetFromParent(prim.dataSource); + HdTokenVectorDataSourceHandle const ds = task.GetRenderTags(); + if (!ds) { + return {}; + } + return ds->GetTypedValue(0.0f); +} + void HdSceneIndexAdapterSceneDelegate::Sync(HdSyncRequestVector* request) { diff --git a/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.h b/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.h index ab112c11c3..7f497927a3 100644 --- a/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.h +++ b/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.h @@ -199,11 +199,12 @@ class HdSceneIndexAdapterSceneDelegate void InvokeExtComputation(SdfPath const &computationId, HdExtComputationContext *context) override; + TfTokenVector GetTaskRenderTags(SdfPath const &taskId) override; + void Sync(HdSyncRequestVector* request) override; void PostSyncCleanup() override; // NOTE: The remaining scene delegate functions aren't used for emulation: - // - GetTaskRenderTags // - GetScenePrimPath // - IsEnabled diff --git a/pxr/imaging/hd/tokens.h b/pxr/imaging/hd/tokens.h index 06eb28fdec..26438478b2 100644 --- a/pxr/imaging/hd/tokens.h +++ b/pxr/imaging/hd/tokens.h @@ -327,7 +327,8 @@ PXR_NAMESPACE_OPEN_SCOPE HD_SPRIMTYPE_TOKENS \ HD_BPRIMTYPE_TOKENS \ /* Scene-index-only prim types */ \ - (renderPass) + (renderPass) \ + (task) HD_API bool HdPrimTypeIsGprim(TfToken const& primType); From 9f2f90690cab78d4044a8c9d7e65a7ad34a24eae Mon Sep 17 00:00:00 2001 From: sarahsunnysideup Date: Thu, 17 Oct 2024 15:54:14 -0700 Subject: [PATCH 045/300] This changes adds an "exposureAdjust" parameter to portal lights. This exposure is added atop the dome light exposure to allow lighters to update the exposure on a portal light. (Internal change: 2345005) --- .../plugin/hdPrman/portalLightResolvingSceneIndexPlugin.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/third_party/renderman-26/plugin/hdPrman/portalLightResolvingSceneIndexPlugin.cpp b/third_party/renderman-26/plugin/hdPrman/portalLightResolvingSceneIndexPlugin.cpp index 74c13dfdb0..609348cad7 100644 --- a/third_party/renderman-26/plugin/hdPrman/portalLightResolvingSceneIndexPlugin.cpp +++ b/third_party/renderman-26/plugin/hdPrman/portalLightResolvingSceneIndexPlugin.cpp @@ -52,6 +52,7 @@ TF_DEFINE_PRIVATE_TOKENS( (exposure) (intensity) ((intensityMult, "ri:light:intensityMult")) + ((exposureAdjust, "ri:light:exposureAdjust")) ((portalName, "ri:light:portalName")) ((portalToDome, "ri:light:portalToDome")) ((tint, "ri:light:tint")) @@ -313,9 +314,11 @@ _BuildPortalLightDataSource( const VtValue portalTintVal = getPortalMatVal(_tokens->tint); const VtValue portalIntMultVal = getPortalMatVal(_tokens->intensityMult); + const VtValue portalExpAdjtVal = getPortalMatVal(_tokens->exposureAdjust); const auto portalTint = portalTintVal.GetWithDefault(GfVec3f(1.0f)); const auto portalIntMult = portalIntMultVal.GetWithDefault(1.0f); + const auto portalExpAdj = portalExpAdjtVal.GetWithDefault(0.0f); GfMatrix4d portalXform; if (const auto origPortalXform = portalXformSchema.GetMatrix()) { @@ -346,7 +349,7 @@ _BuildPortalLightDataSource( const auto computedPortalColor = GfCompMult(portalTint, domeColor); const auto computedPortalIntensity = portalIntMult * domeIntensity * - powf(2.0f, domeExposure); + powf(2.0f, domeExposure+portalExpAdj); const auto computedPortalToDome = portalXform * domeXform.GetInverse(); const auto computedPortalName = _GetPortalName(domeColorMap, domeXform, portalXform); From a652faa09d36732b86d49368de7900a2c8d04097 Mon Sep 17 00:00:00 2001 From: sarahsunnysideup Date: Thu, 17 Oct 2024 15:55:47 -0700 Subject: [PATCH 046/300] Updating the versions specified in the #ifdefs to the actual versions that these features were supported in. (Internal change: 2345006) --- .../renderman-26/plugin/hdPrman/renderPassSceneIndex.cpp | 4 ++-- .../renderman-26/plugin/hdPrman/renderPassSceneIndex.h | 4 ++-- .../plugin/hdPrman/renderPassSceneIndexPlugin.cpp | 4 ++-- .../plugin/hdPrman/renderPassSceneIndexPlugin.h | 4 ++-- third_party/renderman-26/plugin/hdPrman/renderSettings.cpp | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndex.cpp b/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndex.cpp index 0e736e301d..7fdaeac183 100644 --- a/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndex.cpp +++ b/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndex.cpp @@ -4,7 +4,7 @@ // https://openusd.org/license. #include "hdPrman/renderPassSceneIndex.h" -#if PXR_VERSION >= 2405 +#if PXR_VERSION >= 2408 #include "hdPrman/tokens.h" #include "pxr/imaging/hd/version.h" @@ -547,4 +547,4 @@ HdPrman_RenderPassSceneIndex::_UpdateActiveRenderPassState( } PXR_NAMESPACE_CLOSE_SCOPE -#endif //PXR_VERSION >= 2405 +#endif //PXR_VERSION >= 2408 diff --git a/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndex.h b/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndex.h index 776a0b6e71..eca7d9342e 100644 --- a/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndex.h +++ b/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndex.h @@ -7,7 +7,7 @@ #define EXT_RMANPKG_25_0_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_RENDER_PASS_SCENE_INDEX_H #include "pxr/pxr.h" -#if PXR_VERSION >= 2405 +#if PXR_VERSION >= 2408 #include "pxr/imaging/hd/collectionExpressionEvaluator.h" #include "pxr/imaging/hd/filteringSceneIndex.h" #include @@ -92,4 +92,4 @@ class HdPrman_RenderPassSceneIndex : PXR_NAMESPACE_CLOSE_SCOPE #endif -#endif // PXR_VERSION >= 2405 +#endif // PXR_VERSION >= 2408 diff --git a/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndexPlugin.cpp b/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndexPlugin.cpp index e25c1ce62b..18a0cb2a05 100644 --- a/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndexPlugin.cpp +++ b/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndexPlugin.cpp @@ -6,7 +6,7 @@ #include "hdPrman/renderPassSceneIndexPlugin.h" -#if PXR_VERSION >= 2405 +#if PXR_VERSION >= 2408 #include "hdPrman/tokens.h" @@ -56,4 +56,4 @@ HdPrman_RenderPassSceneIndexPlugin::_AppendSceneIndex( PXR_NAMESPACE_CLOSE_SCOPE -#endif // PXR_VERSION >= 2405 +#endif // PXR_VERSION >= 2408 diff --git a/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndexPlugin.h b/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndexPlugin.h index 0297ab05ef..d9a5190493 100644 --- a/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndexPlugin.h +++ b/third_party/renderman-26/plugin/hdPrman/renderPassSceneIndexPlugin.h @@ -8,7 +8,7 @@ #define EXT_RMANPKG_25_0_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_RENDER_PASS_SCENE_INDEX_PLUGIN_H #include "pxr/pxr.h" -#if PXR_VERSION >= 2405 +#if PXR_VERSION >= 2408 #include "pxr/imaging/hd/sceneIndexPlugin.h" #include "hdPrman/api.h" @@ -33,4 +33,4 @@ class HdPrman_RenderPassSceneIndexPlugin : public HdSceneIndexPlugin PXR_NAMESPACE_CLOSE_SCOPE #endif -#endif //PXR_VERSION >= 2405 +#endif //PXR_VERSION >= 2408 diff --git a/third_party/renderman-26/plugin/hdPrman/renderSettings.cpp b/third_party/renderman-26/plugin/hdPrman/renderSettings.cpp index 69fe636b5e..bd3e8c5183 100644 --- a/third_party/renderman-26/plugin/hdPrman/renderSettings.cpp +++ b/third_party/renderman-26/plugin/hdPrman/renderSettings.cpp @@ -231,7 +231,7 @@ _UpdateRileyCamera( } } -#if PXR_VERSION >= 2405 +#if PXR_VERSION >= 2407 // Update the Frame number from the Stage Global Scene Index void _UpdateFrame( @@ -563,7 +563,7 @@ void HdPrman_RenderSettings::_Sync( } #endif -#if PXR_VERSION >= 2405 +#if PXR_VERSION >= 2407 if (*dirtyBits & HdRenderSettings::DirtyFrameNumber || *dirtyBits & HdRenderSettings::DirtyNamespacedSettings) { _UpdateFrame(terminalSi, &_settingsOptions); @@ -587,7 +587,7 @@ void HdPrman_RenderSettings::_Sync( param->SetDrivingRenderSettingsPrimPath(GetId()); -#if PXR_VERSION >= 2405 +#if PXR_VERSION >= 2407 if (*dirtyBits & HdRenderSettings::DirtyNamespacedSettings || *dirtyBits & HdRenderSettings::DirtyActive || *dirtyBits & HdRenderSettings::DirtyShutterInterval || From 8d26aaf3dac5a458b3c1e0e36755abe4757c2a2b Mon Sep 17 00:00:00 2001 From: klucknav Date: Tue, 22 Oct 2024 10:20:02 -0700 Subject: [PATCH 047/300] Update UsdPreviewSurface spec to remove statement that when opacity = 0 we still get a specular reflection. (Internal change: 2345159) --- docs/spec_usdpreviewsurface.rst | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/spec_usdpreviewsurface.rst b/docs/spec_usdpreviewsurface.rst index 56038a7997..6b0ff67717 100644 --- a/docs/spec_usdpreviewsurface.rst +++ b/docs/spec_usdpreviewsurface.rst @@ -151,12 +151,14 @@ and :usda:`opacity`. Roughness for the second specular lobe. Clearcoat results are calculated using the same normal map data used by the primary specular lobe. +.. _updateopacity: + * **opacity - float - 1.0** When *opacity* is 1.0 then the gprim is fully opaque, if it is smaller than - 1.0 then the prim is translucent, when it is 0 the gprim is transparent. Note - that even a fully transparent object still receives lighting as, for example, - perfectly clear glass still has a specular response. + 1.0 then the prim is translucent, when it is 0 the gprim is fully transparent. + Fully transparent objects receive no lighting response, thus they always + serve as cutouts, even in "transparency mode". .. _addopacitythreshold: @@ -1073,10 +1075,20 @@ From version 2.3... of specular components, including the clearcoat when :math:`UsdPreviewSurface.clearcoat > 0`. -Version 2.5 - Current Head -########################## +Version 2.5 +########### From version 2.4... * :ref:`Updates UDIM specification to include tile 1100.` Changes the baseline UDIM tile support from 1001-1099, inclusive, to 1001-1100. This allows for a 10x10 grid of UDIM tiles. + +Version 2.6 - Current Head +########################## + +From version 2.5... + * :ref:`Updates description of UsdPreviewSurface behavior when opacity is 0. + ` + Removes the statement that materials with opacity = 0 still receive a + specular reflection, instead indicating that fully transparent materials + receive no lighting response. From d0a02f65b192a7b88122de76296c2bc46ffe4295 Mon Sep 17 00:00:00 2001 From: sunyab Date: Tue, 22 Oct 2024 10:22:16 -0700 Subject: [PATCH 048/300] python: Avoid std::tuple template instantiations Construct the arg_from_python wrappers as arguments to an immediately-invoked generic lambda instead of storing them in a std::tuple. The time to instantiate these std::tuples showed up as a hotspot when profiling compile times. With this change, a test OpenUSD build on an M1 Mac was reduced from ~13:00 to ~12:30 (~4%). As part of this, copy operations were disabled for arg_from_python implementation classes that managed objects in referent_storage. These operations were unsafe since each copy would invoke the d'tor of the same managed object. pxr_boost::python (and the original boost::python code) never actually invoked these copy operations, but conceptually this is more correct. This also avoids what seems to be a bug in Visual Studio related to C++17 copy elision and destructors being called too many times. See: https://developercommunity.visualstudio.com/t/MSVC-produces-extra-destructor-call-even/10152483 (Internal change: 2345201) --- .../converter/obj_mgr_arg_from_python.hpp | 7 +++ .../converter/rvalue_from_python_data.hpp | 4 ++ pxr/external/boost/python/detail/caller.hpp | 57 +++++++++---------- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/pxr/external/boost/python/converter/obj_mgr_arg_from_python.hpp b/pxr/external/boost/python/converter/obj_mgr_arg_from_python.hpp index 8751e92d36..7ad954c92e 100644 --- a/pxr/external/boost/python/converter/obj_mgr_arg_from_python.hpp +++ b/pxr/external/boost/python/converter/obj_mgr_arg_from_python.hpp @@ -58,6 +58,13 @@ struct object_manager_ref_arg_from_python typedef Ref result_type; object_manager_ref_arg_from_python(PyObject*); + + // Disallow copies to avoid double-destruction of object in m_result. + object_manager_ref_arg_from_python( + object_manager_ref_arg_from_python const&) = delete; + object_manager_ref_arg_from_python& operator=( + object_manager_ref_arg_from_python const&) = delete; + bool convertible() const; Ref operator()() const; ~object_manager_ref_arg_from_python(); diff --git a/pxr/external/boost/python/converter/rvalue_from_python_data.hpp b/pxr/external/boost/python/converter/rvalue_from_python_data.hpp index 24c1f61d58..64f8407198 100644 --- a/pxr/external/boost/python/converter/rvalue_from_python_data.hpp +++ b/pxr/external/boost/python/converter/rvalue_from_python_data.hpp @@ -118,6 +118,10 @@ struct rvalue_from_python_data : rvalue_from_python_storage // conversion, where the construct() function is already known. rvalue_from_python_data(void* convertible); + // Disallow copies to avoid double-destruction of object in storage. + rvalue_from_python_data(rvalue_from_python_data const&) = delete; + rvalue_from_python_data& operator=(rvalue_from_python_data const&) = delete; + // Destroys any object constructed in the storage. ~rvalue_from_python_data(); private: diff --git a/pxr/external/boost/python/detail/caller.hpp b/pxr/external/boost/python/detail/caller.hpp index c0e762c47d..0cabb30287 100644 --- a/pxr/external/boost/python/detail/caller.hpp +++ b/pxr/external/boost/python/detail/caller.hpp @@ -218,12 +218,17 @@ struct caller }; -template +template struct caller_arity> { template - struct impl + struct impl; + + template + struct impl> { + using Sig = python::type_list; + impl(F f, Policies p) : m_data(f,p) {} PyObject* operator()(PyObject* args_, PyObject*) // eliminate @@ -231,39 +236,33 @@ struct caller_arity> // trailing // keyword dict { - typedef typename detail::mpl2::front::type result_t; + typedef Ret result_t; typedef typename select_result_converter::type result_converter; typedef typename Policies::argument_package argument_package; argument_package inner_args(args_); - // N... is a 0-based sequence of indexes corresponding to the - // expected arguments in args_. However, this must be offset by - // 1 to retrieve the corresponding argument type from Sig, since - // that type sequence begins with an additional entry representing - // the function's return type. - using arg_from_python_tuple = std::tuple< - arg_from_python::type>... - >; - arg_from_python_tuple t{ get(detail::mpl2::int_(), inner_args)... }; - - if ( (... || !std::get(t).convertible()) ) { - return 0; - } - - // all converters have been checked. Now we can do the - // precall part of the policy - if (!m_data.second().precall(inner_args)) - return 0; - - PyObject* result = detail::invoke( - detail::invoke_tag() - , create_result_converter(args_, (result_converter*)0, (result_converter*)0) - , m_data.first() - , std::get(t)... - ); + return [&](auto... arg) -> PyObject* + { + if ((!arg.convertible() || ...)) { + return 0; + } + + // all converters have been checked. Now we can do the + // precall part of the policy + if (!m_data.second().precall(inner_args)) + return 0; + + PyObject* result = detail::invoke( + detail::invoke_tag() + , create_result_converter(args_, (result_converter*)0, (result_converter*)0) + , m_data.first() + , arg... + ); - return m_data.second().postcall(inner_args, result); + return m_data.second().postcall(inner_args, result); + + }(arg_from_python(get(detail::mpl2::int_(), inner_args))...); } static unsigned min_arity() { return sizeof...(N); } From c162ebbd17763d2d2082316de5438368e31aae5a Mon Sep 17 00:00:00 2001 From: pixar-oss Date: Wed, 23 Oct 2024 08:26:38 -0700 Subject: [PATCH 049/300] Adding the UsdNamespaceEditor for downstream dependent edits involving sublayers. (Internal change: 2345367) --- pxr/usd/usd/CMakeLists.txt | 7 + ...spaceEditorDependentEditsBasicSublayers.py | 894 ++++++++++++++++++ 2 files changed, 901 insertions(+) create mode 100644 pxr/usd/usd/testenv/testUsdNamespaceEditorDependentEditsBasicSublayers.py diff --git a/pxr/usd/usd/CMakeLists.txt b/pxr/usd/usd/CMakeLists.txt index 2efc40ffd4..872e470716 100644 --- a/pxr/usd/usd/CMakeLists.txt +++ b/pxr/usd/usd/CMakeLists.txt @@ -236,6 +236,7 @@ pxr_test_scripts( testenv/testUsdNamespaceEditor.py testenv/testUsdNamespaceEditorDependentEditsBase.py:testUsdNamespaceEditorDependentEditsBase.py testenv/testUsdNamespaceEditorDependentEditsBasicReferencesAndPayloads.py + testenv/testUsdNamespaceEditorDependentEditsBasicSublayers.py testenv/testUsdNamespaceEditorProperties.py testenv/testUsdNamespaceEditorTargetPathFixup.py testenv/testUsdNotices.py @@ -1288,6 +1289,12 @@ pxr_register_test(testUsdNamespaceEditorDependentEditsBasicReferencesAndPayloads EXPECTED_RETURN_CODE 0 ) +pxr_register_test(testUsdNamespaceEditorDependentEditsBasicSublayers + PYTHON + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdNamespaceEditorDependentEditsBasicSublayers" + EXPECTED_RETURN_CODE 0 +) + pxr_register_test(testUsdNamespaceEditorProperties PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdNamespaceEditorProperties" diff --git a/pxr/usd/usd/testenv/testUsdNamespaceEditorDependentEditsBasicSublayers.py b/pxr/usd/usd/testenv/testUsdNamespaceEditorDependentEditsBasicSublayers.py new file mode 100644 index 0000000000..7de3777c2a --- /dev/null +++ b/pxr/usd/usd/testenv/testUsdNamespaceEditorDependentEditsBasicSublayers.py @@ -0,0 +1,894 @@ +#!/pxrpythonsubst +# +# Copyright 2024 Pixar +# +# Licensed under the terms set forth in the LICENSE.txt file available at +# https://openusd.org/license. + +import unittest +from pxr import Sdf, Usd +from testUsdNamespaceEditorDependentEditsBase \ + import TestUsdNamespaceEditorDependentEditsBase + +class TestUsdNamespaceEditorDependentEditsBasicRelocates( + TestUsdNamespaceEditorDependentEditsBase): + '''Tests downstream dependency namespace edits across sublayers. + ''' + + def test_BasicDependentSublayers(self): + """Tests downstream dependency namespace edits across sublayers from + other dependent stages.""" + + # Setup: + # Layer1 is a simple base layer with a prim hierarchy of /Ref, + # Child, and GrandChild. This layer will be opened as the base stage + # that direct namespace edits will be performed on. + layer1 = Sdf.Layer.CreateAnonymous("layer1.usda") + layer1.ImportFromString('''#usda 1.0 + def "Ref" ( + ) { + int refAttr + + def "Child" { + int childAttr + + def "GrandChild" { + int grandChildAttr + } + } + } + ''') + + # Layer2 includes layer1 as a sublayer and provides opinions for Ref + # Child and GrandChild. + layer2 = Sdf.Layer.CreateAnonymous("layer2.usda") + layer2.ImportFromString('''#usda 1.0 + ( + subLayers = [@''' + layer1.identifier + '''@] + ) + + over "Ref" ( + ) { + int over2RefAttr + + over "Child" { + int over2ChildAttr + + over "GrandChild" { + int over2GrandChildAttr + } + } + } + ''') + + # Layer3Sub will be a sublayer of the next layer, layer3 and provides + # opinions for Ref Child and GrandChild. + layer3Sub = Sdf.Layer.CreateAnonymous("layer3-sub.usda") + layer3Sub.ImportFromString('''#usda 1.0 + over "Ref" ( + ) { + int overSub3RefAttr + + over "Child" { + int overSub3ChildAttr + + over "GrandChild" { + int overSub3GrandChildAttr + } + } + } + ''') + + # Layer3 includes layer2 (which includes layer1) and layer3Sub as + # sublayer and also includes local opionion for the prims. + layer3 = Sdf.Layer.CreateAnonymous("layer3.usda") + layer3.ImportFromString('''#usda 1.0 + ( + subLayers = [ + @''' + layer2.identifier + '''@, + @''' + layer3Sub.identifier + '''@ + ] + ) + + over "Ref" ( + ) { + int over3RefAttr + + over "Child" { + int over3ChildAttr + + over "GrandChild" { + int over3GrandChildAttr + } + } + } + ''') + + # Layer4 includes layer3 as a sublayer as well as its own local + # opinions for the same prims. + layer4 = Sdf.Layer.CreateAnonymous("layer4.usda") + layer4.ImportFromString('''#usda 1.0 + ( + subLayers = [@''' + layer3.identifier + '''@] + ) + + over "Ref" ( + ) { + int over4RefAttr + + over "Child" { + int over4ChildAttr + + over "GrandChild" { + int over4GrandChildAttr + } + } + } + ''') + + # Open stages for the 4 main layers (excludes layer3Sub) + stage1 = Usd.Stage.Open(layer1) + stage2 = Usd.Stage.Open(layer2) + stage3 = Usd.Stage.Open(layer3) + stage4 = Usd.Stage.Open(layer4) + + # Create a namespace editor for stage1 which only includes layer1. + editor = Usd.NamespaceEditor(stage1) + + # Add ONLY stage3 as a dependent stage. This is to specifically show + # how layer2 will be affected by edits because stage3 depends on it + # but layer4 will not be affected as stage4 would've needed to be added + # to introduce any dependencies on layer4. + editor.AddDependentStage(stage3) + + # Verify initial contents of each stage. + + # Stage1 only includes opinions from layer1 + stage1ChildContents = { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'], + } + } + + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'Child' : stage1ChildContents + }, + }) + + # Stage2's contents come from layer1 and layer2. + stage2ChildContents = { + '.' : ['childAttr', 'over2ChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over2GrandChildAttr'], + } + } + + self._VerifyStageContents(stage2, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr'], + 'Child' : stage2ChildContents + }, + }) + + # Stage3's contents come from layers 1, 2, 3, and 3Sub. + stage3ChildContents = { + '.' : ['childAttr', 'over2ChildAttr', 'over3ChildAttr', + 'overSub3ChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over2GrandChildAttr', + 'over3GrandChildAttr', 'overSub3GrandChildAttr'], + } + } + + self._VerifyStageContents(stage3, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', + 'overSub3RefAttr'], + 'Child' : stage3ChildContents + }, + }) + + # Stage4's contents come from all layers: 1, 2 3, 3Sub, and 4 + stage4CombinedChildContents = { + '.' : ['childAttr', 'over2ChildAttr', 'over3ChildAttr', + 'overSub3ChildAttr', 'over4ChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over2GrandChildAttr', + 'over3GrandChildAttr', 'overSub3GrandChildAttr', + 'over4GrandChildAttr'], + } + } + + self._VerifyStageContents(stage4, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', + 'overSub3RefAttr', 'over4RefAttr'], + 'Child' : stage4CombinedChildContents + }, + }) + + # Edit: Rename /Ref/Child to /Ref/RenamedChild + with self.ApplyEdits(editor, "Move /Ref/Child -> /Ref/RenamedChild"): + self.assertTrue(editor.MovePrimAtPath( + '/Ref/Child', '/Ref/RenamedChild')) + + # Verify the direct rename on stage1 + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'RenamedChild' : stage1ChildContents + }, + }) + + # Stage2 was not added as a dependent stage, but layer2 is dependent on + # layer1 edits via stage3 so stage2 reflects the rename in layer1 and + # layer2. + self._VerifyStageContents(stage2, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr'], + 'RenamedChild' : stage2ChildContents + }, + }) + + # Stage3 is a dependent stage of the editor and depends on layer1 edits + # through sublayers, so all sublayers in the dependent layer stack of + # layer3 (this includes layer3Sub) are affected by the rename and Child + # is fully renamed in stage3. + self._VerifyStageContents(stage3, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', + 'overSub3RefAttr'], + 'RenamedChild' : stage3ChildContents + }, + }) + + # Stage4 is not a dependent stage so layer4 is not updated even though + # all its other sublayers have been edited. Thus stage4 has both Child + # and RenamedChild where Child has only opinions from layer4 while + # RenamedChild has the opinions from all other layers. + layer4OnlyChildContents = { + '.' : ['over4ChildAttr'], + 'GrandChild' : { + '.' : ['over4GrandChildAttr'], + } + } + + self._VerifyStageContents(stage4, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', + 'overSub3RefAttr', 'over4RefAttr'], + 'Child' : layer4OnlyChildContents, + 'RenamedChild' : stage3ChildContents + }, + }) + + # Edit: Reparent and rename /Ref/RenamedChild to /MovedChild + with self.ApplyEdits(editor, "Move /Ref/RenamedChild -> /MovedChild"): + self.assertTrue(editor.MovePrimAtPath( + '/Ref/RenamedChild', '/MovedChild')) + + # Verify the direct reparent and rename on stage1 + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + }, + 'MovedChild' : stage1ChildContents + }) + + # Like with the rename edit previously, RenamedChild is moved to + # /MovedChild in all layers and is reflected as a move in both stage2 + # and stage3. + self._VerifyStageContents(stage2, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr'], + }, + 'MovedChild' : stage2ChildContents + }) + + self._VerifyStageContents(stage3, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', 'overSub3RefAttr'], + }, + 'MovedChild' : stage3ChildContents + }) + + # And RenamedChild is also fully moved to /MovedChild in stage4. But + # note that the specs for Child in layer4 were not renamed in the first + # edit so Child still exists with the same "layer4 only" contents as + # before. + self._VerifyStageContents(stage4, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', + 'overSub3RefAttr', 'over4RefAttr'], + 'Child' : layer4OnlyChildContents, + }, + 'MovedChild' : stage3ChildContents + }) + + # Edit: Reparent and rename /MovedChild back to its original path + # /Ref/Child + with self.ApplyEdits(editor, "Move /MovedChild -> /Ref/Child"): + self.assertTrue(editor.MovePrimAtPath('/MovedChild', '/Ref/Child')) + + # All stages return to their exact original contents. + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'Child' : stage1ChildContents + }, + }) + + self._VerifyStageContents(stage2, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr'], + 'Child' : stage2ChildContents + }, + }) + + self._VerifyStageContents(stage3, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', + 'overSub3RefAttr'], + 'Child' : stage3ChildContents + }, + }) + + # This includes stage4 where layer4's Child opinions are once again + # composed with the Child opinions from the other sublayers. + self._VerifyStageContents(stage4, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', + 'overSub3RefAttr', 'over4RefAttr'], + 'Child' : stage4CombinedChildContents + }, + }) + + # Edit: Delete the prim at /Ref/Child + with self.ApplyEdits(editor, "Delete /Ref/Child"): + self.assertTrue(editor.DeletePrimAtPath('/Ref/Child')) + + # Verify the direct delete on stage1 + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + }, + }) + + # Stage2 was not added as a dependent stage, but layer2 is dependent on + # layer1 edits via stage3 so stage2 reflects the delete of Child in + # layer1 and layer2. + self._VerifyStageContents(stage2, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr'], + }, + }) + + # Stage3 is a dependent stage of the editor and depends on layer1 edits + # through sublayers, so all sublayers in the dependent layer stack of + # layer3 are affected by the deletion and Child is fully deleted in + # stage3. + self._VerifyStageContents(stage3, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', + 'overSub3RefAttr'], + }, + }) + + # Stage4 is not a dependent stage so layer4 is not updated even though + # all its other sublayers have been edited. Thus stage4 still has Child + # which now only has opinions from layer4 as the Child opinions from all + # other sublayers have been deleted. + self._VerifyStageContents(stage4, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', + 'overSub3RefAttr', 'over4RefAttr'], + 'Child' : layer4OnlyChildContents + }, + }) + + def test_DependentSublayersAcrossArcs(self): + """Tests downstream dependency namespace edits across sublayers from + within composition arcs.""" + + # Setup: + # Layer1 is a simple base layer with a prim hierarchy of /Ref, + # Child, and GrandChild. This layer will be opened as the base stage + # that direct namespace edits will be performed on. + layer1 = Sdf.Layer.CreateAnonymous("layer1.usda") + layer1.ImportFromString('''#usda 1.0 + def "Ref" ( + ) { + int refAttr + + def "Child" { + int childAttr + + def "GrandChild" { + int grandChildAttr + } + } + } + ''') + + # Layer2 includes layer1 as a sublayer and provides opinions for Ref + # Child and GrandChild. + layer2 = Sdf.Layer.CreateAnonymous("layer2.usda") + layer2.ImportFromString('''#usda 1.0 + ( + subLayers = [@''' + layer1.identifier + '''@] + ) + + over "Ref" ( + ) { + int over2RefAttr + + over "Child" { + int over2ChildAttr + + over "GrandChild" { + int over2GrandChildAttr + } + } + } + ''') + + # Layer3 has three prims that reference /Ref, /Ref/Child, and + # /Ref/Child/GrandChild from layer2 respectively. These will be + # affected by downstream dependency edits. + layer3 = Sdf.Layer.CreateAnonymous("layer3.usda") + layer3.ImportFromString('''#usda 1.0 + def "Prim1" ( + references = @''' + layer2.identifier + '''@ + ) { + int over3RefAttr + over "Child" { + int over3ChildAttr + over "GrandChild" { + int over3GrandChildAttr + } + } + } + + def "Prim2" ( + references = @''' + layer2.identifier + '''@ + ) { + int over3ChildAttr + over "GrandChild" { + int over3GrandChildAttr + } + } + + def "Prim3" ( + references = @''' + layer2.identifier + '''@ + ) { + int over3GrandChildAttr + } + ''') + + # Layer4Sub will be a sublayer of the next layer, layer4, which holds + # overs for all the prims that are defined in layer3. + layer4Sub = Sdf.Layer.CreateAnonymous("layer4-sub.usda") + layer4Sub.ImportFromString('''#usda 1.0 + over "Prim1" { + int over4RefAttr + over "Child" { + int over4ChildAttr + over "GrandChild" { + int over4GrandChildAttr + } + } + } + + over "Prim2" { + int over4ChildAttr + over "GrandChild" { + int over4GrandChildAttr + } + } + + over "Prim3" { + int over4GrandChildAttr + } + ''') + + # Layer4 just has two sublayers, layer3 which defines prims with + # references and layer4Sub which provides local opinions for those + # prims. This layer has no specs of its own. + layer4 = Sdf.Layer.CreateAnonymous("layer4.usda") + layer4.ImportFromString('''#usda 1.0 + ( + subLayers = [ + @''' + layer3.identifier + '''@, + @''' + layer4Sub.identifier + '''@ + ] + ) + ''') + + # Open stages for the 4 main layers (excludes layer4Sub) + stage1 = Usd.Stage.Open(layer1) + stage2 = Usd.Stage.Open(layer2) + stage3 = Usd.Stage.Open(layer3) + stage4 = Usd.Stage.Open(layer4) + + # Create a namespace editor for stage1 which only includes layer1. + editor = Usd.NamespaceEditor(stage1) + + # Add ONLY stage4 as a dependent stage. This is to specifically show + # how all layers will be affected by edits because stage4 introduces + # dependencies on all layers through a combination of sublayers and + # references. + editor.AddDependentStage(stage4) + + # Verify the initial composition fields for layer3 which is the only + # layer with non-sublayer composition fields. + self.assertEqual(self._GetCompositionFieldsInLayer(layer3), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Ref/Child'),) + }, + '/Prim3' : { + 'references' : (Sdf.Reference(layer2.identifier, + '/Ref/Child/GrandChild'),) + }, + }) + + # Verify initial contents of each stage. + + # Stage1 has just the contents of layer1 + stage1ChildContents = { + '.' : ['childAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr'], + } + } + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'Child' : stage1ChildContents + }, + }) + + # Stage2 composes layer2 with its only sublayer, layer1. + stage2ChildContents = { + '.' : ['childAttr', 'over2ChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over2GrandChildAttr'], + } + } + self._VerifyStageContents(stage2, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr'], + 'Child' : stage2ChildContents + }, + }) + + # Stage3 has each prim composed with the referenced opinions from layer2 + # (which includes sublayer layer1) and the local opinions in layer3. + stage3Prim1ChildContents = { + '.' : ['childAttr', 'over2ChildAttr', 'over3ChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over2GrandChildAttr', + 'over3GrandChildAttr'], + } + } + stage3Prim2Contents = { + '.' : ['childAttr', 'over2ChildAttr', 'over3ChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over2GrandChildAttr', + 'over3GrandChildAttr'], + } + } + stage3Prim3Contents = { + '.' : ['grandChildAttr', 'over2GrandChildAttr', + 'over3GrandChildAttr'], + } + + self._VerifyStageContents(stage3, { + 'Prim1': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr'], + 'Child' : stage3Prim1ChildContents + }, + 'Prim2' : stage3Prim2Contents, + 'Prim3' : stage3Prim3Contents + }) + + # Stage4 has the same prims from stage3 composed with local opinions + # from sublayer layer4Sub + stage4Prim1ChildContents = { + '.' : ['childAttr', 'over2ChildAttr', 'over3ChildAttr', + 'over4ChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over2GrandChildAttr', + 'over3GrandChildAttr', 'over4GrandChildAttr'], + } + } + stage4Prim2Contents = { + '.' : ['childAttr', 'over2ChildAttr', 'over3ChildAttr', + 'over4ChildAttr'], + 'GrandChild' : { + '.' : ['grandChildAttr', 'over2GrandChildAttr', + 'over3GrandChildAttr', 'over4GrandChildAttr'], + } + } + stage4Prim3Contents = { + '.' : ['grandChildAttr', 'over2GrandChildAttr', + 'over3GrandChildAttr', 'over4GrandChildAttr'], + } + + self._VerifyStageContents(stage4, { + 'Prim1': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', + 'over4RefAttr'], + 'Child' : stage4Prim1ChildContents + }, + 'Prim2' : stage4Prim2Contents, + 'Prim3' : stage4Prim3Contents + }) + + # Edit: Rename /Ref/Child to /Ref/RenamedChild + with self.ApplyEdits(editor, "Move /Ref/Child -> /Ref/RenamedChild"): + self.assertTrue(editor.MovePrimAtPath( + '/Ref/Child', '/Ref/RenamedChild')) + + # Verify the updated composition fields for layer3 where Prim2 and Prim3 + # reference paths are updated to the renamed path. + self.assertEqual(self._GetCompositionFieldsInLayer(layer3), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : (Sdf.Reference(layer2.identifier, + '/Ref/RenamedChild'),) + }, + '/Prim3' : { + 'references' : (Sdf.Reference(layer2.identifier, + '/Ref/RenamedChild/GrandChild'),) + }, + }) + + # Verify the direct rename of Child on stage1. + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'RenamedChild' : stage1ChildContents + }, + }) + + # On stage2, Child is also fully renamed because layer2's specs were + # updated for the sublayer dependency on layer1. Note that stage4 is the + # only dependent stage added to the namespace editor so this update + # only occurs because stage4 has dependencies on these layer2 specs. + self._VerifyStageContents(stage2, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr'], + 'RenamedChild' : stage2ChildContents + }, + }) + + # On stage3, the rename of Child is propagated across the reference for + # Prim1 where the specs from layer3 are also renamed resulting in a full + # rename of /Prim1/Child. Prim2 and Prim3's composed contents are + # unchanged as their reference fields were updated to the new paths. + # Note that, like with stage2, these updates only occur because stage4 + # has dependencies on layer3 specs. + self._VerifyStageContents(stage3, { + 'Prim1': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr'], + 'RenamedChild' : stage3Prim1ChildContents + }, + 'Prim2' : stage3Prim2Contents, + 'Prim3' : stage3Prim3Contents + }) + + # On stage4, the rename of Child is propagated across the reference for + # Prim1 as in stage3. The sublayer layer4Sub has its specs updated for + # the rename resulting in /Prim1/RenamedChild having all the same + # opinions as /Prim1/Child did prior. + # + # Prim2 and Prim3's composed contents are unchanged as their reference + # fields were updated to the new paths (no changes are necessary to the + # overs in sublayer layer4Sub). + self._VerifyStageContents(stage4, { + 'Prim1': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', 'over4RefAttr'], + 'RenamedChild' : stage4Prim1ChildContents + }, + 'Prim2' : stage4Prim2Contents, + 'Prim3' : stage4Prim3Contents + }) + + # Edit: Reparent and rename /Ref/RenamedChild to /MovedChild + with self.ApplyEdits(editor, "Move /Ref/RenamedChild -> /MovedChild"): + self.assertTrue(editor.MovePrimAtPath( + '/Ref/RenamedChild', '/MovedChild')) + + # Verify the updated composition fields for layer3 where Prim2 and Prim3 + # reference paths are updated to the moved path. + self.assertEqual(self._GetCompositionFieldsInLayer(layer3), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : (Sdf.Reference(layer2.identifier, + '/MovedChild'),) + }, + '/Prim3' : { + 'references' : (Sdf.Reference(layer2.identifier, + '/MovedChild/GrandChild'),) + }, + }) + + # Verify updated contents of stage1 and stage2. /Ref/RenamedChild is + # fully moved to /MovedChild on both stages. + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + }, + 'MovedChild' : stage1ChildContents + }) + + self._VerifyStageContents(stage2, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr'], + }, + 'MovedChild' : stage2ChildContents + }) + + # On stage3 and stage4, RenamedChild has been moved out from under the + # referenced prim for Prim1 resulting in an effective deletion of + # RenamedChild. All specs in layer3 and layer4Sub referring to + # /Prim1/RenamedChild are deleted too resulting in a full deletion of + # this prim on these stages. + # + # Prim2 and Prim3's composed contents are unchanged as their reference + # fields were updated to the new paths and no changes are necessary to + # the local specs in layer3 and layer4Sub). + self._VerifyStageContents(stage3, { + 'Prim1': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr'], + }, + 'Prim2' : stage3Prim2Contents, + 'Prim3' : stage3Prim3Contents + }) + + self._VerifyStageContents(stage4, { + 'Prim1': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', 'over4RefAttr'], + }, + 'Prim2' : stage4Prim2Contents, + 'Prim3' : stage4Prim3Contents + }) + + # Edit: Reparent and rename /MovedChild back to its original path + # /Ref/Child + with self.ApplyEdits(editor, "Move /MovedChild -> /Ref/Child"): + self.assertTrue(editor.MovePrimAtPath('/MovedChild', '/Ref/Child')) + + # Verify the updated composition fields for layer3 where Prim2 and Prim3 + # reference paths are updated to the original paths. + self.assertEqual(self._GetCompositionFieldsInLayer(layer3), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : (Sdf.Reference(layer2.identifier, + '/Ref/Child'),) + }, + '/Prim3' : { + 'references' : (Sdf.Reference(layer2.identifier, + '/Ref/Child/GrandChild'),) + }, + }) + + # Verify updated contents of stage1 and stage2 where /Ref/Child has + # been returned to its original contents. + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + 'Child' : stage1ChildContents + }, + }) + + self._VerifyStageContents(stage2, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr'], + 'Child' : stage2ChildContents + }, + }) + + # On stage3 and stage4, Child has returned under Prim1 but now only + # matches the contents of /Ref/Child as seen on stage2. This is because + # the local specs on layer3 and layer4Sub for this prim were deleted + # by the prior edit and are not able to restored via this namespace + # edit. Thus /Prim1/Child only consists of specs from layer1 and layer2. + # + # Prim2 and Prim3's composed contents remain unchanged as their + # reference fields were updated to the original paths. + self._VerifyStageContents(stage3, { + 'Prim1': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr'], + 'Child' : stage2ChildContents + }, + 'Prim2' : stage3Prim2Contents, + 'Prim3' : stage3Prim3Contents + }) + + self._VerifyStageContents(stage4, { + 'Prim1': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', 'over4RefAttr'], + 'Child' : stage2ChildContents + }, + 'Prim2' : stage4Prim2Contents, + 'Prim3' : stage4Prim3Contents + }) + + # Edit: Delete the prim at /Ref/Child + with self.ApplyEdits(editor, "Delete /Ref/Child"): + self.assertTrue(editor.DeletePrimAtPath('/Ref/Child')) + + # Verify the updated composition fields for layer3 where Prim2 and Prim3 + # references are deleted because prims at those paths have been deleted. + self.assertEqual(self._GetCompositionFieldsInLayer(layer3), { + '/Prim1' : { + 'references' : (Sdf.Reference(layer2.identifier, '/Ref'),) + }, + '/Prim2' : { + 'references' : () + }, + '/Prim3' : { + 'references' : () + }, + }) + + # Verify updated contents of stage1 and stage2. /Ref/Child is fully + # deleted on both stages. + self._VerifyStageContents(stage1, { + 'Ref': { + '.' : ['refAttr'], + }, + }) + + self._VerifyStageContents(stage2, { + 'Ref': { + '.' : ['refAttr', 'over2RefAttr'], + }, + }) + + # On stage3 and stage4, Child is fully deleted from under Prim1 again. + # + # This time Prim2 and Prim3's composed contents have changed as they + # no longer have references to layer2. Local opinions for /Prim2 and + # /Prim3 in layer3 and layer4Sub remain but opinions for + # /Prim2/GrandChild (which is considered an over for the deleted + # ancestral reference to /Ref/Child/GrandChild) are deleted. + self._VerifyStageContents(stage3, { + 'Prim1': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr'], + }, + 'Prim2' : { + '.' : ['over3ChildAttr'], + }, + 'Prim3' : { + '.' : ['over3GrandChildAttr'], + } + }) + + self._VerifyStageContents(stage4, { + 'Prim1': { + '.' : ['refAttr', 'over2RefAttr', 'over3RefAttr', 'over4RefAttr'], + }, + 'Prim2' : { + '.' : ['over3ChildAttr', 'over4ChildAttr'], + }, + 'Prim3' : { + '.' : ['over3GrandChildAttr', 'over4GrandChildAttr'], + } + }) + +if __name__ == '__main__': + unittest.main() From 1abb3631e298505cd1e0387b04cadd3819aa7715 Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Wed, 23 Oct 2024 08:26:53 -0700 Subject: [PATCH 050/300] UsdStage.Open could result in a TF_RUNTIME_ERROR Example from usdAbc plugin, which should be appropriately handled. Note that couple of tests in usdchecker were "passing" because of an expected exception from usdAbc raise tf runtime error. But instead it should be reported as an error from the ComplianceChecker. (Internal change: 2345379) --- pxr/usd/usdUtils/complianceChecker.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pxr/usd/usdUtils/complianceChecker.py b/pxr/usd/usdUtils/complianceChecker.py index fec233e58c..1ad43063a7 100644 --- a/pxr/usd/usdUtils/complianceChecker.py +++ b/pxr/usd/usdUtils/complianceChecker.py @@ -1073,7 +1073,16 @@ def CheckCompliance(self, inputFile): # Collect all warnings using a diagnostic delegate. delegate = UsdUtils.CoalescingDiagnosticDelegate() - usdStage = Usd.Stage.Open(inputFile) + from pxr import Tf + try: + # It is possible Usd.Stage.Open will raise a TF_RUNTIME_ERROR + # (example via usdAbc plugin) which should be appropriately handled. + usdStage = Usd.Stage.Open(inputFile) + except Tf.ErrorException as e: + self._AddError("Failed to open USD stage from file '%s': %s" % + (inputFile, str(e))) + return + stageOpenDiagnostics = delegate.TakeUncoalescedDiagnostics() for rule in self._rules: @@ -1083,8 +1092,15 @@ def CheckCompliance(self, inputFile): with Ar.ResolverContextBinder(usdStage.GetPathResolverContext()): # This recursively computes all of inputFiles's external # dependencies. - (allLayers, allAssets, unresolvedPaths) = \ + from pxr import Tf + try: + (allLayers, allAssets, unresolvedPaths) = \ UsdUtils.ComputeAllDependencies(Sdf.AssetPath(inputFile)) + except Tf.ErrorException as e: + self._AddError( + "Failed to compute dependencies for file '%s': %s" % + (inputFile, str(e))) + return for rule in self._rules: rule.CheckUnresolvedPaths(unresolvedPaths) rule.CheckDependencies(usdStage, allLayers, allAssets) From 26e89def17170907bed763c002c10349929c6cff Mon Sep 17 00:00:00 2001 From: clach Date: Wed, 23 Oct 2024 08:27:04 -0700 Subject: [PATCH 051/300] [hdSt] One more piece Autodesk PR #3170. Removes CMake script duplication for GL and Vulkan versions of testHdStCodeGen. Adds some missing test directories. See github pull request #3170. (Internal change: 2345394) --- pxr/imaging/hdSt/CMakeLists.txt | 314 +++++++++++--------------------- 1 file changed, 103 insertions(+), 211 deletions(-) diff --git a/pxr/imaging/hdSt/CMakeLists.txt b/pxr/imaging/hdSt/CMakeLists.txt index b5d4156117..1aca8b0eb6 100644 --- a/pxr/imaging/hdSt/CMakeLists.txt +++ b/pxr/imaging/hdSt/CMakeLists.txt @@ -2325,6 +2325,7 @@ pxr_register_test(testHdStBufferArray EXPECTED_RETURN_CODE 0 STDOUT_REDIRECT testHdStBufferArray-Run1-stdout.txt POST_COMMAND "diff -I drawingShader -I computeShader -I gpuMemoryUsed -I meshTopology -I basisCurvesTopology -I uboSize -I ssboSize testHdStBufferArray-Run1-stdout.txt ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStBufferArray/baseline/testHdStBufferArray-Run1-stdout.txt" TESTENV testHdStBufferArray + TESTENV testHdStBufferArray ENV TF_DEBUG=HD_SAFE_MODE HD_ENABLE_DOUBLE_MATRIX=1 @@ -2373,217 +2374,106 @@ pxr_register_test(testHdStClipPlanes2 ENV TF_DEBUG=HD_SAFE_MODE ) -pxr_register_test(testHdStCodeGen_GL_Mesh_Indirect - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_indirect.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out" - TESTENV testHdStCodeGen_GL - ENV - TF_DEBUG=HD_SAFE_MODE - HGIGL_ENABLE_BINDLESS_BUFFER=1 - HGIGL_ENABLE_BINDLESS_TEXTURE=1 - HGIGL_GLSL_VERSION=450 - HGI_ENABLE_VULKAN=0 -) -pxr_register_test(testHdStCodeGen_GL_Mesh_Indirect_SmoothNormals - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --smoothNormals | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_indirect_smoothNormals.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_smoothNormals.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out" - TESTENV testHdStCodeGen_GL - ENV - TF_DEBUG=HD_SAFE_MODE - HGIGL_ENABLE_BINDLESS_BUFFER=1 - HGIGL_ENABLE_BINDLESS_TEXTURE=1 - HGIGL_GLSL_VERSION=450 - HGI_ENABLE_VULKAN=0 -) -pxr_register_test(testHdStCodeGen_GL_Mesh_Indirect_DoubleSided - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --doubleSided | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_indirect_doubleSided.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_doubleSided.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out" - TESTENV testHdStCodeGen_GL - ENV - TF_DEBUG=HD_SAFE_MODE - HGIGL_ENABLE_BINDLESS_BUFFER=1 - HGIGL_ENABLE_BINDLESS_TEXTURE=1 - HGIGL_GLSL_VERSION=450 - HGI_ENABLE_VULKAN=0 -) -pxr_register_test(testHdStCodeGen_GL_Mesh_Indirect_FaceVarying - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --faceVarying | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_indirect_faceVarying.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_faceVarying.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out" - TESTENV testHdStCodeGen_GL - ENV - TF_DEBUG=HD_SAFE_MODE - HGIGL_ENABLE_BINDLESS_BUFFER=1 - HGIGL_ENABLE_BINDLESS_TEXTURE=1 - HGIGL_GLSL_VERSION=450 - HGI_ENABLE_VULKAN=0 -) -pxr_register_test(testHdStCodeGen_GL_Mesh_Indirect_Instance - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --instance | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_indirect_instance.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_instance.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out" - TESTENV testHdStCodeGen_GL - ENV - TF_DEBUG=HD_SAFE_MODE - HGIGL_ENABLE_BINDLESS_BUFFER=1 - HGIGL_ENABLE_BINDLESS_TEXTURE=1 - HGIGL_GLSL_VERSION=450 - HGI_ENABLE_VULKAN=0 -) -pxr_register_test(testHdStCodeGen_GL_Mesh_EdgeOnly - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --edgeOnly | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_edgeonly.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_edgeonly.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out" - TESTENV testHdStCodeGen_GL - ENV - TF_DEBUG=HD_SAFE_MODE - HGIGL_ENABLE_BINDLESS_BUFFER=1 - HGIGL_ENABLE_BINDLESS_TEXTURE=1 - HGIGL_GLSL_VERSION=450 - HGI_ENABLE_VULKAN=0 -) -pxr_register_test(testHdStCodeGen_GL_Mesh_EdgeOnly_BlendWireframe - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --edgeOnly --blendWireframe | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_edgeonly_blendwireframe.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_edgeonly_blendwireframe.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out" - TESTENV testHdStCodeGen_GL - ENV - TF_DEBUG=HD_SAFE_MODE - HGIGL_ENABLE_BINDLESS_BUFFER=1 - HGIGL_ENABLE_BINDLESS_TEXTURE=1 - HGIGL_GLSL_VERSION=450 - HGI_ENABLE_VULKAN=0 -) -pxr_register_test(testHdStCodeGen_GL_Curves_Indirect - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --curves | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_curves_indirect.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_curves_indirect.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out" - TESTENV testHdStCodeGen_GL - ENV - TF_DEBUG=HD_SAFE_MODE - HGIGL_ENABLE_BINDLESS_BUFFER=1 - HGIGL_ENABLE_BINDLESS_TEXTURE=1 - HGIGL_GLSL_VERSION=450 - HGI_ENABLE_VULKAN=0 -) -pxr_register_test(testHdStCodeGen_GL_Points_Indirect - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --points | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_points_indirect.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_points_indirect.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_GL/baseline/codegen_points_indirect.out" - TESTENV testHdStCodeGen_GL - ENV - TF_DEBUG=HD_SAFE_MODE - HGIGL_ENABLE_BINDLESS_BUFFER=1 - HGIGL_ENABLE_BINDLESS_TEXTURE=1 - HGIGL_GLSL_VERSION=450 - HGI_ENABLE_VULKAN=0 -) -# Skip Vulkan codegen tests if not supported by build. -if (${PXR_ENABLE_VULKAN_SUPPORT}) -pxr_register_test(testHdStCodeGen_Vulkan_Mesh_Indirect - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_indirect.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out" - TESTENV testHdStCodeGen_Vulkan - ENV - TF_DEBUG=HD_SAFE_MODE - HGI_ENABLE_VULKAN=1 -) -pxr_register_test(testHdStCodeGen_Vulkan_Mesh_Indirect_SmoothNormals - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --smoothNormals | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_indirect_smoothNormals.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_smoothNormals.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out" - TESTENV testHdStCodeGen_Vulkan - ENV - TF_DEBUG=HD_SAFE_MODE - HGI_ENABLE_VULKAN=1 -) -pxr_register_test(testHdStCodeGen_Vulkan_Mesh_Indirect_DoubleSided - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --doubleSided | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_indirect_doubleSided.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_doubleSided.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out" - TESTENV testHdStCodeGen_Vulkan - ENV - TF_DEBUG=HD_SAFE_MODE - HGI_ENABLE_VULKAN=1 -) -pxr_register_test(testHdStCodeGen_Vulkan_Mesh_Indirect_FaceVarying - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --faceVarying | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_indirect_faceVarying.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_faceVarying.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out" - TESTENV testHdStCodeGen_Vulkan - ENV - TF_DEBUG=HD_SAFE_MODE - HGI_ENABLE_VULKAN=1 -) -pxr_register_test(testHdStCodeGen_Vulkan_Mesh_Indirect_Instance - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --instance | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_indirect_instance.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_instance.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out" - TESTENV testHdStCodeGen_Vulkan - ENV - TF_DEBUG=HD_SAFE_MODE - HGI_ENABLE_VULKAN=1 -) -pxr_register_test(testHdStCodeGen_Vulkan_Mesh_EdgeOnly - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --edgeOnly | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_edgeonly.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_edgeonly.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out" - TESTENV testHdStCodeGen_Vulkan - ENV - TF_DEBUG=HD_SAFE_MODE - HGI_ENABLE_VULKAN=1 -) -pxr_register_test(testHdStCodeGen_Vulkan_Mesh_EdgeOnly_BlendWireframe - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --edgeOnly --blendWireframe | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_mesh_edgeonly_blendwireframe.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_edgeonly_blendwireframe.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out" - TESTENV testHdStCodeGen_Vulkan - ENV - TF_DEBUG=HD_SAFE_MODE - HGI_ENABLE_VULKAN=1 -) -pxr_register_test(testHdStCodeGen_Vulkan_Curves_Indirect - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --curves | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_curves_indirect.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_curves_indirect.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out" - TESTENV testHdStCodeGen_Vulkan - ENV - TF_DEBUG=HD_SAFE_MODE - HGI_ENABLE_VULKAN=1 -) -pxr_register_test(testHdStCodeGen_Vulkan_Points_Indirect - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --points | grep -v '// line'" - EXPECTED_RETURN_CODE 0 - STDOUT_REDIRECT codegen_points_indirect.out - POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_points_indirect.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out" - TESTENV testHdStCodeGen_Vulkan - ENV - TF_DEBUG=HD_SAFE_MODE - HGI_ENABLE_VULKAN=1 -) -endif() # PXR_ENABLE_VULKAN_SUPPORT +function(register_codegen_tests suffix hgi_env) + pxr_register_test(testHdStCodeGen${suffix}_Mesh_Indirect + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh | grep -v '// line'" + EXPECTED_RETURN_CODE 0 + STDOUT_REDIRECT codegen_mesh_indirect.out + POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen${suffix}/baseline/codegen_mesh_indirect.out" + TESTENV testHdStCodeGen${suffix} + ENV + TF_DEBUG=HD_SAFE_MODE + ${hgi_env} + ) + pxr_register_test(testHdStCodeGen${suffix}_Mesh_Indirect_SmoothNormals + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --smoothNormals | grep -v '// line'" + EXPECTED_RETURN_CODE 0 + STDOUT_REDIRECT codegen_mesh_indirect_smoothNormals.out + POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_smoothNormals.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen${suffix}/baseline/codegen_mesh_indirect_smoothNormals.out" + TESTENV testHdStCodeGen${suffix} + ENV + TF_DEBUG=HD_SAFE_MODE + ${hgi_env} + ) + pxr_register_test(testHdStCodeGen${suffix}_Mesh_Indirect_DoubleSided + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --doubleSided | grep -v '// line'" + EXPECTED_RETURN_CODE 0 + STDOUT_REDIRECT codegen_mesh_indirect_doubleSided.out + POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_doubleSided.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen${suffix}/baseline/codegen_mesh_indirect_doubleSided.out" + TESTENV testHdStCodeGen${suffix} + ENV + TF_DEBUG=HD_SAFE_MODE + ${hgi_env} + ) + pxr_register_test(testHdStCodeGen${suffix}_Mesh_Indirect_FaceVarying + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --faceVarying | grep -v '// line'" + EXPECTED_RETURN_CODE 0 + STDOUT_REDIRECT codegen_mesh_indirect_faceVarying.out + POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_faceVarying.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen${suffix}/baseline/codegen_mesh_indirect_faceVarying.out" + TESTENV testHdStCodeGen${suffix} + ENV + TF_DEBUG=HD_SAFE_MODE + ${hgi_env} + ) + pxr_register_test(testHdStCodeGen${suffix}_Mesh_Indirect_Instance + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --instance | grep -v '// line'" + EXPECTED_RETURN_CODE 0 + STDOUT_REDIRECT codegen_mesh_indirect_instance.out + POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_indirect_instance.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen${suffix}/baseline/codegen_mesh_indirect_instance.out" + TESTENV testHdStCodeGen${suffix} + ENV + TF_DEBUG=HD_SAFE_MODE + ${hgi_env} + ) + pxr_register_test(testHdStCodeGen${suffix}_Mesh_EdgeOnly + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --edgeOnly | grep -v '// line'" + EXPECTED_RETURN_CODE 0 + STDOUT_REDIRECT codegen_mesh_edgeonly.out + POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_edgeonly.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen${suffix}/baseline/codegen_mesh_edgeonly.out" + TESTENV testHdStCodeGen${suffix} + ENV + TF_DEBUG=HD_SAFE_MODE + ${hgi_env} + ) + pxr_register_test(testHdStCodeGen${suffix}_Mesh_EdgeOnly_BlendWireframe + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --mesh --edgeOnly --blendWireframe | grep -v '// line'" + EXPECTED_RETURN_CODE 0 + STDOUT_REDIRECT codegen_mesh_edgeonly_blendwireframe.out + POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_mesh_edgeonly_blendwireframe.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen${suffix}/baseline/codegen_mesh_edgeonly_blendwireframe.out" + TESTENV testHdStCodeGen${suffix} + ENV + TF_DEBUG=HD_SAFE_MODE + ${hgi_env} + ) + pxr_register_test(testHdStCodeGen${suffix}_Curves_Indirect + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --curves | grep -v '// line'" + EXPECTED_RETURN_CODE 0 + STDOUT_REDIRECT codegen_curves_indirect.out + POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_curves_indirect.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen${suffix}/baseline/codegen_curves_indirect.out" + TESTENV testHdStCodeGen${suffix} + ENV + TF_DEBUG=HD_SAFE_MODE + ${hgi_env} + ) + pxr_register_test(testHdStCodeGen${suffix}_Points_Indirect + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCodeGen --points | grep -v '// line'" + EXPECTED_RETURN_CODE 0 + STDOUT_REDIRECT codegen_points_indirect.out + POST_COMMAND "diff -I '\".*\.glslfx\"' codegen_points_indirect.out ${CMAKE_INSTALL_PREFIX}/tests/ctest/testHdStCodeGen${suffix}/baseline/codegen_points_indirect.out" + TESTENV testHdStCodeGen${suffix} + ENV + TF_DEBUG=HD_SAFE_MODE + ${hgi_env} + ) +endfunction() +# OpenGL codegen tests require X11 to create a context +if(PXR_ENABLE_GL_SUPPORT AND X11_FOUND) + register_codegen_tests(_GL "HGI_ENABLE_VULKAN=0;HGIGL_ENABLE_BINDLESS_BUFFER=1;HGIGL_ENABLE_BINDLESS_TEXTURE=1;HGIGL_GLSL_VERSION=450") +endif() +if(PXR_ENABLE_VULKAN_SUPPORT) + register_codegen_tests(_Vulkan "HGI_ENABLE_VULKAN=1;") +endif() pxr_register_test(testHdStCurveDrawing_lv0_refined COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStCurveDrawing --offscreen --repr refined --refineLevel 0 --write testHdStCurveDrawing_lv0_refined.png" @@ -2773,12 +2663,14 @@ pxr_register_test(testHdStFaceCulling_FrontUnlessDoubleSided pxr_register_test(testHdStFrustumCullingCPU COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStFrustumCulling --offscreen" EXPECTED_RETURN_CODE 0 + TESTENV testHdStFrustumCulling ENV HD_ENABLE_GPU_FRUSTUM_CULLING=0 ) pxr_register_test(testHdStFrustumCullingGPU COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testHdStFrustumCulling --offscreen" EXPECTED_RETURN_CODE 0 + TESTENV testHdStFrustumCulling ENV HD_ENABLE_GPU_FRUSTUM_CULLING=1 HD_ENABLE_GPU_COUNT_VISIBLE_INSTANCES=1 @@ -3469,4 +3361,4 @@ pxr_register_test(testHdStShaders ENV TF_DEBUG=HD_SAFE_MODE ) -endif() # TARGET shared_libs +endif() # TARGET shared_libs \ No newline at end of file From 7044166b26a40aed4b3ea6be9dee83966fb9cf0d Mon Sep 17 00:00:00 2001 From: anwang2009 Date: Wed, 23 Oct 2024 11:18:25 -0700 Subject: [PATCH 052/300] Remove flag PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS; time scaling by layer has been performed by PCP for a while now. This disables any legacy behavior. (Internal change: 2345511) --- pxr/usd/pcp/CMakeLists.txt | 54 --- pxr/usd/pcp/layerStack.cpp | 26 +- pxr/usd/pcp/layerStack.h | 8 - pxr/usd/pcp/primIndex.cpp | 28 +- pxr/usd/pcp/testenv/testPcpChanges.py | 3 - ...tionResults_TimeCodesPerSecond1_Legacy.txt | 395 ------------------ ...tionResults_TimeCodesPerSecond2_Legacy.txt | 395 ------------------ ...tionResults_TimeCodesPerSecond3_Legacy.txt | 395 ------------------ ...tionResults_TimeCodesPerSecond4_Legacy.txt | 395 ------------------ pxr/usd/usd/CMakeLists.txt | 6 - 10 files changed, 16 insertions(+), 1689 deletions(-) delete mode 100644 pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond1_Legacy.txt delete mode 100644 pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond2_Legacy.txt delete mode 100644 pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond3_Legacy.txt delete mode 100644 pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond4_Legacy.txt diff --git a/pxr/usd/pcp/CMakeLists.txt b/pxr/usd/pcp/CMakeLists.txt index 0fa527db03..5232becd8e 100644 --- a/pxr/usd/pcp/CMakeLists.txt +++ b/pxr/usd/pcp/CMakeLists.txt @@ -1399,8 +1399,6 @@ pxr_register_test(testPcpMuseum_TimeCodesPerSecond1 COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testPcpCompositionResults --usd TimeCodesPerSecond/root.sdf" STDOUT_REDIRECT compositionResults_TimeCodesPerSecond1.txt DIFF_COMPARE compositionResults_TimeCodesPerSecond1.txt - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=0 ) pxr_register_test(testPcpMuseum_TimeCodesPerSecond2 @@ -1408,8 +1406,6 @@ pxr_register_test(testPcpMuseum_TimeCodesPerSecond2 COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testPcpCompositionResults --usd TimeCodesPerSecond/root_48tcps.sdf" STDOUT_REDIRECT compositionResults_TimeCodesPerSecond2.txt DIFF_COMPARE compositionResults_TimeCodesPerSecond2.txt - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=0 ) pxr_register_test(testPcpMuseum_TimeCodesPerSecond3 @@ -1417,8 +1413,6 @@ pxr_register_test(testPcpMuseum_TimeCodesPerSecond3 COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testPcpCompositionResults --usd TimeCodesPerSecond/root_24tcps_12fps.sdf" STDOUT_REDIRECT compositionResults_TimeCodesPerSecond3.txt DIFF_COMPARE compositionResults_TimeCodesPerSecond3.txt - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=0 ) pxr_register_test(testPcpMuseum_TimeCodesPerSecond4 @@ -1426,44 +1420,6 @@ pxr_register_test(testPcpMuseum_TimeCodesPerSecond4 COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testPcpCompositionResults --usd TimeCodesPerSecond/root_12fps.sdf" STDOUT_REDIRECT compositionResults_TimeCodesPerSecond4.txt DIFF_COMPARE compositionResults_TimeCodesPerSecond4.txt - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=0 -) - -pxr_register_test(testPcpMuseum_TimeCodesPerSecond_Legacy1 - PYTHON - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testPcpCompositionResults --usd TimeCodesPerSecond/root.sdf" - STDOUT_REDIRECT compositionResults_TimeCodesPerSecond1_Legacy.txt - DIFF_COMPARE compositionResults_TimeCodesPerSecond1_Legacy.txt - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=1 -) - -pxr_register_test(testPcpMuseum_TimeCodesPerSecond_Legacy2 - PYTHON - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testPcpCompositionResults --usd TimeCodesPerSecond/root_48tcps.sdf" - STDOUT_REDIRECT compositionResults_TimeCodesPerSecond2_Legacy.txt - DIFF_COMPARE compositionResults_TimeCodesPerSecond2_Legacy.txt - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=1 -) - -pxr_register_test(testPcpMuseum_TimeCodesPerSecond_Legacy3 - PYTHON - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testPcpCompositionResults --usd TimeCodesPerSecond/root_24tcps_12fps.sdf" - STDOUT_REDIRECT compositionResults_TimeCodesPerSecond3_Legacy.txt - DIFF_COMPARE compositionResults_TimeCodesPerSecond3_Legacy.txt - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=1 -) - -pxr_register_test(testPcpMuseum_TimeCodesPerSecond_Legacy4 - PYTHON - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testPcpCompositionResults --usd TimeCodesPerSecond/root_12fps.sdf" - STDOUT_REDIRECT compositionResults_TimeCodesPerSecond4_Legacy.txt - DIFF_COMPARE compositionResults_TimeCodesPerSecond4_Legacy.txt - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=1 ) pxr_register_test(testPcpMuseum_TimeCodesPerSecondWithSessionLayer1 @@ -1471,8 +1427,6 @@ pxr_register_test(testPcpMuseum_TimeCodesPerSecondWithSessionLayer1 COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testPcpCompositionResults --usd TimeCodesPerSecond/root_24tcps_12fps.sdf --session TimeCodesPerSecond/session_48tcps.sdf" STDOUT_REDIRECT compositionResults_TimeCodesPerSecondWithSessionLayer1.txt DIFF_COMPARE compositionResults_TimeCodesPerSecondWithSessionLayer1.txt - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=0 ) pxr_register_test(testPcpMuseum_TimeCodesPerSecondWithSessionLayer2 @@ -1480,8 +1434,6 @@ pxr_register_test(testPcpMuseum_TimeCodesPerSecondWithSessionLayer2 COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testPcpCompositionResults --usd TimeCodesPerSecond/root_48tcps.sdf --session TimeCodesPerSecond/session_24fps.sdf" STDOUT_REDIRECT compositionResults_TimeCodesPerSecondWithSessionLayer2.txt DIFF_COMPARE compositionResults_TimeCodesPerSecondWithSessionLayer2.txt - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=0 ) pxr_register_test(testPcpMuseum_TimeCodesPerSecondWithSessionLayer3 @@ -1489,8 +1441,6 @@ pxr_register_test(testPcpMuseum_TimeCodesPerSecondWithSessionLayer3 COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testPcpCompositionResults --usd TimeCodesPerSecond/root_12fps.sdf --session TimeCodesPerSecond/session_24fps.sdf" STDOUT_REDIRECT compositionResults_TimeCodesPerSecondWithSessionLayer3.txt DIFF_COMPARE compositionResults_TimeCodesPerSecondWithSessionLayer3.txt - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=0 ) pxr_register_test(testPcpMuseum_TimeCodesPerSecondWithSessionLayer4 @@ -1498,8 +1448,6 @@ pxr_register_test(testPcpMuseum_TimeCodesPerSecondWithSessionLayer4 COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testPcpCompositionResults --usd TimeCodesPerSecond/root_12fps.sdf --session TimeCodesPerSecond/session.sdf" STDOUT_REDIRECT compositionResults_TimeCodesPerSecondWithSessionLayer4.txt DIFF_COMPARE compositionResults_TimeCodesPerSecondWithSessionLayer4.txt - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=0 ) pxr_register_test(testPcpMuseum_TypicalReferenceToRiggedModel @@ -2041,8 +1989,6 @@ pxr_register_test(testPcpChanges PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testPcpChanges" EXPECTED_RETURN_CODE 0 - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=0 ) pxr_register_test(testPcpDependencies diff --git a/pxr/usd/pcp/layerStack.cpp b/pxr/usd/pcp/layerStack.cpp index fc16312f7b..53a346c906 100644 --- a/pxr/usd/pcp/layerStack.cpp +++ b/pxr/usd/pcp/layerStack.cpp @@ -44,11 +44,6 @@ TF_DEFINE_ENV_SETTING( PCP_ENABLE_PARALLEL_LAYER_PREFETCH, true, "Enables parallel, threaded pre-fetch of sublayers."); -TF_DEFINE_ENV_SETTING( - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS, false, - "Disables automatic layer offset scaling from time codes per second " - "metadata in layers."); - TF_DEFINE_ENV_SETTING( PCP_ENABLE_LEGACY_RELOCATES_BEHAVIOR, true, "Enables the legacy behavior of ignoring composition errors that would " @@ -57,12 +52,6 @@ TF_DEFINE_ENV_SETTING( "non-USD caches/layer stacks; the legacy behavior cannot be enabled in USD " "mode"); -bool -PcpIsTimeScalingForLayerTimeCodesPerSecondDisabled() -{ - return TfGetEnvSetting(PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS); -} - struct Pcp_SublayerInfo { Pcp_SublayerInfo() = default; Pcp_SublayerInfo(const SdfLayerRefPtr& layer_, const SdfLayerOffset& offset_, @@ -1557,10 +1546,6 @@ PcpLayerStack::_Compute(const std::string &fileFormatTarget, // Build the layer stack. std::set seenLayers; - // Env setting for disabling TCPS scaling. - const bool scaleLayerOffsetByTcps = - !PcpIsTimeScalingForLayerTimeCodesPerSecondDisabled(); - const double rootTcps = _identifier.rootLayer->GetTimeCodesPerSecond(); SdfLayerOffset rootLayerOffset; @@ -1599,13 +1584,9 @@ PcpLayerStack::_Compute(const std::string &fileFormatTarget, if (_ShouldUseSessionTcps(_identifier.sessionLayer, _identifier.rootLayer)) { _timeCodesPerSecond = sessionTcps; - if (scaleLayerOffsetByTcps) { - rootLayerOffset.SetScale(_timeCodesPerSecond / rootTcps); - } + rootLayerOffset.SetScale(_timeCodesPerSecond / rootTcps); } else { - if (scaleLayerOffsetByTcps) { - sessionLayerOffset.SetScale(_timeCodesPerSecond / sessionTcps); - } + sessionLayerOffset.SetScale(_timeCodesPerSecond / sessionTcps); } _sessionLayerTree = @@ -1821,8 +1802,7 @@ PcpLayerStack::_BuildLayerStack( // Apply the scale from computed layer TCPS to sublayer TCPS to sublayer // layer offset. const double sublayerTcps = sublayerRefPtrs[i]->GetTimeCodesPerSecond(); - if (!PcpIsTimeScalingForLayerTimeCodesPerSecondDisabled() && - layerTcps != sublayerTcps) { + if (layerTcps != sublayerTcps) { sublayerOffset.SetScale(sublayerOffset.GetScale() * layerTcps / sublayerTcps); } diff --git a/pxr/usd/pcp/layerStack.h b/pxr/usd/pcp/layerStack.h index 8ae318b2ba..35b0014d0b 100644 --- a/pxr/usd/pcp/layerStack.h +++ b/pxr/usd/pcp/layerStack.h @@ -381,14 +381,6 @@ bool Pcp_NeedToRecomputeLayerStackTimeCodesPerSecond( const PcpLayerStackPtr& layerStack, const SdfLayerHandle &changedLayer); -/// Returns true when the environment variable has been set to disable the -/// behavior where differing time codes per second metadata in layers sublayered -/// or referenced by another layer are used to apply a layer offset scale to the -/// map function. -PCP_API -bool -PcpIsTimeScalingForLayerTimeCodesPerSecondDisabled(); - PXR_NAMESPACE_CLOSE_SCOPE #endif // PXR_USD_PCP_LAYER_STACK_H diff --git a/pxr/usd/pcp/primIndex.cpp b/pxr/usd/pcp/primIndex.cpp index b41a875c51..44c3aee332 100644 --- a/pxr/usd/pcp/primIndex.cpp +++ b/pxr/usd/pcp/primIndex.cpp @@ -2277,21 +2277,19 @@ _EvalRefOrPayloadArcs(PcpNodeRef node, layerStack = indexer->inputs.cache->ComputeLayerStack( layerStackIdentifier, &indexer->outputs->allErrors); - if (!PcpIsTimeScalingForLayerTimeCodesPerSecondDisabled()) { - // If the referenced or payloaded layer has a different TCPS - // than the source layer that introduces it, we apply the time - // scale between these TCPS values to the layer offset. - // Note that if the introducing layer is a layer stack sublayer, - // any TCPS scaling from the layer stack will already have been - // applied to the layer offset for the reference/payload. - const double srcTimeCodesPerSecond = - srcLayer->GetTimeCodesPerSecond(); - const double destTimeCodesPerSecond = - layerStack->GetTimeCodesPerSecond(); - if (srcTimeCodesPerSecond != destTimeCodesPerSecond) { - layerOffset.SetScale(layerOffset.GetScale() * - srcTimeCodesPerSecond / destTimeCodesPerSecond); - } + // If the referenced or payloaded layer has a different TCPS + // than the source layer that introduces it, we apply the time + // scale between these TCPS values to the layer offset. + // Note that if the introducing layer is a layer stack sublayer, + // any TCPS scaling from the layer stack will already have been + // applied to the layer offset for the reference/payload. + const double srcTimeCodesPerSecond = + srcLayer->GetTimeCodesPerSecond(); + const double destTimeCodesPerSecond = + layerStack->GetTimeCodesPerSecond(); + if (srcTimeCodesPerSecond != destTimeCodesPerSecond) { + layerOffset.SetScale(layerOffset.GetScale() * + srcTimeCodesPerSecond / destTimeCodesPerSecond); } } diff --git a/pxr/usd/pcp/testenv/testPcpChanges.py b/pxr/usd/pcp/testenv/testPcpChanges.py index 2d9550d02c..e2094b1ac4 100644 --- a/pxr/usd/pcp/testenv/testPcpChanges.py +++ b/pxr/usd/pcp/testenv/testPcpChanges.py @@ -378,9 +378,6 @@ def _ChangeAndVerify(newValDict, expectSignificantChange, expectedTcps): _ChangeAndVerify({'tcps' : 24.0, 'fps' : 24.0}, True, 24.0) _ChangeAndVerify({'tcps' : None, 'fps' : None}, False, 24.0) - @unittest.skipIf( - Tf.GetEnvSetting('PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS'), - "Test requires layer TCPS time scaling enabled") def test_TcpsChanges(self): """ Tests change processing for changes that affect the time codes per diff --git a/pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond1_Legacy.txt b/pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond1_Legacy.txt deleted file mode 100644 index 2c29b44719..0000000000 --- a/pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond1_Legacy.txt +++ /dev/null @@ -1,395 +0,0 @@ -Loading @TimeCodesPerSecond/root.sdf@ - ------------------------------------------------------------------------- -Layer Stack: - root.sdf - s.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - s_48tcps.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - s_24tcps_12fps.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - s_12fps.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss_12fps.sdf /SS4 - ss_12fps.sdf /SS4 - ss_12fps.sdf /SS4 - ss_12fps.sdf /SS4 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root.sdf /SS4 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss_24tcps_12fps.sdf /SS3 - ss_24tcps_12fps.sdf /SS3 - ss_24tcps_12fps.sdf /SS3 - ss_24tcps_12fps.sdf /SS3 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root.sdf /SS3 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss_48tcps.sdf /SS2 - ss_48tcps.sdf /SS2 - ss_48tcps.sdf /SS2 - ss_48tcps.sdf /SS2 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root.sdf /SS2 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss.sdf /SS1 - ss.sdf /SS1 - ss.sdf /SS1 - ss.sdf /SS1 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root.sdf /SS1 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s_12fps.sdf /S4 - -Time Offsets: - root.sdf /S4 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s_24tcps_12fps.sdf /S3 - -Time Offsets: - root.sdf /S3 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s_48tcps.sdf /S2 - -Time Offsets: - root.sdf /S2 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s.sdf /S1 - -Time Offsets: - root.sdf /S1 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - root.sdf /Root - -Time Offsets: - root.sdf /Root root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - diff --git a/pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond2_Legacy.txt b/pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond2_Legacy.txt deleted file mode 100644 index a926dac4c7..0000000000 --- a/pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond2_Legacy.txt +++ /dev/null @@ -1,395 +0,0 @@ -Loading @TimeCodesPerSecond/root_48tcps.sdf@ - ------------------------------------------------------------------------- -Layer Stack: - root_48tcps.sdf - s.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - s_48tcps.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - s_24tcps_12fps.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - s_12fps.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss_12fps.sdf /SS4 - ss_12fps.sdf /SS4 - ss_12fps.sdf /SS4 - ss_12fps.sdf /SS4 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root_48tcps.sdf /SS4 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss_24tcps_12fps.sdf /SS3 - ss_24tcps_12fps.sdf /SS3 - ss_24tcps_12fps.sdf /SS3 - ss_24tcps_12fps.sdf /SS3 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root_48tcps.sdf /SS3 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss_48tcps.sdf /SS2 - ss_48tcps.sdf /SS2 - ss_48tcps.sdf /SS2 - ss_48tcps.sdf /SS2 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root_48tcps.sdf /SS2 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss.sdf /SS1 - ss.sdf /SS1 - ss.sdf /SS1 - ss.sdf /SS1 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root_48tcps.sdf /SS1 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s_12fps.sdf /S4 - -Time Offsets: - root_48tcps.sdf /S4 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s_24tcps_12fps.sdf /S3 - -Time Offsets: - root_48tcps.sdf /S3 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s_48tcps.sdf /S2 - -Time Offsets: - root_48tcps.sdf /S2 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s.sdf /S1 - -Time Offsets: - root_48tcps.sdf /S1 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - root_48tcps.sdf /Root - -Time Offsets: - root_48tcps.sdf /Root root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - diff --git a/pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond3_Legacy.txt b/pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond3_Legacy.txt deleted file mode 100644 index ae2edf1fd3..0000000000 --- a/pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond3_Legacy.txt +++ /dev/null @@ -1,395 +0,0 @@ -Loading @TimeCodesPerSecond/root_24tcps_12fps.sdf@ - ------------------------------------------------------------------------- -Layer Stack: - root_24tcps_12fps.sdf - s.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - s_48tcps.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - s_24tcps_12fps.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - s_12fps.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss_12fps.sdf /SS4 - ss_12fps.sdf /SS4 - ss_12fps.sdf /SS4 - ss_12fps.sdf /SS4 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root_24tcps_12fps.sdf /SS4 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss_24tcps_12fps.sdf /SS3 - ss_24tcps_12fps.sdf /SS3 - ss_24tcps_12fps.sdf /SS3 - ss_24tcps_12fps.sdf /SS3 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root_24tcps_12fps.sdf /SS3 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss_48tcps.sdf /SS2 - ss_48tcps.sdf /SS2 - ss_48tcps.sdf /SS2 - ss_48tcps.sdf /SS2 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root_24tcps_12fps.sdf /SS2 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss.sdf /SS1 - ss.sdf /SS1 - ss.sdf /SS1 - ss.sdf /SS1 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root_24tcps_12fps.sdf /SS1 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s_12fps.sdf /S4 - -Time Offsets: - root_24tcps_12fps.sdf /S4 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s_24tcps_12fps.sdf /S3 - -Time Offsets: - root_24tcps_12fps.sdf /S3 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s_48tcps.sdf /S2 - -Time Offsets: - root_24tcps_12fps.sdf /S2 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s.sdf /S1 - -Time Offsets: - root_24tcps_12fps.sdf /S1 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - root_24tcps_12fps.sdf /Root - -Time Offsets: - root_24tcps_12fps.sdf /Root root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - diff --git a/pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond4_Legacy.txt b/pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond4_Legacy.txt deleted file mode 100644 index 755e328558..0000000000 --- a/pxr/usd/pcp/testenv/testPcpMuseum_TimeCodesPerSecond.testenv/baseline/compositionResults_TimeCodesPerSecond4_Legacy.txt +++ /dev/null @@ -1,395 +0,0 @@ -Loading @TimeCodesPerSecond/root_12fps.sdf@ - ------------------------------------------------------------------------- -Layer Stack: - root_12fps.sdf - s.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - s_48tcps.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - s_24tcps_12fps.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - s_12fps.sdf - ss.sdf - ss_48tcps.sdf - ss_24tcps_12fps.sdf - ss_12fps.sdf - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss_12fps.sdf /SS4 - ss_12fps.sdf /SS4 - ss_12fps.sdf /SS4 - ss_12fps.sdf /SS4 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root_12fps.sdf /SS4 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss_24tcps_12fps.sdf /SS3 - ss_24tcps_12fps.sdf /SS3 - ss_24tcps_12fps.sdf /SS3 - ss_24tcps_12fps.sdf /SS3 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root_12fps.sdf /SS3 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss_48tcps.sdf /SS2 - ss_48tcps.sdf /SS2 - ss_48tcps.sdf /SS2 - ss_48tcps.sdf /SS2 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root_12fps.sdf /SS2 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - ss.sdf /SS1 - ss.sdf /SS1 - ss.sdf /SS1 - ss.sdf /SS1 - ref.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_48tcps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_24tcps_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - ref_12fps.sdf /Ref - ref_s.sdf /Ref - ref_s_48tcps.sdf /Ref - ref_s_24tcps_12fps.sdf /Ref - ref_s_12fps.sdf /Ref - -Time Offsets: - root_12fps.sdf /SS1 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ref.sdf /Ref reference (offset=70.00, scale=8.00) - ref_48tcps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_24tcps_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ref_12fps.sdf /Ref reference (offset=70.00, scale=8.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s_12fps.sdf /S4 - -Time Offsets: - root_12fps.sdf /S4 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s_24tcps_12fps.sdf /S3 - -Time Offsets: - root_12fps.sdf /S3 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s_48tcps.sdf /S2 - -Time Offsets: - root_12fps.sdf /S2 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - s.sdf /S1 - -Time Offsets: - root_12fps.sdf /S1 root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - ------------------------------------------------------------------------- -Results for composing - -Prim Stack: - root_12fps.sdf /Root - -Time Offsets: - root_12fps.sdf /Root root (offset=0.00, scale=1.00) - s.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_48tcps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_24tcps_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - s_12fps.sdf sublayer (offset=10.00, scale=2.00) - ss.sdf sublayer (offset=30.00, scale=4.00) - ss_48tcps.sdf sublayer (offset=30.00, scale=4.00) - ss_24tcps_12fps.sdf sublayer (offset=30.00, scale=4.00) - ss_12fps.sdf sublayer (offset=30.00, scale=4.00) - diff --git a/pxr/usd/usd/CMakeLists.txt b/pxr/usd/usd/CMakeLists.txt index 872e470716..da880016e8 100644 --- a/pxr/usd/usd/CMakeLists.txt +++ b/pxr/usd/usd/CMakeLists.txt @@ -1130,8 +1130,6 @@ pxr_register_test(testUsdTimeOffsets PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdTimeOffsets" EXPECTED_RETURN_CODE 0 - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=0 ) pxr_register_test(testUsdPrimRange @@ -1357,15 +1355,11 @@ pxr_register_test(testUsdTimeValueAuthoring PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdTimeValueAuthoring" EXPECTED_RETURN_CODE 0 - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=0 ) pxr_register_test(testUsdTimeValueAuthoringCpp COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdTimeValueAuthoringCpp" EXPECTED_RETURN_CODE 0 - ENV - PCP_DISABLE_TIME_SCALING_BY_LAYER_TCPS=0 ) pxr_register_test(testUsdUsdzFileFormat From 2ca3703be1b517158dbd75d14ae1d648b5a47f58 Mon Sep 17 00:00:00 2001 From: blevin Date: Thu, 24 Oct 2024 13:11:54 -0700 Subject: [PATCH 053/300] testUsdImagingGLBasicDrawing now verifies that the expected error does occur. (Internal change: 2345524) --- .../usdImagingGL/testenv/testUsdImagingGLBasicDrawing.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLBasicDrawing.cpp b/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLBasicDrawing.cpp index 8fb7b634fa..d89ac8b74d 100644 --- a/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLBasicDrawing.cpp +++ b/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLBasicDrawing.cpp @@ -293,7 +293,9 @@ My_TestGLDrawing::DrawTest(bool offscreen) renderTime.Stop(); } - TF_VERIFY(mark.IsClean(), "Errors occurred while rendering!"); + // Note that we do not confirm that mark.IsClear() here, since + // in some tests we do expect to encounter broken materials + // that will fail to compile, ex: testUsdImagingGLInvalidMaterial std::cout << "Iterations to convergence: " << convergenceIterations << std::endl; std::cout << "itemsDrawn " << perfLog.GetCounter(HdTokens->itemsDrawn) << std::endl; From 7af4351e177add2bdb4f43e607db84ee281a6718 Mon Sep 17 00:00:00 2001 From: davvid Date: Thu, 24 Oct 2024 13:12:12 -0700 Subject: [PATCH 054/300] assetLocalization: retain AssetPath metadata in UsdUtilsModifyAssetPaths UsdUtilsModifyAssetPaths was removing SdfAssetPath instances in metadata, which was a change in behavior introduced in 23.11. Retain the processed value when processing metadata fields. (Internal change: 2345531) --- pxr/usd/usdUtils/CMakeLists.txt | 4 +++- pxr/usd/usdUtils/assetLocalization.cpp | 18 ++++++++++++------ pxr/usd/usdUtils/assetLocalization.h | 6 ++++-- pxr/usd/usdUtils/assetLocalizationDelegate.cpp | 13 ++++++++++--- pxr/usd/usdUtils/assetLocalizationDelegate.h | 12 +++++++++--- .../testenv/testUsdUtilsModifyAssetPaths.py | 9 +++++++++ .../baseline/preserve_metadata.usda | 11 +++++++++++ .../testUsdUtilsModifyAssetPaths/metadata.usda | 11 +++++++++++ 8 files changed, 69 insertions(+), 15 deletions(-) create mode 100644 pxr/usd/usdUtils/testenv/testUsdUtilsModifyAssetPaths/baseline/preserve_metadata.usda create mode 100644 pxr/usd/usdUtils/testenv/testUsdUtilsModifyAssetPaths/metadata.usda diff --git a/pxr/usd/usdUtils/CMakeLists.txt b/pxr/usd/usdUtils/CMakeLists.txt index e358361d5d..5e27b27b4c 100644 --- a/pxr/usd/usdUtils/CMakeLists.txt +++ b/pxr/usd/usdUtils/CMakeLists.txt @@ -643,7 +643,9 @@ pxr_register_test(testUsdUtilsLocalizeAssetUdims pxr_register_test(testUsdUtilsModifyAssetPaths PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdUtilsModifyAssetPaths layer.usda modified.usda" - DIFF_COMPARE modified.usda duplicates.usda removal.usda removal_preserve_length.usda ref_layer_mod.usda ref_unmodified.usda + DIFF_COMPARE + modified.usda duplicates.usda removal.usda removal_preserve_length.usda + ref_layer_mod.usda ref_unmodified.usda preserve_metadata.usda EXPECTED_RETURN_CODE 0 ) diff --git a/pxr/usd/usdUtils/assetLocalization.cpp b/pxr/usd/usdUtils/assetLocalization.cpp index 9e830681cd..3ae5e2f092 100644 --- a/pxr/usd/usdUtils/assetLocalization.cpp +++ b/pxr/usd/usdUtils/assetLocalization.cpp @@ -229,7 +229,8 @@ UsdUtils_LocalizationContext::_ProcessMetadata( _delegate->BeginProcessValue(layer, value); _ProcessAssetValue(layer, infoKey, value, - /*processingMetadata*/ true); + /*processingMetadata*/ true, + /*processingDictionary*/ false); _delegate->EndProcessValue( layer, primSpec->GetPath(), infoKey, value); } @@ -440,9 +441,10 @@ void UsdUtils_LocalizationContext::_ProcessAssetValue( const SdfLayerRefPtr& layer, const VtValue &val, - bool processingMetadata) + bool processingMetadata, + bool processingDictionary) { - _ProcessAssetValue(layer, std::string(), val, processingMetadata); + _ProcessAssetValue(layer, std::string(), val, processingMetadata, processingDictionary); } void @@ -450,7 +452,8 @@ UsdUtils_LocalizationContext::_ProcessAssetValue( const SdfLayerRefPtr& layer, const std::string &keyPath, const VtValue &val, - bool processingMetadata) + bool processingMetadata, + bool processingDictionary) { if (_ShouldFilterAssetPath(keyPath, processingMetadata)) { return; @@ -465,7 +468,8 @@ UsdUtils_LocalizationContext::_ProcessAssetValue( const std::vector processedDeps = _delegate->ProcessValuePath( - layer, keyPath, rawAssetPath, dependencies); + layer, keyPath, rawAssetPath, dependencies, + processingMetadata, processingDictionary); _EnqueueDependency(layer, rawAssetPath); _EnqueueDependencies(layer, processedDeps); @@ -504,7 +508,9 @@ UsdUtils_LocalizationContext::_ProcessAssetValue( for (const auto& p : originalDict) { const std::string dictKey = keyPath.empty() ? p.first : keyPath + ':' + p.first; - _ProcessAssetValue(layer, dictKey, p.second, processingMetadata); + _ProcessAssetValue( + layer, dictKey, p.second, + processingMetadata, /*processingDictionary*/true); } } diff --git a/pxr/usd/usdUtils/assetLocalization.h b/pxr/usd/usdUtils/assetLocalization.h index d579fbfdbd..87c8c54173 100644 --- a/pxr/usd/usdUtils/assetLocalization.h +++ b/pxr/usd/usdUtils/assetLocalization.h @@ -112,10 +112,12 @@ class UsdUtils_LocalizationContext { void _ProcessAssetValue(const SdfLayerRefPtr& layer, const std::string &key, const VtValue &val, - bool processingMetadata = false); + bool processingMetadata = false, + bool processingDictionary = false); void _ProcessAssetValue(const SdfLayerRefPtr& layer, const VtValue &val, - bool processingMetadata = false); + bool processingMetadata = false, + bool processingDictionary = false); // Searches for udim tiles associated with the given asset path. std::vector _GetUdimTiles(const SdfLayerRefPtr& layer, diff --git a/pxr/usd/usdUtils/assetLocalizationDelegate.cpp b/pxr/usd/usdUtils/assetLocalizationDelegate.cpp index 8495271b37..9464b725ec 100644 --- a/pxr/usd/usdUtils/assetLocalizationDelegate.cpp +++ b/pxr/usd/usdUtils/assetLocalizationDelegate.cpp @@ -216,7 +216,9 @@ UsdUtils_WritableLocalizationDelegate::ProcessValuePath( const SdfLayerRefPtr &layer, const std::string &keyPath, const std::string &authoredPath, - const std::vector &dependencies) + const std::vector &dependencies, + const bool processingMetadata, + const bool processingDictionary) { if (authoredPath.empty()) { return {}; @@ -228,7 +230,10 @@ UsdUtils_WritableLocalizationDelegate::ProcessValuePath( const std::string relativeKeyPath = _GetRelativeKeyPath(keyPath); - if (relativeKeyPath.empty()) { + if (relativeKeyPath.empty() || ( + processingMetadata && + !processingDictionary && + !info.GetAssetPath().empty())) { _currentValuePath = SdfAssetPath(info.GetAssetPath()); } else if (info.GetAssetPath().empty()){ @@ -567,7 +572,9 @@ UsdUtils_ReadOnlyLocalizationDelegate::ProcessValuePath( const SdfLayerRefPtr &layer, const std::string &keyPath, const std::string &authoredPath, - const std::vector &dependencies) + const std::vector &dependencies, + const bool processingMetadata, + const bool processingDictionary) { if (authoredPath.empty()) { return {}; diff --git a/pxr/usd/usdUtils/assetLocalizationDelegate.h b/pxr/usd/usdUtils/assetLocalizationDelegate.h index 4a36dcb48e..afe0cde0f1 100644 --- a/pxr/usd/usdUtils/assetLocalizationDelegate.h +++ b/pxr/usd/usdUtils/assetLocalizationDelegate.h @@ -66,7 +66,9 @@ struct UsdUtils_LocalizationDelegate const SdfLayerRefPtr &layer, const std::string &keyPath, const std::string &authoredPath, - const std::vector &dependencies) { return {}; } + const std::vector &dependencies, + const bool processingMetadata = false, + const bool processingDictionary = false) { return {}; } virtual std::vector ProcessValuePathArrayElement( const SdfLayerRefPtr &layer, @@ -157,7 +159,9 @@ class UsdUtils_WritableLocalizationDelegate const SdfLayerRefPtr &layer, const std::string &keyPath, const std::string &authoredPath, - const std::vector &dependencies) override; + const std::vector &dependencies, + const bool processingMetadata = false, + const bool processingDictionary = false) override; virtual std::vector ProcessValuePathArrayElement( const SdfLayerRefPtr &layer, @@ -283,7 +287,9 @@ class UsdUtils_ReadOnlyLocalizationDelegate const SdfLayerRefPtr &layer, const std::string &keyPath, const std::string &authoredPath, - const std::vector &dependencies) override; + const std::vector &dependencies, + const bool processingMetadata = false, + const bool processingDictionary = false) override; virtual std::vector ProcessValuePathArrayElement( const SdfLayerRefPtr &layer, diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsModifyAssetPaths.py b/pxr/usd/usdUtils/testenv/testUsdUtilsModifyAssetPaths.py index e1e06b2621..fe6853a671 100644 --- a/pxr/usd/usdUtils/testenv/testUsdUtilsModifyAssetPaths.py +++ b/pxr/usd/usdUtils/testenv/testUsdUtilsModifyAssetPaths.py @@ -62,3 +62,12 @@ def fn(s): refLayer.Export("ref_unmodified.usda") TestDoesNotRecurseDeps() + +def TestDoesNotStripMetadata(): + # Ensure that metadata is retained. + def fn(s): + return s + + Test('metadata.usda', 'preserve_metadata.usda', fn) + +TestDoesNotStripMetadata() diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsModifyAssetPaths/baseline/preserve_metadata.usda b/pxr/usd/usdUtils/testenv/testUsdUtilsModifyAssetPaths/baseline/preserve_metadata.usda new file mode 100644 index 0000000000..fd8c13b9af --- /dev/null +++ b/pxr/usd/usdUtils/testenv/testUsdUtilsModifyAssetPaths/baseline/preserve_metadata.usda @@ -0,0 +1,11 @@ +#usda 1.0 + +def "Model" ( + high = @example:geo/high.usd@ + lod = "low" + low = @example:geo/low.usd@ + payload = @example:geo/payload.usdc@ +) +{ +} + diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsModifyAssetPaths/metadata.usda b/pxr/usd/usdUtils/testenv/testUsdUtilsModifyAssetPaths/metadata.usda new file mode 100644 index 0000000000..fd8c13b9af --- /dev/null +++ b/pxr/usd/usdUtils/testenv/testUsdUtilsModifyAssetPaths/metadata.usda @@ -0,0 +1,11 @@ +#usda 1.0 + +def "Model" ( + high = @example:geo/high.usd@ + lod = "low" + low = @example:geo/low.usd@ + payload = @example:geo/payload.usdc@ +) +{ +} + From 4b977ab6ba3e01c820ad92669daeff1986c45ce9 Mon Sep 17 00:00:00 2001 From: comand Date: Thu, 24 Oct 2024 13:12:31 -0700 Subject: [PATCH 055/300] Fix GCC 11 mismatched new/delete warnings. GCC 11 reports -Werror=mismatched-new-delete seemingly due to an inlining bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103993 Marking the affected methods as alway_inline to work around this. (Internal change: 2345573) --- pxr/base/arch/attributes.h | 2 ++ pxr/base/tf/mallocTag.h | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pxr/base/arch/attributes.h b/pxr/base/arch/attributes.h index 1d2820d1e7..42f9a6e875 100644 --- a/pxr/base/arch/attributes.h +++ b/pxr/base/arch/attributes.h @@ -159,6 +159,7 @@ PXR_NAMESPACE_OPEN_SCOPE # define ARCH_SCANF_FUNCTION(_fmt, _firstArg) \ __attribute__((format(scanf, _fmt, _firstArg))) # define ARCH_NOINLINE __attribute__((noinline)) +# define ARCH_ALWAYS_INLINE __attribute__((always_inline)) # define ARCH_UNUSED_ARG __attribute__ ((unused)) # define ARCH_UNUSED_FUNCTION __attribute__((unused)) # define ARCH_USED_FUNCTION __attribute__((used)) @@ -169,6 +170,7 @@ PXR_NAMESPACE_OPEN_SCOPE # define ARCH_PRINTF_FUNCTION(_fmt, _firstArg) # define ARCH_SCANF_FUNCTION(_fmt, _firstArg) # define ARCH_NOINLINE // __declspec(noinline) +# define ARCH_ALWAYS_INLINE # define ARCH_UNUSED_ARG # define ARCH_UNUSED_FUNCTION # define ARCH_USED_FUNCTION diff --git a/pxr/base/tf/mallocTag.h b/pxr/base/tf/mallocTag.h index e4b326c9c0..d28522c01e 100644 --- a/pxr/base/tf/mallocTag.h +++ b/pxr/base/tf/mallocTag.h @@ -474,28 +474,28 @@ PXR_NAMESPACE_CLOSE_SCOPE #define TF_MALLOC_TAG_NEW(name1, name2) \ /* this is for STL purposes */ \ - inline void* operator new(::std::size_t, void* ptr) { \ + ARCH_ALWAYS_INLINE inline void* operator new(::std::size_t, void* ptr) { \ return ptr; \ } \ \ - inline void* operator new(::std::size_t s) { \ + ARCH_ALWAYS_INLINE inline void* operator new(::std::size_t s) { \ PXR_NS::TfAutoMallocTag tag(name1, name2); \ return malloc(s); \ } \ \ - inline void* operator new[](::std::size_t s) { \ + ARCH_ALWAYS_INLINE inline void* operator new[](::std::size_t s) { \ PXR_NS::TfAutoMallocTag tag(name1, name2); \ return malloc(s); \ } \ \ /* Required due to the placement-new override above. */ \ - inline void operator delete(void* ptr, void* place) {} \ + ARCH_ALWAYS_INLINE inline void operator delete(void* ptr, void* place) {} \ \ - inline void operator delete(void* ptr, size_t) { \ + ARCH_ALWAYS_INLINE inline void operator delete(void* ptr, size_t) { \ free(ptr); \ } \ \ - inline void operator delete[] (void* ptr, size_t) { \ + ARCH_ALWAYS_INLINE inline void operator delete[] (void* ptr, size_t) { \ free(ptr); \ } \ From 88da603cc15062a821b8a95c466d90eb0121bdee Mon Sep 17 00:00:00 2001 From: pixar-oss Date: Thu, 24 Oct 2024 13:14:05 -0700 Subject: [PATCH 056/300] Update schema generation to use 'full' shader doc (Internal change: 2345578) --- .../baseline/schemaConcrete.usda | 9 ++++++++- pxr/usd/usdUtils/updateSchemaWithSdrNode.py | 14 ++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsUpdateSchemaWithSdrNode/baseline/schemaConcrete.usda b/pxr/usd/usdUtils/testenv/testUsdUtilsUpdateSchemaWithSdrNode/baseline/schemaConcrete.usda index 5b22e6c0a4..800b1734ea 100644 --- a/pxr/usd/usdUtils/testenv/testUsdUtilsUpdateSchemaWithSdrNode/baseline/schemaConcrete.usda +++ b/pxr/usd/usdUtils/testenv/testUsdUtilsUpdateSchemaWithSdrNode/baseline/schemaConcrete.usda @@ -20,7 +20,14 @@ class TestSchemaConcrete "TestSchemaConcrete" ( photographic measurements. """ string userDocBrief = """ - exposure: Specify the intensity of the light source as a power of 2 (in stops).""" + exposure: Specify the intensity of the light source as a power of 2 (in stops). + Increasing the exposure by 1 will double the energy emitted by the light source. + A value of 0 produces an intensity of 1, -1 produces .5. You may wonder why you + might use Exposure, and the answer is that real world lighting has high energies + and typical exposures are low values while you may have to type a really large + number for equivalent Intensity. This is also comfortable to artists familiar with + photographic measurements. + """ } displayGroup = "Basic" displayName = "Exposure" diff --git a/pxr/usd/usdUtils/updateSchemaWithSdrNode.py b/pxr/usd/usdUtils/updateSchemaWithSdrNode.py index 2ed04141fb..9e998c865d 100644 --- a/pxr/usd/usdUtils/updateSchemaWithSdrNode.py +++ b/pxr/usd/usdUtils/updateSchemaWithSdrNode.py @@ -46,7 +46,6 @@ class PropertyDefiningKeys(ConstantsGroup): class UserDocConstants(ConstantsGroup): USERDOC_FULL = "userDoc" USERDOC_BRIEF = "userDocBrief" - MAX_LENGTH_FOR_BRIEF = 500 def _IsNSPrefixConnectableAPICompliant(nsPrefix): return (nsPrefix == UsdShade.Tokens.inputs[:1] or \ @@ -177,17 +176,8 @@ def _SetSchemaUserDocFields(spec, doc): and attribute specs. """ # Set the "brief" user doc, used for in-context help, e.g. in DCC tools. - # If the doc string exceeds a certain length, just use the first sentence. - workDoc = "" - if len(doc) > UserDocConstants.MAX_LENGTH_FOR_BRIEF: - workDoc = doc.partition('.')[0] + '.' - # If '.' wasn't found, workDoc will be the entire doc string, so - # instead use the first MAX_LENGTH_FOR_BRIEF chars and append '...' - if len(workDoc) > UserDocConstants.MAX_LENGTH_FOR_BRIEF: - workDoc = workDoc[:UserDocConstants.MAX_LENGTH_FOR_BRIEF] + "..." - else: - workDoc = doc - spec.customData[UserDocConstants.USERDOC_BRIEF] = workDoc + # We currently want the full content, so we don't shorten userDocBrief. + spec.customData[UserDocConstants.USERDOC_BRIEF] = doc # Set the "long-form" user doc, used when generating HTML schema docs # (example: https://openusd.org/release/user_guides/schemas/index.html) spec.customData[UserDocConstants.USERDOC_FULL] = doc From f037c0e6257b2a41cc1c7545b79d9a63e9c7f791 Mon Sep 17 00:00:00 2001 From: gitamohr Date: Thu, 24 Oct 2024 13:14:24 -0700 Subject: [PATCH 057/300] tf: Rework the script module loader code to be thread-safe. Also simplify the code: we don't have to load modules in top-down dependency order; we can let them load bottom-up, protected by the recursive Python GIL. Improve TF_DEBUG output. Remove the unused `GetModuleNames()` and add notes about the what, why, and how this code works. (Internal change: 2345579) --- pxr/base/tf/scriptModuleLoader.cpp | 529 ++++++++---------- pxr/base/tf/scriptModuleLoader.h | 65 +-- .../scriptModuleLoader.out | 62 +- pxr/base/tf/wrapScriptModuleLoader.cpp | 2 - 4 files changed, 301 insertions(+), 357 deletions(-) diff --git a/pxr/base/tf/scriptModuleLoader.cpp b/pxr/base/tf/scriptModuleLoader.cpp index e1472ce7b6..b5590eac3e 100644 --- a/pxr/base/tf/scriptModuleLoader.cpp +++ b/pxr/base/tf/scriptModuleLoader.cpp @@ -11,11 +11,10 @@ #include "pxr/base/tf/debug.h" #include "pxr/base/tf/debugCodes.h" #include "pxr/base/tf/instantiateSingleton.h" -#include "pxr/base/tf/iterator.h" +#include "pxr/base/tf/pyError.h" +#include "pxr/base/tf/pyExceptionState.h" #include "pxr/base/tf/pyUtils.h" #include "pxr/base/tf/registryManager.h" -#include "pxr/base/tf/stackTrace.h" -#include "pxr/base/tf/staticData.h" #include "pxr/base/tf/stringUtils.h" #include "pxr/base/arch/fileSystem.h" @@ -24,13 +23,103 @@ #include "pxr/external/boost/python/dict.hpp" #include "pxr/external/boost/python/handle.hpp" -#include +/* + +Notes for those who venture into this dark crevice: + +We build C++ libs that have python bindings into two shared libraries: 1, the +shared library with the compiled C++ code (`libFoo.so`), and 2, a shared library +with the C++/Python bindings (`_foo.so`). We do this so that we can write pure +C++ programs that link `libFoo.so` and do not pay to load the Python bindings. +The bindings libraries (`_foo.so`) have a shared library link dependency on +their corresponding C++ library (`libFoo.so`) so whenever a bindings lib loads, +the shared library loader automatically loads the main C++ lib. + +The job of the code in this file is to ensure that the Python bindings for +loaded C++ libraries are loaded whenever they are needed. + +When are they needed? There are a few scenarios. + +The most obvious is when a Python module is imported. Suppose libFoo depends on +libBar, and both have Python bindings. If we do `import Foo` in Python, we need +to ensure that the `Bar` module is imported and registers its bindings before +Foo registers its bindings, since Foo's bindings may depend on Bar's. For +example, if Foo wraps a class that derives a base class from Bar, that base +class must be wrapped first. This scenario could in principle be handled by +manually writing `import Bar` in Foo's __init__.py. But, that is prone both to +being forgotten, and to going undetected if Bar happens to be already loaded in +most of the scenarios when Foo is imported. And, as we'll see, that doesn't +solve the other main scenario. + +The other main scenario is when a C++ program initializes Python at some point +during its execution. In this case all currently loaded C++ libraries that have +Python bindings must load them immediately. Further, any C++ library that loads +in the future (via dlopen()) must also immediately import its bindings at load +time. This might sound surprising. Why should we need to eagerly import all +bindings like this? Surely if Python code needs to use the bindings it will +`import` those modules itself, no? Yes this is true, but there can be hidden, +indirect, undetectable dependencies that this does not handle due to +type-erasure. + +Consider a type-erased opaque 'box' container, analogous to `std::any`. Let's +call it `Any`. When an Any is converted to Python, it unboxes its held object +and converts that object to Python. So for example if an Any holding a string +is returned to Python, Python gets a string. An Any holding a double unboxes as +a Python float. An Any holding a FooObject unboxes it and uses its bindings to +convert it to Python. + +Now suppose we have libFoo and libBar. Bar has an Any-valued variable, and +provides a Python binding to access it: `Bar.GetAny()`. Foo depends on Bar, and +stores an Any holding a FooObject to Bar's Any. Now suppose a Python script +does `import Bar; Bar.GetAny()`. The call to `Bar.GetAny()` will fail unless +the bindings for the held FooObject have been imported. + +Whose responsibility is it to ensure they have been imported? Bar cannot know +to import them, since Bar does not depend on Foo -- it has no knowledge of Foo's +existence. The Python code that imported Bar similarly cannot have done it -- +there's no way for it to know ahead of time what type of object is stored in the +Any, and it may not know of Foo's existence either. The answer is that the +_only_ place that we can know for sure the bindings are needed is at the very +moment that a FooObject is requested to be converted to Python. Unfortunately, +we do not have a hook available for this today. It might be possible to build +one now that we have our own copy of boost.python interred, but that's not the +world we currently live in. + +In the meantime, we must do as we said above and load _all_ bindings when Python +is initialized, and then continue to load any bindings for any later-loaded C++ +libraries when they are loaded. + +The Mechanism: + +We build a small bit of initialization code into each C++ library with bindings +to advertise themselves to the TfScriptModuleLoader. These are the +`moduleDeps.cpp` files in `pxr/...`. The initializer calls +TfScriptModuleLoader::RegisterLibrary(), passing the lib name, its python module +name (suitable for `import`), and a list of the lib's direct dependencies. This +way the the loader knows both which libraries have bindings, and what they +directly depend on. + +Then, in a few key places, code calls LoadModules() or LoadModulesForLibrary() +to achieve the goals above. + +- Tf_PyInitWrapModule(), in tf/pyModule.cpp calls LoadModulesForLibrary(). This + function is called by Python when a bindings library is imported. This covers + the "import" scenario above. + +- TfPyInitialize(), in tf/pyInterpreter.cpp calls LoadModules() to ensure that + all bindings are loaded if a C++ program starts up the Python interpreter at + some point. + +- TfDlopen(), in tf/dl.cpp calls LoadModules() to ensure that all bindings are + loaded for any newly loaded C++ libraries if Python is already initialized. + +*/ PXR_NAMESPACE_OPEN_SCOPE TF_INSTANTIATE_SINGLETON(TfScriptModuleLoader); -using std::deque; +using std::pair; using std::string; using std::vector; @@ -39,85 +128,74 @@ using pxr_boost::python::dict; using pxr_boost::python::handle; using pxr_boost::python::object; - -TfScriptModuleLoader::TfScriptModuleLoader() -{ -} - -// CODE_COVERAGE_OFF_GCOV_BUG -TfScriptModuleLoader::~TfScriptModuleLoader() -// CODE_COVERAGE_ON_GCOV_BUG -{ -} +TfScriptModuleLoader::TfScriptModuleLoader() = default; +TfScriptModuleLoader::~TfScriptModuleLoader() = default; void TfScriptModuleLoader:: -RegisterLibrary(TfToken const &name, TfToken const &moduleName, +RegisterLibrary(TfToken const &lib, TfToken const &moduleName, vector const &predecessors) { - if (TfDebug::IsEnabled(TF_SCRIPT_MODULE_LOADER)) { TF_DEBUG(TF_SCRIPT_MODULE_LOADER) - .Msg("Registering library %s with predecessors: ", name.GetText()); - TF_FOR_ALL(pred, predecessors) { - TF_DEBUG(TF_SCRIPT_MODULE_LOADER).Msg("%s, ", pred->GetText()); - } - TF_DEBUG(TF_SCRIPT_MODULE_LOADER).Msg("\n"); + .Msg("SML: Registering lib %s with %spredecessors%s%s\n", + lib.GetText(), + predecessors.empty() ? "no " : "", + predecessors.empty() ? "" : " ", + TfStringJoin(predecessors.begin(), + predecessors.end(), ", ").c_str()); } + vector mutablePreds = predecessors; + std::sort(mutablePreds.begin(), mutablePreds.end()); + // Add library with predecessors. - vector &predsInTable = _libInfo[name].predecessors; - predsInTable = predecessors; - std::sort(predsInTable.begin(), predsInTable.end()); - _libsToModules[name] = moduleName; - - // Add this library as a successor to all predecessors. - TF_FOR_ALL(pred, predecessors) - _AddSuccessor(*pred, name); -} - -vector -TfScriptModuleLoader::GetModuleNames() const -{ - vector order; - vector ret; - _TopologicalSort(&order); - ret.reserve(order.size()); - TF_FOR_ALL(lib, order) { - _TokenToTokenMap::const_iterator i = _libsToModules.find(*lib); - if (i != _libsToModules.end()) - ret.push_back(i->second.GetString()); + TfSpinRWMutex::ScopedLock lock(_mutex); + bool success = _libInfo.emplace( + std::piecewise_construct, + std::make_tuple(lib), + std::make_tuple(moduleName, std::move(mutablePreds))).second; + lock.Release(); + + if (!success) { + TF_WARN("Library %s (with module '%s') already registered, repeated " + "registration ignored", lib.GetText(), moduleName.GetText()); } - return ret; } dict TfScriptModuleLoader::GetModulesDict() const { if (!TfPyIsInitialized()) { - TF_CODING_ERROR("Python is not initialized!"); + TF_CODING_ERROR("Python is not initialized."); return dict(); } - // Kick the registry function so any loaded libraries with script - // bindings register themselves with the script module loading system. + // Subscribe to the registry function so any loaded libraries with script + // bindings publish to this singleton. TfRegistryManager::GetInstance().SubscribeTo(); - TfPyLock lock; + // Collect the libs & module names, then release the lock. + TfSpinRWMutex::ScopedLock lock(_mutex, /*write=*/false); + // Make paired lib & module names. + vector> libAndModNames; + libAndModNames.reserve(_libInfo.size()); + for (auto const &[lib, info]: _libInfo) { + libAndModNames.emplace_back(lib, info.moduleName); + } + lock.Release(); + + // Take the python lock and build a dict. + TfPyLock pyLock; // Get the sys.modules dict from python, so we can see if modules are // already loaded. dict modulesDict(handle<>(borrowed(PyImport_GetModuleDict()))); - - vector order; dict ret; - _TopologicalSort(&order); - TF_FOR_ALL(lib, order) { - _TokenToTokenMap::const_iterator i = _libsToModules.find(*lib); - if (i != _libsToModules.end() && - modulesDict.has_key(i->second.GetText())) { - handle<> modHandle(PyImport_ImportModule(const_cast - (i->second.GetText()))); + + for (auto const &[lib, mod]: libAndModNames) { + if (modulesDict.has_key(mod.GetText())) { + handle<> modHandle(PyImport_ImportModule(mod.GetText())); // Use the upper-cased form of the library name as // the Python module name. @@ -142,9 +220,7 @@ TfScriptModuleLoader::GetModulesDict() const // // For now, we just upper-case the library name. // - string moduleName = TfStringCapitalize(lib->GetString()); - - ret[moduleName] = object(modHandle); + ret[TfStringCapitalize(lib.GetString())] = object(modHandle); } } return ret; @@ -158,16 +234,13 @@ TfScriptModuleLoader::WriteDotFile(string const &file) const TF_RUNTIME_ERROR("Could not open '%s' for writing.\n", file.c_str()); return; } - fprintf(out, "digraph Modules {\n"); - - TF_FOR_ALL(info, _libInfo) { - TF_FOR_ALL(successor, info->second.successors) { - fprintf(out, "\t%s -> %s;\n", info->first.GetText(), - successor->GetText()); + TfSpinRWMutex::ScopedLock lock(_mutex, /*write=*/false); + for (auto const &[lib, info]: _libInfo) { + for (TfToken const &pred: info.predecessors) { + fprintf(out, "\t%s -> %s;\n", lib.GetText(), pred.GetText()); } } - fprintf(out, "}\n"); fclose(out); } @@ -175,257 +248,141 @@ TfScriptModuleLoader::WriteDotFile(string const &file) const void TfScriptModuleLoader::LoadModules() { - _LoadModulesFor(TfToken()); -} + // Do nothing if Python is not initialized. + if (!TfPyIsInitialized()) { + return; + } + + // Subscribe to the registry function so any loaded libraries with script + // bindings publish to this singleton. + TfRegistryManager::GetInstance().SubscribeTo(); -void -TfScriptModuleLoader::LoadModulesForLibrary(TfToken const &name) { - _LoadModulesFor(name); -} + TF_DEBUG(TF_SCRIPT_MODULE_LOADER).Msg("SML: Begin loading all modules\n"); -bool -TfScriptModuleLoader::_HasTransitiveSuccessor(TfToken const &predecessor, - TfToken const &successor) const -{ - // This function does a simple DFS of the dependency dag, to determine if \a - // predecessor has \a successor somewhere in the transitive closure. - - vector predStack(1, predecessor); - TfToken::HashSet seenPreds; - - while (!predStack.empty()) { - TfToken pred = predStack.back(); - predStack.pop_back(); - - // A name counts as its own successor. - if (pred == successor) - return true; - - // Look up successors, and push ones not yet visted as possible - // predecessors. - _TokenToInfoMap::const_iterator i = _libInfo.find(pred); - if (i != _libInfo.end()) { - // Walk all the successors. - TF_FOR_ALL(j, i->second.successors) { - // Push those that haven't yet been visited on the stack. - if (seenPreds.insert(pred).second) - predStack.push_back(pred); - } + // Take the lock, then collect all the modules that aren't yet loaded into a + // vector. Then release the lock and call _LoadLibModules() to do the work. + TfSpinRWMutex::ScopedLock lock(_mutex); + vector<_LibAndInfo const *> toLoad; + for (auto iter = _libInfo.begin(), end = _libInfo.end(); + iter != end; ++iter) { + if (!iter->second.isLoaded) { + toLoad.push_back(std::addressof(*iter)); + } + else { + TF_DEBUG(TF_SCRIPT_MODULE_LOADER) + .Msg("SML: Skipping already-loaded %s\n", + iter->first.GetText()); } } - return false; -} + lock.Release(); -static bool _DidPyErrorOccur() -{ - TfPyLock pyLock; - return PyErr_Occurred(); + _LoadLibModules(toLoad); + + TF_DEBUG(TF_SCRIPT_MODULE_LOADER).Msg("SML: End loading all modules\n"); } void -TfScriptModuleLoader::_LoadUpTo(TfToken const &name) +TfScriptModuleLoader +::_LoadLibModules(vector<_LibAndInfo const *> const &toLoad) const { - static size_t indent = 0; - string indentString; - char const *indentTxt = 0; - - if (TfDebug::IsEnabled(TF_SCRIPT_MODULE_LOADER)) { - indentString = std::string(indent * 2, ' '); - indentTxt = indentString.c_str(); - } - - // Don't do anything if the name isn't empty and it's not a name we know - // about. - if (!name.IsEmpty() && !_libInfo.count(name)) { - TF_DEBUG(TF_SCRIPT_MODULE_LOADER) - .Msg("%s*** Not loading modules for unknown lib '%s'\n", - indentTxt, name.GetText()); + if (toLoad.empty()) { return; } + + TfPyLock pyLock; + + for (_LibAndInfo const *libAndInfo: toLoad) { + auto const &[lib, info] = *libAndInfo; - // Otherwise load modules in topological dependency order until we - // encounter the requested module. - vector order; - if (name.IsEmpty()) { - _TopologicalSort(&order); - } else { - _GetOrderedDependencies(vector(1, name), &order); - } - - TF_DEBUG(TF_SCRIPT_MODULE_LOADER) - .Msg("%s_LoadUpTo('%s') {\n", indentTxt, name.GetText()); - TF_FOR_ALL(lib, order) { - // If we encounter the library we're loading on behalf of, quit. - // Mostly this is the last library in the order, but it may not be. - if (*lib == name) - break; - - if (_libsToModules.count(*lib) && !_loadedSet.count(*lib)) { + if (info.moduleName.IsEmpty()) { TF_DEBUG(TF_SCRIPT_MODULE_LOADER) - .Msg("%s Load('%s');\n", indentTxt, lib->GetText()); - _loadedSet.insert(*lib); - ++indent; - Tf_PyLoadScriptModule(_libsToModules[*lib]); - --indent; + .Msg("SML: Not loading unknown module for lib %s\n", + lib.GetText()); + continue; } + if (info.isLoaded) { + TF_DEBUG(TF_SCRIPT_MODULE_LOADER) + .Msg("SML: Lib %s's module '%s' is already loaded\n", + lib.GetText(), info.moduleName.GetText()); + continue; + } + + TF_DEBUG(TF_SCRIPT_MODULE_LOADER) + .Msg("SML: Loading lib %s's module '%s'\n", + lib.GetText(), info.moduleName.GetText()); - if (_DidPyErrorOccur()) { - TF_DEBUG(TF_SCRIPT_MODULE_LOADER).Msg("%s *error*\n", indentTxt); - break; + // Try to load the module. + if (!PyImport_ImportModule(info.moduleName.GetText())) { + // If an error occurred, warn about it with the python traceback, + // and continue. + TF_DEBUG(TF_SCRIPT_MODULE_LOADER) + .Msg("SML: Error loading lib %s's module '%s'\n", + lib.GetText(), info.moduleName.GetText()); + TfPyExceptionState exc = TfPyExceptionState::Fetch(); + string traceback = exc.GetExceptionString(); + TF_WARN("Error loading lib %s's module '%s':\n%s", + lib.GetText(), info.moduleName.GetText(), + traceback.c_str()); } + + // Mark the module loaded, even if there was an error. Otherwise we'll + // keep trying to load it and keep generating the same error. + info.isLoaded = true; } - - TF_DEBUG(TF_SCRIPT_MODULE_LOADER).Msg("%s}\n", indentTxt); } -void -TfScriptModuleLoader::_LoadModulesFor(TfToken const &inName) +TfScriptModuleLoader::_LibInfo const * +TfScriptModuleLoader::_FindInfo(TfToken const &lib) const { - // Don't load anything if python isn't initialized. - if (!TfPyIsInitialized()) - return; - if (_DidPyErrorOccur()) - return; - - ////////////////////////////////////////////////////////////////////////// - // This function handles requests to load modules in topological dependency - // order up to \a inName. Doing so may cause reentrant calls to this - // function. Handling reentrancy works as follows. There are two cases to - // consider. - // - // ----------------------------------------------------------------------- - // Case 1: The reentrant request is for a module that depends (transitively) - // on the module we're currently loading (or is a request to load all - // modules). - // - // In this case, we defer until after the current request is completed. - // We do this because the dependent library may attempt to load the - // library we're currently loading, which would fail. - // - // ------------------------------------------------------------------------ - // Case 2: The reentrant request is for a module that does not depend on the - // module we're currently loading. - // - // In this case, we immediately load the module and its dependencies. - // This is a dynamically discovered dependency of the module we're - // currently loading. - // - // We achieve this by keeping a queue of requests. We always push the - // request on the back of the queue. If we're the outermost call (i.e. not - // reentrant) we loop, processing the queue from the front to the back. For - // a reentrant call, in case 1 (above), we return immediately, deferring the - // work. In case 2 (above) we process the element on the back of the queue - // immediately and pop it. - // - - // Add this request to the remaining work to do. - _remainingLoadWork.push_back(inName); - - // Kick the registry function so any loaded libraries with script bindings - // register themselves with the script module loading system. - TfRegistryManager::GetInstance().SubscribeTo(); - - // If this is the outermost caller initiating loading, start processing the - // queue. - if (_remainingLoadWork.size() == 1) { - while (!_remainingLoadWork.empty() && !_DidPyErrorOccur()) { - // Note: we copy the front of the deque here, since _LoadUpTo may - // add items into the deque. _LoadUpTo currently doesn't access the - // reference-to-token it's passed after it might have modified the - // deque, but this is good defensive coding in case it's changed in - // the future to do so. - TfToken name = _remainingLoadWork.front(); - _LoadUpTo(name); - // We must pop the queue *after* processing, since reentrant calls - // need to see \a name on the front of the queue. See the access of - // _remainingLoadWork.front() below. - _remainingLoadWork.pop_front(); - } - - // Otherwise, this is a reentrant load request. If the reentrant - // request is not to load everything (empty token) and it's also not a - // (transitive) dependency of the library we're currently working on, - // then load it immediately. - } else if (!_remainingLoadWork.back().IsEmpty() && - !_HasTransitiveSuccessor(_remainingLoadWork.front(), - _remainingLoadWork.back())) { - TfToken name = _remainingLoadWork.back(); - _remainingLoadWork.pop_back(); - _LoadUpTo(name); - } + auto iter = _libInfo.find(lib); + return iter != _libInfo.end() ? &iter->second : nullptr; } void -TfScriptModuleLoader:: -_AddSuccessor(TfToken const &lib, TfToken const &successor) +TfScriptModuleLoader::LoadModulesForLibrary(TfToken const &lib) { - if (ARCH_UNLIKELY(lib == successor)) { - // CODE_COVERAGE_OFF Can only happen if there's a bug. - TF_FATAL_ERROR("Library '%s' cannot depend on itself.", lib.GetText()); + // Do nothing if Python is not running. + if (!TfPyIsInitialized()) { return; - // CODE_COVERAGE_ON } - // Add dependent as a dependent of lib. - vector *successors = &(_libInfo[lib].successors); - successors->insert(std::lower_bound(successors->begin(), - successors->end(), successor), - successor); -} - -void -TfScriptModuleLoader -::_GetOrderedDependenciesRecursive(TfToken const &lib, - TfToken::HashSet *seenLibs, - vector *result) const -{ - // If we've not yet visited this library, then visit its predecessors, and - // finally add it to the order. - if (seenLibs->insert(lib).second) { - TF_FOR_ALL(i, _libInfo.find(lib)->second.predecessors) - _GetOrderedDependenciesRecursive(*i, seenLibs, result); - - result->push_back(lib); + // Special-case calling LoadModulesForLibrary with empty token means all. + if (lib.IsEmpty()) { + TF_DEBUG(TF_SCRIPT_MODULE_LOADER).Msg( + "SML: Request to load modules for empty lib name -> load all\n"); + return LoadModules(); } -} -void -TfScriptModuleLoader:: -_GetOrderedDependencies(vector const &input, - vector *result) const -{ - TfToken::HashSet seenLibs; - TF_FOR_ALL(i, input) { - // If we haven't seen the current input yet, add its predecessors (and - // their dependencies) to the result. - if (seenLibs.insert(*i).second) { - TF_FOR_ALL(j, _libInfo.find(*i)->second.predecessors) - _GetOrderedDependenciesRecursive(*j, &seenLibs, result); + // Subscribe to the registry function so any loaded libraries with script + // bindings publish to this singleton. + TfRegistryManager::GetInstance().SubscribeTo(); + + // We only load direct dependencies, since when we run the initializer for + // the python bindings lib, it will call back into here to load _its_ + // dependencies, and we get the transitive loading that way. + + TF_DEBUG(TF_SCRIPT_MODULE_LOADER).Msg( + "SML: Begin loading %s's predecessors\n", lib.GetText()); + + // Take the lock, then collect all the modules that this lib directly + // depends on that aren't already loaded, add them to `toLoad`, then release + // the lock and load all the modules. + TfSpinRWMutex::ScopedLock lock(_mutex); + vector<_LibAndInfo const *> toLoad; + if (_LibInfo const *libInfo = _FindInfo(lib)) { + for (TfToken const &pred: libInfo->predecessors) { + auto iter = _libInfo.find(pred); + if (iter != _libInfo.end() && !iter->second.isLoaded) { + toLoad.push_back(std::addressof(*iter)); + } } } -} - - -void -TfScriptModuleLoader:: -_TopologicalSort(vector *result) const -{ - // Find all libs with no successors, then produce all ordered dependencies - // from them. - vector leaves; - TF_FOR_ALL(i, _libInfo) { - if (i->second.successors.empty()) - leaves.push_back(i->first); - } - - // Sort to ensure determinism. - std::sort(leaves.begin(), leaves.end()); - - // Find all the leaves' dependencies. - _GetOrderedDependencies(leaves, result); + lock.Release(); + + _LoadLibModules(toLoad); - // Add the leaves themselves, at the end. - result->insert(result->end(), leaves.begin(), leaves.end()); + TF_DEBUG(TF_SCRIPT_MODULE_LOADER).Msg( + "SML: End loading %s's predecessors\n", lib.GetText()); } PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/base/tf/scriptModuleLoader.h b/pxr/base/tf/scriptModuleLoader.h index d8d48e8eaa..2779c2b16e 100644 --- a/pxr/base/tf/scriptModuleLoader.h +++ b/pxr/base/tf/scriptModuleLoader.h @@ -12,6 +12,7 @@ #include "pxr/base/tf/api.h" #include "pxr/base/tf/hash.h" #include "pxr/base/tf/singleton.h" +#include "pxr/base/tf/spinRWMutex.h" #include "pxr/base/tf/token.h" #include "pxr/base/tf/weakBase.h" @@ -21,9 +22,8 @@ #include "pxr/external/boost/python/dict.hpp" #include -#include "pxr/base/tf/hashmap.h" -#include "pxr/base/tf/hashset.h" #include +#include #include PXR_NAMESPACE_OPEN_SCOPE @@ -67,61 +67,46 @@ class TfScriptModuleLoader : public TfWeakBase { /// RegisterLibrary that depend on library \a name. TF_API void LoadModulesForLibrary(TfToken const &name); - - /// Return a list of all currently known modules in a valid dependency - /// order. - TF_API - std::vector GetModuleNames() const; - + /// Return a python dict containing all currently known modules under /// their canonical names. TF_API pxr_boost::python::dict GetModulesDict() const; - /// Write a graphviz dot-file for the dependency graph of all. currently - /// known libraries/modules to \a file. + /// Write a graphviz dot-file for the dependency graph of all currently + /// registered libraries/modules to \a file. TF_API void WriteDotFile(std::string const &file) const; private: + friend class TfSingleton; struct _LibInfo { - _LibInfo() {} - std::vector predecessors, successors; + _LibInfo() = default; + _LibInfo(TfToken const &moduleName, + std::vector &&predecessors) + : moduleName(moduleName) + , predecessors(predecessors) { } + + TfToken moduleName; + std::vector predecessors; + mutable std::atomic isLoaded = false; }; - typedef TfHashMap - _TokenToInfoMap; + using _LibInfoMap = + std::unordered_map; + + using _LibAndInfo = _LibInfoMap::value_type; - typedef TfHashMap - _TokenToTokenMap; - - typedef TfHashSet - _TokenSet; - TfScriptModuleLoader(); virtual ~TfScriptModuleLoader(); - friend class TfSingleton; + + _LibInfo const *_FindInfo(TfToken const &lib) const; + + void _LoadLibModules(std::vector<_LibAndInfo const *> const &toLoad) const; - void _AddSuccessor(TfToken const &lib, TfToken const &successor); - void _LoadModulesFor(TfToken const &name); - void _LoadUpTo(TfToken const &name); - void _GetOrderedDependenciesRecursive(TfToken const &lib, - TfToken::HashSet *seenLibs, - std::vector *result) const; - void _GetOrderedDependencies(std::vector const &input, - std::vector *result) const; - void _TopologicalSort(std::vector *result) const; - - bool _HasTransitiveSuccessor(TfToken const &predecessor, - TfToken const &successor) const; - - _TokenToInfoMap _libInfo; - _TokenToTokenMap _libsToModules; - _TokenSet _loadedSet; - - // This is only used to handle reentrant loading requests. - std::deque _remainingLoadWork; + _LibInfoMap _libInfo; + mutable TfSpinRWMutex _mutex; }; TF_API_TEMPLATE_CLASS(TfSingleton); diff --git a/pxr/base/tf/testenv/baseline/testTfScriptModuleLoader/scriptModuleLoader.out b/pxr/base/tf/testenv/baseline/testTfScriptModuleLoader/scriptModuleLoader.out index d68d118571..c517705788 100644 --- a/pxr/base/tf/testenv/baseline/testTfScriptModuleLoader/scriptModuleLoader.out +++ b/pxr/base/tf/testenv/baseline/testTfScriptModuleLoader/scriptModuleLoader.out @@ -1,45 +1,49 @@ # Test case: loading one library generates a request to load all # libraries, one of which attemps to import the library we're # currently loading. -Registering library LoadsAll with predecessors: -Registering library DepLoadsAll with predecessors: LoadsAll, -Registering library Other with predecessors: LoadsAll, +SML: Registering lib LoadsAll with no predecessors +SML: Registering lib DepLoadsAll with predecessors LoadsAll +SML: Registering lib Other with predecessors LoadsAll # This should attempt to (forwardly) load Other, which in turn tries # to import LoadsAll, which would fail, but we defer loading Other # until after LoadsAll is finished loading. -_LoadUpTo('DepLoadsAll') { - Load('LoadsAll'); - _LoadUpTo('LoadsAll') { - } -} -_LoadUpTo('') { - Load('DepLoadsAll'); - _LoadUpTo('DepLoadsAll') { - } - Load('Other'); - _LoadUpTo('Other') { - } -} +SML: Begin loading DepLoadsAll's predecessors +SML: Loading lib LoadsAll's module 'pxr.Tf.testenv.testTfScriptModuleLoader_LoadsAll' +SML: Begin loading LoadsAll's predecessors +SML: End loading LoadsAll's predecessors +SML: Request to load modules for empty lib name -> load all +SML: Begin loading all modules +SML: Skipping already-loaded tf +SML: Loading lib Other's module 'pxr.Tf.testenv.testTfScriptModuleLoader_Other' +SML: Begin loading Other's predecessors +SML: Loading lib LoadsAll's module 'pxr.Tf.testenv.testTfScriptModuleLoader_LoadsAll' +SML: End loading Other's predecessors +SML: Loading lib DepLoadsAll's module 'pxr.Tf.testenv.testTfScriptModuleLoader_DepLoadsAll' +SML: Begin loading DepLoadsAll's predecessors +SML: End loading DepLoadsAll's predecessors +SML: Lib LoadsAll's module 'pxr.Tf.testenv.testTfScriptModuleLoader_LoadsAll' is already loaded +SML: End loading all modules +SML: End loading DepLoadsAll's predecessors # Registering a library that is totally independent, and raises an # error when loaded, but whose name comes first in dependency order. # Since there is no real dependency, the SML should not try to load # this module, which would cause an exception. -Registering library AAA_RaisesError with predecessors: +SML: Registering lib AAA_RaisesError with no predecessors # Test case: loading one library dynamically imports a new, # previously unknown dependent library, which registers further # dependencies, and expects them to load. -Registering library LoadsUnknown with predecessors: -Registering library Test with predecessors: LoadsUnknown, +SML: Registering lib LoadsUnknown with no predecessors +SML: Registering lib Test with predecessors LoadsUnknown # This should load LoadsUnknown, which loads Unknown dynamically, # which should request for Unknown's dependencies (NewDependency) to # load, which should work. -_LoadUpTo('Test') { - Load('LoadsUnknown'); - _LoadUpTo('LoadsUnknown') { - } -Registering library Unknown with predecessors: NewDynamicDependency, -Registering library NewDynamicDependency with predecessors: - _LoadUpTo('Unknown') { - Load('NewDynamicDependency'); - } -} +SML: Begin loading Test's predecessors +SML: Loading lib LoadsUnknown's module 'pxr.Tf.testenv.testTfScriptModuleLoader_LoadsUnknown' +SML: Begin loading LoadsUnknown's predecessors +SML: End loading LoadsUnknown's predecessors +SML: Registering lib Unknown with predecessors NewDynamicDependency +SML: Registering lib NewDynamicDependency with no predecessors +SML: Begin loading Unknown's predecessors +SML: Loading lib NewDynamicDependency's module 'sys' +SML: End loading Unknown's predecessors +SML: End loading Test's predecessors diff --git a/pxr/base/tf/wrapScriptModuleLoader.cpp b/pxr/base/tf/wrapScriptModuleLoader.cpp index f35a54a045..1099f097ee 100644 --- a/pxr/base/tf/wrapScriptModuleLoader.cpp +++ b/pxr/base/tf/wrapScriptModuleLoader.cpp @@ -24,8 +24,6 @@ void wrapScriptModuleLoader() { class_, noncopyable>("ScriptModuleLoader", no_init) .def(TfPySingleton()) - .def("GetModuleNames", &This::GetModuleNames, - return_value_policy()) .def("GetModulesDict", &This::GetModulesDict) .def("WriteDotFile", &This::WriteDotFile) From 804e8b9c0590ba377abdf81a33db45279d0ffe11 Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Thu, 24 Oct 2024 13:14:43 -0700 Subject: [PATCH 058/300] Correct UsdUI schema.usda file description (Internal change: 2345606) --- pxr/usd/usdUI/schema.usda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pxr/usd/usdUI/schema.usda b/pxr/usd/usdUI/schema.usda index 88d022c67f..c8b9571883 100644 --- a/pxr/usd/usdUI/schema.usda +++ b/pxr/usd/usdUI/schema.usda @@ -1,6 +1,6 @@ #usda 1.0 ( - "This file describes the USD Shader schemata for code generation." + "This file describes the USD User Interface schemata for code generation." subLayers = [ @usd/schema.usda@ ] From 89407621c2244754d47e2e75fe746ef252ffe0b8 Mon Sep 17 00:00:00 2001 From: klucknav Date: Thu, 24 Oct 2024 13:14:56 -0700 Subject: [PATCH 059/300] Remove 'glass' references in Preview Surface Spec This change removes the glass references made in OpacityThreshold paragraph since we have now specified that fully transparent materials essentially disappear. (Internal change: 2345615) --- docs/spec_usdpreviewsurface.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/spec_usdpreviewsurface.rst b/docs/spec_usdpreviewsurface.rst index 6b0ff67717..f3f5204cba 100644 --- a/docs/spec_usdpreviewsurface.rst +++ b/docs/spec_usdpreviewsurface.rst @@ -178,8 +178,8 @@ and :usda:`opacity`. interpreted; this "translucent or masked" behavior is common in engines and renderers, and makes the UsdPreviewSurface easier to interchange. It does imply, however, that it is not possible to faithfully recreate a - glassy/translucent material that also provides an opacity-based mask... so no - single-polygon glass leaves. + translucent material that also provides an opacity-based mask... so no + single-polygon translucent leaves. .. _updateior: From a337d3834390c023b589d326130337eb2657ef02 Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Fri, 25 Oct 2024 09:00:55 -0700 Subject: [PATCH 060/300] Fix issues where type alias of usdSchema were not getting queried correctly. (Internal change: 2345733) --- pxr/usd/usd/validationContext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pxr/usd/usd/validationContext.cpp b/pxr/usd/usd/validationContext.cpp index b515b6a419..0f7aba863a 100644 --- a/pxr/usd/usd/validationContext.cpp +++ b/pxr/usd/usd/validationContext.cpp @@ -67,7 +67,7 @@ _CollectAncestorTypeValidators( // This is done before filtering the validators by schema types, so that // validators for all ancestor types are collected. for (const TfToken &schemaType : schemaTypeNames) { - const TfType type = TfType::FindByName(schemaType.GetString()); + const TfType type = UsdSchemaRegistry::GetTypeFromName(schemaType); std::vector ancestorTypes; type.GetAllAncestorTypes(&ancestorTypes); for (const TfType &ancestorType : ancestorTypes) { From cc3941f75e619b0d797436ce8b2a21b330a292e5 Mon Sep 17 00:00:00 2001 From: diyajoy Date: Fri, 25 Oct 2024 11:13:03 -0700 Subject: [PATCH 061/300] Make all SdfListOp setter methods enforce uniqueness by removing duplicates in explicit setter methods. Deprecate ModifyOperations(callback, removeDuplicates) as removeDuplicates is now assumed true. (Internal change: 2345750) --- pxr/usd/sdf/listOp.cpp | 137 ++++++++++++------ pxr/usd/sdf/listOp.h | 101 +++++++++---- pxr/usd/sdf/listOpListEditor.h | 2 +- pxr/usd/sdf/testenv/testSdfAttribute.py | 5 +- pxr/usd/sdf/testenv/testSdfListOp.py | 34 ++++- pxr/usd/sdf/vectorListEditor.h | 2 +- .../usdUtils/assetLocalizationDelegate.cpp | 4 +- 7 files changed, 203 insertions(+), 82 deletions(-) diff --git a/pxr/usd/sdf/listOp.cpp b/pxr/usd/sdf/listOp.cpp index 8a31c5adb4..1bb19a0838 100644 --- a/pxr/usd/sdf/listOp.cpp +++ b/pxr/usd/sdf/listOp.cpp @@ -160,12 +160,35 @@ SdfListOp::GetAppliedItems() const return result; } +template +std::vector _MakeUnique(const std::vector items, bool reverse=false) +{ + TfDenseHashSet existingSet; + std::vector uniqueItems; + + if (reverse) { + for (auto it = items.rbegin(); it != items.rend(); it++) { + if (existingSet.insert(*it).second) { + uniqueItems.push_back(*it); + } + } + std::reverse(uniqueItems.begin(), uniqueItems.end()); + } else { + for (auto it = items.cbegin(); it != items.cend(); it++) { + if (existingSet.insert(*it).second) { + uniqueItems.push_back(*it); + } + } + } + return uniqueItems; +} + template void SdfListOp::SetExplicitItems(const ItemVector &items) { _SetExplicit(true); - _explicitItems = items; + _explicitItems = _MakeUnique(items); } template @@ -181,7 +204,7 @@ void SdfListOp::SetPrependedItems(const ItemVector &items) { _SetExplicit(false); - _prependedItems = items; + _prependedItems = _MakeUnique(items); } template @@ -189,7 +212,7 @@ void SdfListOp::SetAppendedItems(const ItemVector &items) { _SetExplicit(false); - _appendedItems = items; + _appendedItems = _MakeUnique(items, true); } template @@ -197,7 +220,7 @@ void SdfListOp::SetDeletedItems(const ItemVector &items) { _SetExplicit(false); - _deletedItems = items; + _deletedItems = _MakeUnique(items); } template @@ -312,11 +335,11 @@ SdfListOp::ApplyOperations(ItemVector* vec, const ApplyCallback& cb) const search[*i] = i; } - _DeleteKeys (SdfListOpTypeDeleted, cb, &result, &search); + _DeleteKeys (cb, &result, &search); _AddKeys(SdfListOpTypeAdded, cb, &result, &search); - _PrependKeys(SdfListOpTypePrepended, cb, &result, &search); - _AppendKeys(SdfListOpTypeAppended, cb, &result, &search); - _ReorderKeys(SdfListOpTypeOrdered, cb, &result, &search); + _PrependKeys(cb, &result, &search); + _AppendKeys(cb, &result, &search); + _ReorderKeys(cb, &result, &search); } // Copy the result back to vec. @@ -463,15 +486,14 @@ SdfListOp::_AddKeys( template void SdfListOp::_PrependKeys( - SdfListOpType op, const ApplyCallback& callback, _ApplyList* result, _ApplyMap* search) const { - const ItemVector& items = GetItems(op); + const ItemVector& items = GetItems(SdfListOpTypePrepended); if (callback) { for (auto i = items.rbegin(), iEnd = items.rend(); i != iEnd; ++i) { - if (std::optional mappedItem = callback(op, *i)) { + if (std::optional mappedItem = callback(SdfListOpTypePrepended, *i)) { _InsertOrMove(*mappedItem, result->begin(), result, search); } } @@ -485,15 +507,14 @@ SdfListOp::_PrependKeys( template void SdfListOp::_AppendKeys( - SdfListOpType op, const ApplyCallback& callback, _ApplyList* result, _ApplyMap* search) const { - const ItemVector& items = GetItems(op); + const ItemVector& items = GetItems(SdfListOpTypeAppended); if (callback) { for (const T& item: items) { - if (std::optional mappedItem = callback(op, item)) { + if (std::optional mappedItem = callback(SdfListOpTypeAppended, item)) { _InsertOrMove(*mappedItem, result->end(), result, search); } } @@ -507,14 +528,13 @@ SdfListOp::_AppendKeys( template void SdfListOp::_DeleteKeys( - SdfListOpType op, const ApplyCallback& callback, _ApplyList* result, _ApplyMap* search) const { - TF_FOR_ALL(i, GetItems(op)) { + TF_FOR_ALL(i, GetItems(SdfListOpTypeDeleted)) { if (callback) { - if (std::optional item = callback(op, *i)) { + if (std::optional item = callback(SdfListOpTypeDeleted, *i)) { _RemoveIfPresent(*item, result, search); } } @@ -527,29 +547,36 @@ SdfListOp::_DeleteKeys( template void SdfListOp::_ReorderKeys( - SdfListOpType op, const ApplyCallback& callback, _ApplyList* result, _ApplyMap* search) const { + _ReorderKeysHelper(GetItems(SdfListOpTypeOrdered), callback, result, search); +} + +template +void +SdfListOp::_ReorderKeysHelper(ItemVector order, const ApplyCallback& callback, + _ApplyList* result, _ApplyMap* search) { + // Make a vector and set of the source items. - ItemVector order; + ItemVector uniqueOrder; std::set orderSet; - TF_FOR_ALL(i, GetItems(op)) { + TF_FOR_ALL(i, order) { if (callback) { - if (std::optional item = callback(op, *i)) { + if (std::optional item = callback(SdfListOpTypeOrdered, *i)) { if (orderSet.insert(*item).second) { - order.push_back(*item); + uniqueOrder.push_back(*item); } } } else { if (orderSet.insert(*i).second) { - order.push_back(*i); + uniqueOrder.push_back(*i); } } } - if (order.empty()) { + if (uniqueOrder.empty()) { return; } @@ -559,9 +586,9 @@ SdfListOp::_ReorderKeys( // Find each item from the order vector in the scratch list. // Then find the next item in the scratch list that's also in - // in the order vector. All of these items except the last + // in the uniqueOrder vector. All of these items except the last // form the next continuous sequence in the result. - TF_FOR_ALL(i, order) { + TF_FOR_ALL(i, uniqueOrder) { typename _ApplyMap::const_iterator j = search->find(*i); if (j != search->end()) { // Find the next item in both scratch and order. @@ -585,16 +612,17 @@ template static inline bool _ModifyCallbackHelper(const typename SdfListOp::ModifyCallback& cb, - std::vector* itemVector, bool removeDuplicates) + std::vector* itemVector) { bool didModify = false; std::vector modifiedVector; + modifiedVector.reserve(itemVector->size()); TfDenseHashSet existingSet; for (const T& item : *itemVector) { std::optional modifiedItem = cb(item); - if (removeDuplicates && modifiedItem) { + if (modifiedItem) { if (!existingSet.insert(*modifiedItem).second) { modifiedItem = std::nullopt; } @@ -620,29 +648,36 @@ _ModifyCallbackHelper(const typename SdfListOp::ModifyCallback& cb, template bool -SdfListOp::ModifyOperations(const ModifyCallback& callback, - bool removeDuplicates) +SdfListOp::ModifyOperations(const ModifyCallback& callback) { bool didModify = false; if (callback) { didModify |= _ModifyCallbackHelper( - callback, &_explicitItems, removeDuplicates); + callback, &_explicitItems); didModify |= _ModifyCallbackHelper( - callback, &_addedItems, removeDuplicates); + callback, &_addedItems); didModify |= _ModifyCallbackHelper( - callback, &_prependedItems, removeDuplicates); + callback, &_prependedItems); didModify |= _ModifyCallbackHelper( - callback, &_appendedItems, removeDuplicates); + callback, &_appendedItems); didModify |= _ModifyCallbackHelper( - callback, &_deletedItems, removeDuplicates); + callback, &_deletedItems); didModify |= _ModifyCallbackHelper( - callback, &_orderedItems, removeDuplicates); + callback, &_orderedItems); } return didModify; } +template +bool +SdfListOp::ModifyOperations(const ModifyCallback& callback, + bool unusedRemoveDuplicates) +{ + return ModifyOperations(callback); +} + template bool SdfListOp::ReplaceOperations(const SdfListOpType op, size_t index, size_t n, @@ -713,7 +748,7 @@ SdfListOp::ComposeOperations(const SdfListOp& stronger, SdfListOpType op) if (op == SdfListOpTypeOrdered) { stronger._AddKeys(op, ApplyCallback(), &weakerList, &weakerSearch); - stronger._ReorderKeys(op, ApplyCallback(), + stronger._ReorderKeys(ApplyCallback(), &weakerList, &weakerSearch); } else if (op == SdfListOpTypeAdded) { stronger._AddKeys(op, @@ -726,13 +761,11 @@ SdfListOp::ComposeOperations(const SdfListOp& stronger, SdfListOpType op) &weakerList, &weakerSearch); } else if (op == SdfListOpTypePrepended) { - stronger._PrependKeys(op, - ApplyCallback(), + stronger._PrependKeys(ApplyCallback(), &weakerList, &weakerSearch); } else if (op == SdfListOpTypeAppended) { - stronger._AppendKeys(op, - ApplyCallback(), + stronger._AppendKeys(ApplyCallback(), &weakerList, &weakerSearch); } @@ -749,10 +782,24 @@ void SdfApplyListOrdering(std::vector* v, const std::vector& order) { if (!order.empty() && !v->empty()) { - // XXX: This is lame, but just for now... - SdfListOp tmp; - tmp.SetOrderedItems(order); - tmp.ApplyOperations(v); + // Make a list of the inputs. We can efficiently (O(1)) splice + // these elements later. + typename SdfListOp::_ApplyList result; + result.insert(result.end(), v->begin(), v->end()); + + // Make a map of keys to list iterators. This avoids O(n) + // searches within O(n) loops below. + typename SdfListOp::_ApplyMap search; + typename SdfListOp::_ApplyList::iterator i = result.begin(); + for (; + i != result.end(); ++i) { + search[*i] = i; + } + SdfListOp::_ReorderKeysHelper(order, nullptr, &result, &search); + + // Copy the result back to vec. + v->clear(); + v->insert(v->end(), result.begin(), result.end()); } } diff --git a/pxr/usd/sdf/listOp.h b/pxr/usd/sdf/listOp.h index 19b24e087c..e930674a78 100644 --- a/pxr/usd/sdf/listOp.h +++ b/pxr/usd/sdf/listOp.h @@ -48,11 +48,23 @@ struct Sdf_ListOpTraits /// \class SdfListOp /// -/// Value type representing a list-edit operation. -/// /// SdfListOp is a value type representing an operation that edits a list. -/// It may add or remove items, reorder them, or replace the list entirely. +/// It may append or prepend items, delete them, or replace the list entirely. +/// +/// SdfListOp maintains lists of items to be prepended, appended, deleted, or +/// used explicitly. If used in explicit mode, the ApplyOperations method replaces the given list +/// with the set explicit items. Otherwise, the ApplyOperations +/// method is used to apply the list-editing options in the input list in the +/// following order: +/// - Delete +/// - Prepend +/// - Append /// +/// Lists are meant to contain unique values, and all list operations +/// will remove duplicates if encountered. Prepending items and using +/// explicit mode will preserve the position of the first of the duplicates +/// to be encountered, while appending items will preserve the last. + template class SdfListOp { public: @@ -111,12 +123,6 @@ class SdfListOp { return _explicitItems; } - /// Returns the explicit items. - const ItemVector& GetAddedItems() const - { - return _addedItems; - } - /// Returns the explicit items. const ItemVector& GetPrependedItems() const { @@ -135,12 +141,6 @@ class SdfListOp { return _deletedItems; } - /// Returns the ordered items. - const ItemVector& GetOrderedItems() const - { - return _orderedItems; - } - /// Return the item vector identified by \p type. SDF_API const ItemVector& GetItems(SdfListOpType type) const; @@ -152,14 +152,24 @@ class SdfListOp { /// This is equivalent to calling ApplyOperations on an empty item vector. SDF_API ItemVector GetAppliedItems() const; + /// Sets the explicit items. If duplicates are present in \p items, + /// preserves the first occurence. SDF_API void SetExplicitItems(const ItemVector &items); - SDF_API void SetAddedItems(const ItemVector &items); + + /// Sets the prepended items. If duplicates are present in \p items, + /// preserves the first occurence. SDF_API void SetPrependedItems(const ItemVector &items); + + /// Sets the appended items. If duplicates are present in \p items, + /// preserves the last occurence. SDF_API void SetAppendedItems(const ItemVector &items); + + /// Sets the deleted items. If duplicates are present in \p items, + /// preserves the first occurence. SDF_API void SetDeletedItems(const ItemVector &items); - SDF_API void SetOrderedItems(const ItemVector &items); /// Sets the item vector for the given operation \p type. + /// Removes duplicates in \p items if present. SDF_API void SetItems(const ItemVector &items, SdfListOpType type); /// Removes all items and changes the list to be non-explicit. @@ -206,14 +216,19 @@ class SdfListOp { /// returned key is empty then the key is removed, otherwise it's replaced /// with the returned key. /// - /// If \p removeDuplicates is \c true and \p callback returns a key that was - /// previously returned for the current operation vector being processed, - /// the returned key will be removed. + /// If \p callback returns a key that was previously returned for the + /// current operation vector being processed, the returned key will be + /// removed. /// /// Returns true if a change was made, false otherwise. SDF_API + bool ModifyOperations(const ModifyCallback& callback); + + /// \deprecated Please use ModifyOperations(const ModifyCallback& callback) + /// instead. + SDF_API bool ModifyOperations(const ModifyCallback& callback, - bool removeDuplicates = false); + bool unusedRemoveDuplicates); /// Replaces the items in the specified operation vector in the range /// (index, index + n] with the given \p newItems. If \p newItems is empty @@ -227,6 +242,27 @@ class SdfListOp { SDF_API void ComposeOperations(const SdfListOp& stronger, SdfListOpType op); + /// \deprecated The add and reorder operations have been deprecated in favor + /// of the append and prepend operations. + const ItemVector& GetAddedItems() const + { + return _addedItems; + } + + /// \deprecated The add and reorder operations have been deprecated in favor + /// of the append and prepend operations. + const ItemVector& GetOrderedItems() const + { + return _orderedItems; + } + /// \deprecated The add and reorder operations have been deprecated in favor + /// of the append and prepend operations. + SDF_API void SetAddedItems(const ItemVector &items); + + /// \deprecated The add and reorder operations have been deprecated in favor + /// of the append and prepend operations. + SDF_API void SetOrderedItems(const ItemVector &items); + friend inline size_t hash_value(const SdfListOp &op) { return TfHash::Combine( op._isExplicit, @@ -261,16 +297,27 @@ class SdfListOp { typedef std::map _ApplyMap; - void _AddKeys(SdfListOpType, const ApplyCallback& cb, - _ApplyList* result, _ApplyMap* search) const; - void _PrependKeys(SdfListOpType, const ApplyCallback& cb, + void _PrependKeys(const ApplyCallback& cb, _ApplyList* result, _ApplyMap* search) const; - void _AppendKeys(SdfListOpType, const ApplyCallback& cb, + void _AppendKeys(const ApplyCallback& cb, _ApplyList* result, _ApplyMap* search) const; - void _DeleteKeys(SdfListOpType, const ApplyCallback& cb, + void _DeleteKeys(const ApplyCallback& cb, _ApplyList* result, _ApplyMap* search) const; - void _ReorderKeys(SdfListOpType, const ApplyCallback& cb, + + /// \deprecated + /// Use _PrependKeys or _AppendKeys instead. + void _AddKeys(SdfListOpType, const ApplyCallback& cb, + _ApplyList* result, _ApplyMap* search) const; + + /// \deprecated + /// Use _PrependKeys or _AppendKeys instead. + void _ReorderKeys(const ApplyCallback& cb, _ApplyList* result, _ApplyMap* search) const; + static void _ReorderKeysHelper(ItemVector order, const ApplyCallback& cb, + _ApplyList *result, _ApplyMap *search); + template + friend void SdfApplyListOrdering(std::vector *v, + const std::vector &order); private: bool _isExplicit; diff --git a/pxr/usd/sdf/listOpListEditor.h b/pxr/usd/sdf/listOpListEditor.h index 3e1a3740b6..8856daf18b 100644 --- a/pxr/usd/sdf/listOpListEditor.h +++ b/pxr/usd/sdf/listOpListEditor.h @@ -238,7 +238,7 @@ Sdf_ListOpListEditor::ModifyItemEdits(const ModifyCallback& cb) modifiedListOp.ModifyOperations( [this, &cb](const value_type &t) { return _ModifyCallbackHelper(cb, _GetTypePolicy(), t); - }, /* removeDuplicates = */ true); + }); _UpdateListOp(modifiedListOp); } diff --git a/pxr/usd/sdf/testenv/testSdfAttribute.py b/pxr/usd/sdf/testenv/testSdfAttribute.py index d6cee7e166..c4cf5888d6 100644 --- a/pxr/usd/sdf/testenv/testSdfAttribute.py +++ b/pxr/usd/sdf/testenv/testSdfAttribute.py @@ -315,12 +315,11 @@ def test_Connections(self): self.assertTrue( testPath_dead not in attr.connectionPathList.explicitItems) - # adding duplicate connection path: error expected + # adding duplicate connection path testPath = attr.connectionPathList.explicitItems[0] self.assertEqual( attr.connectionPathList.explicitItems.count(testPath), 1) - with self.assertRaises(Tf.ErrorException): - attr.connectionPathList.explicitItems.append(testPath) + attr.connectionPathList.explicitItems.append(testPath) self.assertEqual( attr.connectionPathList.explicitItems.count(testPath), 1) diff --git a/pxr/usd/sdf/testenv/testSdfListOp.py b/pxr/usd/sdf/testenv/testSdfListOp.py index 9cec8858ff..5a9a2674fd 100644 --- a/pxr/usd/sdf/testenv/testSdfListOp.py +++ b/pxr/usd/sdf/testenv/testSdfListOp.py @@ -59,8 +59,30 @@ def test_BasicSemantics(self): _ExplicitItems([1,2,3]) .ApplyOperations([0,3]), [1,2,3]) + self.assertEqual( + _ExplicitItems([1,2,1,3]) + .ApplyOperations([]), + [1,2,3]) - # "Add" leaves existing values in place and appends any new values. + # Ensure duplicates are removed when using setter methods. + self.assertEqual( + _ExplicitItems([1,2,1,3]) + .explicitItems, + [1,2,3]) + self.assertEqual( + _DeletedItems([1,2,1,3]) + .deletedItems, + [1,2,3]) + self.assertEqual( + _AppendedItems([1,2,1,3]) + .appendedItems, + [2,1,3]) + self.assertEqual( + _PrependedItems([1,2,1,3]) + .prependedItems, + [1,2,3]) + + # (deprecated)"Add" leaves existing values in place and appends any new values. self.assertEqual( _AddedItems([1,2,3]) .ApplyOperations([]), @@ -102,6 +124,10 @@ def test_BasicSemantics(self): _AppendedItems([1,2,3]) .ApplyOperations([3,4]), [4,1,2,3]) + self.assertEqual( + _AppendedItems([1,2,1,3]) + .ApplyOperations([]), + [2,1,3]) # "Prepend" is similar, but for the front of the list. self.assertEqual( @@ -116,8 +142,12 @@ def test_BasicSemantics(self): _PrependedItems([1,2,3]) .ApplyOperations([0,1]), [1,2,3,0]) + self.assertEqual( + _PrependedItems([1,2,1,3]) + .ApplyOperations([]), + [1,2,3]) - # "Order" is the most subtle. + # (deprecated) "Order" is the most subtle. self.assertEqual( _OrderedItems([1,2,3]) .ApplyOperations([]), diff --git a/pxr/usd/sdf/vectorListEditor.h b/pxr/usd/sdf/vectorListEditor.h index 2403175b00..ee45d63785 100644 --- a/pxr/usd/sdf/vectorListEditor.h +++ b/pxr/usd/sdf/vectorListEditor.h @@ -256,7 +256,7 @@ Sdf_VectorListEditor::ModifyItemEdits(const ModifyCallback& cb) valueListOp.ModifyOperations( [this, &cb](const value_type &t) { return _ModifyCallbackHelper(cb, _GetTypePolicy(), t); - }, /* removeDuplicates = */ true); + }); _UpdateFieldData(valueListOp.GetItems(_op)); } diff --git a/pxr/usd/usdUtils/assetLocalizationDelegate.cpp b/pxr/usd/usdUtils/assetLocalizationDelegate.cpp index 9464b725ec..d993100065 100644 --- a/pxr/usd/usdUtils/assetLocalizationDelegate.cpp +++ b/pxr/usd/usdUtils/assetLocalizationDelegate.cpp @@ -137,9 +137,7 @@ UsdUtils_WritableLocalizationDelegate::_ProcessReferencesOrPayloads( return _ProcessRefOrPayload ( layer, item, &dependencies); - }, - /*removeDuplicates*/ true - ); + }); if (!modified) { return dependencies; From 7bbb6367a72de521aa19a26ba081d347af8a67f2 Mon Sep 17 00:00:00 2001 From: rajabala Date: Fri, 25 Oct 2024 14:45:29 -0700 Subject: [PATCH 062/300] [hd, hdsi] Fix emulation propagation of light linking dirty bits for instancers. - For hydra instancer prims, both instanceCategories and categories data source locators are relevant and map to the legacy DirtyCategories bit. This missing piece of invalidation forwarding resulted in incorrect light linking edits to point instancer prims. (Internal change: 2345763) --- pxr/imaging/hd/dirtyBitsTranslator.cpp | 11 ++++++++++- pxr/imaging/hdsi/lightLinkingSceneIndex.cpp | 20 +++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/pxr/imaging/hd/dirtyBitsTranslator.cpp b/pxr/imaging/hd/dirtyBitsTranslator.cpp index 7be39fe128..fda98cf58b 100644 --- a/pxr/imaging/hd/dirtyBitsTranslator.cpp +++ b/pxr/imaging/hd/dirtyBitsTranslator.cpp @@ -397,7 +397,12 @@ HdDirtyBitsTranslator::InstancerDirtyBitsToLocatorSet(TfToken const& primType, set->append(HdXformSchema::GetDefaultLocator()); } if (bits & HdChangeTracker::DirtyCategories) { + // Note: We don't have a DirtyInstanceCategories bit. + // For point instancers, instance categories is not relevant (i.e. all + // instances are affected), so we invalidate both categories and + // instanceCategories locators. set->append(HdInstanceCategoriesSchema::GetDefaultLocator()); + set->append(HdCategoriesSchema::GetDefaultLocator()); } } @@ -935,8 +940,13 @@ HdDirtyBitsTranslator::InstancerLocatorSetToDirtyBits( HdDataSourceLocatorSet::const_iterator end = set.end(); HdDirtyBits bits = HdChangeTracker::Clean; + if (_FindLocator(HdCategoriesSchema::GetDefaultLocator(), end, &it)) { + // This is relevant for point instancers. + bits |= HdChangeTracker::DirtyCategories; + } if (_FindLocator(HdInstanceCategoriesSchema::GetDefaultLocator(), end, &it)) { // We don't have an instance categories dirty bit. + // This is relevant for native instancers. bits |= HdChangeTracker::DirtyCategories; } if (_FindLocator(HdInstancedBySchema::GetDefaultLocator(), end, &it)) { @@ -972,7 +982,6 @@ HdDirtyBitsTranslator::TaskLocatorSetToDirtyBits( // we only end up making one trip through the set. If you add to this // function, make sure you sort the addition by locator name, or // _FindLocator won't work. - // Also note, this should match InstancerDirtyBitsToLocatorSet if (*it == HdDataSourceLocator::EmptyLocator()) { return HdChangeTracker::AllDirty; diff --git a/pxr/imaging/hdsi/lightLinkingSceneIndex.cpp b/pxr/imaging/hdsi/lightLinkingSceneIndex.cpp index 1853733c20..d28daf8005 100644 --- a/pxr/imaging/hdsi/lightLinkingSceneIndex.cpp +++ b/pxr/imaging/hdsi/lightLinkingSceneIndex.cpp @@ -755,10 +755,11 @@ _BuildDependenciesDataSource( const HdPathArrayDataSourceHandle instancePathsDs = topologySchema.GetInstanceLocations(); - if (!instancePathsDs) { - // XXX Point instancer. Per-instance categories does not make sense for - // point instancers. Should we use categories to reflect that they - // apply to all instances (of all prototypes)? + const bool isPointInstancer = + !instancePathsDs || instancePathsDs->GetTypedValue(0.0).empty(); + + if (isPointInstancer) { + // instanceCategories is not relevant to point instancers. return nullptr; } @@ -781,7 +782,9 @@ _BuildDependenciesDataSource( // on all prims targeted by the collection, including instance prims. // // We publish categories only for geometry prims and not instance - // prims. See HdsiLightLinkingSceneIndex::GetPrim. + // prims. See HdsiLightLinkingSceneIndex::GetPrim. + // Note: categories is relevant for instancer prims corresponding + // to point instancers. // size_t idx = 0; for (const SdfPath &instancePath : instancePaths) { @@ -964,7 +967,7 @@ class _LightDataSource : public HdContainerDataSource : name; // Note: Since this scene index relies on linking collections to - // be transported, use an overlay only when we have a + // be transported, provide an override only when we have a // collections data source on the prim to provide the category // ID for the collections, including an empty token for the // trivial case. @@ -1025,7 +1028,10 @@ class _LightPrimDataSource : public HdContainerDataSource TfTokenVector GetNames() override { - return _inputPrimDs->GetNames(); + // 'light' may be absent. + TfTokenVector names = _inputPrimDs->GetNames(); + _AddIfAbsent(HdLightSchemaTokens->light, &names); + return names; } HdDataSourceBaseHandle Get(const TfToken &name) override From 94d81995c6efb717630b6d3ed09f100c0e702807 Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Fri, 25 Oct 2024 14:45:37 -0700 Subject: [PATCH 063/300] Add Error identifier information to GetErrorAsString. (Internal change: 2345778) --- pxr/usd/usd/validationError.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pxr/usd/usd/validationError.cpp b/pxr/usd/usd/validationError.cpp index 4471f5a304..a448004fc4 100644 --- a/pxr/usd/usd/validationError.cpp +++ b/pxr/usd/usd/validationError.cpp @@ -77,8 +77,17 @@ UsdValidationError::GetIdentifier() const std::string UsdValidationError::GetErrorAsString() const { - return _errorType == UsdValidationErrorType::None ? _errorMsg : TfStringPrintf( - "%s: %s", TfEnum::GetDisplayName(_errorType).c_str(), _errorMsg.c_str()); + if (_validator) { + return _errorType == UsdValidationErrorType::None ? _errorMsg : + TfStringPrintf( + "%s: (%s) %s", TfEnum::GetDisplayName(_errorType).c_str(), + GetIdentifier().GetString().c_str(), _errorMsg.c_str()); + } else { + return _errorType == UsdValidationErrorType::None ? _errorMsg : + TfStringPrintf( + "%s: %s", TfEnum::GetDisplayName(_errorType).c_str(), + _errorMsg.c_str()); + } } void From 3fd3147af4d42cfe6e26106cb4cb549909739632 Mon Sep 17 00:00:00 2001 From: Andy Shiue Date: Sun, 27 Oct 2024 17:33:53 -0400 Subject: [PATCH 064/300] The staged copy of HgiVulkanBlitCmds has incorrect source and destination offset Source offset of a cpu-to-gpu-copy defines the offset of the source cpu memory, and the destination offset of a cpu-to-gpu-copy defines the offset of the destination gpu buffer. The `memcpy`` from the cpu memory to the staging buffer should use the source offset and the destination offset respectively. But the copy from the staging buffer to the gpu buffer should use the destination offset to define `VkBufferCopy.srcOffset`. --- pxr/imaging/hgiVulkan/blitCmds.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pxr/imaging/hgiVulkan/blitCmds.cpp b/pxr/imaging/hgiVulkan/blitCmds.cpp index 583d80249a..9ef164094a 100644 --- a/pxr/imaging/hgiVulkan/blitCmds.cpp +++ b/pxr/imaging/hgiVulkan/blitCmds.cpp @@ -283,15 +283,15 @@ void HgiVulkanBlitCmds::CopyBufferCpuToGpu( if (!buffer->IsCPUStagingAddress(copyOp.cpuSourceBuffer) || copyOp.sourceByteOffset != copyOp.destinationByteOffset) { - uint8_t* dst = static_cast(buffer->GetCPUStagingAddress()); - size_t dstOffset = copyOp.destinationByteOffset; - // Offset into the src buffer - uint8_t* src = ((uint8_t*) copyOp.cpuSourceBuffer) + + const uint8_t* src = static_cast(copyOp.cpuSourceBuffer) + copyOp.sourceByteOffset; - // Offset into the dst buffer - memcpy(dst + dstOffset, src, copyOp.byteSize); + // Offset into the dst buffer. + uint8_t* dst = static_cast(buffer->GetCPUStagingAddress()) + + copyOp.destinationByteOffset; + + memcpy(dst, src, copyOp.byteSize); } // Schedule copy data from staging buffer to device-local buffer. @@ -299,7 +299,9 @@ void HgiVulkanBlitCmds::CopyBufferCpuToGpu( if (TF_VERIFY(stagingBuffer)) { VkBufferCopy copyRegion = {}; - copyRegion.srcOffset = copyOp.sourceByteOffset; + // Note we use the destinationByteOffset as the srcOffset here. The staging buffer + // should be prepared with the same data layout of the destination buffer. + copyRegion.srcOffset = copyOp.destinationByteOffset; copyRegion.dstOffset = copyOp.destinationByteOffset; copyRegion.size = copyOp.byteSize; From fef828d6c6aa275294f17e064fe6cd9a45aabcf3 Mon Sep 17 00:00:00 2001 From: klucknav Date: Mon, 28 Oct 2024 15:18:19 -0700 Subject: [PATCH 065/300] Update HdPrman's implementation of PreviewSurface to match the updated spec The preview surface spec was recently updated to state that there is no lighting response for fully transparent materials. This change removes the refractionGain connection between the adapter and pxrSurface nodes that appears to be resulting in that additional lighting response. Previously this connection was only added when in cutout mode. This meant that when opacityThreshold was non-zero OR not authored we would get additional lighting response for fully transparent materials. This change means that HdPrman will match the new spec and fully transparent materials (opacity = 0) will not have any lighting response regardless of if we are in cutout or transparent mode. (Internal change: 2345815) --- .../hdPrman/matfiltConvertPreviewMaterial.cpp | 18 +++--------------- .../shaders/UsdPreviewSurfaceParameters.osl | 12 +++++------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/third_party/renderman-26/plugin/hdPrman/matfiltConvertPreviewMaterial.cpp b/third_party/renderman-26/plugin/hdPrman/matfiltConvertPreviewMaterial.cpp index 9e1e1dcc41..8bc55e74d4 100644 --- a/third_party/renderman-26/plugin/hdPrman/matfiltConvertPreviewMaterial.cpp +++ b/third_party/renderman-26/plugin/hdPrman/matfiltConvertPreviewMaterial.cpp @@ -66,13 +66,13 @@ TF_DEFINE_PRIVATE_TOKENS( (dispScalarOut) (glassIor) (glassIorOut) + (glassRoughness) + (glassRoughnessOut) (glowGain) (glowGainOut) (glowColor) (glowColorOut) (normalIn) - (refractionGain) - (refractionGainOut) (specularEdgeColor) (specularEdgeColorOut) (specularFaceColor) @@ -225,6 +225,7 @@ _ProcessPreviewSurfaceNode( {_tokens->diffuseColor, _tokens->diffuseColorOut}, {_tokens->diffuseGain, _tokens->diffuseGainOut}, {_tokens->glassIor, _tokens->glassIorOut}, + {_tokens->glassRoughness, _tokens->glassRoughnessOut}, {_tokens->glowColor, _tokens->glowColorOut}, {_tokens->glowGain, _tokens->glowGainOut}, {_tokens->specularFaceColor, _tokens->specularFaceColorOut}, @@ -242,19 +243,6 @@ _ProcessPreviewSurfaceNode( pxrSurfaceNodeName, inOutPair.first, {{nodeName, inOutPair.second}}); } - - // If opacityThreshold is > 0, do *not* use refraction. - VtValue vtOpThres; - if (_GetParameter( - netInterface, nodeName, _tokens->opacityThreshold, - &vtOpThres)) { - - if (vtOpThres.Get() <= 0.0f) { - netInterface->SetNodeInputConnection( - pxrSurfaceNodeName, _tokens->refractionGain, - {{nodeName, _tokens->refractionGainOut}}); - } - } } // Check for non-zero displacement param or connection diff --git a/third_party/renderman-26/shaders/UsdPreviewSurfaceParameters.osl b/third_party/renderman-26/shaders/UsdPreviewSurfaceParameters.osl index a7e6b9ba30..11b3e8d921 100644 --- a/third_party/renderman-26/shaders/UsdPreviewSurfaceParameters.osl +++ b/third_party/renderman-26/shaders/UsdPreviewSurfaceParameters.osl @@ -56,17 +56,15 @@ shader UsdPreviewSurfaceParameters output normal bumpNormalOut = normal(0.0,0.0,0.0) [[ string widget = "null" ]], - // Opacity - output float refractionGainOut = 0.0 - [[ string widget = "null" ]], + // Opacity & Presence outputs output float glassIorOut= 0.0 [[ string widget = "null" ]], - - // Presence output + output float glassRoughnessOut = 0.0 + [[ string widget = "null" ]], output float presenceOut = 1.0 [[ string widget = "null" ]], - // Displacement output + // Displacement outputs output float dispAmountOut = 0.0 [[ string widget = "null" ]], output float dispScalarOut = 0.0 @@ -145,7 +143,7 @@ shader UsdPreviewSurfaceParameters // Opacity if (opacityAdjusted < 1.0) { glassIorOut = ior; - refractionGainOut = 1.0 - opacityAdjusted; + glassRoughnessOut = 0.0; diffuseGainOut *= opacityAdjusted; presenceOut = opacityAdjusted; } From d6353ccba60ba2a984d825fa159c6d7e11c27107 Mon Sep 17 00:00:00 2001 From: klucknav Date: Mon, 28 Oct 2024 15:19:10 -0700 Subject: [PATCH 066/300] Update wording around opacityThreshold. (Internal change: 2345853) --- docs/spec_usdpreviewsurface.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/spec_usdpreviewsurface.rst b/docs/spec_usdpreviewsurface.rst index f3f5204cba..81e5c7082c 100644 --- a/docs/spec_usdpreviewsurface.rst +++ b/docs/spec_usdpreviewsurface.rst @@ -178,8 +178,8 @@ and :usda:`opacity`. interpreted; this "translucent or masked" behavior is common in engines and renderers, and makes the UsdPreviewSurface easier to interchange. It does imply, however, that it is not possible to faithfully recreate a - translucent material that also provides an opacity-based mask... so no - single-polygon translucent leaves. + translucent material that also provides an opacity-based mask with a + non-zero opacityThreshold. .. _updateior: From 2602568ea0cd8af8e5ea21f6b9dea3fd851871af Mon Sep 17 00:00:00 2001 From: tgvarik Date: Mon, 28 Oct 2024 15:19:29 -0700 Subject: [PATCH 067/300] Check prototypes before creating gprim instances HdPrmanInstancer::Populate() expects to receive invalid geometry prototype ids when instancing analytic lights, so it checks to make sure it has a light shader id whenever it sees an invalid geometry prototype id and fails a verify if both are invalid. We want to keep that behavior, but avoid hitting the failed verify when we expected to have valid geometry prototype ids. So we add a check in Gprim::Sync() to ensure we have valid ids before calling Populate() and issue a better (and non-fatal) warning if we do not. (Internal change: 2345857) --- .../renderman-26/plugin/hdPrman/gprim.h | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/third_party/renderman-26/plugin/hdPrman/gprim.h b/third_party/renderman-26/plugin/hdPrman/gprim.h index aa74251f84..3dc0c4e436 100644 --- a/third_party/renderman-26/plugin/hdPrman/gprim.h +++ b/third_party/renderman-26/plugin/hdPrman/gprim.h @@ -473,19 +473,34 @@ HdPrman_Gprim::Sync(HdSceneDelegate* sceneDelegate, "size mismatch (%lu, %lu, %lu)\n", _prototypeIds.size(), subsetMaterialIds.size(), subsetPaths.size()); - // next, tell the hdprman instancer to sync the riley instances - HdPrmanInstancer *instancer = static_cast( - renderIndex.GetInstancer(instancerId)); - if (instancer) { - instancer->Populate( - renderParam, - dirtyBits, - id, - _prototypeIds, - coordSysList, - attrs, xf, - subsetMaterialIds, - subsetPaths); + // XXX: To avoid a failed verify inside Populate(), we will check the + // prototype ids for validity here. We don't usually do this, relying on + // Riley to report invalid prototype ids on instance creation. But + // Populate() allows and expects an invalid prototype id when instancing + // lights, so doing this check here lets us make a more informative + // warning. HYD-3206 + if (std::any_of(_prototypeIds.begin(), _prototypeIds.end(), + [](const auto& id){ + return id == riley::GeometryPrototypeId::InvalidId(); + })) { + TF_WARN("Riley geometry prototype creation failed for " + "instanced gprim <%s>; the prim will not be instanced.", + id.GetText()); + } else { + // next, tell the hdprman instancer to sync the riley instances + HdPrmanInstancer *instancer = static_cast( + renderIndex.GetInstancer(instancerId)); + if (instancer) { + instancer->Populate( + renderParam, + dirtyBits, + id, + _prototypeIds, + coordSysList, + attrs, xf, + subsetMaterialIds, + subsetPaths); + } } } *dirtyBits &= ~HdChangeTracker::AllSceneDirtyBits; From 3a70f7cd87699ebefe8e1fdd8ebca826d5c93d88 Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Mon, 28 Oct 2024 15:20:30 -0700 Subject: [PATCH 068/300] Updated PlugPlugin python wrapper to allow stl sequence of pluginPtr - Added a TfPyRegisterStlSequencesFromPython call to wrapPlugin.cpp - Added a test case to testPlug.py to test the new functionality (Internal change: 2345868) --- pxr/base/plug/testPlug.py | 5 +++++ pxr/base/plug/testPlugBase.h | 5 +++++ pxr/base/plug/wrapPlugin.cpp | 1 + pxr/base/plug/wrapTestPlugBase.cpp | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/pxr/base/plug/testPlug.py b/pxr/base/plug/testPlug.py index ba8feed7da..578e9cc62e 100644 --- a/pxr/base/plug/testPlug.py +++ b/pxr/base/plug/testPlug.py @@ -327,5 +327,10 @@ def test_DebugCodeExistence(self): self.assertTrue('PLUG_INFO_SEARCH' in debugCodes) self.assertTrue('PLUG_REGISTRATION' in debugCodes) + def test_StlSequencesForPlugPluginPtr(self): + pd1 = Plug.Registry().GetPluginForType('TestPlugDerived1') + td1 = Plug._TestPlugBase1('TestPlugDerived1') + self.assertTrue(td1.TestAcceptPluginSequence([pd1])) + if __name__ == '__main__': unittest.main() diff --git a/pxr/base/plug/testPlugBase.h b/pxr/base/plug/testPlugBase.h index 9b17ae5aaa..2bd210cd69 100644 --- a/pxr/base/plug/testPlugBase.h +++ b/pxr/base/plug/testPlugBase.h @@ -13,6 +13,7 @@ #include "pxr/base/tf/stringUtils.h" #include "pxr/base/tf/type.h" #include "pxr/base/tf/weakBase.h" +#include "pxr/base/plug/plugin.h" #include @@ -36,6 +37,10 @@ class _TestPlugBase : public TfRefBase, public TfWeakBase { return TfCreateRefPtr(new This()); } + bool TestAcceptPluginSequence(const PlugPluginPtrVector &plugins) { + return true; + } + PLUG_API static RefPtr Manufacture(const std::string & subclass); diff --git a/pxr/base/plug/wrapPlugin.cpp b/pxr/base/plug/wrapPlugin.cpp index 07929dbc5b..2c87ed069a 100644 --- a/pxr/base/plug/wrapPlugin.cpp +++ b/pxr/base/plug/wrapPlugin.cpp @@ -87,6 +87,7 @@ void wrapPlugin() (arg("path"), arg("verify") = true)) ; + TfPyRegisterStlSequencesFromPython(); // The call to JsConvertToContainerType in _ConvertDict creates // vectors of pxr_boost::python::objects for array values, so register diff --git a/pxr/base/plug/wrapTestPlugBase.cpp b/pxr/base/plug/wrapTestPlugBase.cpp index ea6f172535..5037ec7c7e 100644 --- a/pxr/base/plug/wrapTestPlugBase.cpp +++ b/pxr/base/plug/wrapTestPlugBase.cpp @@ -7,6 +7,8 @@ #include "pxr/pxr.h" #include "pxr/base/plug/testPlugBase.h" +#include "pxr/external/boost/python/def.hpp" +#include "pxr/external/boost/python/args.hpp" #include "pxr/base/tf/makePyConstructor.h" #include "pxr/base/tf/pyPtrHelpers.h" #include "pxr/base/tf/pyContainerConversions.h" @@ -33,6 +35,9 @@ void wrap_TestPlugBase(const std::string & name) .def("GetTypeName", &This::GetTypeName) + .def("TestAcceptPluginSequence", &This::TestAcceptPluginSequence, + (arg("plugins"))); + ; } From 82e8f2c6a4d49df9fd338179ae86c5114d819f57 Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Mon, 28 Oct 2024 15:20:48 -0700 Subject: [PATCH 069/300] test plugin library for testing ValidationContext APIs - The test validators registered here can now be shared between cpp and python test, which is introduced in a subsequent change (Internal change: 2345871) --- pxr/usd/usd/CMakeLists.txt | 10 + ...dValidationContextValidators_plugInfo.json | 52 +++++ .../usd/testenv/testUsdValidationContext.cpp | 182 +++--------------- .../resources/plugInfo.json | 39 ---- .../testUsdValidationContextValidators.cpp | 169 ++++++++++++++++ 5 files changed, 253 insertions(+), 199 deletions(-) create mode 100644 pxr/usd/usd/testenv/TestUsdValidationContextValidators_plugInfo.json create mode 100644 pxr/usd/usd/testenv/testUsdValidationContextValidators.cpp diff --git a/pxr/usd/usd/CMakeLists.txt b/pxr/usd/usd/CMakeLists.txt index da880016e8..6bb5caa018 100644 --- a/pxr/usd/usd/CMakeLists.txt +++ b/pxr/usd/usd/CMakeLists.txt @@ -300,6 +300,16 @@ pxr_build_test_shared_lib(TestUsdResolverChangedResolver testenv/TestUsdResolverChangedResolver.cpp ) +pxr_build_test_shared_lib(TestUsdValidationContextValidators + INSTALL_PREFIX UsdPlugins + LIBRARIES + tf + usd + + CPPFILES + testenv/testUsdValidationContextValidators.cpp +) + pxr_build_test_shared_lib(TestUsdValidationRegistryPy INSTALL_PREFIX UsdPlugins LIBRARIES diff --git a/pxr/usd/usd/testenv/TestUsdValidationContextValidators_plugInfo.json b/pxr/usd/usd/testenv/TestUsdValidationContextValidators_plugInfo.json new file mode 100644 index 0000000000..a43029c8c2 --- /dev/null +++ b/pxr/usd/usd/testenv/TestUsdValidationContextValidators_plugInfo.json @@ -0,0 +1,52 @@ +{ + "Plugins": [ + { + "Type": "library", + "Name": "testUsdValidationContextValidatorsPlugin", + "Root": "@TEST_PLUG_INFO_ROOT@", + "ResourcePath": "@TEST_PLUG_INFO_RESOURCE_PATH@", + "LibraryPath": "@TEST_PLUG_INFO_LIBRARY_PATH@", + "Info": { + "Validators": { + "Test1": { + "doc": "Stage Validator", + "keywords": ["Keyword1"] + }, + "Test2": { + "doc": "Layer Validator", + "keywords": ["Keyword2"] + }, + "Test3": { + "doc": "A generic prim validator", + "keywords": ["Keyword1"] + }, + "Test4": { + "doc": "validator for testBaseType", + "keywords": ["Keyword2"], + "schemaTypes": ["testBaseType"] + }, + "Test5": { + "doc": "validator for testDerivedType", + "keywords": ["Keyword1"], + "schemaTypes": ["testDerivedType"] + }, + "Test6": { + "doc": "validator for testNestedDerivedType", + "keywords": ["Keyword2"], + "schemaTypes": ["testNestedDerivedType"] + }, + "Test7": { + "doc": "validator for testAPISchema", + "keywords": ["Keyword1"], + "schemaTypes": ["testAPISchemaAPI"] + }, + "TestSuite": { + "doc": "A suite of validators for Test1, Test2 and Test3", + "isSuite": true, + "keywords": ["Keyword2"] + } + } + } + } + ] +} diff --git a/pxr/usd/usd/testenv/testUsdValidationContext.cpp b/pxr/usd/usd/testenv/testUsdValidationContext.cpp index c7e66b76a5..db83eacbef 100644 --- a/pxr/usd/usd/testenv/testUsdValidationContext.cpp +++ b/pxr/usd/usd/testenv/testUsdValidationContext.cpp @@ -15,154 +15,6 @@ PXR_NAMESPACE_USING_DIRECTIVE -TF_REGISTRY_FUNCTION(UsdValidationRegistry) -{ - UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); - - // Register test plugin validators here - // Test validators simply just return errors, we need to make sure various - // UsdValidationContext APIs work and get the expected errors back, when - // Validate is called in various scenarios on a validation context instance. - { - const TfToken validatorName("testUsdValidationContext:Test1"); - const UsdValidateStageTaskFn stageTaskFn = []( - const UsdStagePtr & usdStage) - { - const TfToken validationErrorId("Test1Error"); - return UsdValidationErrorVector{ - UsdValidationError( - validationErrorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(usdStage, - SdfPath::AbsoluteRootPath())}, - "A stage validator error")}; - }; - - TfErrorMark m; - registry.RegisterPluginValidator(validatorName, stageTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const TfToken validatorName("testUsdValidationContext:Test2"); - const UsdValidateLayerTaskFn layerTaskFn = []( - const SdfLayerHandle & layer) - { - const TfToken validationErrorId("Test2Error"); - return UsdValidationErrorVector{ - UsdValidationError( - validationErrorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(layer, - SdfPath::AbsoluteRootPath())}, - "A layer validator error")}; - }; - - TfErrorMark m; - registry.RegisterPluginValidator(validatorName, layerTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const TfToken validatorName("testUsdValidationContext:Test3"); - const UsdValidatePrimTaskFn primTaskFn = []( - const UsdPrim & prim) - { - const TfToken validationErrorId("Test3Error"); - return UsdValidationErrorVector{ - UsdValidationError( - validationErrorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(prim.GetStage(), - prim.GetPath())}, - "A generic prim validator error")}; - }; - - TfErrorMark m; - registry.RegisterPluginValidator(validatorName, primTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const TfToken validatorName("testUsdValidationContext:Test4"); - const UsdValidatePrimTaskFn primTaskFn = []( - const UsdPrim & prim) - { - const TfToken validationErrorId("Test4Error"); - return UsdValidationErrorVector{ - UsdValidationError( - validationErrorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(prim.GetStage(), - prim.GetPath())}, - "A testBaseType prim type validator error")}; - }; - - TfErrorMark m; - registry.RegisterPluginValidator(validatorName, primTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const TfToken validatorName("testUsdValidationContext:Test5"); - const UsdValidatePrimTaskFn primTaskFn = []( - const UsdPrim & prim) - { - const TfToken validationErrorId("Test5Error"); - return UsdValidationErrorVector{ - UsdValidationError( - validationErrorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(prim.GetStage(), - prim.GetPath())}, - "A testDerivedType prim type validator error")}; - }; - - TfErrorMark m; - registry.RegisterPluginValidator(validatorName, primTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const TfToken validatorName("testUsdValidationContext:Test6"); - const UsdValidatePrimTaskFn primTaskFn = []( - const UsdPrim & prim) - { - const TfToken validationErrorId("Test6Error"); - return UsdValidationErrorVector{ - UsdValidationError( - validationErrorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(prim.GetStage(), - prim.GetPath())}, - "A testNestedDerivedType prim type validator error")}; - }; - - TfErrorMark m; - registry.RegisterPluginValidator(validatorName, primTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const TfToken validatorName("testUsdValidationContext:Test7"); - const UsdValidatePrimTaskFn primTaskFn = []( - const UsdPrim & prim) - { - const TfToken validationErrorId("Test7Error"); - return UsdValidationErrorVector{ - UsdValidationError( - validationErrorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(prim.GetStage(), - prim.GetPath())}, - "A testAPISchema prim type validator error")}; - }; - - TfErrorMark m; - registry.RegisterPluginValidator(validatorName, primTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const TfToken suiteName("testUsdValidationContext:TestSuite"); - const std::vector containedValidators = - registry.GetOrLoadValidatorsByName( - {TfToken("testUsdValidationContext:Test1"), - TfToken("testUsdValidationContext:Test2"), - TfToken("testUsdValidationContext:Test3")}); - - TfErrorMark m; - registry.RegisterPluginValidatorSuite(suiteName, containedValidators); - TF_AXIOM(m.IsClean()); - } -} - static std::string _LayerContents() { @@ -202,7 +54,7 @@ void _TestError1(const UsdValidationError &error) { TF_AXIOM( error.GetValidator()->GetMetadata().name == - TfToken("testUsdValidationContext:Test1")); + TfToken("testUsdValidationContextValidatorsPlugin:Test1")); TF_AXIOM(error.GetSites().size() == 1); TF_AXIOM(error.GetSites()[0].IsPrim()); TF_AXIOM(error.GetSites()[0].GetPrim().GetPath() == @@ -214,7 +66,7 @@ void _TestError2(const UsdValidationError &error) { TF_AXIOM( error.GetValidator()->GetMetadata().name == - TfToken("testUsdValidationContext:Test2")); + TfToken("testUsdValidationContextValidatorsPlugin:Test2")); TF_AXIOM(error.GetSites().size() == 1); TF_AXIOM(error.GetSites()[0].IsValidSpecInLayer()); } @@ -224,7 +76,7 @@ void _TestError3(const UsdValidationError &error) { TF_AXIOM( error.GetValidator()->GetMetadata().name == - TfToken("testUsdValidationContext:Test3")); + TfToken("testUsdValidationContextValidatorsPlugin:Test3")); const std::set expectedPrimPaths = { SdfPath("/World"), SdfPath("/World/baseType"), @@ -241,7 +93,7 @@ void _TestError4(const UsdValidationError &error) { TF_AXIOM( error.GetValidator()->GetMetadata().name == - TfToken("testUsdValidationContext:Test4")); + TfToken("testUsdValidationContextValidatorsPlugin:Test4")); const std::set expectedPrimPaths = { SdfPath("/World/baseType"), SdfPath("/World/derivedType"), @@ -256,7 +108,7 @@ void _TestError5(const UsdValidationError &error) { TF_AXIOM( error.GetValidator()->GetMetadata().name == - TfToken("testUsdValidationContext:Test5")); + TfToken("testUsdValidationContextValidatorsPlugin:Test5")); const std::set expectedPrimPaths = { SdfPath("/World/derivedType"), SdfPath("/World/nestedDerivedType")}; @@ -270,7 +122,7 @@ void _TestError6(const UsdValidationError &error) { TF_AXIOM( error.GetValidator()->GetMetadata().name == - TfToken("testUsdValidationContext:Test6")); + TfToken("testUsdValidationContextValidatorsPlugin:Test6")); TF_AXIOM(error.GetSites().size() == 1); TF_AXIOM(error.GetSites()[0].IsPrim()); TF_AXIOM(error.GetSites()[0].GetPrim().GetName() == @@ -283,7 +135,7 @@ _TestError7(const UsdValidationError &error) { TF_AXIOM(error.GetName() == TfToken("Test7Error")); TF_AXIOM( error.GetValidator()->GetMetadata().name == - TfToken("testUsdValidationContext:Test7")); + TfToken("testUsdValidationContextValidatorsPlugin:Test7")); TF_AXIOM(error.GetSites().size() == 1); TF_AXIOM(error.GetSites()[0].IsPrim()); TF_AXIOM(error.GetSites()[0].GetPrim().GetName() == @@ -309,7 +161,7 @@ _TestUsdValidationContext() // Create a ValidationContext with a suite const UsdValidatorSuite* suite = UsdValidationRegistry::GetInstance().GetOrLoadValidatorSuiteByName( - TfToken("testUsdValidationContext:TestSuite")); + TfToken("testUsdValidationContextValidatorsPlugin:TestSuite")); UsdValidationContext context({suite}); SdfLayerRefPtr testLayer = _CreateTestLayer(); // Run Validate(layer) @@ -494,7 +346,7 @@ _TestUsdValidationContext() // Create a ValidationContext with plugins UsdValidationContext context({ PlugRegistry::GetInstance().GetPluginWithName( - "testUsdValidationContext")}); + "testUsdValidationContextValidatorsPlugin")}); SdfLayerRefPtr testLayer = _CreateTestLayer(); UsdStageRefPtr stage = UsdStage::Open(testLayer); UsdValidationErrorVector errors = context.Validate(stage); @@ -536,9 +388,19 @@ _TestUsdValidationContext() int main() { - // Register the test plugin - const std::string pluginPath = ArchGetCwd() + "/resources"; - TF_AXIOM(!PlugRegistry::GetInstance().RegisterPlugins(pluginPath).empty()); + // Register the test plugins + // Plugin which provides test usd schema types + const std::string testTypePluginPath = ArchGetCwd() + "/resources"; + TF_AXIOM(!PlugRegistry::GetInstance().RegisterPlugins( + testTypePluginPath).empty()); + // Plugin which provides test validators + const std::string testValidatorPluginPath = + TfStringCatPaths( + TfGetPathName(ArchGetExecutablePath()), + "UsdPlugins/lib/TestUsdValidationContextValidators*/Resources/") + + "/"; + TF_AXIOM(!PlugRegistry::GetInstance().RegisterPlugins( + testValidatorPluginPath).empty()); // Add a non-plugin based validator here. { diff --git a/pxr/usd/usd/testenv/testUsdValidationContext/resources/plugInfo.json b/pxr/usd/usd/testenv/testUsdValidationContext/resources/plugInfo.json index 1ed9b05b62..2b64e63ab9 100644 --- a/pxr/usd/usd/testenv/testUsdValidationContext/resources/plugInfo.json +++ b/pxr/usd/usd/testenv/testUsdValidationContext/resources/plugInfo.json @@ -34,45 +34,6 @@ }, "bases": ["UsdAPISchemaBase"] } - }, - "Validators": { - "Test1": { - "doc": "Stage Validator", - "keywords": ["Keyword1"] - }, - "Test2": { - "doc": "Layer Validator", - "keywords": ["Keyword2"] - }, - "Test3": { - "doc": "A generic prim validator", - "keywords": ["Keyword1"] - }, - "Test4": { - "doc": "validator for testBaseType", - "keywords": ["Keyword2"], - "schemaTypes": ["testBaseType"] - }, - "Test5": { - "doc": "validator for testDerivedType", - "keywords": ["Keyword1"], - "schemaTypes": ["testDerivedType"] - }, - "Test6": { - "doc": "validator for testNestedDerivedType", - "keywords": ["Keyword2"], - "schemaTypes": ["testNestedDerivedType"] - }, - "Test7": { - "doc": "validator for testAPISchema", - "keywords": ["Keyword1"], - "schemaTypes": ["testAPISchemaAPI"] - }, - "TestSuite": { - "doc": "A suite of validators for Test1, Test2 and Test3", - "isSuite": true, - "keywords": ["Keyword2"] - } } } } diff --git a/pxr/usd/usd/testenv/testUsdValidationContextValidators.cpp b/pxr/usd/usd/testenv/testUsdValidationContextValidators.cpp new file mode 100644 index 0000000000..66615018d2 --- /dev/null +++ b/pxr/usd/usd/testenv/testUsdValidationContextValidators.cpp @@ -0,0 +1,169 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// + +#include "pxr/pxr.h" +#include "pxr/usd/usd/validationError.h" +#include "pxr/usd/usd/validationRegistry.h" +#include "pxr/usd/usd/validator.h" + +PXR_NAMESPACE_USING_DIRECTIVE + +TF_REGISTRY_FUNCTION(UsdValidationRegistry) +{ + UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); + + // Register test plugin validators here + // Test validators simply just return errors, we need to make sure various + // UsdValidationContext APIs work and get the expected errors back, when + // Validate is called in various scenarios on a validation context instance. + { + const TfToken validatorName( + "testUsdValidationContextValidatorsPlugin:Test1"); + const UsdValidateStageTaskFn stageTaskFn = []( + const UsdStagePtr & usdStage) + { + const TfToken validationErrorId("Test1Error"); + return UsdValidationErrorVector{ + UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + {UsdValidationErrorSite(usdStage, + SdfPath::AbsoluteRootPath())}, + "A stage validator error")}; + }; + + TfErrorMark m; + registry.RegisterPluginValidator(validatorName, stageTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const TfToken validatorName( + "testUsdValidationContextValidatorsPlugin:Test2"); + const UsdValidateLayerTaskFn layerTaskFn = []( + const SdfLayerHandle & layer) + { + const TfToken validationErrorId("Test2Error"); + return UsdValidationErrorVector{ + UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + {UsdValidationErrorSite(layer, + SdfPath::AbsoluteRootPath())}, + "A layer validator error")}; + }; + + TfErrorMark m; + registry.RegisterPluginValidator(validatorName, layerTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const TfToken validatorName( + "testUsdValidationContextValidatorsPlugin:Test3"); + const UsdValidatePrimTaskFn primTaskFn = []( + const UsdPrim & prim) + { + const TfToken validationErrorId("Test3Error"); + return UsdValidationErrorVector{ + UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + {UsdValidationErrorSite(prim.GetStage(), + prim.GetPath())}, + "A generic prim validator error")}; + }; + + TfErrorMark m; + registry.RegisterPluginValidator(validatorName, primTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const TfToken validatorName( + "testUsdValidationContextValidatorsPlugin:Test4"); + const UsdValidatePrimTaskFn primTaskFn = []( + const UsdPrim & prim) + { + const TfToken validationErrorId("Test4Error"); + return UsdValidationErrorVector{ + UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + {UsdValidationErrorSite(prim.GetStage(), + prim.GetPath())}, + "A testBaseType prim type validator error")}; + }; + + TfErrorMark m; + registry.RegisterPluginValidator(validatorName, primTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const TfToken validatorName( + "testUsdValidationContextValidatorsPlugin:Test5"); + const UsdValidatePrimTaskFn primTaskFn = []( + const UsdPrim & prim) + { + const TfToken validationErrorId("Test5Error"); + return UsdValidationErrorVector{ + UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + {UsdValidationErrorSite(prim.GetStage(), + prim.GetPath())}, + "A testDerivedType prim type validator error")}; + }; + + TfErrorMark m; + registry.RegisterPluginValidator(validatorName, primTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const TfToken validatorName( + "testUsdValidationContextValidatorsPlugin:Test6"); + const UsdValidatePrimTaskFn primTaskFn = []( + const UsdPrim & prim) + { + const TfToken validationErrorId("Test6Error"); + return UsdValidationErrorVector{ + UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + {UsdValidationErrorSite(prim.GetStage(), + prim.GetPath())}, + "A testNestedDerivedType prim type validator error")}; + }; + + TfErrorMark m; + registry.RegisterPluginValidator(validatorName, primTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const TfToken validatorName( + "testUsdValidationContextValidatorsPlugin:Test7"); + const UsdValidatePrimTaskFn primTaskFn = []( + const UsdPrim & prim) + { + const TfToken validationErrorId("Test7Error"); + return UsdValidationErrorVector{ + UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + {UsdValidationErrorSite(prim.GetStage(), + prim.GetPath())}, + "A testAPISchema prim type validator error")}; + }; + + TfErrorMark m; + registry.RegisterPluginValidator(validatorName, primTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const TfToken suiteName( + "testUsdValidationContextValidatorsPlugin:TestSuite"); + const std::vector containedValidators = + registry.GetOrLoadValidatorsByName( + {TfToken("testUsdValidationContextValidatorsPlugin:Test1"), + TfToken("testUsdValidationContextValidatorsPlugin:Test2"), + TfToken("testUsdValidationContextValidatorsPlugin:Test3")}); + + TfErrorMark m; + registry.RegisterPluginValidatorSuite(suiteName, containedValidators); + TF_AXIOM(m.IsClean()); + } +} From 4ca1dff19c435a67ff0b9360aa20d9108c4bff16 Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Mon, 28 Oct 2024 15:21:27 -0700 Subject: [PATCH 070/300] Add python wrappings for UsdValidationContext - The python test for these python wrappings is the exact same test as the cpp version and also shares the test validators and types registered for the test. - The only thing missing is the registration of a non-plugin validator, that is because validator registration is not exposed to python at the moment. Other things to note here: - For appropriate UsdValidationContext's constructor to be initialized, TfPyRegisterStlSequencesFromPython is added to python wrappings of UsdValidatorMetadata, UsdValidator* and UsdValidatorSuite*. This makes sure python list to std::vector conversion happens appropriately and correct constructors are called. (Internal change: 2345872) --- pxr/usd/usd/CMakeLists.txt | 14 + pxr/usd/usd/module.cpp | 1 + .../usd/testenv/testUsdValidationContextPy.py | 327 ++++++++++++++++++ pxr/usd/usd/wrapValidationContext.cpp | 81 +++++ pxr/usd/usd/wrapValidator.cpp | 3 + 5 files changed, 426 insertions(+) create mode 100644 pxr/usd/usd/testenv/testUsdValidationContextPy.py create mode 100644 pxr/usd/usd/wrapValidationContext.cpp diff --git a/pxr/usd/usd/CMakeLists.txt b/pxr/usd/usd/CMakeLists.txt index 6bb5caa018..7c77c2dea7 100644 --- a/pxr/usd/usd/CMakeLists.txt +++ b/pxr/usd/usd/CMakeLists.txt @@ -146,6 +146,7 @@ pxr_library(usd wrapTimeCode.cpp wrapUsdFileFormat.cpp wrapUtils.cpp + wrapValidationContext.cpp wrapValidationError.cpp wrapValidationRegistry.cpp wrapValidator.cpp @@ -268,6 +269,7 @@ pxr_test_scripts( testenv/testUsdTimeSamples.py testenv/testUsdTimeValueAuthoring.py testenv/testUsdUsdzFileFormat.py + testenv/testUsdValidationContextPy.py testenv/testUsdValidationError.py testenv/testUsdValidationRegistryPy.py testenv/testUsdValidatorMetadata.py @@ -806,6 +808,11 @@ pxr_install_test_dir( DEST testUsdValidationContext ) +pxr_install_test_dir( + SRC testenv/testUsdValidationContext + DEST testUsdValidationContextPy +) + pxr_install_test_dir( SRC testenv/testUsdValidationRegistry DEST testUsdValidationRegistry @@ -1428,11 +1435,18 @@ pxr_register_test(testUsdValidationError EXPECTED_RETURN_CODE 0 ) +pxr_register_test(testUsdValidationContextPy + PYTHON + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationContextPy" + EXPECTED_RETURN_CODE 0 +) + pxr_register_test(testUsdValidationRegistryPy PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationRegistryPy" EXPECTED_RETURN_CODE 0 ) + pxr_register_test(testUsdUsdzBugGHSA01 COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdUsdzBugGHSA01" EXPECTED_RETURN_CODE 0 diff --git a/pxr/usd/usd/module.cpp b/pxr/usd/usd/module.cpp index 544ffacfcf..c68763c61b 100644 --- a/pxr/usd/usd/module.cpp +++ b/pxr/usd/usd/module.cpp @@ -37,6 +37,7 @@ TF_WRAP_MODULE TF_WRAP(UsdSpecializes); TF_WRAP(UsdPrimRange); TF_WRAP(UsdVariantSets); + TF_WRAP(UsdValidationContext); TF_WRAP(UsdValidationError); TF_WRAP(UsdValidationRegistry); TF_WRAP(UsdValidator); diff --git a/pxr/usd/usd/testenv/testUsdValidationContextPy.py b/pxr/usd/usd/testenv/testUsdValidationContextPy.py new file mode 100644 index 0000000000..4d04077d9b --- /dev/null +++ b/pxr/usd/usd/testenv/testUsdValidationContextPy.py @@ -0,0 +1,327 @@ +#!/pxrpythonsubst +# +# Copyright 2024 Pixar +# +# Licensed under the terms set forth in the LICENSE.txt file available at +# https://openusd.org/license. + +import os, unittest + +from pxr import Plug, Sdf, Tf, Usd + +class TestUsdValidationContextPy(unittest.TestCase): + + @classmethod + def setUpClass(cls) -> None: + testTypePluginPath = os.path.abspath( + os.path.join(os.path.curdir, "resources")) + assert os.path.exists(testTypePluginPath) + testValidatorPluginPath = os.path.join( + os.path.dirname(__file__), + "UsdPlugins/lib/TestUsdValidationContextValidators*/Resources/") + try: + typePlugins = Plug.Registry().RegisterPlugins(testTypePluginPath) + assert typePlugins + assert len(typePlugins) == 1 + assert typePlugins[0].name == "testUsdValidationContext" + validatorPlugins = Plug.Registry().RegisterPlugins( + testValidatorPluginPath) + assert validatorPlugins + assert len(validatorPlugins) == 1 + assert validatorPlugins[0].name == \ + "testUsdValidationContextValidatorsPlugin" + except RuntimeError: + pass + + def _LayerContents(self): + layerContents = """#usda 1.0 + def "World" + { + def BaseTypeTest "baseType" + { + } + def DerivedTypeTest "derivedType" + { + } + def NestedDerivedTypeTest "nestedDerivedType" + { + } + def "somePrim" ( + prepend apiSchemas = ["APISchemaTestAPI"] + ) + { + } + } + """ + return layerContents + + def _CreateTestLayer(self): + layer = Sdf.Layer.CreateAnonymous(".usda") + layer.ImportFromString(self._LayerContents()) + return layer + + def _TestError1(self, error): + self.assertEqual( + error.GetValidator().GetMetadata().name, + "testUsdValidationContextValidatorsPlugin:Test1") + self.assertEqual(len(error.GetSites()), 1) + self.assertTrue(error.GetSites()[0].IsPrim()) + self.assertEqual( + error.GetSites()[0].GetPrim().GetPath(), + Sdf.Path.absoluteRootPath) + + def _TestError2(self, error): + self.assertEqual( + error.GetValidator().GetMetadata().name, + "testUsdValidationContextValidatorsPlugin:Test2") + self.assertEqual(len(error.GetSites()), 1) + self.assertTrue(error.GetSites()[0].IsValidSpecInLayer()) + + def _TestError3(self, error): + self.assertEqual( + error.GetValidator().GetMetadata().name, + "testUsdValidationContextValidatorsPlugin:Test3") + expectedPrimPaths = { + Sdf.Path("/World"), + Sdf.Path("/World/baseType"), + Sdf.Path("/World/derivedType"), + Sdf.Path("/World/nestedDerivedType"), + Sdf.Path("/World/somePrim")} + self.assertTrue( + error.GetSites()[0].GetPrim().GetPath() in expectedPrimPaths) + + def _TestError4(self, error): + self.assertEqual( + error.GetValidator().GetMetadata().name, + "testUsdValidationContextValidatorsPlugin:Test4") + expectedPrimPaths = { + Sdf.Path("/World/baseType"), + Sdf.Path("/World/derivedType"), + Sdf.Path("/World/nestedDerivedType")} + self.assertTrue( + error.GetSites()[0].GetPrim().GetPath() in expectedPrimPaths) + + def _TestError5(self, error): + self.assertEqual( + error.GetValidator().GetMetadata().name, + "testUsdValidationContextValidatorsPlugin:Test5") + expectedPrimPaths = { + Sdf.Path("/World/derivedType"), + Sdf.Path("/World/nestedDerivedType")} + self.assertTrue( + error.GetSites()[0].GetPrim().GetPath() in expectedPrimPaths) + + def _TestError6(self, error): + self.assertEqual( + error.GetValidator().GetMetadata().name, + "testUsdValidationContextValidatorsPlugin:Test6") + self.assertEqual(len(error.GetSites()), 1) + self.assertTrue(error.GetSites()[0].IsPrim()) + self.assertEqual( + error.GetSites()[0].GetPrim().GetName(), + "nestedDerivedType") + + def _TestError7(self, error): + self.assertEqual(error.GetName(), "Test7Error") + self.assertEqual( + error.GetValidator().GetMetadata().name, + "testUsdValidationContextValidatorsPlugin:Test7") + self.assertEqual(len(error.GetSites()), 1) + self.assertTrue(error.GetSites()[0].IsPrim()) + self.assertEqual( + error.GetSites()[0].GetPrim().GetName(), + "somePrim") + + + def test_UsdValidationContext(self): + # Create a ValidationContext with a suite + suite = Usd.ValidationRegistry().GetOrLoadValidatorSuiteByName( + "testUsdValidationContextValidatorsPlugin:TestSuite") + context = Usd.ValidationContext([suite]) + testLayer = self._CreateTestLayer() + # Run Validate(layer) + errors = context.Validate(testLayer) + # 1 error for Test2 validator - root layer of the stage + self.assertEqual(len(errors), 1) + self._TestError2(errors[0]) + # Run Validate(stage) + stage = Usd.Stage.Open(testLayer) + errors = context.Validate(stage) + # 1 error for Test1 validator (stage) + # 2 error for Test2 validator - root layer and session layer + # 5 errors for Test3 generic prim validator which runs on all 5 prims + self.assertEqual(len(errors), 8) + for error in errors: + if error.GetName() == "Test1Error": + self._TestError1(error) + elif error.GetName() == "Test2Error": + self._TestError2(error) + elif error.GetName() == "Test3Error": + self._TestError3(error) + else: + self.assertFalse(True) + + # Create a ValidationContext with explicit schemaTypes + context = Usd.ValidationContext( + [Tf.Type.FindByName("testBaseType")]) + testLayer = self._CreateTestLayer() + # Run Validate(layer) + errors = context.Validate(testLayer) + # 0 errors as we do not have any layer validators selected in this + # context. + self.assertTrue(not errors) + # Run Validate(stage) + stage = Usd.Stage.Open(testLayer) + errors = context.Validate(stage) + # 3 errors for Test4 testBaseType prim type validator which runs on + # the baseType, derivedType and nestedDerivedType prims + self.assertEqual(len(errors), 3) + for error in errors: + self._TestError4(error) + + # Create a ValidationContext with explicit schemaType - apiSchema + context = Usd.ValidationContext( + [Tf.Type.FindByName("testAPISchemaAPI")]) + testLayer = self._CreateTestLayer() + # Run Validate(layer) + errors = context.Validate(testLayer) + # 0 errors as we do not have any layer validators selected in this + # context. + self.assertTrue(not errors) + # Run Validate(stage) + stage = Usd.Stage.Open(testLayer) + errors = context.Validate(stage) + # 1 error for Test7 testAPISchema prim type validator which runs on + # the somePrim prim + self.assertEqual(len(errors), 1) + self._TestError7(errors[0]) + + # Create a ValidationContext with keywords API and have + # includeAllAncestors set to true + context = Usd.ValidationContext(["Keyword1"], True) + testLayer = self._CreateTestLayer() + # Run Validate(layer) + errors = context.Validate(testLayer) + # 0 errors as we do not have any layer validators selected in this + # context. + self.assertTrue(not errors) + # Run Validate(stage) + stage = Usd.Stage.Open(testLayer) + errors = context.Validate(stage) + # 1 error for Test1 validator + # 5 errors for Test3 generic prim validator which runs on all 5 prims + # 2 errors for Test5 testDerivedType prim type validator which runs on + # the derivedType and nestedDerivedType prims + # 3 errors for Test4 testBaseType prim type validator which runs on + # the baseType, derivedType and nestedDerivedType prims (This gets + # includes as an ancestor type of derivedType) + # 1 error for Test7 testAPISchema prim type validator which runs on + # the somePrim prim + self.assertEqual(len(errors), 12) + for error in errors: + if error.GetName() == "Test1Error": + self._TestError1(error) + elif error.GetName() == "Test3Error": + self._TestError3(error) + elif error.GetName() == "Test4Error": + self._TestError4(error) + elif error.GetName() == "Test5Error": + self._TestError5(error) + elif error.GetName() == "Test7Error": + self._TestError7(error) + else: + self.assertFalse(True) + + # Create a ValidationContext with keywords API and have + # includeAllAncestors set to false + context = Usd.ValidationContext(["Keyword2"], False) + testLayer = self._CreateTestLayer() + # Run Validate(layer) + errors = context.Validate(testLayer) + # 1 error for Test2 validator - root layer of the stage + self.assertEqual(len(errors), 1) + self._TestError2(errors[0]) + # Run Validate(prims) + stage = Usd.Stage.Open(testLayer) + errors = context.Validate(stage.Traverse()) + # 3 errors for Test4 testBaseType prim type validator which runs on + # the baseType, derivedType and nestedDerivedType prims + # 1 error for Test6 testNestedDerivedType prim type validator which + # runs on the nestedDerivedType prim + # 5 errors for Test3 generic prim validator which runs on all 5 prims + self.assertEqual(len(errors), 9) + for error in errors: + if error.GetName() == "Test3Error": + self._TestError3(error) + elif error.GetName() == "Test4Error": + self._TestError4(error) + elif error.GetName() == "Test6Error": + self._TestError6(error) + else: + self.assertFalse(True) + + # Run Validate(stage) + errors = context.Validate(stage) + # 2 error for Test2 validator - root layer and session layer + # 3 errors for Test4 testBaseType prim type validator which runs on + # the baseType, derivedType and nestedDerivedType prims + # 1 error for Test6 testNestedDerivedType prim type validator which + # runs on the nestedDerivedType prim + # Because of TestSuite: + # 1 error for Test1 validator + # 5 errors for Test3 generic prim validator which runs on all 5 prims + self.assertEqual(len(errors), 12) + for error in errors: + if error.GetName() == "Test1Error": + self._TestError1(error) + elif error.GetName() == "Test2Error": + self._TestError2(error) + elif error.GetName() == "Test3Error": + self._TestError3(error) + elif error.GetName() == "Test4Error": + self._TestError4(error) + elif error.GetName() == "Test6Error": + self._TestError6(error) + else: + self.assertFalse(True) + + # Create a ValidationContext with plugins + context = Usd.ValidationContext( + [Plug.Registry().GetPluginWithName( + "testUsdValidationContextValidatorsPlugin")], True) + testLayer = self._CreateTestLayer() + stage = Usd.Stage.Open(testLayer) + errors = context.Validate(stage) + # 1 error for Test1 validator + # 2 error for Test2 validator - root layer and session layer + # 5 errors for Test3 generic prim validator which runs on all 5 prims + # 3 errors for Test4 testBaseType prim type validator which runs on + # the baseType, derivedType and nestedDerivedType prims + # 2 error for Test5 testDerivedType prim type validator which runs on + # the derivedType and nestedDerivedType prims + # 1 error for Test6 testNestedDerivedType prim type validator which + # runs on the nestedDerivedType prim + # 1 error for Test7 testAPISchema prim type validator which runs on + # the somePrim prim + self.assertEqual(len(errors), 15) + for error in errors: + if error.GetName() == "Test1Error": + self._TestError1(error) + elif error.GetName() == "Test2Error": + self._TestError2(error) + elif error.GetName() == "Test3Error": + self._TestError3(error) + elif error.GetName() == "Test4Error": + self._TestError4(error) + elif error.GetName() == "Test5Error": + self._TestError5(error) + elif error.GetName() == "Test6Error": + self._TestError6(error) + elif error.GetName() == "Test7Error": + self._TestError7(error) + else: + self.assertFalse(True) + +if __name__ == "__main__": + unittest.main() + diff --git a/pxr/usd/usd/wrapValidationContext.cpp b/pxr/usd/usd/wrapValidationContext.cpp new file mode 100644 index 0000000000..d6f63d3883 --- /dev/null +++ b/pxr/usd/usd/wrapValidationContext.cpp @@ -0,0 +1,81 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https:/(); + class_("ValidationContext", no_init) + .def(init( + (arg("keywords"), arg("includeAllAncestors") = true))) + .def(init( + (arg("plugins"), arg("includeAllAncestors") = true))) + .def(init( + (arg("metadata"), arg("includeAllAncestors") = true))) + .def(init &>(arg("schemaTypes"))) + .def(init &>(arg("validators"))) + .def(init &>(arg("suites"))) + .def("Validate", + +[](const UsdValidationContext &ctx, const SdfLayerHandle &layer) + -> UsdValidationErrorVector { + return ctx.Validate(layer); + }, + return_value_policy(), + (arg("layer"))) + .def("Validate", + +[](const UsdValidationContext &ctx, const UsdStagePtr &stage) + -> UsdValidationErrorVector { + return ctx.Validate(stage); + }, + return_value_policy(), + (arg("stage"))) + .def("Validate", + +[](const UsdValidationContext &ctx, const UsdStagePtr &stage, + const Usd_PrimFlagsPredicate &predicate) + -> UsdValidationErrorVector { + return ctx.Validate(stage, predicate); + }, + return_value_policy(), + (arg("stage"), arg("predicate"))) + .def("Validate", + +[](const UsdValidationContext &ctx, + const std::vector &prims) + -> UsdValidationErrorVector { + return ctx.Validate(prims); + }, + return_value_policy(), + (arg("prims"))) + .def("Validate", + +[](const UsdValidationContext &ctx, const UsdPrimRange &prims) + -> UsdValidationErrorVector { + return ctx.Validate(prims); + }, + return_value_policy(), + (arg("prims"))); +} diff --git a/pxr/usd/usd/wrapValidator.cpp b/pxr/usd/usd/wrapValidator.cpp index 1654115918..19aa0f6e35 100644 --- a/pxr/usd/usd/wrapValidator.cpp +++ b/pxr/usd/usd/wrapValidator.cpp @@ -84,6 +84,7 @@ void wrapUsdValidator() +[](const UsdValidatorMetadata &self) { return self.schemaTypes; }); + TfPyRegisterStlSequencesFromPython(); TfPyRegisterStlSequencesFromPython(); class_("Validator", no_init) @@ -118,6 +119,7 @@ void wrapUsdValidator() return left == right; }) .def("__repr__", &_Repr); + TfPyRegisterStlSequencesFromPython(); class_("ValidatorSuite", no_init) .def("GetMetadata", @@ -130,4 +132,5 @@ void wrapUsdValidator() +[](const UsdValidatorSuite *left, const UsdValidatorSuite *right) { return left == right; }); + TfPyRegisterStlSequencesFromPython(); } From 4e088c90399f9a34233121c75c25839c12e46098 Mon Sep 17 00:00:00 2001 From: tgvarik Date: Mon, 28 Oct 2024 15:25:03 -0700 Subject: [PATCH 071/300] [hdPrman] Role Lookup in SdrRegistry Riley requires accurate role information for certain integrator, projection, and display and sample filter parameters, Previously these were (partially, in the case of integrator params) retrieved with lookup tables in projectionParams.h/cpp. To reduce reliance on lookup tables, we change to using the SdrRegistry to look up the shader node and input associated with the object type and parameter name and retrieve role information from there. Also extends role setting for integrator params to those set via render settings prim. Deletes the now redundant projectionParams.h/cpp. (Internal change: 2345909) --- .../plugin/hdPrman/CMakeLists.txt | 3 +- .../plugin/hdPrman/projectionParams.cpp | 128 ----- .../plugin/hdPrman/projectionParams.h | 32 -- .../plugin/hdPrman/renderParam.cpp | 514 ++++++++++-------- 4 files changed, 302 insertions(+), 375 deletions(-) delete mode 100644 third_party/renderman-26/plugin/hdPrman/projectionParams.cpp delete mode 100644 third_party/renderman-26/plugin/hdPrman/projectionParams.h diff --git a/third_party/renderman-26/plugin/hdPrman/CMakeLists.txt b/third_party/renderman-26/plugin/hdPrman/CMakeLists.txt index bb04189919..9bb2dc8c9d 100644 --- a/third_party/renderman-26/plugin/hdPrman/CMakeLists.txt +++ b/third_party/renderman-26/plugin/hdPrman/CMakeLists.txt @@ -1,4 +1,4 @@ -# To be sure our VtVisitValue polyfill works correctly, the preprocessor must +# To be sure our VtVisitValue polyfill works correctly, the preprocessor must # resolve the #include in our identically-named # polyfill to the real one in libpxr. But CMAKE_INCLUDE_CURRENT_DIR injects the # cpp source directory as the first include search path. The preprocessor @@ -155,7 +155,6 @@ pxr_plugin(${PXR_PACKAGE} matfiltSceneIndexPlugins motionBlurSceneIndexPlugin pinnedCurveExpandingSceneIndexPlugin - projectionParams renderBuffer renderParam renderPass diff --git a/third_party/renderman-26/plugin/hdPrman/projectionParams.cpp b/third_party/renderman-26/plugin/hdPrman/projectionParams.cpp deleted file mode 100644 index 96c8e2940c..0000000000 --- a/third_party/renderman-26/plugin/hdPrman/projectionParams.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// -// Copyright 2019 Pixar -// -// Licensed under the terms set forth in the LICENSE.txt file available at -// https://openusd.org/license. -// -#include "hdPrman/projectionParams.h" -#include - -PXR_NAMESPACE_OPEN_SCOPE - -namespace HdPrman_ProjectionParams { - - void GetIntegratorParamRole(const TfToken& paramName, TfToken& role) -{ - static std::map _integratorParamMap = { - {TfToken("ri:integrator:PxrUnified:photonVisibilityRodMin"), TfToken("point")}, - {TfToken("ri:integrator:PxrUnified:photonVisibilityRodMax"), TfToken("point")}, - - {TfToken("ri:integrator:PxrVCM:photonGuidingBBoxMin"), TfToken("point")}, - {TfToken("ri:integrator:PxrVCM:photonGuidingBBoxMax"), TfToken("point")}, - - {TfToken("ri:integrator:PxrVisualizer:wireframeColor"), TfToken("color")} - }; - - const auto it = _integratorParamMap.find(paramName); - if (it != _integratorParamMap.end()) - { - role = it->second; - } -} - -void GetProjectionParamRole(TfToken& paramName, TfToken& role) -{ - static std::map _ProjectionParamMap = { - //// PxrPerspective - {TfToken("ri:projection:PxrPerspective:fovEnd"), TfToken("float")}, - - //// PxrCamera - {TfToken("ri:projection:PxrCamera:fovEnd"), TfToken("float")}, - // Tilt shift - {TfToken("ri:projection:PxrCamera:tilt"), TfToken("float")}, - {TfToken("ri:projection:PxrCamera:roll"), TfToken("float")}, - {TfToken("ri:projection:PxrCamera:focus1"), TfToken("point")}, - {TfToken("ri:projection:PxrCamera:focus2"), TfToken("point")}, - {TfToken("ri:projection:PxrCamera:focus3"), TfToken("point")}, - {TfToken("ri:projection:PxrCamera:shiftX"), TfToken("float")}, - {TfToken("ri:projection:PxrCamera:shiftY"), TfToken("float")}, - // Lens Distortion - {TfToken("ri:projection:PxrCamera:radial1"), TfToken("float")}, - {TfToken("ri:projection:PxrCamera:radial2"), TfToken("float")}, - {TfToken("ri:projection:PxrCamera:assymX"), TfToken("float")}, - {TfToken("ri:projection:PxrCamera:assymY"), TfToken("float")}, - {TfToken("ri:projection:PxrCamera:squeeze"), TfToken("float")}, - // Chromatic Aberration - {TfToken("ri:projection:PxrCamera:axial"), TfToken("color")}, - {TfToken("ri:projection:PxrCamera:transverse"), TfToken("color")}, - // Vignetting - {TfToken("ri:projection:PxrCamera:natural"), TfToken("float")}, - {TfToken("ri:projection:PxrCamera:optical"), TfToken("float")}, - // Shutter - {TfToken("ri:projection:PxrCamera:sweep"), TfToken("string")}, - {TfToken("ri:projection:PxrCamera:duration"), TfToken("float")}, - // Advanced - {TfToken("ri:projection:PxrCamera:detail"), TfToken("float")}, - {TfToken("ri:projection:PxrCamera:enhance"), TfToken("vector")}, - {TfToken("ri:projection:PxrCamera:matte"), TfToken("string")}, - - //// PxrCylinderCamera - {TfToken("ri:projection:PxrCylinderCamera:hsweep"), TfToken("float")}, - {TfToken("ri:projection:PxrCylinderCamera:vsweep"), TfToken("float")}, - - //// PxrSphereCamera - {TfToken("ri:projection:PxrSphereCamera:hsweep"), TfToken("float")}, - {TfToken("ri:projection:PxrSphereCamera:vsweep"), TfToken("float")}, - - //// OmnidirectionalStereo - {TfToken("ri:projection:OmnidirectionalStereo:interpupilaryDistance"), TfToken("float")} - }; - - const auto it = _ProjectionParamMap.find(paramName); - if (it != _ProjectionParamMap.end()) - { - role = it->second; - } -} - -void GetFilterParamRole(TfToken& paramName, TfToken& role) -{ - // color params won't work unless set in the param list as color - // rather than float3 - static const std::map _filterParamMap = { - {TfToken("PxrBackgroundSampleFilter:backgroundColor"), TfToken("color")}, - {TfToken("PxrGradeSampleFilter:blackPoint"), TfToken("color")}, - {TfToken("PxrGradeSampleFilter:whitePoint"), TfToken("color")}, - {TfToken("PxrGradeSampleFilter:lift"), TfToken("color")}, - {TfToken("PxrGradeSampleFilter:gain"), TfToken("color")}, - {TfToken("PxrGradeSampleFilter:multiply"), TfToken("color")}, - {TfToken("PxrGradeSampleFilter:gamma"), TfToken("color")}, - {TfToken("PxrGradeSampleFilter:offset"), TfToken("color")}, - {TfToken("PxrGradeSampleFilter:mask"), TfToken("color")}, - {TfToken("PxrBackgroundDisplayFilter:backgroundColor"), TfToken("color")}, - {TfToken("PxrImagePlaneFilter:colorGain"), TfToken("color")}, - {TfToken("PxrImagePlaneFilter:colorOffset"), TfToken("color")}, - {TfToken("PxrWhitePointSampleFilter:manualWhitePoint"), TfToken("color")}, - {TfToken("PxrGradeDisplayFilter:blackPoint"), TfToken("color")}, - {TfToken("PxrGradeDisplayFilter:whitePoint"), TfToken("color")}, - {TfToken("PxrGradeDisplayFilter:lift"), TfToken("color")}, - {TfToken("PxrGradeDisplayFilter:gain"), TfToken("color")}, - {TfToken("PxrGradeDisplayFilter:multiply"), TfToken("color")}, - {TfToken("PxrGradeDisplayFilter:gamma"), TfToken("color")}, - {TfToken("PxrGradeDisplayFilter:offset"), TfToken("color")}, - {TfToken("PxrGradeDisplayFilter:mask"), TfToken("color")}, - {TfToken("PxrImageDisplayFilter:colorGain"), TfToken("color")}, - {TfToken("PxrImageDisplayFilter:colorOffset"), TfToken("color")}, - {TfToken("PxrWhitePointDisplayFilter:manualWhitePoint"), TfToken("color")} - }; - - const auto it = _filterParamMap.find(paramName); - if (it != _filterParamMap.end()) - { - role = it->second; - } -} - -} // namespace HdPrman_ProjectionParams - -PXR_NAMESPACE_CLOSE_SCOPE diff --git a/third_party/renderman-26/plugin/hdPrman/projectionParams.h b/third_party/renderman-26/plugin/hdPrman/projectionParams.h deleted file mode 100644 index b253816d8a..0000000000 --- a/third_party/renderman-26/plugin/hdPrman/projectionParams.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright 2019 Pixar -// -// Licensed under the terms set forth in the LICENSE.txt file available at -// https://openusd.org/license. -// -#ifndef EXT_RMANPKG_25_0_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_PROJECTION_PARAMS_H -#define EXT_RMANPKG_25_0_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_PROJECTION_PARAMS_H - -#include "pxr/base/tf/token.h" - -PXR_NAMESPACE_OPEN_SCOPE - -// This file should be considered temporary and only exists -// because we currently are unable to ascertain parameter value -// roles from an HdRenderSettingsMap -// -// TODO: Stop setting these on RenderSettings prim. They should be set on -// the integrator/camera/filter prims to which they apply. If they are not -// in usdRiPxr schema, they should be added there. - -namespace HdPrman_ProjectionParams { - - void GetIntegratorParamRole(const TfToken& paramName, TfToken& role); - void GetProjectionParamRole(TfToken& paramName, TfToken& role); - void GetFilterParamRole(TfToken& paramName, TfToken& role); - -} // namespace HdPrman_ProjectionParams - -PXR_NAMESPACE_CLOSE_SCOPE - -#endif // EXT_RMANPKG_25_0_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_PROJECTION_PARAMS_H diff --git a/third_party/renderman-26/plugin/hdPrman/renderParam.cpp b/third_party/renderman-26/plugin/hdPrman/renderParam.cpp index 6ee733ea10..dcd43c1206 100644 --- a/third_party/renderman-26/plugin/hdPrman/renderParam.cpp +++ b/third_party/renderman-26/plugin/hdPrman/renderParam.cpp @@ -16,48 +16,103 @@ #include "hdPrman/material.h" #include "hdPrman/motionBlurSceneIndexPlugin.h" #include "hdPrman/prmanArchDefs.h" // required for stats/Session.h -#include "hdPrman/projectionParams.h" #include "hdPrman/renderDelegate.h" -#if PXR_VERSION >= 2308 -#include "hdPrman/renderSettings.h" -#endif +#include "hdPrman/renderViewContext.h" #include "hdPrman/rixStrings.h" -#include "hdPrman/tokens.h" #include "hdPrman/utils.h" +#include "pxr/imaging/hd/aov.h" +#include "pxr/imaging/hd/enums.h" #include "pxr/imaging/hd/extComputationUtils.h" +#include "pxr/imaging/hd/material.h" #include "pxr/imaging/hd/renderBuffer.h" +#include "pxr/imaging/hd/renderDelegate.h" #include "pxr/imaging/hd/renderThread.h" #include "pxr/imaging/hd/rprim.h" #include "pxr/imaging/hd/sceneDelegate.h" -#include "pxr/imaging/hd/sceneIndexPluginRegistry.h" +#include "pxr/imaging/hd/sprim.h" +#include "pxr/imaging/hd/timeSampleArray.h" +#include "pxr/imaging/hd/tokens.h" +#include "pxr/imaging/hd/types.h" #include "pxr/imaging/hd/version.h" #include "pxr/usd/sdf/path.h" +#include "pxr/usd/sdr/declare.h" +#include "pxr/usd/sdr/registry.h" +#include "pxr/usd/sdr/shaderNode.h" +#include "pxr/usd/sdr/shaderProperty.h" #include "pxr/base/arch/library.h" +#include "pxr/base/gf/vec2d.h" +#include "pxr/base/gf/vec2f.h" +#include "pxr/base/gf/vec2i.h" #include "pxr/base/plug/plugin.h" #include "pxr/base/plug/registry.h" #include "pxr/base/tf/debug.h" +#include "pxr/base/tf/diagnostic.h" +#include "pxr/base/tf/enum.h" #include "pxr/base/tf/envSetting.h" #include "pxr/base/tf/getenv.h" +#include "pxr/base/tf/iterator.h" #include "pxr/base/tf/pathUtils.h" // Extract extension from tf token +#include "pxr/base/tf/registryManager.h" #include "pxr/base/tf/scopeDescription.h" +#include "pxr/base/tf/staticData.h" +#include "pxr/base/tf/staticTokens.h" #include "pxr/base/tf/stringUtils.h" - -#if PXR_VERSION >= 2302 -#include "pxr/imaging/hd/retainedDataSource.h" -#include "pxr/imaging/hd/containerDataSourceEditor.h" -#endif - +#include "pxr/base/tf/token.h" +#include "pxr/base/trace/trace.h" +#include "pxr/base/vt/array.h" +#include "pxr/base/vt/dictionary.h" +#include "pxr/base/vt/types.h" +#include "pxr/pxr.h" + +#include +#include +#include #include #include +#include +#include +#include #include #include +#include +#include #include - +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include + +#if PXR_VERSION >= 2302 +#include "pxr/imaging/hd/retainedDataSource.h" +#include "pxr/imaging/hd/containerDataSourceEditor.h" +#endif + +#if PXR_VERSION >= 2308 +#include "hdPrman/renderSettings.h" +#include "pxr/imaging/hd/renderSettings.h" +#endif PXR_NAMESPACE_OPEN_SCOPE @@ -80,11 +135,13 @@ TF_DEFINE_PRIVATE_TOKENS( ((riDisplayChannelNamespace, "ri:displayChannel:")) // See PxrDisplayDriverAPI ((riDisplayDriverNamespace, "ri:displayDriver:")) - + ((renderTagPrefix, "rendertag_")) (renderCameraPath) ((displayfilterPrefix, "ri:displayfilter")) ((samplefilterPrefix, "ri:samplefilter")) + + (PxrCryptomatte) ); TF_DEFINE_PRIVATE_TOKENS( @@ -182,7 +239,7 @@ HdPrman_RenderParam::HdPrman_RenderParam( TfRegistryManager::GetInstance().SubscribeTo(); _CreateRiley(rileyVariant, xpuCpuConfig, xpuGpuConfig, extraArgs); - + // Register RenderMan display driver HdPrmanFramebuffer::Register(_rix); @@ -211,7 +268,7 @@ HdPrman_RenderParam::IncrementLightLinkCount(TfToken const& name) ++_lightLinkRefs[name]; } -void +void HdPrman_RenderParam::DecrementLightLinkCount(TfToken const& name) { std::lock_guard lock(_lightLinkMutex); @@ -220,7 +277,7 @@ HdPrman_RenderParam::DecrementLightLinkCount(TfToken const& name) } } -bool +bool HdPrman_RenderParam::IsLightLinkUsed(TfToken const& name) { std::lock_guard lock(_lightLinkMutex); @@ -234,7 +291,7 @@ HdPrman_RenderParam::IncrementLightFilterCount(TfToken const& name) ++_lightFilterRefs[name]; } -void +void HdPrman_RenderParam::DecrementLightFilterCount(TfToken const& name) { std::lock_guard lock(_lightFilterMutex); @@ -243,7 +300,7 @@ HdPrman_RenderParam::DecrementLightFilterCount(TfToken const& name) } } -bool +bool HdPrman_RenderParam::IsLightFilterUsed(TfToken const& name) { std::lock_guard lock(_lightFilterMutex); @@ -277,7 +334,7 @@ _ConvertPointsPrimvar( #if HD_API_VERSION >= 68 shutterInterval[0], shutterInterval[1], -#endif +#endif &boxedPoints); } else { HdExtComputationUtils::SampledValueStore @@ -516,11 +573,11 @@ _Convert(HdSceneDelegate *sceneDelegate, SdfPath const& id, std::is_same, std::is_same>::value, "params must be RtParamList or RtPrimVarList"); - + // XXX:TODO: To support array-valued types, we need more // shaping information. Currently we assume arrays are // simply N scalar values, according to the detail. - + std::string label; if constexpr (std::is_same()) { label = "primvar"; @@ -541,14 +598,14 @@ _Convert(HdSceneDelegate *sceneDelegate, SdfPath const& id, // XXX: Prman doesn't seem to check dirtyness before pulling a value. // Passing AllDirty until we plumb/respect change tracking. HdExtComputationPrimvarDescriptorVector computedPrimvars = - _GetComputedPrimvars(sceneDelegate, id, hdInterp, + _GetComputedPrimvars(sceneDelegate, id, hdInterp, HdChangeTracker::AllDirty); if (!computedPrimvars.empty()) { // Execute the computations HdExtComputationUtils::ValueStore valueStore = HdExtComputationUtils::GetComputedPrimvarValues( computedPrimvars, sceneDelegate); - + for (auto const& compPrimvar : computedPrimvars) { auto const it = valueStore.find(compPrimvar.name); if (!TF_VERIFY(it != valueStore.end())) { @@ -571,7 +628,7 @@ _Convert(HdSceneDelegate *sceneDelegate, SdfPath const& id, name.CStr(), TfStringify(val).c_str()); - if (val.IsArrayValued() && + if (val.IsArrayValued() && val.GetArraySize() != static_cast(expectedSize)) { TF_WARN("<%s> primvar '%s' size (%zu) did not match " "expected (%d)", id.GetText(), @@ -703,7 +760,7 @@ _Convert(HdSceneDelegate *sceneDelegate, SdfPath const& id, TF_WARN("<%s> provided multiple representations of the primvar " "'%s'", id.GetText(), name.CStr()); } - // When both ri:attributes and primvar:ri:attributes versions of + // When both ri:attributes and primvar:ri:attributes versions of // the same primvars exist, the primvar:ri:attributes version should // win out. if (hasRiAttributesPrefix && !hasPrimvarsPrefix && @@ -749,7 +806,7 @@ _Convert(HdSceneDelegate *sceneDelegate, SdfPath const& id, // For non-constant primvars, check array size to make sure it // matches the expected topology size. if (hdInterp != HdInterpolationConstant && - val.IsArrayValued() && + val.IsArrayValued() && val.GetArraySize() != static_cast(expectedSize)) { TF_WARN("<%s> %s '%s' size (%zu) did not match " "expected (%d)", id.GetText(), label.c_str(), @@ -817,14 +874,14 @@ HdPrman_TransferMaterialPrimvarOpinions(HdSceneDelegate *sceneDelegate, const HdPrmanMaterial *material = dynamic_cast(sprim); if (material && material->IsValid()) { - const HdMaterialNetwork2 & matNetwork = + const HdMaterialNetwork2 & matNetwork = material->GetMaterialNetwork(); for (const auto & nodeIt : matNetwork.nodes) { const HdMaterialNode2 & node = nodeIt.second; if (node.nodeTypeId == _tokens->PrimvarPass) { for (const auto ¶m : node.parameters) { uint32_t paramId; - RtUString paramName = + RtUString paramName = RtUString(param.first.GetText()); if (!primvars.GetParamId(paramName, paramId)) { HdPrman_Utils::SetPrimVarFromVtValue(paramName, @@ -892,7 +949,7 @@ HdPrman_RenderParam::ConvertAttributes(HdSceneDelegate *sceneDelegate, // e.g., the cards drawmode adapter. // TODO: (tgvarik) Check how Ri:ReverseOrientation interacts with - // displacement. What is intended when front-face culling is applied + // displacement. What is intended when front-face culling is applied // to a surface with displacement? Should be vanishingly rare. const HdCullStyle cullStyle = sceneDelegate->GetCullStyle(id); @@ -907,11 +964,11 @@ HdPrman_RenderParam::ConvertAttributes(HdSceneDelegate *sceneDelegate, attrs.SetInteger(RixStr.k_Ri_Sides, 1); break; case HdCullStyleFrontUnlessDoubleSided: - attrs.SetInteger(RixStr.k_Ri_ReverseOrientation, + attrs.SetInteger(RixStr.k_Ri_ReverseOrientation, sceneDelegate->GetDoubleSided(id) ? 0 : 1); // fallthrough case HdCullStyleBackUnlessDoubleSided: - attrs.SetInteger(RixStr.k_Ri_Sides, + attrs.SetInteger(RixStr.k_Ri_Sides, sceneDelegate->GetDoubleSided(id) ? 2 : 1); break; case HdCullStyleDontCare: @@ -919,7 +976,7 @@ HdPrman_RenderParam::ConvertAttributes(HdSceneDelegate *sceneDelegate, // defer to Prman default by not setting Ri:Sides. break; } - + // Double-sidedness in usd is a property of the gprim for legacy reasons. // Double-sidedness in prman is a property of the material. To achieve @@ -935,7 +992,7 @@ HdPrman_RenderParam::ConvertAttributes(HdSceneDelegate *sceneDelegate, sceneDelegate->GetDoubleSided(id) ? 1 : 0 ); } - + return attrs; } @@ -1153,12 +1210,12 @@ HdPrman_RenderParam::UpdateLegacyOptions() RtUString riName; riName = RtUString(token.GetText()+3); - // XXX there is currently no way to distinguish the type of a + // XXX there is currently no way to distinguish the type of a // float3 setting (color, point, vector). All float3 settings are - // treated as float[3] until we have a way to determine the type. + // treated as float[3] until we have a way to determine the type. HdPrman_Utils::SetParamFromVtValue(riName, val, TfToken(), &options); } else { - + // ri: namespaced settings win over custom settings tokens when // present. if (token == HdRenderSettingsTokens->convergedSamplesPerPixel) { @@ -1183,7 +1240,7 @@ HdPrman_RenderParam::UpdateLegacyOptions() } else if (token == HdPrmanRenderSettingsTokens->pixelAspectRatio) { if (!_Contains(renderSettingsMap, _riOptionsTokens->riRiFormatPixelAspectRatio)) { - options.SetFloat(RixStr.k_Ri_FormatPixelAspectRatio, + options.SetFloat(RixStr.k_Ri_FormatPixelAspectRatio, val.UncheckedGet()); } @@ -1191,7 +1248,7 @@ HdPrman_RenderParam::UpdateLegacyOptions() if (!_Contains(renderSettingsMap, _riOptionsTokens->riRiFormatResolution)) { const GfVec2i& res = val.UncheckedGet(); - options.SetIntegerArray(RixStr.k_Ri_FormatResolution, + options.SetIntegerArray(RixStr.k_Ri_FormatResolution, res.data(), 2); } } else if (token == HdRenderSettingsTokens->threadLimit) { @@ -1208,7 +1265,7 @@ HdPrman_RenderParam::UpdateLegacyOptions() batchCommandLine = val; } // Note: HdPrmanRenderSettingsTokens->disableMotionBlur is handled in - // SetRileyShutterIntervalFromCameraContextCameraPath. + // SetRileyShutterIntervalFromCameraContextCameraPath. } } @@ -1225,23 +1282,49 @@ HdPrman_RenderParam::UpdateLegacyOptions() SetBatchCommandLineArgs(batchCommandLine, &options); } +static TfToken _GetShaderInputParamRole( + const TfToken& shader, + const TfToken& param) +{ + SdrRegistry& registry = SdrRegistry::GetInstance(); + const SdrShaderNode* entry = registry.GetShaderNodeByIdentifier(shader); + if (!entry) { + return TfToken(); + } + const SdrShaderProperty* input = entry->GetShaderInput(param); + if (!input) { + return TfToken(); + } + return input->GetType(); +} + void HdPrman_RenderParam::SetIntegratorParamsFromRenderSettingsMap( HdPrmanRenderDelegate *renderDelegate, const std::string& integratorName, RtParamList& params) { + // An integrator param in the render settings map looks like this: + // ri:integrator:: + // When asking Sdr for the param, the param name will look like this: + // ri: + // Finally, RenderMan expects to get the param name like this: + // + HdRenderSettingsMap renderSettings = renderDelegate->GetRenderSettingsMap(); - TfToken prefix(std::string("ri:integrator:") + integratorName + ":"); - for (auto const& entry : renderSettings) { + const TfToken prefix(std::string("ri:integrator:") + integratorName + ":"); + for (const auto& entry : renderSettings) { if (TfStringStartsWith(entry.first.GetText(), prefix.GetText())) { - // Strip namespace prefix from USD. - RtUString riName(entry.first.GetText() + prefix.size()); - TfToken role; - HdPrman_ProjectionParams::GetIntegratorParamRole(entry.first, role); - HdPrman_Utils::SetParamFromVtValue(riName, entry.second, - role, ¶ms); + // For RenderMan, strip the whole prefix + const RtUString riName(entry.first.GetText() + prefix.size()); + // for SdrRegistry, strip the prefix but re-prepend 'ri:' + const TfToken inputName( + "ri:" + entry.first.GetString().substr(prefix.size())); + const TfToken role = _GetShaderInputParamRole( + TfToken(integratorName), inputName); + HdPrman_Utils::SetParamFromVtValue( + riName, entry.second, role, ¶ms); } } } @@ -1252,22 +1335,27 @@ HdPrman_RenderParam::SetProjectionParamsFromRenderSettings( std::string& projectionName, RtParamList& params) { - HdRenderSettingsMap renderSettings = renderDelegate->GetRenderSettingsMap(); + // A projection param in the render settings map looks like this: + // ri:projection:: + // When asking Sdr for the param, the param name will look like this: + // ri: + // Finally, RenderMan expects to get the param name like this: + // - TfToken preFix(std::string("ri:projection:") + projectionName); - for (auto const& entry : renderSettings) { - TfToken token = entry.first; - VtValue val = entry.second; + HdRenderSettingsMap renderSettings = renderDelegate->GetRenderSettingsMap(); - bool hasRiPrefix = TfStringStartsWith(token.GetText(), - preFix.GetText()); - if (hasRiPrefix) { - // Strip namespace from USD. - RtUString riName; - riName = RtUString(token.GetText()+preFix.size()+1); - TfToken role; - HdPrman_ProjectionParams::GetProjectionParamRole(token, role); - HdPrman_Utils::SetParamFromVtValue(riName, val, role, ¶ms); + const TfToken prefix(std::string("ri:projection:") + projectionName + ":"); + for (const auto& entry : renderSettings) { + if (TfStringStartsWith(entry.first.GetText(), prefix.GetText())) { + // For RenderMan, strip the whole prefix + const RtUString riName(entry.first.GetText() + prefix.size()); + // for SdrRegistry, strip the prefix but re-prepend 'ri:' + const TfToken inputName( + "ri:" + entry.first.GetString().substr(prefix.size())); + const TfToken role = _GetShaderInputParamRole( + TfToken(projectionName), inputName); + HdPrman_Utils::SetParamFromVtValue( + riName, entry.second, role, ¶ms); } } } @@ -1646,26 +1734,21 @@ HdPrman_RenderParam::SetFiltersFromRenderSettings( return; } - for(auto const& prefix : prefixes) - { - - // Create shading nodes for each sample filter + for (auto const& prefix : prefixes) { + // Create shading nodes for each sample/display filter // They're numbered starting with 1 std::vector nodes; int nodeIdx = 0; bool isSample = (prefix == _tokens->samplefilterPrefix); - while(true) - { - std::string defaultFilterName("None"); + while (true) { + const std::string defaultFilterName("None"); std::string nmStr = prefix.GetText(); nmStr += std::to_string(nodeIdx); nmStr += ":name"; - std::string filterName = - renderDelegate->GetRenderSetting( - TfToken(nmStr.c_str()), - defaultFilterName); - if(!filterName.empty() && filterName != "None") - { + auto filterName = + renderDelegate->GetRenderSetting( + TfToken(nmStr.c_str()), defaultFilterName); + if (!filterName.empty() && filterName != "None") { riley::ShadingNode sn; sn.name = RtUString(filterName.c_str()); std::string handle = filterName += std::to_string(nodeIdx); @@ -1674,9 +1757,7 @@ HdPrman_RenderParam::SetFiltersFromRenderSettings( riley::ShadingNode::Type::k_SampleFilter : riley::ShadingNode::Type::k_DisplayFilter; nodes.push_back(sn); - } - else - { + } else { break; } nodeIdx++; @@ -1685,65 +1766,66 @@ HdPrman_RenderParam::SetFiltersFromRenderSettings( // Append filters collected from shading nodes, // which is not currently the primary workflow, // but they may be present - if(isSample) - { - for(auto it = _sampleFilters.begin(); - it != _sampleFilters.end(); ++it) - { - nodes.push_back(it->second); + if (isSample) { + for (const auto& sampleFilter : _sampleFilters) { + nodes.push_back(sampleFilter.second); } - } - else - { - for(auto it = _displayFilters.begin(); - it != _displayFilters.end(); ++it) - { - nodes.push_back(it->second); + } else { + for (const auto& displayFilter : _displayFilters) { + nodes.push_back(displayFilter.second); } } _sampleFiltersDirty = false; _displayFiltersDirty = false; - if(!nodes.empty()) - { + if (!nodes.empty()) { for (auto const& entry : renderSettings) { - TfToken token = entry.first; - VtValue val = entry.second; - bool hasRiPrefix = TfStringStartsWith(token.GetText(), - prefix.GetText()); - if (hasRiPrefix) { - std::vector toks = TfStringSplit(token, ":"); + // Filter params in render settings map look like this: + // ri::: + // Note that 'prefix' (set above for outer loop) will be: + // ri: + // So we can extract the index, filter name, and param name + // by first stripping the prefix, then splitting on ':' + + if (TfStringStartsWith( + entry.first.GetString(), prefix.GetText())) { + const std::vector toks = TfStringSplit( + entry.first.GetString().substr(prefix.size()), ":"); + // toks[0] : index + // toks[1] : filter name + // toks[2] : param name unsigned long idx = 0; - // strip off the index - // eg. ri:samplefilter0:PxrBackgroundSampleFilter:name - // eg. ri:displayfilter0:PxrBackgroundSampleFilter:name - RtUString riName;; - if(toks.size() == 4) - { - int offset = isSample ? 12 : 13; - std::string idxStr(toks[1].begin()+offset, toks[1].end()); - if(!idxStr.empty()) - idx = std::stoi(idxStr); + RtUString riName; + if (toks.size() == 3 && !toks[0].empty()) { + try { + idx = std::stoi(toks[0]); + } catch (const std::logic_error& e) { + TF_WARN("Malformed sample/display filter param " + "name in render settings: '%s'", + entry.first.GetText()); + continue; + } } - if(toks.size() != 4 || - idx >= nodes.size()) + if (toks.size() != 3 || idx >= nodes.size()) { continue; - std::vector toks2; - toks2.push_back(toks[2]); - toks2.push_back(toks[3]); - riName = RtUString(toks2[1].c_str()); - token = TfToken(TfStringJoin(toks2, ":")); + } + riName = RtUString(toks[2].c_str()); + const TfToken inputName("ri:" + toks[2]); + const TfToken shaderName(toks[1]); + + // copy the value + VtValue value = entry.second; // Some specific fixes for cryptomatte sample filter - if (isSample && toks[2] == "PxrCryptomatte") { - _AddCryptomatteFixes(riName, val); + if (isSample && shaderName == _tokens->PxrCryptomatte) { + _AddCryptomatteFixes(riName, value); } - TfToken role; - HdPrman_ProjectionParams::GetFilterParamRole(token, role); + const TfToken role = _GetShaderInputParamRole( + shaderName, inputName); - HdPrman_Utils::SetParamFromVtValue(riName, val, - role, &nodes[idx].params); + HdPrman_Utils::SetParamFromVtValue( + riName, value, role, &nodes[idx].params); } } @@ -1791,7 +1873,7 @@ HdPrman_RenderParam::SetIntegratorParamsFromCamera( } } -void +void HdPrman_RenderParam::RegisterIntegratorCallbackForCamera( IntegratorCameraCallback const& callback) { @@ -1882,7 +1964,7 @@ HdPrman_RenderParam::_CreateStatsSession(void) HdRetainedTypedSampledDataSource::New(serverId)); // Finalize addition of scene index information - _statsSceneIndex->AddPrims({{SdfPath("/globals"), TfToken("globals"), + _statsSceneIndex->AddPrims({{SdfPath("/globals"), TfToken("globals"), editor.Finish()}}); #endif #endif @@ -2058,7 +2140,7 @@ HdPrman_RenderParam::_CreateRiley(const std::string &rileyVariant, } } -struct RenderOutputDataTypeDesc +struct RenderOutputDataTypeDesc { riley::RenderOutputType rileyType; RtUString fileDataType; @@ -2205,7 +2287,7 @@ _GetOutputDisplayDriverType(const std::string &extension) { std::string("tiff"), TfToken("tiff") }, { std::string("png"), TfToken("png") } }; - + const auto it = extToDisplayDriver.find(extension); if (it != extToDisplayDriver.end()) { return RtUString(it->second.GetText()); @@ -2305,7 +2387,7 @@ _ComputeRenderViewDesc( VtDictionaryGet>( renderSpec, HdPrmanExperimentalRenderSpecTokens->renderVars); - + for (const VtValue &renderVarVal : renderVars) { const VtDictionary renderVar = renderVarVal.Get(); @@ -2351,7 +2433,7 @@ _ComputeRenderViewDesc( _tokens->riDisplayChannelNamespace); renderViewDesc.renderOutputDescs.push_back(renderOutputDesc); } - + const std::vector & renderProducts = VtDictionaryGet>( renderSpec, @@ -2395,8 +2477,8 @@ _ComputeRenderViewDesc( // Forward declaration of helper to create Render Output in the RenderViewDesc static RtUString -_AddRenderOutput(RtUString aovName, - const TfToken &dataType, HdFormat aovFormat, +_AddRenderOutput(RtUString aovName, + const TfToken &dataType, HdFormat aovFormat, RtUString sourceName, const RtParamList ¶ms, const RtUString& filter, const GfVec2f& filterWidth, std::vector *renderOutputDescs, @@ -2454,7 +2536,7 @@ _ComputeRenderViewDesc( if (renderVarIt != seenRenderVars.end()) { displayDesc.renderOutputIndices.push_back(renderVarIt->second); continue; - } + } seenRenderVars.insert( std::pair(renderVar.varPath, renderVarIndex)); displayDesc.renderOutputIndices.push_back(renderVarIndex); @@ -2466,21 +2548,21 @@ _ComputeRenderViewDesc( std::string aovNameStr = (renderVar.sourceType == _tokens->lpe) ? renderVar.varPath.GetName() : renderVar.sourceName; - std::string sourceNameStr = (renderVar.sourceType == _tokens->lpe) + std::string sourceNameStr = (renderVar.sourceType == _tokens->lpe) ? "lpe:" + renderVar.sourceName : renderVar.sourceName; const RtUString aovName(aovNameStr.c_str()); const RtUString sourceName(sourceNameStr.c_str()); - // Create a RenderOutputDesc for this RenderVar and add it to the + // Create a RenderOutputDesc for this RenderVar and add it to the // renderViewDesc. - // Note that we are not using the renderOutputIndices passed into + // Note that we are not using the renderOutputIndices passed into // this function, we are instead relying on the indices stored above std::vector renderOutputIndices; - _AddRenderOutput(aovName, - renderVar.dataType, + _AddRenderOutput(aovName, + renderVar.dataType, HdFormatInvalid, // using renderVar.dataType - sourceName, + sourceName, _ToRtParamList(renderVar.namespacedSettings, _tokens->riDisplayChannelNamespace), defaultPixelFilter, defaultPixelFilterWidth, @@ -2508,13 +2590,13 @@ HdPrman_RenderParam::CreateRenderViewFromRenderSpec( TF_DEBUG(HDPRMAN_RENDER_PASS) .Msg("Create Riley RenderView from the RenderSpec.\n"); - + GetRenderViewContext().CreateRenderView(renderViewDesc, AcquireRiley()); } #if PXR_VERSION >= 2308 /// XXX This should eventually replace the above use of the RenderSpec -void +void HdPrman_RenderParam::CreateRenderViewFromRenderSettingsProducts( HdRenderSettings::RenderProducts const &products, HdPrman_RenderViewContext *renderViewContext) @@ -2524,8 +2606,8 @@ HdPrman_RenderParam::CreateRenderViewFromRenderSettingsProducts( const HdPrman_RenderViewDesc renderViewDesc = _ComputeRenderViewDesc( products, - GetCameraContext().GetCameraId(), - GetActiveIntegratorId(), + GetCameraContext().GetCameraId(), + GetActiveIntegratorId(), GetSampleFilterList(), GetDisplayFilterList()); @@ -2717,7 +2799,7 @@ HdPrman_RenderParam::_ComputeIntegratorNode( const HdPrmanCamera * const cam) { #if PXR_VERSION >= 2308 - // Use the integrator node from a terminal connection on the + // Use the integrator node from a terminal connection on the // renderSettingsPrim if we can if (!GetRenderSettingsIntegratorPath().IsEmpty()) { @@ -2729,14 +2811,16 @@ HdPrman_RenderParam::_ComputeIntegratorNode( rileyIntegratorNode.name = RtUString(integratorNodeType.GetText()); rileyIntegratorNode.handle = RtUString(integratorNodeType.GetText()); - // Initialize the Integrator parameters + // Initialize the Integrator parameters const TfToken prefix("ri:"); for (const auto ¶m : GetRenderSettingsIntegratorNode().parameters) { // Strip the 'ri' namespace before setting the param if (TfStringStartsWith(param.first.GetText(), prefix.GetText())) { - RtUString riName(param.first.GetText() + prefix.size()); - HdPrman_Utils::SetParamFromVtValue(riName, param.second, - TfToken(), &rileyIntegratorNode.params); + const RtUString riName(param.first.GetText() + prefix.size()); + const TfToken role = _GetShaderInputParamRole( + integratorNodeType, param.first); + HdPrman_Utils::SetParamFromVtValue( + riName, param.second, role, &rileyIntegratorNode.params); } } @@ -2747,7 +2831,7 @@ HdPrman_RenderParam::_ComputeIntegratorNode( integratorNodeType.GetString(), rileyIntegratorNode.params); } - + // TODO: Adjust when PxrPathTracer adds support for excludeSubset if (integratorNodeType == HdPrmanIntegratorTokens->PbsPathTracer || integratorNodeType == HdPrmanIntegratorTokens->PxrUnified) { @@ -2783,7 +2867,7 @@ HdPrman_RenderParam::_ComputeIntegratorNode( integratorName, _integratorParams); } - + // TODO: Adjust when PxrPathTracer adds support for excludeSubset if (integratorName == HdPrmanIntegratorTokens->PbsPathTracer.GetString() || integratorName == HdPrmanIntegratorTokens->PxrUnified.GetString()) { @@ -2812,7 +2896,7 @@ HdPrman_RenderParam::_CreateIntegrator(HdRenderDelegate * const renderDelegate) riley::UserId( stats::AddDataLocation(integratorNode.name.CStr()).GetValue()), integratorNode); - + TF_VERIFY(_integratorId != riley::IntegratorId::InvalidId()); _activeIntegratorId = _integratorId; @@ -2826,17 +2910,17 @@ HdPrman_RenderParam::SetActiveRenderTags( // sort the active tags for set_difference TfTokenVector sortedTags(activeRenderTags); std::sort(sortedTags.begin(), sortedTags.end()); - + // set for uniqueness, ordered for set_difference - std::set rprimTags; + std::set rprimTags; for (const SdfPath& id : renderIndex->GetRprimIds()) { const HdRprim* rprim = renderIndex->GetRprim(id); rprimTags.insert(rprim->GetRenderTag()); } - + // fast set for comparison with cached TfToken::Set excludedTags; - + // All rprim tags not in activeTags should be excluded (rprim - active) std::set_difference( rprimTags.begin(), rprimTags.end(), @@ -2859,10 +2943,10 @@ HdPrman_RenderParam::AddRenderTagToGroupingMembership( if (!renderTag.IsEmpty()) { const std::string renderTagString = TfStringPrintf("%s%s", _tokens->renderTagPrefix.GetText(), renderTag.GetText()); - + RtUString membership; params.GetString(RixStr.k_grouping_membership, membership); - + if (membership.Empty()) { membership = RtUString(renderTagString.c_str()); } else { @@ -2910,16 +2994,16 @@ HdPrman_RenderParam::UpdateIntegrator(const HdRenderIndex * const renderIndex) AcquireRiley()->ModifyIntegrator(_integratorId, &node); } -void +void HdPrman_RenderParam::_RenderThreadCallback() { static RtUString const US_RENDERMODE = RtUString("renderMode"); static RtUString const US_INTERACTIVE = RtUString("interactive"); static RtUString const US_PROGRESSMODE = RtUString("progressMode"); - // Note: this is currently hard-coded because hdprman currently + // Note: this is currently hard-coded because hdprman currently // creates only one single camera (via the camera context). - // When this changes, we will need to make sure + // When this changes, we will need to make sure // the correct name is used here. RtUString const &defaultReferenceCamera = GetCameraContext().GetCameraName(); @@ -2927,7 +3011,7 @@ HdPrman_RenderParam::_RenderThreadCallback() RtParamList renderOptions; renderOptions.SetString(US_RENDERMODE, US_INTERACTIVE); renderOptions.SetString( - RixStr.k_dice_referencecamera, + RixStr.k_dice_referencecamera, defaultReferenceCamera); renderOptions.SetInteger(US_PROGRESSMODE, _progressMode); @@ -2940,7 +3024,7 @@ HdPrman_RenderParam::_RenderThreadCallback() renderOptions); } -void +void HdPrman_RenderParam::_ProgressCallback(RixEventCallbacks::Event, RtConstPointer data, RtPointer clientData) { @@ -2956,18 +3040,18 @@ HdPrman_RenderParam::_ProgressCallback(RixEventCallbacks::Event, } } -bool +bool HdPrman_RenderParam::IsValid() const { return _riley; } -void +void HdPrman_RenderParam::Begin(HdPrmanRenderDelegate *renderDelegate) { // Initialize legacy options from the render settings map. UpdateLegacyOptions(); - + // Force initialization of Riley scene options. // (see related comments in SetRileyOptions) #if PXR_VERSION >= 2311 // avoid deferring for now because can cause crash @@ -2977,7 +3061,7 @@ HdPrman_RenderParam::Begin(HdPrmanRenderDelegate *renderDelegate) { SetRileyOptions(); } - + // Set the camera path before the first sync so that // HdPrmanCamera::Sync can detect whether it is syncing the // current camera and needs to set the riley shutter interval @@ -3170,7 +3254,7 @@ HdPrman_RenderParam::SetRileyOptions() _envOptions, _rileySceneIndexObserverOptions, #if PXR_VERSION >= 2311 // causes issues for houdini 20, eg. bad shutter interval - _renderSettingsPrimOptions, + _renderSettingsPrimOptions, #endif GetLegacyOptions(), _fallbackOptions); @@ -3204,7 +3288,7 @@ HdPrman_RenderParam::SetRileyOptions() } } -void +void HdPrman_RenderParam::SetActiveIntegratorId(const riley::IntegratorId id) { _activeIntegratorId = id; @@ -3214,7 +3298,7 @@ HdPrman_RenderParam::SetActiveIntegratorId(const riley::IntegratorId id) GetRenderViewContext().SetIntegratorId(id, riley); } -void +void HdPrman_RenderParam::StartRender() { // Last chance to set Ri options before starting riley! @@ -3242,7 +3326,7 @@ HdPrman_RenderParam::StartRender() _renderThread->StartRender(); } -void +void HdPrman_RenderParam::End() { DeleteRenderThread(); @@ -3324,7 +3408,7 @@ HdPrman_RenderParam::_UpdatePixelFilter() // Riley API is modified to set filter and filter width as an option, we // need to get the render setting ourselves and set it for each AOV. - // WARNING: Defaults are hardcoded. + // WARNING: Defaults are hardcoded. // Make sure they match the values in PRManOptions.args. #if _PRMANAPI_VERSION_MAJOR_ >= 26 static const std::string defaultPixelFilter("gaussian"); @@ -3353,14 +3437,14 @@ HdPrman_RenderParam::_UpdatePixelFilter() bool HdPrman_RenderParam::_UpdateQNSettings() -{ +{ // look for QN settings const HdRenderSettingsMap renderSettingsMap = _renderDelegate->GetRenderSettingsMap(); - const bool useQN = _renderDelegate->GetRenderSetting(TfToken("rmanEnableQNDenoise"), false); - const bool qnCheapPass = _renderDelegate->GetRenderSetting(TfToken("rmanQNCheapPass"), false); - const int qnMinSamples = _renderDelegate->GetRenderSetting(TfToken("rmanQNMinSamples"), 2); - const int qnInterval = _renderDelegate->GetRenderSetting(TfToken("rmanQNInterval"), 4); + const bool useQN = _renderDelegate->GetRenderSetting(TfToken("rmanEnableQNDenoise"), false); + const bool qnCheapPass = _renderDelegate->GetRenderSetting(TfToken("rmanQNCheapPass"), false); + const int qnMinSamples = _renderDelegate->GetRenderSetting(TfToken("rmanQNMinSamples"), 2); + const int qnInterval = _renderDelegate->GetRenderSetting(TfToken("rmanQNInterval"), 4); if (useQN != _useQN || qnCheapPass != _qnCheapPass || qnMinSamples != _qnMinSamples || qnInterval != _qnInterval) { @@ -3374,7 +3458,7 @@ HdPrman_RenderParam::_UpdateQNSettings() } static riley::RenderOutputType -_ToRenderOutputTypeFromHdFormat(const HdFormat aovFormat) +_ToRenderOutputTypeFromHdFormat(const HdFormat aovFormat) { // Prman only supports float, color, and integer if(aovFormat == HdFormatFloat32) { @@ -3391,7 +3475,7 @@ _ToRenderOutputTypeFromHdFormat(const HdFormat aovFormat) // If the aovFormat has 3 or 4 channels, make format Float32 static void -_AdjustColorFormat(HdFormat* aovFormat) +_AdjustColorFormat(HdFormat* aovFormat) { // Prman always renders colors as float, so for types with 3 or 4 // components, always set the format in our framebuffer to float. @@ -3406,9 +3490,9 @@ _AdjustColorFormat(HdFormat* aovFormat) } } -// Update the given Rman AOV and Source names +// Update the given Rman AOV and Source names // - aovName: Map the given hdAovName to the Prman equivalent -// - SourceName: Add 'lpe:' prefix as needed +// - SourceName: Add 'lpe:' prefix as needed static void _UpdateRmanAovAndSourceName( const TfToken &hdAovName, @@ -3439,7 +3523,7 @@ _UpdateRmanAovAndSourceName( } if(rmanSourceName->Empty()) { - // Update the Aov and Source names by mapping the HdAovName to an + // Update the Aov and Source names by mapping the HdAovName to an // equivalent Prman name if (hdAovName == HdAovTokens->color || hdAovName.GetString() == "ci") { *rmanAovName = RixStr.k_Ci; @@ -3496,8 +3580,8 @@ _GetOutputParamsAndUpdateRmanNames( settingVal.GetWithDefault().GetString(); } - // Gather all properties with the 'driver:parameters:aov' prefix - // into the RtParamList, updating the hdAovName if needed. + // Gather all properties with the 'driver:parameters:aov' prefix + // into the RtParamList, updating the hdAovName if needed. else if (TfStringStartsWith( settingName.GetText(), "driver:parameters:aov:") || TfStringStartsWith( @@ -3564,12 +3648,12 @@ HdPrman_RenderParam::_CreateRileyDisplay( PlugRegistry::GetInstance().GetPluginWithName("hdPrman")) { const std::string path = TfGetPathName(plugin->GetPath()); if (!path.empty()) { - hdPrmanPath = + hdPrmanPath = TfStringCatPaths(path, "hdPrman" ARCH_LIBRARY_SUFFIX); } driver = RtUString("quicklyNoiseless"); displayParams.SetString(RtUString("dspyDSOPath"), RtUString(hdPrmanPath.c_str())); - displayParams.SetInteger(RtUString("cheaPass"), (int) _qnCheapPass); + displayParams.SetInteger(RtUString("cheaPass"), (int) _qnCheapPass); displayParams.SetInteger(RtUString("minSamples"), _qnMinSamples); displayParams.SetInteger(RtUString("interval"), _qnInterval); displayParams.SetInteger(RtUString("normalAsColor"), 1); @@ -3642,7 +3726,11 @@ _AddRenderOutput( } // Get the relativePixelVariance and remap from the given RtParamList +#if _PRMANAPI_VERSION_MAJOR_ >= 26 + float relativePixelVariance = 0.0f; +#else float relativePixelVariance = 1.0f; +#endif params.GetFloat(RixStr.k_relativepixelvariance, relativePixelVariance); RtParamList extraParams; @@ -3681,7 +3769,7 @@ _AddRenderOutput( TF_DEBUG(HDPRMAN_RENDER_PASS) .Msg("Add RenderOutputDesc: \n - name: '%s'\n - type: '%d'\n" " - sourceName: '%s'\n - rule: '%s'\n - filter: '%s'\n\n", - aovName.CStr(), int(rType), sourceName.CStr(), + aovName.CStr(), int(rType), sourceName.CStr(), rule.CStr(), filter.CStr()); renderOutputDescs->push_back(std::move(renderOutputDesc)); @@ -3855,8 +3943,8 @@ HdPrman_RenderParam::CreateFramebufferAndRenderViewFromAovs( // isn't the intent in case it becomes a problem. auto rsrvd = _ComputeRenderViewDesc(renderSettings->GetRenderProducts(), - renderViewDesc.cameraId, - renderViewDesc.integratorId, + renderViewDesc.cameraId, + renderViewDesc.integratorId, renderViewDesc.sampleFilterList, renderViewDesc.displayFilterList); @@ -3897,7 +3985,7 @@ HdPrman_RenderParam::CreateRenderViewFromLegacyProducts( const VtArray& renderProducts, int frame) { // Display edits are not currently supported in HdPrman - // RenderMan Display drivers are inteded for use in batch rendering, + // RenderMan Display drivers are inteded for use in batch rendering, // so bail here if Riley has already been started, since this means that // the Displays already exist. if (renderProducts.empty() || @@ -3913,12 +4001,12 @@ HdPrman_RenderParam::CreateRenderViewFromLegacyProducts( // Here we loop over the Render Products (a USD concept which corresponds // to a Riley Display), make a list of Riley Displays, and collect a list // of all the outputs (AOVs) used by the Displays. - // One Target will be used for all Displays, it needs to be created + // One Target will be used for all Displays, it needs to be created // before the Displays, and takes a list of all possible outputs (AOVs). - // + // // The View and Displays are created, each referencing the Target's id. - // - // XXX In the future, when xpu supports it, we may want to change this to + // + // XXX In the future, when xpu supports it, we may want to change this to // allow for a different Target/View for each Display. HdPrman_RenderViewDesc renderViewDesc; @@ -3945,7 +4033,7 @@ HdPrman_RenderParam::CreateRenderViewFromLegacyProducts( } else if (settingName == HdPrmanRenderProductTokens->orderedVars) { VtArray orderedVars = settingVal.UncheckedGet>(); - + // Find Ci and a Outputs in the RenderVar list int Ci_idx = -1; int a_idx = -1; @@ -3971,7 +4059,7 @@ HdPrman_RenderParam::CreateRenderViewFromLegacyProducts( } // Populate the AOVs Array from the RenderVar list making sure - // that the Ci and a RenderVars are first. + // that the Ci and a RenderVars are first. aovs.reserve(orderedVars.size()); if (Ci_idx >= 0 && Ci_idx < static_cast(orderedVars.size())) { aovs.push_back(orderedVars[Ci_idx]); @@ -3998,8 +4086,8 @@ HdPrman_RenderParam::CreateRenderViewFromLegacyProducts( // If an --output or -o has been specified on command line, override the // product's name and expand variables: - // : source prim (render product node name) - // , , , , , : frame number with padding + // : source prim (render product node name) + // , , , , , : frame number with padding // : the ordinial frame number // Vars can also use dollar style (braces optional) eg. $F4 // ${F4} $OS or printf style formatting: %04d @@ -4028,7 +4116,7 @@ HdPrman_RenderParam::CreateRenderViewFromLegacyProducts( productName = TfToken(outputName); } - // Build Display Settings ParamList using the driverParameters gathered + // Build Display Settings ParamList using the driverParameters gathered // above from the Render Product Settings RtParamList displayParams; for (const TfToken& paramName : driverParameters) { @@ -4057,7 +4145,7 @@ HdPrman_RenderParam::CreateRenderViewFromLegacyProducts( } } - // Keep a list of the indices for the Render Outputs (AOVs/RenderVars) + // Keep a list of the indices for the Render Outputs (AOVs/RenderVars) // of this Display (RenderProduct) // renderViewDesc.renderOutputDescs is a list of all Render Outputs // across all Displays, these renderOutputIndices index into that list. @@ -4075,7 +4163,7 @@ HdPrman_RenderParam::CreateRenderViewFromLegacyProducts( HdFormatFloat32); _AdjustColorFormat(&aovFormat); - // RmanSourceName + // RmanSourceName RtUString rmanSourceName = _GetAsRtUString(aov, HdPrmanAovSettingsTokens->sourceName); @@ -4191,7 +4279,7 @@ HdPrman_RenderParam::_ComputeQuickIntegratorNode( static const RtUString numBxdfSamples("numBxdfSamples"); _quickIntegratorParams.SetInteger(numLightSamples, 1); - _quickIntegratorParams.SetInteger(numBxdfSamples, 1); + _quickIntegratorParams.SetInteger(numBxdfSamples, 1); return riley::ShadingNode{ riley::ShadingNode::Type::k_Integrator, @@ -4233,7 +4321,7 @@ HdPrman_RenderParam::UpdateQuickIntegrator( _ComputeQuickIntegratorNode( renderIndex->GetRenderDelegate(), _cameraContext.GetCamera(renderIndex)); - + AcquireRiley()->ModifyIntegrator( _quickIntegratorId, &node); @@ -4337,7 +4425,7 @@ HdPrman_RenderParam::SetRenderSettingsIntegratorPath( if (! HdRenderIndex::IsSceneIndexEmulationEnabled()) { // Mark the Integrator Prim Dirty sceneDelegate->GetRenderIndex().GetChangeTracker() - .MarkSprimDirty(renderSettingsIntegratorPath, + .MarkSprimDirty(renderSettingsIntegratorPath, HdChangeTracker::DirtyParams); } _renderSettingsIntegratorPath = renderSettingsIntegratorPath; @@ -4349,7 +4437,7 @@ HdPrman_RenderParam::SetRenderSettingsIntegratorPath( } } -void +void HdPrman_RenderParam::SetRenderSettingsIntegratorNode( HdRenderIndex *renderIndex, HdMaterialNode2 const &integratorNode) { @@ -4453,16 +4541,16 @@ HdPrman_RenderParam::CreateSampleFilterNetwork(HdSceneDelegate *sceneDelegate) filterArrayName, filterRefs.data(), filterRefs.size()); shadingNodes.push_back(combinerNode); } - + // Create or update the Riley SampleFilters riley::ShadingNetwork const sampleFilterNetwork = { static_cast(shadingNodes.size()), &shadingNodes[0] }; - + if (_sampleFiltersId == riley::SampleFilterId::InvalidId()) { _sampleFiltersId = AcquireRiley()->CreateSampleFilter( riley::UserId(stats::AddDataLocation("/sampleFilters"). GetValue()), - sampleFilterNetwork, + sampleFilterNetwork, RtParamList()); } else { @@ -4510,16 +4598,16 @@ HdPrman_RenderParam::CreateDisplayFilterNetwork(HdSceneDelegate *sceneDelegate) filterArrayName, filterRefs.data(), filterRefs.size()); shadingNodes.push_back(combinerNode); } - + // Create or update the Riley DisplayFilters riley::ShadingNetwork const displayFilterNetwork = { static_cast(shadingNodes.size()), &shadingNodes[0] }; - + if (_displayFiltersId == riley::DisplayFilterId::InvalidId()) { _displayFiltersId = AcquireRiley()->CreateDisplayFilter( riley::UserId(stats::AddDataLocation("/displayFilters"). GetValue()), - displayFilterNetwork, + displayFilterNetwork, RtParamList()); } else { @@ -4562,7 +4650,7 @@ HdPrman_RenderParam::AddDisplayFilter( filterIt.first->second = node; } - // If we have all the Shading Nodes, creat the DisplayFilters in Riley + // If we have all the Shading Nodes, creat the DisplayFilters in Riley if (_displayFilterNodes.size() == _connectedDisplayFilterPaths.size()) { CreateDisplayFilterNetwork(sceneDelegate); } @@ -4571,7 +4659,7 @@ HdPrman_RenderParam::AddDisplayFilter( riley::SampleFilterList HdPrman_RenderParam::GetSampleFilterList() { - return (_sampleFiltersId == riley::SampleFilterId::InvalidId()) + return (_sampleFiltersId == riley::SampleFilterId::InvalidId()) ? riley::SampleFilterList({ 0, nullptr }) : riley::SampleFilterList({ 1, &_sampleFiltersId }); } @@ -4588,7 +4676,7 @@ void HdPrman_RenderParam::_CreateFallbackLight() { static const RtUString us_PxrDomeLight("PxrDomeLight"); - static const RtUString us_lightA("lightA"); + static const RtUString us_lightA("lightA"); static const RtUString us_traceLightPaths("traceLightPaths"); static const RtUString us_lightGroup("lightGroup"); static const RtUString us_A("A"); @@ -4607,9 +4695,9 @@ HdPrman_RenderParam::_CreateFallbackLight() }; _fallbackLightShader = _riley->CreateLightShader( riley::UserId::DefaultId(), {1, &lightNode}, {0, nullptr}); - + riley::CoordinateSystemList const k_NoCoordsys = { 0, nullptr }; - + // Constant identity transform const float zerotime[1] = { 0.0f }; const RtMatrix4x4 matrix[1] = { RixConstants::k_IdentityMatrix }; From f01aa082ffba2bca3df4cd98db6c2a52f74370da Mon Sep 17 00:00:00 2001 From: Matt Kuruc Date: Tue, 29 Oct 2024 11:51:25 -0400 Subject: [PATCH 072/300] Disambiguate semantic labels from model hierarchy --- pxr/usd/usdSemantics/overview.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pxr/usd/usdSemantics/overview.md b/pxr/usd/usdSemantics/overview.md index 1eb804b00d..9a18f69a76 100644 --- a/pxr/usd/usdSemantics/overview.md +++ b/pxr/usd/usdSemantics/overview.md @@ -1,6 +1,6 @@ -# UsdSemantics : Semantic Labeling for Model Hierarchy {#usd_semantics_overview} +# UsdSemantics : Semantic Labeling of Scenes {#usd_semantics_overview} \if ( PIXAR_MFB_BUILD ) -\mainpage UsdSemantics : Semantic Labeling for Model Hierarchy +\mainpage UsdSemantics : Semantic Labeling of Scenes \endif While prims have a unique name and hierarchical identifier, it is sometimes From 324f17e7a89bbb28fe73e0d7ec75ca70fd1b2588 Mon Sep 17 00:00:00 2001 From: sunyab Date: Tue, 29 Oct 2024 11:07:04 -0700 Subject: [PATCH 073/300] build: Set /Zc:__cplusplus for Visual Studio builds This ensures the __cplusplus preprocessor symbol is set to the correct value for the C++ standard being used. Otherwise, Visual Studio sets __cplusplus to 199711L for backwards compatibility reasons. (Internal change: 2345929) --- cmake/defaults/msvcdefaults.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/defaults/msvcdefaults.cmake b/cmake/defaults/msvcdefaults.cmake index 13d77d0ae7..e8823599ae 100644 --- a/cmake/defaults/msvcdefaults.cmake +++ b/cmake/defaults/msvcdefaults.cmake @@ -11,6 +11,13 @@ set(_PXR_CXX_FLAGS "${_PXR_CXX_FLAGS} /EHsc") # Standards compliant. set(_PXR_CXX_FLAGS "${_PXR_CXX_FLAGS} /Zc:rvalueCast /Zc:strictStrings") +# Visual Studio sets the value of __cplusplus to 199711L regardless of +# the C++ standard actually being used, unless /Zc:__cplusplus is enabled. +# +# For more details, see: +# https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus +set(_PXR_CXX_FLAGS "${_PXR_CXX_FLAGS} /Zc:__cplusplus") + # The /Zc:inline option strips out the "arch_ctor_" symbols used for # library initialization by ARCH_CONSTRUCTOR starting in Visual Studio 2019, # causing release builds to fail. Disable the option for this and later From 9814aca097639b2ee82cb1b9bbf17f42e276f0d8 Mon Sep 17 00:00:00 2001 From: clach Date: Tue, 29 Oct 2024 11:07:26 -0700 Subject: [PATCH 074/300] [usdviewq] Remove ability to set "enableIdRender" param from usdview, which hasn't been exposed for a while now. If users wish to view prim ids, they should switch to viewing the primId AOV. (Internal change: 2345966) --- pxr/usdImaging/usdviewq/appController.py | 9 --------- pxr/usdImaging/usdviewq/mainWindowUI.ui | 8 -------- pxr/usdImaging/usdviewq/stageView.py | 4 ++-- pxr/usdImaging/usdviewq/viewSettingsDataModel.py | 11 ----------- 4 files changed, 2 insertions(+), 30 deletions(-) diff --git a/pxr/usdImaging/usdviewq/appController.py b/pxr/usdImaging/usdviewq/appController.py index 6e60a3acd5..e09297b8c7 100644 --- a/pxr/usdImaging/usdviewq/appController.py +++ b/pxr/usdImaging/usdviewq/appController.py @@ -897,9 +897,6 @@ def __init__(self, parserData, resolverContextFn): self._ui.actionDisplay_Camera_Oracles.triggered.connect( self._toggleDisplayCameraOracles) - self._ui.actionDisplay_PrimId.triggered.connect( - self._toggleDisplayPrimId) - self._ui.actionEnable_Scene_Materials.triggered.connect( self._toggleEnableSceneMaterials) @@ -2648,10 +2645,6 @@ def _toggleDisplayCameraOracles(self): self._dataModel.viewSettings.displayCameraOracles = ( self._ui.actionDisplay_Camera_Oracles.isChecked()) - def _toggleDisplayPrimId(self): - self._dataModel.viewSettings.displayPrimId = ( - self._ui.actionDisplay_PrimId.isChecked()) - def _toggleEnableSceneMaterials(self): self._dataModel.viewSettings.enableSceneMaterials = ( self._ui.actionEnable_Scene_Materials.isChecked()) @@ -5370,8 +5363,6 @@ def _refreshViewMenu(self): self._dataModel.viewSettings.enableSceneMaterials) self._ui.actionEnable_Scene_Lights.setChecked( self._dataModel.viewSettings.enableSceneLights) - self._ui.actionDisplay_PrimId.setChecked( - self._dataModel.viewSettings.displayPrimId) self._ui.actionCull_Backfaces.setChecked( self._dataModel.viewSettings.cullBackfaces) self._ui.actionDomeLightTexturesVisible.setChecked( diff --git a/pxr/usdImaging/usdviewq/mainWindowUI.ui b/pxr/usdImaging/usdviewq/mainWindowUI.ui index 94c7a01586..69de7637cf 100644 --- a/pxr/usdImaging/usdviewq/mainWindowUI.ui +++ b/pxr/usdImaging/usdviewq/mainWindowUI.ui @@ -2414,14 +2414,6 @@ Render - - - true - - - Display Prim Id - - true diff --git a/pxr/usdImaging/usdviewq/stageView.py b/pxr/usdImaging/usdviewq/stageView.py index 782760b15e..dc620a0880 100644 --- a/pxr/usdImaging/usdviewq/stageView.py +++ b/pxr/usdImaging/usdviewq/stageView.py @@ -1452,8 +1452,8 @@ def renderSinglePass(self, renderMode, renderSelHighlights): if self._dataModel.viewSettings.cullBackfaces else UsdImagingGL.CullStyle.CULL_STYLE_NOTHING) self._renderParams.gammaCorrectColors = False - self._renderParams.enableIdRender = self._dataModel.viewSettings.displayPrimId - self._renderParams.enableSampleAlphaToCoverage = not self._dataModel.viewSettings.displayPrimId + self._renderParams.enableIdRender = False + self._renderParams.enableSamlpeAlphaToCoverage = True self._renderParams.highlight = renderSelHighlights self._renderParams.enableSceneMaterials = self._dataModel.viewSettings.enableSceneMaterials self._renderParams.domeLightCameraVisibility = self._dataModel.viewSettings.domeLightTexturesVisible diff --git a/pxr/usdImaging/usdviewq/viewSettingsDataModel.py b/pxr/usdImaging/usdviewq/viewSettingsDataModel.py index f0493e4e8a..319dd33c2c 100644 --- a/pxr/usdImaging/usdviewq/viewSettingsDataModel.py +++ b/pxr/usdImaging/usdviewq/viewSettingsDataModel.py @@ -165,7 +165,6 @@ def __init__(self, rootDataModel, parent): self._displayGuide = self.stateProperty("displayGuide", default=False) self._displayProxy = self.stateProperty("displayProxy", default=True) self._displayRender = self.stateProperty("displayRender", default=False) - self._displayPrimId = self.stateProperty("displayPrimId", default=False) self._enableSceneMaterials = self.stateProperty("enableSceneMaterials", default=True) self._enableSceneLights = self.stateProperty("enableSceneLights", default=True) self._cullBackfaces = self.stateProperty("cullBackfaces", default=False) @@ -238,7 +237,6 @@ def onSaveState(self, state): state["displayGuide"] = self._displayGuide state["displayProxy"] = self._displayProxy state["displayRender"] = self._displayRender - state["displayPrimId"] = self._displayPrimId state["enableSceneMaterials"] = self._enableSceneMaterials state["enableSceneLights"] = self._enableSceneLights state["cullBackfaces"] = self._cullBackfaces @@ -552,15 +550,6 @@ def displayCameraOracles(self): def displayCameraOracles(self, value): self._displayCameraOracles = value - @property - def displayPrimId(self): - return self._displayPrimId - - @displayPrimId.setter - @visibleViewSetting - def displayPrimId(self, value): - self._displayPrimId = value - @property def enableSceneMaterials(self): return self._enableSceneMaterials From 524ad40d6d6b69998b11f03b85138cc5940feef5 Mon Sep 17 00:00:00 2001 From: clach Date: Tue, 29 Oct 2024 11:11:04 -0700 Subject: [PATCH 075/300] Improvements to prim id rendering in Storm. One goal of this change is to move away from using "enableIdRender" in UsdImagingGLRenderParams and HdxRenderTaskParams to indicate prim id rendering, and instead move to requesting primId as a separate AOV. Currently, when one wants to do id rendering and sets enableIdRender to true, Storm will render prim ids to the default/color AOV. We instead want to use a primId AOV, which has an int32 format. This change adds support for rendering to an int32 format AOV. This change also introduces the renderPassShaderKey, which is used to flexibly generate a renderPassShader based on the desired AOVs. The AOVs currently supported by this in Storm are color, primId and instanceId, and Neye. There is still support for rendering primIds using the previous method i.e. requesting it via "enableIdRender". This support will be deprecated in the coming months, which will clean up some of the logic required to support both xodepaths. (Internal change: 2345969) --- pxr/imaging/hdSt/CMakeLists.txt | 1 + pxr/imaging/hdSt/renderDelegate.cpp | 2 +- pxr/imaging/hdSt/renderPassShader.cpp | 46 +++++ pxr/imaging/hdSt/renderPassShader.h | 9 + pxr/imaging/hdSt/renderPassShaderKey.cpp | 161 ++++++++++++++++++ pxr/imaging/hdSt/renderPassShaderKey.h | 54 ++++++ pxr/imaging/hdSt/renderPassState.cpp | 8 +- pxr/imaging/hdSt/resourceRegistry.cpp | 10 ++ pxr/imaging/hdSt/resourceRegistry.h | 11 ++ pxr/imaging/hdSt/shaderKey.cpp | 5 +- pxr/imaging/hdSt/shaderKey.h | 19 ++- pxr/imaging/hdSt/shaders/renderPass.glslfx | 76 ++++++++- .../hdSt/shaders/renderPassShader.glslfx | 5 +- pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp | 14 +- .../baseline/codegen_curves_indirect.out | 27 ++- .../baseline/codegen_mesh_edgeonly.out | 54 +++++- .../codegen_mesh_edgeonly_blendwireframe.out | 54 +++++- .../baseline/codegen_mesh_indirect.out | 54 +++++- .../codegen_mesh_indirect_doubleSided.out | 54 +++++- .../codegen_mesh_indirect_faceVarying.out | 54 +++++- .../codegen_mesh_indirect_instance.out | 54 +++++- .../codegen_mesh_indirect_smoothNormals.out | 54 +++++- .../baseline/codegen_points_indirect.out | 27 ++- .../baseline/codegen_curves_indirect.out | 27 ++- .../baseline/codegen_mesh_edgeonly.out | 54 +++++- .../codegen_mesh_edgeonly_blendwireframe.out | 54 +++++- .../baseline/codegen_mesh_indirect.out | 54 +++++- .../codegen_mesh_indirect_doubleSided.out | 54 +++++- .../codegen_mesh_indirect_faceVarying.out | 54 +++++- .../codegen_mesh_indirect_instance.out | 54 +++++- .../codegen_mesh_indirect_smoothNormals.out | 54 +++++- .../baseline/codegen_points_indirect.out | 27 ++- .../hdSt/testenv/testHdStCurvesPrimvars.cpp | 19 ++- .../hdSt/testenv/testHdStDrawBatching.cpp | 14 +- .../hdSt/testenv/testHdStDynamicUvTexture.cpp | 6 +- .../hdSt/testenv/testHdStMeshTopology.cpp | 14 +- .../hdSt/testenv/testHdStPrimitiveParam.cpp | 15 +- .../hdSt/testenv/testHdStQuadrangulation.cpp | 13 +- .../testenv/testHdStSamplerObjectRegistry.cpp | 7 +- .../hdSt/testenv/testHdStSubdivision.cpp | 13 +- .../testenv/testHdStTextureHandleRegistry.cpp | 7 +- .../testenv/testHdStTextureObjectRegistry.cpp | 6 +- pxr/imaging/hdSt/unitTestHelper.cpp | 11 ++ pxr/imaging/hdSt/unitTestHelper.h | 8 + pxr/imaging/hdx/pickTask.cpp | 4 +- pxr/imaging/hdx/renderSetupTask.cpp | 95 ++++++++--- pxr/imaging/hdx/renderSetupTask.h | 5 +- pxr/imaging/hdx/shaders/renderPass.glslfx | 28 ++- .../hdx/shaders/renderPassColorShader.glslfx | 6 +- .../hdx/shaders/renderPassIdShader.glslfx | 3 +- .../hdx/shaders/renderPassShadowShader.glslfx | 6 +- pxr/imaging/hdx/testenv/testHdxIdRender.cpp | 1 - pxr/imaging/hgiGL/ops.cpp | 24 ++- pxr/imaging/hgiVulkan/graphicsCmds.cpp | 27 ++- pxr/usdImaging/usdImagingGL/engine.cpp | 36 +++- pxr/usdImaging/usdImagingGL/engine.h | 17 +- ...sdImagingGLAovVisualization_Storm_Neye.png | Bin 0 -> 55568 bytes ...ImagingGLAovVisualization_Storm_primId.png | Bin 0 -> 16470 bytes .../testenv/testUsdImagingGLBasicDrawing.cpp | 1 - .../testUsdImagingGLBasicDrawing_id.png | Bin 14572 -> 14623 bytes .../testenv/testUsdImagingGLHighlight.cpp | 1 - .../testUsdImagingGLPickAndHighlight.cpp | 2 - 62 files changed, 1523 insertions(+), 151 deletions(-) create mode 100644 pxr/imaging/hdSt/renderPassShaderKey.cpp create mode 100644 pxr/imaging/hdSt/renderPassShaderKey.h create mode 100644 pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLAovVisualization/baseline/testUsdImagingGLAovVisualization_Storm_Neye.png create mode 100644 pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLAovVisualization/baseline/testUsdImagingGLAovVisualization_Storm_primId.png diff --git a/pxr/imaging/hdSt/CMakeLists.txt b/pxr/imaging/hdSt/CMakeLists.txt index 1aca8b0eb6..407f022a3e 100644 --- a/pxr/imaging/hdSt/CMakeLists.txt +++ b/pxr/imaging/hdSt/CMakeLists.txt @@ -170,6 +170,7 @@ pxr_library(hdSt pipelineDrawBatch pointsShaderKey quadrangulate + renderPassShaderKey resourceBinder shaderKey subdivision diff --git a/pxr/imaging/hdSt/renderDelegate.cpp b/pxr/imaging/hdSt/renderDelegate.cpp index 37d22c5127..d35c0cf1c1 100644 --- a/pxr/imaging/hdSt/renderDelegate.cpp +++ b/pxr/imaging/hdSt/renderDelegate.cpp @@ -321,7 +321,7 @@ HdStRenderDelegate::GetDefaultAovDescriptor(TfToken const& name) const VtValue(HdDepthStencilType(1.0f, 0))); } else if (_AovHasIdSemantic(name)) { return HdAovDescriptor( - HdFormatUNorm8Vec4, colorDepthMSAA, VtValue(GfVec4f(0))); + HdFormatInt32, colorDepthMSAA, VtValue(-1)); } else if (name == HdAovTokens->Neye) { return HdAovDescriptor( HdFormatUNorm8Vec4, colorDepthMSAA, VtValue(GfVec4f(0))); diff --git a/pxr/imaging/hdSt/renderPassShader.cpp b/pxr/imaging/hdSt/renderPassShader.cpp index a6f3fc9dd2..d3ba975e56 100644 --- a/pxr/imaging/hdSt/renderPassShader.cpp +++ b/pxr/imaging/hdSt/renderPassShader.cpp @@ -13,6 +13,7 @@ #include "pxr/imaging/hdSt/materialParam.h" #include "pxr/imaging/hdSt/renderBuffer.h" #include "pxr/imaging/hdSt/renderPassShader.h" +#include "pxr/imaging/hdSt/renderPassShaderKey.h" #include "pxr/imaging/hdSt/resourceBinder.h" #include "pxr/imaging/hdSt/textureBinder.h" #include "pxr/imaging/hdSt/textureHandle.h" @@ -327,4 +328,49 @@ HdStRenderPassShader::UpdateAovInputTextures( } } +namespace { +size_t +_GetRenderPassShaderHash( + HdRenderPassAovBindingVector const &aovBindings, + const HdStRenderPassState * const renderPassState) +{ + size_t hash = 0; + + // Aov binding names determine the configuration of the render pass shader + // key. + for (const auto& aovBinding : aovBindings) { + hash = TfHash::Combine(hash, aovBinding.aovName); + } + + // We want each renderPassState to have its own renderPassShader, so + // include renderPassState in the hash. + hash = TfHash::Combine(hash, renderPassState); + + return hash; +} +} + +// static +HdStRenderPassShaderSharedPtr +HdStRenderPassShader::CreateRenderPassShaderFromAovs( + HdStRenderPassState *renderPassState, + HdStResourceRegistrySharedPtr const &resourceRegistry, + HdRenderPassAovBindingVector const &aovBindings) +{ + HdInstance renderPassShaderInstance = + resourceRegistry->RegisterRenderPassShader( + _GetRenderPassShaderHash(aovBindings, renderPassState)); + + if (renderPassShaderInstance.IsFirstInstance()) { + HdSt_RenderPassShaderKey shaderKey(aovBindings); + std::istringstream s(shaderKey.GetGlslfxString()); + HioGlslfxSharedPtr glslfx = std::make_shared(s); + + renderPassShaderInstance.SetValue( + std::make_shared(glslfx)); + } + + return renderPassShaderInstance.GetValue(); +} + PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/imaging/hdSt/renderPassShader.h b/pxr/imaging/hdSt/renderPassShader.h index 3b1dd3f3af..34e4ef7b72 100644 --- a/pxr/imaging/hdSt/renderPassShader.h +++ b/pxr/imaging/hdSt/renderPassShader.h @@ -23,6 +23,7 @@ PXR_NAMESPACE_OPEN_SCOPE using HdStRenderPassShaderSharedPtr = std::shared_ptr; +class HdStRenderPassState; class HdRenderIndex; using HdRenderPassAovBindingVector = std::vector; @@ -84,6 +85,14 @@ class HdStRenderPassShader : public HdStShaderCode { HdRenderPassAovBindingVector const &aovInputBindings, HdRenderIndex * const renderIndex); + HDST_API + static + HdStRenderPassShaderSharedPtr + CreateRenderPassShaderFromAovs( + HdStRenderPassState *renderPassState, + HdStResourceRegistrySharedPtr const &resourceRegistry, + HdRenderPassAovBindingVector const &aovBindings); + private: HioGlslfxSharedPtr _glslfx; mutable size_t _hash; diff --git a/pxr/imaging/hdSt/renderPassShaderKey.cpp b/pxr/imaging/hdSt/renderPassShaderKey.cpp new file mode 100644 index 0000000000..3e08168cb8 --- /dev/null +++ b/pxr/imaging/hdSt/renderPassShaderKey.cpp @@ -0,0 +1,161 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +#include "pxr/pxr.h" +#include "pxr/imaging/hdSt/renderPassShaderKey.h" +#include "pxr/imaging/hd/tokens.h" + +#include "pxr/base/tf/staticTokens.h" + +PXR_NAMESPACE_OPEN_SCOPE + + +TF_DEFINE_PRIVATE_TOKENS( + _tokens, + // Glslfx files to include + ((renderPassGlslfx, "renderPass.glslfx")) + ((selectionGlslfx, "selection.glslfx")) + + // render pass mixins + ((renderPassCamera, "RenderPass.Camera")) + ((renderPassCameraFS, "RenderPass.CameraFS")) + ((renderPassApplyClipPlanes, "RenderPass.ApplyClipPlanes")) + ((renderPassApplyColorOverrides, "RenderPass.ApplyColorOverrides")) + ((renderPassRenderOutput, "RenderPass.RenderOutput")) + ((renderPassNoSelection, "RenderPass.NoSelection")) + ((renderPassNoColorOverrides, "RenderPass.NoColorOverrides")) + + // selection mixins + ((selectionDecodeUtils, "Selection.DecodeUtils")) + ((selectionComputeColor, "Selection.ComputeColor")) + + // Render AOV outputs mixins + ((renderPassRenderColor, "RenderPass.RenderColor")) + ((renderPassRenderColorNoOp, "RenderPass.RenderColorNoOp")) + + ((renderPassRenderId, "RenderPass.RenderId")) + ((renderPassRenderIdNoOp, "RenderPass.RenderIdNoOp")) + + ((renderPassRenderNeye, "RenderPass.RenderNeye")) + ((renderPassRenderNeyeNoOp, "RenderPass.RenderNeyeNoOp")) +); + +static +bool +_AovHasIdSemantic(TfToken const & name) +{ + // For now id render only means primId or instanceId. + return name == HdAovTokens->primId || + name == HdAovTokens->instanceId; +} + +HdSt_RenderPassShaderKey::HdSt_RenderPassShaderKey( + const HdRenderPassAovBindingVector& aovBindings) + : glslfx(_tokens->renderPassGlslfx) +{ + bool renderColor = false; + bool renderId = false; + bool renderNeye = false; + + for (size_t i = 0; i < aovBindings.size(); ++i) { + if (!renderColor && aovBindings[i].aovName == HdAovTokens->color) { + renderColor = true; + } + if (!renderId && _AovHasIdSemantic(aovBindings[i].aovName)) { + renderId = true; + } + if (!renderNeye && aovBindings[i].aovName == HdAovTokens->Neye) { + renderNeye = true; + } + } + + VS[0] = _tokens->renderPassCamera; + VS[1] = _tokens->renderPassApplyClipPlanes; + VS[2] = TfToken(); + + PTCS[0] = _tokens->renderPassCamera; + PTCS[1] = TfToken(); + + PTVS[0] = _tokens->renderPassCamera; + PTVS[1] = _tokens->renderPassApplyClipPlanes; + PTVS[2] = TfToken(); + + TCS[0] = _tokens->renderPassCamera; + TCS[1] = TfToken(); + + TES[0] = _tokens->renderPassCamera; + TES[1] = _tokens->renderPassApplyClipPlanes; + TES[2] = TfToken(); + + GS[0] = _tokens->renderPassCamera; + GS[1] = _tokens->renderPassApplyClipPlanes; + GS[2] = TfToken(); + + uint8_t fsIndex = 0; + FS[fsIndex++] = _tokens->renderPassCamera; + FS[fsIndex++] = _tokens->renderPassCameraFS; + + if (renderColor) { + FS[fsIndex++] = _tokens->selectionDecodeUtils; + FS[fsIndex++] = _tokens->selectionComputeColor; + FS[fsIndex++] = _tokens->renderPassApplyColorOverrides; + FS[fsIndex++] = _tokens->renderPassRenderColor; + } else { + FS[fsIndex++] = _tokens->renderPassNoSelection; + FS[fsIndex++] = _tokens->renderPassNoColorOverrides; + FS[fsIndex++] = _tokens->renderPassRenderColorNoOp; + } + + if (renderId) { + FS[fsIndex++] = _tokens->renderPassRenderId; + } else { + FS[fsIndex++] = _tokens->renderPassRenderIdNoOp; + } + + if (renderNeye) { + FS[fsIndex++] = _tokens->renderPassRenderNeye; + } else { + FS[fsIndex++] = _tokens->renderPassRenderNeyeNoOp; + } + + FS[fsIndex++] = _tokens->renderPassRenderOutput; + FS[fsIndex++] = TfToken(); +} + +HdSt_RenderPassShaderKey::~HdSt_RenderPassShaderKey() = default; + +std::string +HdSt_RenderPassShaderKey::GetGlslfxString() const +{ + std::stringstream ss; + + ss << "-- glslfx version 0.1\n"; + + if (!GetGlslfxFilename().IsEmpty()) { + ss << "#import $TOOLS/hdSt/shaders/" + << GetGlslfxFilename().GetText() << "\n"; + } + // Additionally need one more import. + ss << "#import $TOOLS/hdx/shaders/" << _tokens->selectionGlslfx << "\n"; + + ss << "-- configuration\n" + << "{\"techniques\": {\"default\": {\n"; + + bool firstStage = true; + ss << _JoinTokens("vertexShader", GetVS(), &firstStage); + ss << _JoinTokens("tessControlShader", GetTCS(), &firstStage); + ss << _JoinTokens("tessEvalShader", GetTES(), &firstStage); + ss << _JoinTokens("postTessControlShader", GetPTCS(), &firstStage); + ss << _JoinTokens("postTessVertexShader", GetPTVS(), &firstStage); + ss << _JoinTokens("geometryShader", GetGS(), &firstStage); + ss << _JoinTokens("fragmentShader", GetFS(), &firstStage); + ss << "}}}\n"; + + return ss.str(); +} + + +PXR_NAMESPACE_CLOSE_SCOPE \ No newline at end of file diff --git a/pxr/imaging/hdSt/renderPassShaderKey.h b/pxr/imaging/hdSt/renderPassShaderKey.h new file mode 100644 index 0000000000..151dbb19ca --- /dev/null +++ b/pxr/imaging/hdSt/renderPassShaderKey.h @@ -0,0 +1,54 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +#ifndef PXR_IMAGING_HD_ST_RENDER_PASS_SHADER_KEY_H +#define PXR_IMAGING_HD_ST_RENDER_PASS_SHADER_KEY_H + +#include "pxr/pxr.h" +#include "pxr/imaging/hdSt/geometricShader.h" +#include "pxr/imaging/hdSt/shaderKey.h" +#include "pxr/imaging/hd/aov.h" +#include "pxr/base/tf/token.h" + +PXR_NAMESPACE_OPEN_SCOPE + +struct HdSt_RenderPassShaderKey : public HdSt_ShaderKey +{ + HDST_API + HdSt_RenderPassShaderKey(const HdRenderPassAovBindingVector& aovBindings); + HDST_API + ~HdSt_RenderPassShaderKey(); + + TfToken const &GetGlslfxFilename() const override { return glslfx; } + TfToken const *GetVS() const override { return VS; } + TfToken const *GetPTCS() const override { return PTCS; } + TfToken const *GetPTVS() const override { return PTVS; } + TfToken const *GetTCS() const override { return TCS; } + TfToken const *GetTES() const override { return TES; } + TfToken const *GetGS() const override { return GS; } + TfToken const *GetFS() const override { return FS; } + + HDST_API + std::string GetGlslfxString() const override; + + // Unused for HdSt_RenderPassShaderKey. + HdSt_GeometricShader::PrimitiveType GetPrimitiveType() const override { + return HdSt_GeometricShader::PrimitiveType::PRIM_POINTS; + } + + TfToken glslfx; + TfToken VS[3]; + TfToken PTCS[2]; + TfToken PTVS[3]; + TfToken TCS[2]; + TfToken TES[3]; + TfToken GS[3]; + TfToken FS[10]; +}; + +PXR_NAMESPACE_CLOSE_SCOPE + +#endif // PXR_IMAGING_HD_ST_RENDER_PASS_SHADER_KEY_H \ No newline at end of file diff --git a/pxr/imaging/hdSt/renderPassState.cpp b/pxr/imaging/hdSt/renderPassState.cpp index 1cd4918f4d..189a0a7ee7 100644 --- a/pxr/imaging/hdSt/renderPassState.cpp +++ b/pxr/imaging/hdSt/renderPassState.cpp @@ -490,11 +490,11 @@ HdStRenderPassState::SetLightingShader(HdStLightingShaderSharedPtr const &lighti } void -HdStRenderPassState::SetRenderPassShader(HdStRenderPassShaderSharedPtr const &renderPassShader) +HdStRenderPassState::SetRenderPassShader( + HdStRenderPassShaderSharedPtr const &renderPassShader) { _renderPassShader = renderPassShader; if (_renderPassStateBar) { - HdStBufferArrayRangeSharedPtr _renderPassStateBar_ = std::static_pointer_cast (_renderPassStateBar); @@ -856,6 +856,10 @@ GfVec4f _ToVec4f(const VtValue &v) const double val = v.UncheckedGet(); return GfVec4f(val); } + if (v.IsHolding()) { + const double val = v.UncheckedGet(); + return GfVec4f(val); + } if (v.IsHolding()) { const GfVec2f val = v.UncheckedGet(); return GfVec4f(val[0], val[1], 0.0, 1.0); diff --git a/pxr/imaging/hdSt/resourceRegistry.cpp b/pxr/imaging/hdSt/resourceRegistry.cpp index b4a06ded12..cc62846c3c 100644 --- a/pxr/imaging/hdSt/resourceRegistry.cpp +++ b/pxr/imaging/hdSt/resourceRegistry.cpp @@ -11,6 +11,7 @@ #include "pxr/imaging/hdSt/dispatchBuffer.h" #include "pxr/imaging/hdSt/glslProgram.h" #include "pxr/imaging/hdSt/interleavedMemoryManager.h" +#include "pxr/imaging/hdSt/renderPassShader.h" #include "pxr/imaging/hdSt/resourceRegistry.h" #include "pxr/imaging/hdSt/stagingBuffer.h" #include "pxr/imaging/hdSt/vboMemoryManager.h" @@ -137,6 +138,7 @@ HdStResourceRegistry::~HdStResourceRegistry() void HdStResourceRegistry::InvalidateShaderRegistry() { _geometricShaderRegistry.Invalidate(); + _renderPassShaderRegistry.Invalidate(); _glslfxFileRegistry.Invalidate(); #ifdef PXR_MATERIALX_SUPPORT_ENABLED _materialXShaderRegistry.Invalidate(); @@ -633,6 +635,13 @@ HdStResourceRegistry::RegisterGeometricShader( return _geometricShaderRegistry.GetInstance(id); } +HdInstance +HdStResourceRegistry::RegisterRenderPassShader( + HdInstance::ID id) +{ + return _renderPassShaderRegistry.GetInstance(id); +} + HdInstance HdStResourceRegistry::RegisterGLSLProgram( HdInstance::ID id) @@ -1097,6 +1106,7 @@ HdStResourceRegistry::_GarbageCollect() // Cleanup Shader registries _geometricShaderRegistry.GarbageCollect(); + _renderPassShaderRegistry.GarbageCollect(); _glslProgramRegistry.GarbageCollect(); _glslfxFileRegistry.GarbageCollect(); #ifdef PXR_MATERIALX_SUPPORT_ENABLED diff --git a/pxr/imaging/hdSt/resourceRegistry.h b/pxr/imaging/hdSt/resourceRegistry.h index d6f2b7e15c..ae2e10a6b3 100644 --- a/pxr/imaging/hdSt/resourceRegistry.h +++ b/pxr/imaging/hdSt/resourceRegistry.h @@ -49,6 +49,8 @@ using HdStShaderCodePtr = std::weak_ptr; using HdSt_GeometricShaderSharedPtr = std::shared_ptr; +using HdStRenderPassShaderSharedPtr = + std::shared_ptr; using HdStTextureHandleSharedPtr = std::shared_ptr; @@ -396,6 +398,11 @@ class HdStResourceRegistry final : public HdResourceRegistry HdInstance RegisterGeometricShader(HdInstance::ID id); + /// Register a render pass shader. + HDST_API + HdInstance + RegisterRenderPassShader(HdInstance::ID id); + /// Register a GLSL program into the program registry. HDST_API HdInstance @@ -661,6 +668,10 @@ class HdStResourceRegistry final : public HdResourceRegistry // geometric shader registry HdInstanceRegistry _geometricShaderRegistry; + + // render pass shader registry + HdInstanceRegistry + _renderPassShaderRegistry; // glsl shader program registry HdInstanceRegistry diff --git a/pxr/imaging/hdSt/shaderKey.cpp b/pxr/imaging/hdSt/shaderKey.cpp index 2b9dbeec5f..364ed9791c 100644 --- a/pxr/imaging/hdSt/shaderKey.cpp +++ b/pxr/imaging/hdSt/shaderKey.cpp @@ -96,9 +96,10 @@ HdSt_ShaderKey::ComputeHash() const return hash; } -static +/*static*/ std::string -_JoinTokens(const char *stage, TfToken const *tokens, bool *firstStage) +HdSt_ShaderKey::_JoinTokens( + const char *stage, TfToken const *tokens, bool *firstStage) { if ((!tokens) || tokens->IsEmpty()) return std::string(); diff --git a/pxr/imaging/hdSt/shaderKey.h b/pxr/imaging/hdSt/shaderKey.h index fe2d3c699c..36af8b254c 100644 --- a/pxr/imaging/hdSt/shaderKey.h +++ b/pxr/imaging/hdSt/shaderKey.h @@ -20,7 +20,7 @@ PXR_NAMESPACE_OPEN_SCOPE // Abstract interface for geometric shader keys that may be used to // construct a geometric shader. struct HdSt_ShaderKey { - typedef size_t ID; + using ID = size_t; HDST_API virtual ~HdSt_ShaderKey(); @@ -30,11 +30,6 @@ struct HdSt_ShaderKey { HDST_API ID ComputeHash() const; - // Stitches the glslfx filename and the shader stage mixin names into - // a string for consumption by HioGlslfx. - HDST_API - std::string GetGlslfxString() const; - // ------------------------------------------------------------------------- // Virtual interface // ------------------------------------------------------------------------- @@ -45,6 +40,11 @@ struct HdSt_ShaderKey { // define any functions it uses. virtual TfToken const &GetGlslfxFilename() const = 0; + // Stitches the glslfx filename and the shader stage mixin names into + // a string for consumption by HioGlslfx. + HDST_API + virtual std::string GetGlslfxString() const; + // Each shader stage specifies the various mixins to stitch together // via their token names. The Get* flavor of methods return the first // token in the array. @@ -96,8 +96,13 @@ struct HdSt_ShaderKey { // of the face-varying primvar accessors. Only relevant for mesh prims with // face-varying primvars. HDST_API - virtual HdSt_GeometricShader::FvarPatchType GetFvarPatchType() const; + virtual HdSt_GeometricShader::FvarPatchType GetFvarPatchType() const; +protected: + + HDST_API + static std::string _JoinTokens( + const char *stage, TfToken const *tokens, bool *firstStage); }; diff --git a/pxr/imaging/hdSt/shaders/renderPass.glslfx b/pxr/imaging/hdSt/shaders/renderPass.glslfx index 95433df404..c1d180b4fe 100644 --- a/pxr/imaging/hdSt/shaders/renderPass.glslfx +++ b/pxr/imaging/hdSt/shaders/renderPass.glslfx @@ -233,6 +233,17 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) return color; } +-- glsl RenderPass.RenderOutput + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + -- layout RenderPass.RenderColor [ @@ -241,23 +252,76 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -- glsl RenderPass.RenderColor -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } +-- glsl RenderPass.RenderColorNoOp + +void RenderColor(vec4 color) +{ + // do nothing +} + -- layout RenderPass.RenderId +[ + ["out", "int", "primIdOut"], + ["out", "int", "instanceIdOut"] +] + +-- glsl RenderPass.RenderId + +void RenderId() +{ + primIdOut = HdGet_primID(); + + // instanceIndex is a tuple of integers (num nested levels). + // for picking, we store global instanceId (instanceIndex[0]) in the + // selection framebuffer and then reconstruct the tuple in postprocess. + instanceIdOut = GetDrawingCoord().instanceIndex[0]; +} + +-- glsl RenderPass.RenderIdNoOp + +void RenderId() +{ + // do nothing +} + +-- layout RenderPass.RenderNeye + +[ + ["out", "vec4", "NeyeOut"] +] + +-- glsl RenderPass.RenderNeye + +void RenderNeye(vec3 Neye) +{ + NeyeOut = vec4(Neye, 1.0); +} + +-- glsl RenderPass.RenderNeyeNoOp + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + +-- layout RenderPass.RenderIdNoIdAov + [ ["out", "vec4", "primIdOut"], ["out", "vec4", "instanceIdOut"] ] --- glsl RenderPass.RenderId +-- glsl RenderPass.RenderIdNoIdAov -// XXX: This whole snippet is a little sketchy and should ideally be replaced -// with AoVs. We generate "primId" and "instanceId", and depending on how -// the client called glDrawBuffers, they will get one or both. +// XXX: This snippet is legacy code soon to be deprecated. It is used when the +// client asks for an id render using HdxRenderTaskParams rather than via an id +// aov. vec4 IntToVec4(int id) { @@ -282,4 +346,4 @@ void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) // selection framebuffer and then reconstruct the tuple in postprocess. int instanceId = GetDrawingCoord().instanceIndex[0]; instanceIdOut = IntToVec4(instanceId); -} +} \ No newline at end of file diff --git a/pxr/imaging/hdSt/shaders/renderPassShader.glslfx b/pxr/imaging/hdSt/shaders/renderPassShader.glslfx index cae3277529..dc1961135d 100644 --- a/pxr/imaging/hdSt/shaders/renderPassShader.glslfx +++ b/pxr/imaging/hdSt/shaders/renderPassShader.glslfx @@ -43,7 +43,10 @@ "RenderPass.CameraFS", "RenderPass.NoSelection", "RenderPass.ApplyColorOverrides", - "RenderPass.RenderColor" ] + "RenderPass.RenderColor", + "RenderPass.RenderIdNoOp", + "RenderPass.RenderNeyeNoOp", + "RenderPass.RenderOutput"] } } } diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp b/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp index c968776adc..9cffd2b109 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp @@ -16,15 +16,20 @@ #include "pxr/imaging/hdSt/meshShaderKey.h" #include "pxr/imaging/hdSt/package.h" #include "pxr/imaging/hdSt/pointsShaderKey.h" +#include "pxr/imaging/hdSt/renderDelegate.h" #include "pxr/imaging/hdSt/renderPassShader.h" #include "pxr/imaging/hdSt/resourceBinder.h" #include "pxr/imaging/hdSt/resourceRegistry.h" #include "pxr/imaging/hd/drawingCoord.h" +#include "pxr/imaging/hd/driver.h" #include "pxr/imaging/hd/basisCurves.h" +#include "pxr/imaging/hd/renderIndex.h" #include "pxr/imaging/hd/rprimSharedData.h" #include "pxr/imaging/hd/tokens.h" +#include "pxr/imaging/hgi/tokens.h" + #include "pxr/imaging/glf/testGLContext.h" #include "pxr/imaging/hio/glslfx.h" #include "pxr/base/tf/errorMark.h" @@ -70,8 +75,13 @@ CodeGenTest(HdSt_ShaderKey const &key, bool instance, bool smoothNormals) HdStDrawItem drawItem(&sharedData); static HgiUniquePtr hgi = Hgi::CreatePlatformDefaultHgi(); - static HdStResourceRegistrySharedPtr registry( - new HdStResourceRegistry(hgi.get())); + static HdDriver driver{HgiTokens->renderDriver, VtValue(hgi.get())}; + static HdStRenderDelegate renderDelegate; + static std::unique_ptr index( + HdRenderIndex::New(&renderDelegate, {&driver})); + HdStResourceRegistrySharedPtr const & registry = + std::static_pointer_cast( + index->GetResourceRegistry()); HdDrawingCoord *drawingCoord = drawItem.GetDrawingCoord(); diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out index e3ec0a77c9..955e677491 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_curves_indirect.out @@ -2385,12 +2385,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out index 294b7071e9..86d45a5143 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly.out @@ -1967,12 +1967,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif @@ -4689,12 +4714,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out index d962cc16e9..abbd8a00e8 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_edgeonly_blendwireframe.out @@ -1967,12 +1967,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif @@ -4695,12 +4720,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out index 7ee8a125f8..250423a51c 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect.out @@ -1967,12 +1967,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif @@ -4640,12 +4665,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out index 5776e78e69..531ef99eea 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_doubleSided.out @@ -1967,12 +1967,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif @@ -4639,12 +4664,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out index 7ee8a125f8..250423a51c 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_faceVarying.out @@ -1967,12 +1967,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif @@ -4640,12 +4665,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out index 9960bc8fe8..30328f80d7 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_instance.out @@ -2072,12 +2072,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif @@ -4850,12 +4875,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out index 3b23416cb3..abaa7580fd 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_mesh_indirect_smoothNormals.out @@ -1967,12 +1967,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif @@ -4640,12 +4665,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out index ebd462d16f..074b689687 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_GL/baseline/codegen_points_indirect.out @@ -1532,12 +1532,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out index c7b6f0e0d5..5b7c6b3359 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_curves_indirect.out @@ -2366,12 +2366,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out index b9234ebf1a..2a3b4cf9c2 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly.out @@ -1953,12 +1953,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif @@ -4661,12 +4686,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out index bf10479360..ac333842a2 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_edgeonly_blendwireframe.out @@ -1953,12 +1953,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif @@ -4667,12 +4692,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out index f95f474377..27706fa6cd 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect.out @@ -1953,12 +1953,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif @@ -4612,12 +4637,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out index 3ca7b27104..fbb7744dce 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_doubleSided.out @@ -1953,12 +1953,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif @@ -4611,12 +4636,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out index f95f474377..27706fa6cd 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_faceVarying.out @@ -1953,12 +1953,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif @@ -4612,12 +4637,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out index 607e326867..ae48e42cba 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_instance.out @@ -2058,12 +2058,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif @@ -4822,12 +4847,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out index e5807d1ad8..e544b38e41 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_mesh_indirect_smoothNormals.out @@ -1953,12 +1953,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif @@ -4612,12 +4637,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out index 17c0dd2246..3dae5bf8e6 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen_Vulkan/baseline/codegen_points_indirect.out @@ -1523,12 +1523,37 @@ vec4 ApplyColorOverridesPostLighting(vec4 color) -void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +void RenderColor(vec4 color) { colorOut = color; } + +void RenderId() +{ + // do nothing +} + + + +void RenderNeye(vec3 Neye) +{ + // do nothing +} + + + +void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) +{ + // Write to any desired AOVs here. The render pass shader configuation + // decides if any of these are no-ops. + RenderColor(color); + RenderId(); + RenderNeye(Neye); +} + + #ifndef HD_HAS_integrateLights #define HD_HAS_integrateLights #endif diff --git a/pxr/imaging/hdSt/testenv/testHdStCurvesPrimvars.cpp b/pxr/imaging/hdSt/testenv/testHdStCurvesPrimvars.cpp index 04c9bd3c6b..dd9c9fd0bb 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCurvesPrimvars.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStCurvesPrimvars.cpp @@ -27,8 +27,6 @@ PXR_NAMESPACE_USING_DIRECTIVE -HdStResourceRegistrySharedPtr registry; - template static VtArray _BuildArray(T values[], int numValues) @@ -58,6 +56,7 @@ _CompareArrays(VtArray const & result, static bool _ComparePoints(std::string const & name, + HdStResourceRegistrySharedPtr const & registry, VtIntArray numVerts, VtIntArray indices, VtVec3fArray points, VtVec3fArray expected) { @@ -100,6 +99,7 @@ _ComparePoints(std::string const & name, static bool _CompareVertexPrimvar(std::string const & name, + HdStResourceRegistrySharedPtr const & registry, VtIntArray numVerts, VtIntArray indices, VtFloatArray primvar, VtFloatArray expected) { @@ -140,7 +140,7 @@ _CompareVertexPrimvar(std::string const & name, } bool -TopologyWithIndicesTest() +TopologyWithIndicesTest(HdStResourceRegistrySharedPtr const & registry) { { int numVerts[] = { 11 }; @@ -163,6 +163,7 @@ TopologyWithIndicesTest() GfVec3f(0, 0, 6) }; if (!_ComparePoints("topology_w_indices_points_small", + registry, _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), _BuildArray(indices, sizeof(indices)/sizeof(int)), _BuildArray(points, sizeof(points)/sizeof(GfVec3f)), @@ -187,6 +188,7 @@ TopologyWithIndicesTest() GfVec3f(0, 0, 10) }; if (!_ComparePoints("topology_w_indices_points_equal", + registry, _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), _BuildArray(indices, sizeof(indices)/sizeof(int)), _BuildArray(points, sizeof(points)/sizeof(GfVec3f)), @@ -224,6 +226,7 @@ TopologyWithIndicesTest() GfVec3f(0, 0, 9) }; if (!_ComparePoints("topology_w_indices_points_big", + registry, _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), _BuildArray(indices, sizeof(indices)/sizeof(int)), _BuildArray(points, sizeof(points)/sizeof(GfVec3f)), @@ -248,6 +251,7 @@ TopologyWithIndicesTest() std::fill_n(expected, 10, GfVec3f(1, 0, 0)); if (!_ComparePoints("topology_w_indices_points_insufficient", + registry, _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), _BuildArray(indices, sizeof(indices)/sizeof(int)), _BuildArray(points, sizeof(points)/sizeof(GfVec3f)), @@ -262,6 +266,7 @@ TopologyWithIndicesTest() float primvar[] = { 0, 1, 2, 3, 4, 5, 6}; float expected[] = { 0, 1, 2, 3, 4, 5, 6}; if (!_CompareVertexPrimvar("topology_w_indices_primvar_small", + registry, _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), _BuildArray(indices, sizeof(indices)/sizeof(int)), _BuildArray(primvar, sizeof(primvar)/sizeof(float)), @@ -275,6 +280,7 @@ TopologyWithIndicesTest() int indices[] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; float primvar[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; if (!_CompareVertexPrimvar("topology_w_indices_primvar_equal", + registry, _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), _BuildArray(indices, sizeof(indices)/sizeof(int)), _BuildArray(primvar, sizeof(primvar)/sizeof(float)), @@ -289,6 +295,7 @@ TopologyWithIndicesTest() float primvar[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; float expected[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; if (!_CompareVertexPrimvar("topology_w_indices_primvar_big", + registry, _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), _BuildArray(indices, sizeof(indices)/sizeof(int)), _BuildArray(primvar, sizeof(primvar)/sizeof(float)), @@ -307,6 +314,7 @@ TopologyWithIndicesTest() float expected[9]; std::fill_n(expected, 9, 0); if (!_CompareVertexPrimvar("topology_w_indices_primvar_insufficient", + registry, _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), _BuildArray(indices, sizeof(indices)/sizeof(int)), _BuildArray(primvar, sizeof(primvar)/sizeof(float)), @@ -326,10 +334,11 @@ int main() TfErrorMark mark; static HgiUniquePtr _hgi = Hgi::CreatePlatformDefaultHgi(); - registry = std::make_shared(_hgi.get()); + HdStResourceRegistrySharedPtr registry = + std::make_shared(_hgi.get()); bool success = true; - success &= TopologyWithIndicesTest(); + success &= TopologyWithIndicesTest(registry); registry->GarbageCollect(); registry.reset(); diff --git a/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp b/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp index 75bfc5c78e..3c86714807 100644 --- a/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp @@ -15,17 +15,22 @@ #include "pxr/imaging/hdSt/renderPass.h" #include "pxr/imaging/hdSt/renderPassShader.h" #include "pxr/imaging/hdSt/resourceRegistry.h" +#include "pxr/imaging/hdSt/renderDelegate.h" #include "pxr/imaging/hdSt/tokens.h" #include "pxr/imaging/hdSt/unitTestHelper.h" #include "pxr/imaging/hdSt/geometricShader.h" +#include "pxr/imaging/hd/driver.h" #include "pxr/imaging/hd/mesh.h" #include "pxr/imaging/hd/perfLog.h" +#include "pxr/imaging/hd/renderIndex.h" #include "pxr/imaging/hd/renderPassState.h" #include "pxr/imaging/hd/rprimSharedData.h" #include "pxr/imaging/hd/tokens.h" #include "pxr/imaging/hd/vtBufferSource.h" +#include "pxr/imaging/hgi/tokens.h" + #include "pxr/imaging/hio/glslfx.h" #include "pxr/imaging/glf/testGLContext.h" @@ -55,10 +60,13 @@ static HdSt_MaterialNetworkShaderSharedPtr _GetFallbackShader() static HdStResourceRegistrySharedPtr _GetResourceRegistry() { static HgiUniquePtr _hgi = Hgi::CreatePlatformDefaultHgi(); - static HdStResourceRegistrySharedPtr _resourceRegistry = - std::make_shared(_hgi.get()); + static HdDriver _driver{HgiTokens->renderDriver, VtValue(_hgi.get())}; + static HdStRenderDelegate _renderDelegate; + static std::unique_ptr _index( + HdRenderIndex::New(&_renderDelegate, {&_driver})); - return _resourceRegistry; + return std::static_pointer_cast( + _index->GetResourceRegistry()); } template diff --git a/pxr/imaging/hdSt/testenv/testHdStDynamicUvTexture.cpp b/pxr/imaging/hdSt/testenv/testHdStDynamicUvTexture.cpp index a899def894..59b135617b 100644 --- a/pxr/imaging/hdSt/testenv/testHdStDynamicUvTexture.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStDynamicUvTexture.cpp @@ -40,8 +40,6 @@ class My_TestGLDrawing : public HdSt_UnitTestGLDrawing private: std::unique_ptr _driver; - - std::unique_ptr _hdStRegistry; std::unique_ptr _textureHandleRegistry; }; @@ -49,9 +47,9 @@ void My_TestGLDrawing::InitTest() { _driver = std::make_unique(); - _hdStRegistry = std::make_unique(_driver->GetHgi()); _textureHandleRegistry = - std::make_unique(_hdStRegistry.get()); + std::make_unique( + _driver->GetResourceRegistry().get()); } template diff --git a/pxr/imaging/hdSt/testenv/testHdStMeshTopology.cpp b/pxr/imaging/hdSt/testenv/testHdStMeshTopology.cpp index 145488da61..a24387c41f 100644 --- a/pxr/imaging/hdSt/testenv/testHdStMeshTopology.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStMeshTopology.cpp @@ -8,19 +8,24 @@ #include "pxr/imaging/hdSt/flatNormals.h" #include "pxr/imaging/hdSt/meshTopology.h" #include "pxr/imaging/hdSt/quadrangulate.h" +#include "pxr/imaging/hdSt/renderDelegate.h" +#include "pxr/imaging/hdSt/resourceRegistry.h" #include "pxr/imaging/hdSt/smoothNormals.h" #include "pxr/imaging/hdSt/triangulate.h" #include "pxr/imaging/hdSt/vertexAdjacency.h" #include "pxr/imaging/hd/bufferSource.h" +#include "pxr/imaging/hd/driver.h" #include "pxr/imaging/hd/smoothNormals.h" #include "pxr/imaging/hd/flatNormals.h" +#include "pxr/imaging/hd/renderIndex.h" #include "pxr/imaging/hd/tokens.h" #include "pxr/imaging/hd/vertexAdjacency.h" #include "pxr/imaging/hd/vtBufferSource.h" -#include "pxr/imaging/hdSt/resourceRegistry.h" #include "pxr/imaging/glf/testGLContext.h" +#include "pxr/imaging/hgi/tokens.h" + #include "pxr/usd/sdf/path.h" #include "pxr/base/gf/math.h" @@ -977,7 +982,12 @@ int main() TfErrorMark mark; static HgiUniquePtr _hgi = Hgi::CreatePlatformDefaultHgi(); - registry = std::make_shared(_hgi.get()); + HdDriver driver{HgiTokens->renderDriver, VtValue(_hgi.get())}; + HdStRenderDelegate renderDelegate; + std::unique_ptr index( + HdRenderIndex::New(&renderDelegate, {&driver})); + registry = std::static_pointer_cast( + index->GetResourceRegistry()); bool success = true; success &= BasicTest(); diff --git a/pxr/imaging/hdSt/testenv/testHdStPrimitiveParam.cpp b/pxr/imaging/hdSt/testenv/testHdStPrimitiveParam.cpp index 8534141911..a12555a4ef 100644 --- a/pxr/imaging/hdSt/testenv/testHdStPrimitiveParam.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStPrimitiveParam.cpp @@ -7,15 +7,19 @@ #include "pxr/imaging/hdSt/meshTopology.h" #include "pxr/imaging/hdSt/quadrangulate.h" +#include "pxr/imaging/hdSt/renderDelegate.h" +#include "pxr/imaging/hdSt/resourceRegistry.h" #include "pxr/imaging/hd/bufferSource.h" +#include "pxr/imaging/hd/driver.h" #include "pxr/imaging/hd/meshUtil.h" #include "pxr/imaging/hd/perfLog.h" +#include "pxr/imaging/hd/renderIndex.h" #include "pxr/imaging/hd/tokens.h" #include "pxr/imaging/hd/vtBufferSource.h" -#include "pxr/imaging/hdSt/resourceRegistry.h" #include "pxr/imaging/glf/testGLContext.h" #include "pxr/imaging/hgi/hgi.h" +#include "pxr/imaging/hgi/tokens.h" #include "pxr/base/gf/math.h" #include "pxr/base/gf/vec2i.h" @@ -349,8 +353,13 @@ int main() TfErrorMark mark; - std::unique_ptr hgi = Hgi::CreatePlatformDefaultHgi(); - registry = std::make_shared(hgi.get()); + HgiUniquePtr hgi = Hgi::CreatePlatformDefaultHgi(); + HdDriver driver{HgiTokens->renderDriver, VtValue(hgi.get())}; + HdStRenderDelegate renderDelegate; + std::unique_ptr index( + HdRenderIndex::New(&renderDelegate, {&driver})); + registry = std::static_pointer_cast( + index->GetResourceRegistry()); bool success = true; success &= PrimitiveIDMapTest(); diff --git a/pxr/imaging/hdSt/testenv/testHdStQuadrangulation.cpp b/pxr/imaging/hdSt/testenv/testHdStQuadrangulation.cpp index 569d7ad69c..9fc247972e 100644 --- a/pxr/imaging/hdSt/testenv/testHdStQuadrangulation.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStQuadrangulation.cpp @@ -9,12 +9,16 @@ #include "pxr/imaging/hdSt/meshTopology.h" #include "pxr/imaging/hd/bufferSource.h" +#include "pxr/imaging/hd/driver.h" #include "pxr/imaging/hd/perfLog.h" #include "pxr/imaging/hd/tokens.h" #include "pxr/imaging/hd/types.h" +#include "pxr/imaging/hd/renderIndex.h" #include "pxr/imaging/hd/vtBufferSource.h" #include "pxr/imaging/hdSt/resourceRegistry.h" +#include "pxr/imaging/hdSt/renderDelegate.h" #include "pxr/imaging/glf/testGLContext.h" +#include "pxr/imaging/hgi/tokens.h" #include "pxr/base/gf/math.h" #include "pxr/base/gf/vec3d.h" @@ -75,8 +79,13 @@ _CompareQuadPoints(std::string const & name, std::cout << "GPU quadrangulate = " << gpu << "\n"; static HgiUniquePtr _hgi = Hgi::CreatePlatformDefaultHgi(); - static HdStResourceRegistrySharedPtr registry( - new HdStResourceRegistry(_hgi.get())); + static HdDriver driver{HgiTokens->renderDriver, VtValue(_hgi.get())}; + static HdStRenderDelegate renderDelegate; + static std::unique_ptr index( + HdRenderIndex::New(&renderDelegate, {&driver})); + HdStResourceRegistrySharedPtr const& registry = + std::static_pointer_cast( + index->GetResourceRegistry()); HdMeshTopology m(_tokens->bilinear, TfToken(orientation), numVerts, verts); diff --git a/pxr/imaging/hdSt/testenv/testHdStSamplerObjectRegistry.cpp b/pxr/imaging/hdSt/testenv/testHdStSamplerObjectRegistry.cpp index 4386fe78d5..6c3e0c34fe 100644 --- a/pxr/imaging/hdSt/testenv/testHdStSamplerObjectRegistry.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStSamplerObjectRegistry.cpp @@ -45,11 +45,12 @@ void My_TestGLDrawing::InitTest() { _driver = std::make_unique(); - _hdStRegistry = std::make_unique(_driver->GetHgi()); _textureRegistry = - std::make_unique(_hdStRegistry.get()); + std::make_unique( + _driver->GetResourceRegistry().get()); _samplerRegistry = - std::make_unique(_hdStRegistry.get()); + std::make_unique( + _driver->GetResourceRegistry().get()); } template diff --git a/pxr/imaging/hdSt/testenv/testHdStSubdivision.cpp b/pxr/imaging/hdSt/testenv/testHdStSubdivision.cpp index 52c3b2c0e3..7662359005 100644 --- a/pxr/imaging/hdSt/testenv/testHdStSubdivision.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStSubdivision.cpp @@ -7,10 +7,13 @@ #include "pxr/imaging/hdSt/subdivision.h" #include "pxr/imaging/hdSt/meshTopology.h" +#include "pxr/imaging/hdSt/renderDelegate.h" #include "pxr/imaging/hd/bufferSource.h" +#include "pxr/imaging/hd/driver.h" #include "pxr/imaging/hd/meshUtil.h" #include "pxr/imaging/hd/perfLog.h" +#include "pxr/imaging/hd/renderIndex.h" #include "pxr/imaging/hd/tokens.h" #include "pxr/imaging/hd/vtBufferSource.h" #include "pxr/imaging/hdSt/resourceRegistry.h" @@ -18,6 +21,7 @@ #include "pxr/imaging/pxOsd/tokens.h" #include "pxr/imaging/glf/testGLContext.h" #include "pxr/imaging/hgi/hgi.h" +#include "pxr/imaging/hgi/tokens.h" #include "pxr/base/gf/math.h" #include "pxr/base/gf/vec3d.h" @@ -840,8 +844,13 @@ int main() TfErrorMark mark; - std::unique_ptr hgi = Hgi::CreatePlatformDefaultHgi(); - registry = std::make_shared(hgi.get()); + HgiUniquePtr hgi = Hgi::CreatePlatformDefaultHgi(); + HdDriver driver{HgiTokens->renderDriver, VtValue(hgi.get())}; + HdStRenderDelegate renderDelegate; + std::unique_ptr index( + HdRenderIndex::New(&renderDelegate, {&driver})); + registry = std::static_pointer_cast( + index->GetResourceRegistry()); bool success = true; success &= SubdivisionTest(PxOsdOpenSubdivTokens->catmullClark); diff --git a/pxr/imaging/hdSt/testenv/testHdStTextureHandleRegistry.cpp b/pxr/imaging/hdSt/testenv/testHdStTextureHandleRegistry.cpp index 1cf09a6c4e..7587051a97 100644 --- a/pxr/imaging/hdSt/testenv/testHdStTextureHandleRegistry.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStTextureHandleRegistry.cpp @@ -39,8 +39,6 @@ class My_TestGLDrawing : public HdSt_UnitTestGLDrawing { private: std::unique_ptr _driver; - - std::unique_ptr _hdStRegistry; std::unique_ptr _textureHandleRegistry; }; @@ -48,10 +46,9 @@ void My_TestGLDrawing::InitTest() { _driver = std::make_unique(); - _hdStRegistry = std::make_unique(_driver->GetHgi()); _textureHandleRegistry = - std::make_unique(_hdStRegistry.get()); - + std::make_unique( + _driver->GetResourceRegistry().get()); } template diff --git a/pxr/imaging/hdSt/testenv/testHdStTextureObjectRegistry.cpp b/pxr/imaging/hdSt/testenv/testHdStTextureObjectRegistry.cpp index 0913ebe992..21f48790b6 100644 --- a/pxr/imaging/hdSt/testenv/testHdStTextureObjectRegistry.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStTextureObjectRegistry.cpp @@ -33,8 +33,6 @@ class My_TestGLDrawing : public HdSt_UnitTestGLDrawing { private: std::unique_ptr _driver; - - std::unique_ptr _hdStRegistry; std::unique_ptr _registry; }; @@ -42,9 +40,9 @@ void My_TestGLDrawing::InitTest() { _driver = std::make_unique(); - _hdStRegistry = std::make_unique(_driver->GetHgi()); _registry = - std::make_unique(_hdStRegistry.get()); + std::make_unique( + _driver->GetResourceRegistry().get()); } void diff --git a/pxr/imaging/hdSt/unitTestHelper.cpp b/pxr/imaging/hdSt/unitTestHelper.cpp index 584e3ab940..31f1328ee8 100644 --- a/pxr/imaging/hdSt/unitTestHelper.cpp +++ b/pxr/imaging/hdSt/unitTestHelper.cpp @@ -325,6 +325,11 @@ HdSt_TestLightingShader::SetLight(int light, HdSt_TextureTestDriver::HdSt_TextureTestDriver() : _hgi(Hgi::CreatePlatformDefaultHgi()) + , _hgiDriver{HgiTokens->renderDriver, VtValue(_hgi.get())} + , _renderDelegate() + , _renderIndex(HdRenderIndex::New(&_renderDelegate, {&_hgiDriver})) + , _resourceRegistry(std::static_pointer_cast( + _renderIndex->GetResourceRegistry())) , _indexBuffer() , _vertexBuffer() , _shaderProgram() @@ -353,6 +358,12 @@ HdSt_TextureTestDriver::~HdSt_TextureTestDriver() } } +HdStResourceRegistrySharedPtr const & +HdSt_TextureTestDriver::GetResourceRegistry() +{ + return _resourceRegistry; +} + void HdSt_TextureTestDriver::Draw(HgiTextureHandle const &colorDst, HgiTextureHandle const &inputTexture, diff --git a/pxr/imaging/hdSt/unitTestHelper.h b/pxr/imaging/hdSt/unitTestHelper.h index 6cdc6567aa..61fdc6de45 100644 --- a/pxr/imaging/hdSt/unitTestHelper.h +++ b/pxr/imaging/hdSt/unitTestHelper.h @@ -636,6 +636,9 @@ class HdSt_TextureTestDriver HDST_API Hgi * GetHgi() { return _hgi.get(); } + + HDST_API + HdStResourceRegistrySharedPtr const & GetResourceRegistry(); private: void _CreateShaderProgram(); @@ -648,6 +651,11 @@ class HdSt_TextureTestDriver void _PrintCompileErrors(); HgiUniquePtr _hgi; + HdDriver _hgiDriver; + HdStRenderDelegate _renderDelegate; + std::unique_ptr _renderIndex; + HdStResourceRegistrySharedPtr _resourceRegistry; + HgiBufferHandle _indexBuffer; HgiBufferHandle _vertexBuffer; HgiShaderProgramHandle _shaderProgram; diff --git a/pxr/imaging/hdx/pickTask.cpp b/pxr/imaging/hdx/pickTask.cpp index 55d2e917da..ffa03df24e 100644 --- a/pxr/imaging/hdx/pickTask.cpp +++ b/pxr/imaging/hdx/pickTask.cpp @@ -217,9 +217,7 @@ HdxPickTask::_CreateAovBindings() binding.renderBufferId = aovId; binding.aovSettings = aovDesc.aovSettings; binding.renderBuffer = _pickableAovBuffers.back().get(); - // Clear all color channels to 1, so when cast as int, an unwritten - // pixel is encoded as -1. - binding.clearValue = VtValue(GfVec4f(1)); + binding.clearValue = aovDesc.clearValue; _pickableAovBindings.push_back(binding); diff --git a/pxr/imaging/hdx/renderSetupTask.cpp b/pxr/imaging/hdx/renderSetupTask.cpp index 83c3f679e2..9baea7e93a 100644 --- a/pxr/imaging/hdx/renderSetupTask.cpp +++ b/pxr/imaging/hdx/renderSetupTask.cpp @@ -18,13 +18,12 @@ #include "pxr/imaging/hd/camera.h" #include "pxr/imaging/hdSt/renderPassShader.h" #include "pxr/imaging/hdSt/renderPassState.h" +#include "pxr/imaging/hdSt/resourceRegistry.h" #include "pxr/imaging/hdSt/tokens.h" #include "pxr/imaging/hdSt/volume.h" #include "pxr/imaging/cameraUtil/conformWindow.h" -#include - PXR_NAMESPACE_OPEN_SCOPE static const HioGlslfxSharedPtr & @@ -43,13 +42,15 @@ _GetRenderPassIdGlslfx() return glslfx; } -HdxRenderSetupTask::HdxRenderSetupTask(HdSceneDelegate* delegate, SdfPath const& id) +HdxRenderSetupTask::HdxRenderSetupTask( + HdSceneDelegate* delegate, SdfPath const& id) : HdTask(id) , _colorRenderPassShader( std::make_shared(_GetRenderPassColorGlslfx())) , _idRenderPassShader( std::make_shared(_GetRenderPassIdGlslfx())) , _viewport(0) + , _enableIdRenderFromParams(false) { } @@ -96,6 +97,12 @@ HdxRenderSetupTask::Prepare(HdTaskContext* ctx, HdStVolume::defaultStepSizeLighting); renderPassState->SetVolumeRenderingConstants(stepSize, stepSizeLighting); + if (HdStRenderPassState * const hdStRenderPassState = + dynamic_cast(renderPassState.get())) { + _SetRenderpassShadersForStorm(hdStRenderPassState, + renderIndex->GetResourceRegistry()); + } + renderPassState->Prepare(renderIndex->GetResourceRegistry()); (*ctx)[HdxTokens->renderPassState] = VtValue(_renderPassState); } @@ -110,23 +117,67 @@ HdxRenderSetupTask::Execute(HdTaskContext* ctx) (*ctx)[HdxTokens->renderPassState] = VtValue(_renderPassState); } +static +bool +_AovHasIdSemantic(TfToken const &name) +{ + // For now id render only means primId or instanceId. + return name == HdAovTokens->primId || + name == HdAovTokens->instanceId; +} + void HdxRenderSetupTask::_SetRenderpassShadersForStorm( - HdxRenderTaskParams const ¶ms, - HdStRenderPassState *renderPassState) + HdStRenderPassState *renderPassState, + HdResourceRegistrySharedPtr const &resourceRegistry) { - renderPassState->SetUseSceneMaterials(params.enableSceneMaterials); - if (params.enableIdRender) { + // XXX: This id render codepath will be deprecated soon. + if (_enableIdRenderFromParams) { renderPassState->SetRenderPassShader(_idRenderPassShader); - } else { + return; + // If no aovs are bound, use pre-assembled color render pass shader. + } else if (_aovBindings.empty()) { renderPassState->SetRenderPassShader(_colorRenderPassShader); + return; } + + HdStResourceRegistrySharedPtr const& hdStResourceRegistry = + std::static_pointer_cast(resourceRegistry); + + renderPassState->SetRenderPassShader( + HdStRenderPassShader::CreateRenderPassShaderFromAovs( + renderPassState, + hdStResourceRegistry, + _aovBindings)); } void HdxRenderSetupTask::SyncParams(HdSceneDelegate* delegate, HdxRenderTaskParams const ¶ms) { + _viewport = params.viewport; + _framing = params.framing; + _overrideWindowPolicy = params.overrideWindowPolicy; + _cameraId = params.camera; + _aovBindings = params.aovBindings; + _aovInputBindings = params.aovInputBindings; + + // Inspect aovs to see if we're doing an id render. + bool usingIdAov = false; + for (size_t i = 0; i < _aovBindings.size(); ++i) { + if (_AovHasIdSemantic(_aovBindings[i].aovName)) { + usingIdAov = true; + break; + } + } + + // XXX: For now, we track enabling an id render via params vs. AOV bindings + // as two slightly different states regarding MSAA. We will soon deprecate + // "enableIdRender" as an option, though. + _enableIdRenderFromParams = params.enableIdRender; + const bool enableIdRender = params.enableIdRender || usingIdAov; + const bool enableIdRenderNoIdAov = params.enableIdRender && !usingIdAov; + HdRenderIndex &renderIndex = delegate->GetRenderIndex(); HdRenderPassStateSharedPtr &renderPassState = _GetRenderPassState(&renderIndex); @@ -167,34 +218,34 @@ HdxRenderSetupTask::SyncParams(HdSceneDelegate* delegate, renderPassState->SetBlendConstantColor(params.blendConstantColor); // Don't enable alpha to coverage for id renders. + // XXX: If the list of aovs includes both color and an id aov (such as + // primdId), we still disable alpha to coverage for the render pass, + // which may result in different behavior for the color output compared + // to if the user didn't request an id aov at the same time. + // If this becomes an issue, we'll need to reconsider this approach. renderPassState->SetAlphaToCoverageEnabled( params.enableAlphaToCoverage && - !params.enableIdRender && + !enableIdRender && !TfDebug::IsEnabled(HDX_DISABLE_ALPHA_TO_COVERAGE)); + // For id renders that use an id aov (which use an int format), it's ok + // to have multi-sampling enabled. During the MSAA resolve for integer + // types, a single sample will be selected. renderPassState->SetMultiSampleEnabled( - params.useAovMultiSample && !params.enableIdRender); + params.useAovMultiSample && !enableIdRenderNoIdAov); if (HdStRenderPassState * const hdStRenderPassState = dynamic_cast(renderPassState.get())) { - + hdStRenderPassState->SetUseSceneMaterials( + params.enableSceneMaterials); + // Don't enable multisample for id renders. hdStRenderPassState->SetUseAovMultiSample( - params.useAovMultiSample && !params.enableIdRender); + params.useAovMultiSample && !enableIdRenderNoIdAov); hdStRenderPassState->SetResolveAovMultiSample( params.resolveAovMultiSample); - - _SetRenderpassShadersForStorm( - params, hdStRenderPassState); } } - - _viewport = params.viewport; - _framing = params.framing; - _overrideWindowPolicy = params.overrideWindowPolicy; - _cameraId = params.camera; - _aovBindings = params.aovBindings; - _aovInputBindings = params.aovInputBindings; } void diff --git a/pxr/imaging/hdx/renderSetupTask.h b/pxr/imaging/hdx/renderSetupTask.h index 396b57bfb1..6268917da2 100644 --- a/pxr/imaging/hdx/renderSetupTask.h +++ b/pxr/imaging/hdx/renderSetupTask.h @@ -97,10 +97,11 @@ class HdxRenderSetupTask : public HdTask GfVec4d _viewport; HdRenderPassAovBindingVector _aovBindings; HdRenderPassAovBindingVector _aovInputBindings; + bool _enableIdRenderFromParams; void _SetRenderpassShadersForStorm( - HdxRenderTaskParams const& params, - HdStRenderPassState *renderPassState); + HdStRenderPassState *renderPassState, + HdResourceRegistrySharedPtr const &resourceRegistry); HdRenderPassStateSharedPtr &_GetRenderPassState(HdRenderIndex* renderIndex); diff --git a/pxr/imaging/hdx/shaders/renderPass.glslfx b/pxr/imaging/hdx/shaders/renderPass.glslfx index 9b9e515f79..be46118ac9 100644 --- a/pxr/imaging/hdx/shaders/renderPass.glslfx +++ b/pxr/imaging/hdx/shaders/renderPass.glslfx @@ -125,11 +125,11 @@ void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) -- layout HdxRenderPass.RenderPick [ - ["out", "vec4", "primIdOut"], - ["out", "vec4", "instanceIdOut"], - ["out", "vec4", "elementIdOut"], - ["out", "vec4", "edgeIdOut"], - ["out", "vec4", "pointIdOut"], + ["out", "int", "primIdOut"], + ["out", "int", "instanceIdOut"], + ["out", "int", "elementIdOut"], + ["out", "int", "edgeIdOut"], + ["out", "int", "pointIdOut"], ["out", "vec4", "neyeOut"], ["buffer readWrite", "CounterBuffer", "PickBuffer", ["atomic_int", "PickBuffer"]] ] @@ -156,27 +156,21 @@ FORWARD_DECL(void RenderDeepPicks(int primId, int instanceId, int elementId, int void RenderOutput(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) { - int primId = HdGet_primID(); - primIdOut = IntToVec4(primId); + primIdOut = HdGet_primID(); // instanceIndex is a tuple of integers (num nested levels). // for picking, we store global instanceId (instanceIndex[0]) in the // selection framebuffer and then reconstruct the tuple in postprocess. - int instanceId = GetDrawingCoord().instanceIndex[0]; - instanceIdOut = IntToVec4(instanceId); + instanceIdOut = GetDrawingCoord().instanceIndex[0]; - int elementId = GetElementID(); - int edgeId = GetPrimitiveEdgeId(); - int pointId = GetPointId(); - - elementIdOut = IntToVec4(elementId); - edgeIdOut = IntToVec4(edgeId); - pointIdOut = IntToVec4(pointId); + elementIdOut = GetElementID(); + edgeIdOut = GetPrimitiveEdgeId(); + pointIdOut = GetPointId(); neyeOut = IntToVec4(hd_vec4_2_10_10_10_set(vec4(Neye,0))); #if defined(HD_HAS_PickBuffer) - RenderDeepPicks(primId, instanceId, elementId, edgeId, pointId); + RenderDeepPicks(primIdOut, instanceIdOut, elementIdOut, edgeIdOut, pointIdOut); #endif } diff --git a/pxr/imaging/hdx/shaders/renderPassColorShader.glslfx b/pxr/imaging/hdx/shaders/renderPassColorShader.glslfx index bb05ce38ff..d4b6075937 100644 --- a/pxr/imaging/hdx/shaders/renderPassColorShader.glslfx +++ b/pxr/imaging/hdx/shaders/renderPassColorShader.glslfx @@ -11,7 +11,6 @@ --- #import $TOOLS/hdx/shaders/renderPassColorShader.glslfx #import $TOOLS/hdSt/shaders/renderPass.glslfx -#import $TOOLS/hdx/shaders/renderPass.glslfx #import $TOOLS/hdx/shaders/selection.glslfx -- configuration @@ -46,7 +45,10 @@ "Selection.DecodeUtils", "Selection.ComputeColor", "RenderPass.ApplyColorOverrides", - "RenderPass.RenderColor" ] + "RenderPass.RenderColor", + "RenderPass.RenderIdNoOp", + "RenderPass.RenderNeyeNoOp", + "RenderPass.RenderOutput" ] } } } diff --git a/pxr/imaging/hdx/shaders/renderPassIdShader.glslfx b/pxr/imaging/hdx/shaders/renderPassIdShader.glslfx index 67495226ea..ea45bd8498 100644 --- a/pxr/imaging/hdx/shaders/renderPassIdShader.glslfx +++ b/pxr/imaging/hdx/shaders/renderPassIdShader.glslfx @@ -11,7 +11,6 @@ --- #import $TOOLS/hdx/shaders/renderPassIdShader.glslfx #import $TOOLS/hdSt/shaders/renderPass.glslfx -#import $TOOLS/hdx/shaders/renderPass.glslfx -- configuration { @@ -44,7 +43,7 @@ "RenderPass.CameraFS", "RenderPass.NoSelection", "RenderPass.NoColorOverrides", - "RenderPass.RenderId" ] + "RenderPass.RenderIdNoIdAov"] } } } diff --git a/pxr/imaging/hdx/shaders/renderPassShadowShader.glslfx b/pxr/imaging/hdx/shaders/renderPassShadowShader.glslfx index 967a419f3e..67219ef8df 100644 --- a/pxr/imaging/hdx/shaders/renderPassShadowShader.glslfx +++ b/pxr/imaging/hdx/shaders/renderPassShadowShader.glslfx @@ -11,7 +11,6 @@ --- #import $TOOLS/hdx/shaders/renderPassShadowShader.glslfx #import $TOOLS/hdSt/shaders/renderPass.glslfx -#import $TOOLS/hdx/shaders/renderPass.glslfx -- configuration { @@ -44,7 +43,10 @@ "RenderPass.CameraFS", "RenderPass.NoSelection", "RenderPass.NoColorOverrides", - "RenderPass.RenderColor" ] + "RenderPass.RenderColor", + "RenderPass.RenderIdNoOp", + "RenderPass.RenderNeyeNoOp", + "RenderPass.RenderOutput" ] } } } diff --git a/pxr/imaging/hdx/testenv/testHdxIdRender.cpp b/pxr/imaging/hdx/testenv/testHdxIdRender.cpp index f92b86e503..2678526d23 100644 --- a/pxr/imaging/hdx/testenv/testHdxIdRender.cpp +++ b/pxr/imaging/hdx/testenv/testHdxIdRender.cpp @@ -90,7 +90,6 @@ Hdx_TestDriver::Draw(GfVec4d const &viewport, PickParam const * pickParam) HdxRenderTaskParams param = delegate.GetTaskParam( renderSetupTask, HdTokens->params).Get(); - param.enableIdRender = (pickParam != nullptr); param.viewport = viewport; param.aovBindings = pickParam ? _pickableAovBindings : _aovBindings; delegate.SetTaskParam(renderSetupTask, HdTokens->params, VtValue(param)); diff --git a/pxr/imaging/hgiGL/ops.cpp b/pxr/imaging/hgiGL/ops.cpp index a0473c4797..1f69ecd8b5 100644 --- a/pxr/imaging/hgiGL/ops.cpp +++ b/pxr/imaging/hgiGL/ops.cpp @@ -740,6 +740,16 @@ HgiGLOps::Dispatch(int dimX, int dimY) }; } +static +bool +_IsInt32Format(HgiFormat format) +{ + return (format == HgiFormatInt32) || + (format == HgiFormatInt32Vec2) || + (format == HgiFormatInt32Vec3) || + (format == HgiFormatInt32Vec4); +} + HgiGLOpsFn HgiGLOps::BindFramebufferOp( HgiGLDevice* device, @@ -769,7 +779,19 @@ HgiGLOps::BindFramebufferOp( } if (colorAttachment.loadOp == HgiAttachmentLoadOpClear) { - glClearBufferfv(GL_COLOR, i, colorAttachment.clearValue.data()); + // Special handling for int format used by id renders. + if (_IsInt32Format(colorAttachment.format)) { + GLint clearValue[4] = { + static_cast(colorAttachment.clearValue[0]), + static_cast(colorAttachment.clearValue[1]), + static_cast(colorAttachment.clearValue[2]), + static_cast(colorAttachment.clearValue[3]) + }; + glClearBufferiv(GL_COLOR, i, clearValue); + } else { + glClearBufferfv( + GL_COLOR, i, colorAttachment.clearValue.data()); + } } blendEnabled |= colorAttachment.blendEnabled; diff --git a/pxr/imaging/hgiVulkan/graphicsCmds.cpp b/pxr/imaging/hgiVulkan/graphicsCmds.cpp index 6e76681e5e..d6669206d1 100644 --- a/pxr/imaging/hgiVulkan/graphicsCmds.cpp +++ b/pxr/imaging/hgiVulkan/graphicsCmds.cpp @@ -19,6 +19,16 @@ PXR_NAMESPACE_OPEN_SCOPE +static +bool +_IsInt32Format(HgiFormat format) +{ + return (format == HgiFormatInt32) || + (format == HgiFormatInt32Vec2) || + (format == HgiFormatInt32Vec3) || + (format == HgiFormatInt32Vec4); +} + HgiVulkanGraphicsCmds::HgiVulkanGraphicsCmds( HgiVulkan* hgi, HgiGraphicsCmdsDesc const& desc) @@ -38,10 +48,19 @@ HgiVulkanGraphicsCmds::HgiVulkanGraphicsCmds( for (HgiAttachmentDesc const& attachmentDesc : _descriptor.colorAttachmentDescs) { VkClearValue vkClearValue; - vkClearValue.color.float32[0] = attachmentDesc.clearValue[0]; - vkClearValue.color.float32[1] = attachmentDesc.clearValue[1]; - vkClearValue.color.float32[2] = attachmentDesc.clearValue[2]; - vkClearValue.color.float32[3] = attachmentDesc.clearValue[3]; + + // Special handling for int format used by id renders. + if (_IsInt32Format(attachmentDesc.format)) { + vkClearValue.color.int32[0] = attachmentDesc.clearValue[0]; + vkClearValue.color.int32[1] = attachmentDesc.clearValue[1]; + vkClearValue.color.int32[2] = attachmentDesc.clearValue[2]; + vkClearValue.color.int32[3] = attachmentDesc.clearValue[3]; + } else { + vkClearValue.color.float32[0] = attachmentDesc.clearValue[0]; + vkClearValue.color.float32[1] = attachmentDesc.clearValue[1]; + vkClearValue.color.float32[2] = attachmentDesc.clearValue[2]; + vkClearValue.color.float32[3] = attachmentDesc.clearValue[3]; + } _vkClearValues.push_back(vkClearValue); } diff --git a/pxr/usdImaging/usdImagingGL/engine.cpp b/pxr/usdImaging/usdImagingGL/engine.cpp index 12b4bc6610..bc822e8d1b 100644 --- a/pxr/usdImaging/usdImagingGL/engine.cpp +++ b/pxr/usdImaging/usdImagingGL/engine.cpp @@ -867,15 +867,28 @@ UsdImagingGLEngine::DecodeIntersection( SdfPath *outHitInstancerPath, int *outHitInstanceIndex, HdInstancerContext *outInstancerContext) +{ + const int primIdx = HdxPickTask::DecodeIDRenderColor(primIdColor); + const int instanceIdx = HdxPickTask::DecodeIDRenderColor(instanceIdColor); + + return DecodeIntersection(primIdx, instanceIdx, outHitPrimPath, + outHitInstancerPath, outHitInstanceIndex, outInstancerContext); +} + +bool +UsdImagingGLEngine::DecodeIntersection( + int primIdx, + int instanceIdx, + SdfPath *outHitPrimPath, + SdfPath *outHitInstancerPath, + int *outHitInstanceIndex, + HdInstancerContext *outInstancerContext) { if (ARCH_UNLIKELY(!_renderDelegate)) { return false; } - const int primId = HdxPickTask::DecodeIDRenderColor(primIdColor); - const int instanceIdx = HdxPickTask::DecodeIDRenderColor(instanceIdColor); - - SdfPath primPath = _renderIndex->GetRprimPathFromPrimId(primId); + SdfPath primPath = _renderIndex->GetRprimPathFromPrimId(primIdx); if (primPath.IsEmpty()) { return false; } @@ -1267,6 +1280,7 @@ UsdImagingGLEngine::GetRendererAovs() const { HdAovTokens->primId, HdAovTokens->depth, HdAovTokens->normal, + HdAovTokens->Neye, HdAovTokensMakePrimvar(TfToken("st")) }; TfTokenVector aovs = { HdAovTokens->color }; @@ -1295,6 +1309,20 @@ UsdImagingGLEngine::SetRendererAov(TfToken const &id) return false; } +bool +UsdImagingGLEngine::SetRendererAovs(TfTokenVector const &ids) +{ + if (ARCH_UNLIKELY(!_renderDelegate)) { + return false; + } + + if (_renderIndex->IsBprimTypeSupported(HdPrimTypeTokens->renderBuffer)) { + _taskController->SetRenderOutputs(ids); + return true; + } + return false; +} + HgiTextureHandle UsdImagingGLEngine::GetAovTexture( TfToken const& name) const diff --git a/pxr/usdImaging/usdImagingGL/engine.h b/pxr/usdImaging/usdImagingGL/engine.h index e90410f3cd..1a7ff92e3d 100644 --- a/pxr/usdImaging/usdImagingGL/engine.h +++ b/pxr/usdImaging/usdImagingGL/engine.h @@ -379,7 +379,7 @@ class UsdImagingGLEngine IntersectionResultVector* outResults); /// Decodes a pick result given hydra prim ID/instance ID (like you'd get - /// from an ID render). + /// from an ID render), where ID is represented as a vec4 color. USDIMAGINGGL_API bool DecodeIntersection( unsigned char const primIdColor[4], @@ -389,6 +389,17 @@ class UsdImagingGLEngine int *outHitInstanceIndex = NULL, HdInstancerContext *outInstancerContext = NULL); + /// Decodes a pick result given hydra prim ID/instance ID (like you'd get + /// from an ID render), where ID is represented as a int. + USDIMAGINGGL_API + bool DecodeIntersection( + int primIdx, + int instanceIdx, + SdfPath *outHitPrimPath = NULL, + SdfPath *outHitInstancerPath = NULL, + int *outHitInstanceIndex = NULL, + HdInstancerContext *outInstancerContext = NULL); + /// @} // --------------------------------------------------------------------- @@ -432,6 +443,10 @@ class UsdImagingGLEngine USDIMAGINGGL_API bool SetRendererAov(TfToken const& id); + /// Set the current renderer AOVs to a list of \p ids. + USDIMAGINGGL_API + bool SetRendererAovs(TfTokenVector const &ids); + /// Returns an AOV texture handle for the given token. USDIMAGINGGL_API HgiTextureHandle GetAovTexture(TfToken const& name) const; diff --git a/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLAovVisualization/baseline/testUsdImagingGLAovVisualization_Storm_Neye.png b/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLAovVisualization/baseline/testUsdImagingGLAovVisualization_Storm_Neye.png new file mode 100644 index 0000000000000000000000000000000000000000..9ce3d5b9872285e7603896e292e17442394b864c GIT binary patch literal 55568 zcmeFY`&UwH*fk6+SfDNhH5KpxMx|{l@oZ@VT4?P`JKIq_wow7;# zfi+}liMt6!=0H$2%g%v#!`qO^#Xd8UG=c#tgeAxs2H=q?k&7H!BTOZlFv>R3B3AHk z#s|CuJp;nFS}I=HMkF0~VZ1^(E*|}#CuKb+Mk4)Q`3UiWkv30oD$uuWhQP-aIQI$M zeD50TC5<9Je)h?n_4p7e-DSStW`Nj%GZ4}cA(VXn*#SN@1TjegB%>G4%YbaB85}g+ z{I+^hCh4AcS7Jb}z^3Zk9OZ4mo_xhQ9=tgBJ}_N^NWv9~ z5ieb6P^xAD(qYej)>@~%yM@z)41%;z96O8l#O%JT(%}k7V@BdFR=#f(^f-txO8YuI zD@{g86JLe8SUc8pZ=MlI?zcjTfb!q}xm^L`aZ*w7|J>}p z3%6CPz-_r_2v#w?C>A5o2!x&QNV4o_JLL9?Cs&|5ul z3Xpqd$8xu-Gjs_71Gu8+Z5(aVQcns>>4xSw2r3@#{`dXW5Z&HiOym+{x$?;ETn45% zYXZAu>vhz5TmCk0oR=w{$Tc)5GCp@AH}<`Ne%(p)y%#jLJ=4!|^GXMj5l{*zcQ zl8@oeAYJoUd*i${-r3y9IQ`-~^G(8vV|!Nq@|Jf^+tsW(+gqYCR@l7tar_>abZ*^F zi}m-;#N?cNpY+rDpI5DLMpfVyZAU!4LS<1mPoGs)A+H;qqpo^-g}iv>{YUj}?B%!b z3~+UoE8go(XOK;Odh9uqCqs}_%rAmcgA&Qb`nNl?bK=oO*|y;w-sfKWFbs#V-!>qw zY#ld;Tp|IThXX)=&j&e`(NIeflZ?KJc0?N|;v=K0dUPL#KLCl-y0&EVhJNWb<8q%R zaP{~_j(&VHsaRSrVNG91s@f--HTvC*_n~_kxD~`|e-a7e7gJvDZZZ!jzzO)3`&NBmuZFMKYb zD+~~2P2r<#e%OfZ!%S4i(w^hf*0(aAjUq&)mjPwqOi)Z!lw3`p3_;OCy*JLnQ=ao7 zPHSj>tQb92D6|OQj!Z5-_ztrE;}7#y_x><*guau%ot&7H-RMe}2^;1e5xPVPgbmi3 zW0n}Z^ARjkM-{LIA&k-7VG{AbZM!dAFb}o&Q@1G>G4QAhSYmMkc%N5*tXb1b;AQLl zCz()w1h(E)*^x(uTxS@)(N}sC17cA{-BgyL|1}`CIjGuK4+h7q!OYIt0alvoplzi= zmZkS0yop@z6*T)P>%_43sP7qJH>Y8FXGf22ALgG5*_`HsCjC>u`?ymIS$87mDto&C zXs5L$#1!I5L?eFv9*nYHfNzYZ1?MNAuD?{2oe|G8DGy`3#r>>=aUOA}o)ag*b&V#bqxsrfPa%lEn?y1VO{U~c z^-01lyb;KVdhX9)?Dte%H^j+Je;w=TIJ^rRW?_QcDjwNEB%MMzFSer7(bqe^kiBM7 zNXDGPqO}u9zx6CUQ{CZV(>{p-WSEyBx6N@#YO~Sz`e}zfc;drCt8i}tgGVVV!PIt2 zjvp149G3|9?X%tclGOWrgJXw%^!9)`AGRsann9ubUYDqQryE|}5%vJQj?eb;o*{y! zKMuV(I%LV2I6Wa%YXI!%{3yY*dc~*6KBnS=wwqP#RHtX zdvRfv)PLl0XAo&D=7&S;@RrF8*Nbe^UN!o^7v~W?x+XeGqr7giY1COXM&(b)v?f`u6Iz;No%OZ@hUm>Ml|BQ_}>rl zH09~FYAp3n)!w=lKyvcry`$?9wbKi!1D&gj9HG;lNAd10AHC#=!>(vkqCR72uwmEv z(?w~U$(K!>3>>4l*_4EX#)^cWN|%Q=wY zZ5&r`$iMRFqaw2R+L<0E@9%CZ7wB{44ez%KSZN8v-TB!jWT;ubiQ%ndm=cMxV?aYu zJqb_&O)<7?vG>!^ee92pSGf0GLWGYu~vSan2o zA}=nb)Vy5e5a5)W#5*3dz_i_vR>%8_2#v9s{b{tmx|9-{x!f55Ya*aEh?nJj&MPmq4a_xuLn^=JoLkZjguN$O>kHd~sfE}X_cRC3j`f=p?tC%iT z10qE)tkmTq9R#vwY8IgLcLyG)C&dvYVjsOgQePhlIZnim-ftAVCB{!En`pCWm$dy4 zfw#16?}L=;HHGmPmbJ=aOAyHhWSB7+b)FxCum7$Vcl&eclrBBsce4JPm)yiH@HYh9 z^A6Q?v+yip0@@EvCI_(b3aaA7^jv`-Et~Qv<;En^K#&b7Um&^5luqY?@mc%k0HJ?Q zl@C7f%@}$ym0R%%#an*ht2+p$=4KiDkV@m5bAAY00aB{_^kg0A@I4X)Bj0~#dIQx+ zTsqFU347%!F;-9LN^R61qrM{c?vkS}TlrY=GKYS*ycS3eiZxLiu?4eI(WZy%K=BQQ zUXO+LOjA!{1Ook1Cr@qoTzk3Ac_`@BSn(u(J!S4H?YA6K=Wyo&m?ED!wI}G#5?)QP zVbA>M`q^EYtMJu!-Ef%3LA7w3`8?>L>Evb<37AY2t%M zwq6TrJ(B3e4#oHrRO%$uAXObsts2DsX<~Q@!T`Rf=mQ(i?Ch3Xv1N|Drlk?fU$MLO zN0pcCnbdo^vsGchRKc?kc26xx_W*~SXdyl?UBMY%%`F(S33!F=>TN)D4K(O%H2veq zMumI~**F6lU>+yc=6ZVaP@XR$VDd@T=}*Gg|ASfEgWYV{Y8t~kBGISG`u7CUDO|ns zxcx!P;L)Ktx8i$l42^yY1NVsQSGvm0n^C>Wv3&HiEu+{2_#x3!L9n5|DtFJ|7*cuG zDc%>s7RG#aMyBb7oj~3TbVwM=O2XFer7;LbjHI1!k4dw$LR_?umnM!kaqsV$REv9W zqdd$E$Fsq6e>%`Ce!_KBk2wF@gme(LD3)&4j;%PyLVEQce+~n(Vj}p&Gwu_30OO`xQIx4gZ3(KFO0yUf%Dm+Ee<4- zfSwaAz}uB}IJAo!=Kh{}I;wX6I78Dmuj5=#U@0)5h!_bOyejcMI4EZzUWk#gG0HH*# z_Xm^`qzdco->5fvDES=i8sUrqsEF0l(qtLrA(b>NWHlM}2MD3t@tqOe%5m6zsxrRxJCA~a!lDQfe-x%el1$@5OBx*)ltl%ZL-vdx?U$h zX~9kWKqZQXoCD^fUSCx>jdcrlkGR`7D7S-C!TM(pNIxk^|Ff(^zX6)r3Jz`WDzqQ! z`JP^<;u!($a{j}%wu(5;m*yDizYS_$a8QVX5b)s(X8jaP%7rmPwL~;rDox#@y(Cat0&*%f9i|F|9D|^I(Za2=%#DOaWf}?clGM&L-p!r zD&1{>6$3WO80aM*Jq0>uKV=3NkRtu&W6j;0>lF<21N$`@B!P&OFQSeNm0U#H0JlM z*9J^e61Zaq)IfI7IQX`TQ2qI#C3?e2xPAY8hZLeg9E`J)6 zH8Rw;ZXV~$gBYiO7aSd26RN;x-a4~*As|vc~A!nRbX67~Y0QbS$E02R93%^on;EDU_6;B{X zM-i9%7^|6qF0Rf#wkf>kS1RK$^DAS|lzXB8;vG*gXqmZ%N2JJ7 zWjt6!ZcAH+Ts5p%8leqxW-x?3O^9}j4s4KLp|Aj-eE>)2t!Snst@c+wIXn9ms(g%- zjxcVb1W$d$(XRMy8$I&XE1`AkgvoNV!35mACs+fMYILj)M@wBn)T}}Hny;bV%_j>a zOwcY#B>mv8rGrr6y_}$jHUGU5Ss6(n$ zh&e_54)Px(CBhRu_zFkS$K#Ko!jUP82aSx-Fq1-}sF(fe2yxw?`)+cotp07Bc_H`q z`^#S{?&gPGde{S#qkpF9x$wfb*<@yln|FEuf+QOYK0#Dbq{}Kx|-Q81!+mUeDr(mBSnP%t0rl3n$B#W zoCl2B_`LZ^rEJvl5Km5oDzPdPA=S{}$;2LPhn_-j0EomT}qAUA#oVYbPP-%3);2VpFr5|6JTfqYd zc9Dudc?n>0QNfq(oaTP+vf299acUP1y)pesVTCO)$;3eplUYzJ~rvI#L79=B$V{>6(hMc!!If? z=Y{8Tx#JYHkp73Ft(~uUq^H7IRxK5t5B1idz6KdSPN>&m^*}$r7i{11t!HJqBcizK zc+Q{YXPn>s-9mGXQy_vL6JSzJNW&Sie>IU}B*7XAn`UBWOp#j6F~>R21{YfZ>k{DG zvO#S^bv^So$ymP{?d(3BFC2WZSX^<8^~K}3_S2w;THmb*8U@N;)FY31)J?dz=uWTP z-|)#WSM0sk8q$fWykSD4k>H$(_BFD;MszYw!eiPf|9cjdP^dk;}UM7-B8EoZL7BV4{ z#jfPDT^^$xx5XGOQl|hZ8>c-jgiMK!vE2SvSZX?$U?*>!AT%nLPAgs8oYgl0X{X;l zgC&cXgz8+Ykb7%9Q9h`Eu1ALfh0}0Cbk%!zZld-^z}jC z8LxA)Gkkb8ZyoLaqot})e>A$3sOnsIQN9H_Dw}h*@xfR|;G;f|y z(Wk2j(NUlC%6Rej;ma$kg_61Jz&+qJuIBjy)UG9f`&d0In?y?3P){NiHy*-Foa(+~n_BOPE(>Ph7^oN9oHKI-U%KtZcQ5lDqMeO3Yywto{TnP+r3zhf8-wSL4QvdzyE7d!vQ~5g+Q^QS!Yw$or^rbmua+**EhK} zaCdx|u3Wik0T@X?h}Y=j#wVzm>OkFI68HT<+a_@THAHd(5$}^v*3gP})uh&DjX!KS zK;VR-!Y(~M`yUHh5#$pJW2|5lle)to@-wo&Jm)U2GsWQ9nj;=nD3Qd_LqX>IXi4f$ zcyl<+FtKMk(8NAtByNSk%>|q6*3fLuro&K1?N^besXaXv$q_u5`s}u!A#YH)skk%2 zaxgcfKGQA!QljdwbS}cF)S?<9pGKX3%Fjy+?}_0O0l&{#f+e%D)tFXbBCrtYm36G{ zkgx%(2{0hmr;K7X2m`+3hkfl^{3}Ghzl{k9OA**k1-`7-p1OJxnlZx>Dtfmb8o*kR zNIyhm($h-ne7 z0nf*84fZ@_Yl!HtTq8I$q;M!LA$$6F6r=b#fBDocMy$AvuNC&dvuY-q2)DP`3Lo5Y zcA&_l3_~y735gu|iVQR7a$uGxVz41}7fb_ndQwuHdhM{8XvPbBG5+I8vf!`f-U1Gi zj|$9{-4sv-FW9-UwlV5EBS(5}1<`@m>5&!RnMcI(HEg<|p8c#rIz0xaL78JVx{WCu z5SUFKZv(YS_h&nXaBGkO<;8^wIMSnkx=96}W+1%k2hRMCO+kbtgXi8{g47`Gkr-5i z*rq!!8gmv$UpJLEh0tZ4zhsvetxbMPsg2C9&WJ<%64{bq-K?1Y*#dP1mqcP$2v{xX z6JTE~7c55Eod~}0eeUA-$=VE1n{)9M9%81FN#8c366L~}29&vjT4gK6zx`yf<g!_BG0?1^dTBF8+peZDH=*O?$Znl}{9qRWttGrcRvCSx?JW_}O2l>{g zj~Wy$hGOC1VP_!h!&0ykf1X_G73etwZy$@;NGJ;5qh$cAw2(DqG8%wyr;QJFA59V9 z?D_Mt%GrrdmJxHG$#X!Zwmb`P&VHhkklz*l?x_50%5G>8wUIylXSXR@YQ+L0l?1Vn zE;Jpd(LX@yrEGN)t(J{*HZu@jdO~y0e_+PnodxuF*>TR5u+*{lOfoAr5xmvUst^vP zGD$7*SG|L>Djy-%VsQ=_0~lmKY@@5H@+kTP0{zc;21!fveT=zmhrD_kT_~H*)!=A0 zy3|F}xI{sJyu}xBK_Tb7@c-U#S_fSvMm@$H{uHghoiRfS>~FZcm3<;u$}y^6n1s8o z$5N5;ESUCi^V19hUqp$>vOPQ=P0faaexl#%fu~eYb}?J%XsUo>LKv%JY_Dr*bw!;N;$SW z-Qns+%9IMB?9%WhmXPFP-8c++FyQdEXdkz_&1&F1xYWOT4R=V?OVK1tKYj z24r>+TEr1np<$@wriv?8=ydB*?CcwuAamTwX$b{a2>CPn06+9){TXi^f^anVNn;}{ zK%CW&oTSz|OON+h=uWCzTN)vALNp@?`!gj#;O?M-L5U)XdzG-CLW!)8>O~iOHLOQ8ld46XZY>H4Zdl{%+ zlW8IskbZl9pK_;_`R5bdYLOuq+(gBS&%a}RM>z0IEc~3bdGI8d{MUDW)%o06o4A=4 zCqHiz`xymyUCGA0ooj%Db4Fpl@JY*8mxT7$%#Od~m|=sHH^-w--vfu-)!lqy#dXt~ zC>V6O74{lUN7myeh9n0NNn|r8e-%;$G8a2dzLOjt8LQ>T1u3`6gng#m#Aey_$sf2I zws$so5BR*7h1bZY;+TR@UlA!Wptxt{^LuVaE z?s5}cvgE?Ax!J`#X%g{VB%c z=K-#gOjs5SR>B=Y%I)iCp&@b?Z7I>Y-qGvU`kykZxdG<|X6}3HwA>4*B^(dC|cYQP`OxS+<$W$%-7#__*JY#&3O&$(UUM0$%1UJ^adlg|R%x%*%>L-5fD! zzl)??#^mb`sSko`T~xT2D+ms@Xn!b15`un$EB6vd;7y5w=pN);H6i0fS)-`J5U*bWWg8(k*lAWB*` zoDSK`S8PGvd7H^cmpOA`)IIRonZOhYK8B?8S9}%u(;6IEwkb{C$U7m>>nxcObh^3 zNL&q2+e{3SKElmeI7S8Bc{wrHxAK73zve^Fb`o^uESOe0aBFiCD8@fkfimVA)6(7u z)g*?E&xwh`M1S>YnRL@lSt*4M0PR(@pgmsfbz8NcVk1AAzj8xwA;pXmg4Yr2b`mwj zpwGDnkagvG_y|I1lk9&QA+MZw7b{J?74UbotLVo56HPd3RTPALlECCL#Itvs2f4tZWyOIh7 zi2mw1Ij~769~>miL5)x^4`PEmF;NE;4!a|N^80c2ndLT9z>CSG5?H|TY`p}$SR{Mm zB;(L)Q1SWCBjJu8znW1M3wJ2?OD*t6jD#g6NuMCjn!K+G&d+0?2q6g^LX1dWkkw-qN= z4hv(Dsk#Z|#c^P>TV7>0oAl2tdv^oo))i|?vHZj`*-gKySgaHD1YP&>=sv3&f=w;G ztl+TFOoNC=Iy09K=eR24OS4sTSRB}$Wy&ij2rDesi(7Tnx`${D8hel^tb8tfwnq_K zc|1x_9vV66Q2F(3pu9p*&ow$D3smmhS6Wj8||B`yid3Tea{>vk!II>8zu&nyi;ESm6!DgptY;Nd6Nci zC9u-DU%XRvKSp9bMH3~ZX04wAI4|w7a{AUqUK0=xL2sB=WPGZ>h7i2msn%&F`84ZGy7&1q%r_osG`;PTf$f${F!PVV<|2j;&lBaO0m%0CB#Y|A|Ea;`S zgATg3IgvS9E2i`?`$=$k8N2f78b#O>M&k?Mx|adC5@;X?E50zx=w-k>eJ~M+daFmAd_CU!$O4)bES^jr7oWcI8oYu6pDyz@ zIKnRA)gyigGHtibY>T`@__d|+O^4?9Naky+Xz?~?jLQvSII`k^p?Kfvm`sCx=IK5g zjtWOha$@jYb*r6Mfx+5G=KFpXL5HrIJaP9%;UrDTJ|VuJnxHOkf@1|H4Mwob0{G$N z$~#wXlR0hbF9NvAnH#F3Qmt6DtP$9Ta(%xikoJ!PJ*_ui@#6X5uVM_ zjHHL(B+>Pa0hvl-Mg#-x9kO{kCyGwYoJJXPqw$UmcpRpM&iyMq)LUus$idg->!|pb zL{+&wKsbFBojQz5SFjy+$ZsApjgv|DP+0*=aB2+eea(AC_By5d;WBf`LwcI8ZdM6x4>H#k9#&gNrl`Y3lR4G09)PEh5g>IR8oee##FhY?|6$goRoXa7e}56lP=gw~$!ah3OiS7YKt zscQur-it#-b?D2sT1jx!d&1w%!Yu0BE6U{$dk)3sJCmQ_ZXUCGmnCW$UCxzz>weqwlOQ6PdIabh)MIav{1+#&HBP zKHKHe{Ji5c`i{*3fd1ljy!V8fw}hw*jg%Z6L;SoJ(p}gQr8X4$?kCf115!JFP;Fv| ze|V^_Dw?}tG}QUua16Cw?X8@mP1wZg-|8g;QTm|!CfSck?B$QuBOJWcw<(((E7+(**EWo134K<;@YDN%bMoBMdTaCD>5v|Vgb zG!4=oB`T)B=gSsPO=X#>>pUM&!Gy?A=|@+3Uzd%9u^K3~=R@ZG}{JpKHVcWeK z@L(!#OXiA~GA8}U8q*4wz^w7@M&zqn#Kv)Kd1?OT(NJel@SM{BHt(j+c=&ttA2&lb z`$@O$wF?KVY7XkD%jh~PZw2%gm%rq&aU9cyH()ygDrC1XPiXat1wKz%^jTVvMvvX> zcxwT8>%R4^*#EXc+HIbk`jN$6n0`!V!Zw_V(rHV zk93FGu-YA1<%zxYoNSfiMkY1fy~M_c#s!&M&C#db^+2topl3X3mb1BwKt-H) z+wMmF{k?Ox?d=f6qo)dgDe?)9&qdK%;NA#U)Bf7yF%PU25HwA|TjUV-kR3b6!H;_n z9XsnnE3|CcFY?Cqn2pPE8C0xrA)+;XzP`0kGsDp9{Jy zhXDE0F+xy;Wk$qjrgr`){~q$Z&}88sImy*@`z!gaH_J{5yqN2$U?f?Y!eqZQkspHT zJsvDSl8CZT<}xXArg@`mews||HY4>~f#-}Cmu<2*t|F{Kp(M5s6m&^ZOO;U206EhG zV9dxxy6#|lX>tS2yLPk)6uiIKZ_L*pQsFWJ>FS80NWSMiz|T@>yl$ErAowD;WE7#^ zg(41lvrb{m89t8z{}C^Qe|{)~L6|!>dPIoKp#I=%%2#RDuJw}x5vb*_=W_3iBT^^j zeFKcZonxe0Vd3BtrubM_9)!BnO6s+};>idG(#&_G9CzfR9dmLKj_LQXO}hlkoBh|2 zqpn={maj)U$7CEj(_?a;E@r0GkjqNTJvG@~?b4;&2I|+$(q*@|q5pw`|4HcXNXkcK zMx&GVP^*@r%J%>(u(~qiRWI*QI%ShX@Sxv0C92(TMvQdHi_1y#RJGCdUnTRJT;#Fc4ILry$ ztP#bVLd%cP%%p9!dgQ4jlVlG9j`-*(3nU7YNLH;lU3!_^LLx=_(S_|Zs;yLwI+WWu zLZjbWm;`XuSb z{2*R?5wb%8w3*J1nY>wPdM^6b5;B>!Qs>Y0HI(--L{30|k;DX<7)hGFlk+)6j!1$y z1~F*ql}*vwl}+G&W4moZ7!zr8nbudsO4-&Yb6KbGP1a(QBDot*!wD~Zuw^8|(XgBe z#G=Azp@GVJ{@^lu*J5v2IvY?-diao*xZSqQTo~9Y+-z(ZOs9RZpJYPpJa|udqJ-a| z9EcEBZp7|)+7!^BeJMZ5K2p+Sr|efVlx`$*7sefs=X1*PEU^~IxI_Ya%lK-dnwlge zI243Xt@2kotDYTMq+Zxh?dWC%&mgg~xHfm>=7e^gqPkA{Wd4d3>TAD&y+`>n(2{PD z_3|NUiKnWHN(VBA2^vOhtlqqOZt(Ibq2QvQ8s}WS^%wO*Y<_`l^&s@aJ?V|hUi{ic z7zzgcR@#d2!sg$WHaf0|rxg-ZLBumw&R1j{_&@b)6T{;snEm~BZV70@Vk2U8eGx8KkO!0qk?lCcV?>HiUOyi)$!xvyz?H4UKvu4!YJ@KjNQ@^L5q+x{W}80_J0iCG zDXy9!LM!7yttSJL`Qlt7QZ;SiNvM9Xi>DKaCE8w*o*7dlgo2$md0`k`>^D#XG23xXeEQVprP4#Mi&ymSPd+d{IpFNr3VlZ=sTOAsR>&LGQTTyVFN%zbuS zeqlRIM_%vUh+)h{yjU(&k~(TpF`6oOm1ER<>x5~GEZL!y-Apo#o8 zS}|Oeut?#}dz^p`omPX?pFsMA;FPkqVAucnx?=+n4v_2N+r`jP)Lpi9zFHZd|Oq6&kI3}*d zOFPEY_EYJZXeniRxGXRiRwN>o*1NX`dHXz#!IOr8Q-E+tW=_Zu;b2K;^YAs=%4!vT zKRk}YGs8I-XvjeoEepsiYHy(A(8gfV@~3?lF8c{0xl7m~^lMRYIP4yP%#H^mY(H+t6>D(5a<#`X*&plk$#Owf`8OhF4K9Zok%^3at+DGnf+%uWUEkvJ5EFjwAb}%~m zAUVZD{NTFclD7DC0>a;GQ!m-b+>JVkGCt-lUj^1tKV#sG0Jeo+2h}&cnHBkT+#;y- zldFz5d`59oz$DKWN`hvAGfzBLRQ9BZZ#;M|gvnU8j#8U2GD&`R^ms#FgSqBNO|0OE z83g4(uADFviPI2i@$Zyb?zGSa;rJD~7!XyumW18pN|+gxP6g8U8yD}HYD?Z$LD&Tl zy*3M9%0f5Z6>BgD9xvuEt>n8rJ0k;as!B#M8rj*-@>_8Vxz~0<>Sb7GU`u?XMEDiS zd6Zc)@#HLk=(A04UN$SA#HvVzAS#JS_hXnu!+ATS@*3@G>dB==tRdN#uH4Wt1Fa%= z5hMd&yK?7`;nyEG0_D4pu#0<0ybkbsC-EHBIzc*ptJ*q8o$-1XH#0{RD`nCu&Y6UL z6Tp>*IV}o?f-az$P#YSwUPZrKN1a^WH^1ZN4NXf(y2g|B%xTfgdCu3alp;^hI-@cs zMv*a#9%#4E{F6kA7oH;Z-#!{mZh_ka!So(@w@cxU85K;|dFWam)+@Y2*gm!H;0lX0 zgqPggU}!a~(-s^MPB8sNSDwQ#rn7*LOIVAn7`7plTxl1=#pT2Ot>On2UyT3fO2@kJ zr~&xYw}_V~5hr#wb!r-)>qFDD6NRg2stP`FcW)bJ-p%}%`Z(6hT0xMlq}s0L3cj&$ zOEIfDE`RZs+)W5cs;{S^vOT=fiCb{a{GU|VR#{0;PxVy}POV;Mz-~}t*O{=C+ae!hnIOf;(t7|^R==#H z@S@6n^`gavzE{X(+Ou}~$SN7=MhDKdJwW^khb#GfVS-a)ZII$99D-GED?2t>R%-~u zFheT0xPTL3-h_riA03IL_FogTKXmB3=NA+7pnA>V9fI9*sb_-9&nkR1bjQ{r0Hw!j zG7T_7#P@O$i!r9y-UL0q>20Y$DZcnML$DBxbYrcm3we4EeJ!HM&&Ww>bAb=c!fB{; zflVP=Y6hk3un>9Aj(DpS-^mcR$*nwy)Z0DS6R3%UD;~1;?`T?ZLk{B4P0m|vnp`Q2 zk<6X<-sW1I?M=3M@-W-apLNk$1KNeZCtMG-tMM4LP`Z4UB>9FES!4W4*@k7q9C5;+H^57e7ug&|`oqO~NoEE1`?qAFKCMJWEs2 z<78IJKV#OG8!GqL({_LK04BS_Ga-(`e@~cQKN*f#d?J?Pu|&0V zM(=%4o}-s1Yop;dP)}k#Q?Oc8_i3B&x9WZcocogRHkIaIATo5cGO}zPVODVHKXI@& zbS7H%Ofi|Y%ak7*S%Lg}5WDb|Tuh={GT)^mCi^sW2!G3t3dP)j+hLcB|4-W8H7;p_ zYb9Zbn7eUg#R;E#j7U@X;qMBteK(xq@-fHVor&pl*G!s~YEJUQLl*Ap{_X{`cNVPb z2KZFrx@XvwGGzL9F2XmH);BrC`qr}_fk1q(WsT*ajePKD3DW25<3=9UE%#WArN~>E z4B~0y78hmBJK>m(PEz=`=M^ z_Q=itG^r&{s*m05oi~k}1Ygq%7Ec%x1+bx#q;`9;S}Ro5Co%rmK_;zw$Et1;z-i=B z%XkkM@v7WlR~aoatVE8iKn+f(b;b&+SLbgTKorc*s<4`rB;QZ*LFqBCGGPI|8xdwq z0~~n%Bs)*E*NiyaCP9(87p=hO92@g;V*CX1`gXm0W{1ur6FrDg7bPmh?>_*`$)IxL zlKjF}sr@2x@&Z(OuIYE%dUpAGz9PZp>7)E}I~UL(b=Z?C2QsP%hOS@fZT9 z3|p}lxrR2U#EcJGJy{BGD;4&N#k@rT;2==gpxJa`s$wb2&s|%tdA|&z*$Y-LUjJ3rv4XW{izgu~C69 z2s@{=@b%>Zsx1E~5#f3+zGjbYUP;&l5q2$~Siy%yyOPk0({p12LQYuC=u{bzn#udThN0Zy}pA+b10r9;~9T|bB&4x8D5u+ht z2G*n*d%R`Es6Waqdj*xE2H5cxeedQ+g%Y>9wlcMAS!y?0Jf#enW3DoD#Pr5;Z)P{^ zzSm9xRL|ucZByH)Xqb&={3oVl6~^Kad*194eghY8X@nDI^tG~PD0Mrk+L|@X$R1(@ zr@qGyy$a}9iq6bw6m-eiZ(EQlHLT){7_PvHk9w^UX5Dg%pG3Sph+T$#HFX@5N%NYS zUZXcJHwV*jqqs%|?=TR%l?FPU2R6?WF{<1UF~ie+)D5pWteblT0oc8*sB09Wg*S^c z$tngkn+m&L@pteU?_T9_w~spW4h7;eY3bHLQrK1>dEQ3zt|sA09qkKf3W3i)2zL=h zegcMf9m>zZ3TqEasBPq#6rlL3WHkwVyx2ls1O9jzOj90=(IXXp?+09 z?-x0pvwWSj13t_-l-Ph=u&byj>C-{0tAQrEzkx*bU#>haAam_)QGZck1%nR^dT>;3 z+H^1pP=Cf}Q1nbqnpAS0<1b(o<(+l-7j8NN=Y?u#@#a0QL0-?b?8KoZkRgHPh(53- z9(kmf{Z7{A9tl|bE!*3r58e1DIvJeo$7gZ=;{LUYRmm^eb)}Jlk#0AKr$z}`oiS}7 zX;LHr*F}TOdyw_z)g4l9duFIIJq#3|P=MM(I5603-@kEF)^NfK5IQg0`LhmQ!b2{hn64Z(O1493rB?SjN z1)OKOD2F{v0erUC#|8+Wu#nA+Ao+O)rD>k(_|j81VftJZ*s{NirUTa-FSv|BA4MgGo#%(8w7UFvAb3j9yiml7fOM0*i-xK=DZO);E(TMaml-az#&Rg?MJ zW~xuU*JRk4Ngd|U+$R3G>J}f*V(xUTvC&h3ci|+pk1m~~N|1KLxFTDsV8TDD6-yP} z52iNscx}oU+g0<^@!fw7u`$#aEvR72ypb3(twJCZ168pINm2u4rb@!plsGXcejgTO z!jOBxjQkvR-0bxRD8;}zu_W~s&>2g|^C`eb zd!CQZuWH$?L@pQG9;9xj!L!etj}f@v%UPDo-DN@HfkQ6s^7&CFGB@S#G7>jXyw%n7 zcP_oXyl0k@464N?-yzwFkhfmhvvo&$J|cH&HQj%*ue}70jmHd1W}NX|v~ZHTk1+hH z``M%|nSzsF_Xam&dz76o8s|jGzoGZm2fbq|r2ZQiMlLnGOUG>!OaSn@A31gOZ5kRN^!~H9}yEFJ5izVTo|~=Dy+-^9?TVT6mS{^p7lE; zz;L?G0rvF+O8TDFM^%tk90xp;K9ha&9%&Ivr{cOs&VEO{epw`o>DjwpsMOF-$>pIl zG+{+I45F)d@`|r9XkQ!98!wM&6;|S1*wfw&N5_-&oZ9QSTUH7Q>;6U70Hf)5J57#S z^;VWKhjb)@_6hK8EIb|I^1!{pZ>`f!Bew1pzV=!l^_Ek8(Y!)Wm0d@rYlahTfJ2Ph zAD>^THc8>45uN1&FHm`&IFOOK1j4gMi!v%IFNSF zvpkM>z|TuV=W#C6PWY1)FPcOh^av!K;w>!!V25d00V|UjNKEWxcm5Jma`z^`jV4K$ zs+*go)0e1l+C*`^_ERg{3ZpjvI#+6(pn4YIPrMQrkhke4pP9M03z5I#ok|kkbRk75 z@shRCIQ>fl{y+Bq`>Uz!egDUkoa7|H2?Rk%p#-CXm4q&qB%;8~Sg?#>C3F?$EM(X|GAvUfs(u#a8JbbaoqK=dubIJGL!a?hL32%ZrmvU#B{O zE#|#X^zmfHwkBo&hfr93r##{r_GMxiN1~V%N{<$t?tj1=L-~p?>PwF$p55e%dcr^? zYPlj(Cx}EtT2|6X?h{0K z{f!n2Sq#Cq$}3#xHZ{%Z)^09tQ?)2O$-HRSN*;#*Zy(w%>7Ot z{Y~ES_Tv{I&jj;q(of1LaayNP+28?TZpTROLQqo%c{^1!E}a^rccRTSpOpWA&^(># zK9%TYh}^9E=)K2)PBRg7%?L_C!vfoe@#|o1V9!kDqd-kzyQF*QkkMp;(ct{aBM_oJ z)5$&)2J`V}ZT$Tv|CNt)Q~4Cfrjx?5 zyEcv8BNppA;W0*>-Cf+mtFuWfN-WG5IOe?%C2Th6aUa&!D)zCiKV>xH(y~k|t8#}x z?CnEXbHrQko=h^AKY$GMJ*1Rk)2YxfVqvsvq5pdZ-w*?mm24!T6}CKwAGX30Vn zxEZE!2}|e5Ifv?4t(3Hla99j3i(tSfm=2lQk?Q_g{#VQo3RT+AYAHE=Cj~bpFBqGw z8IxOPK2WvR#|NEJ#4Ob zpvx82Zl9irx?l&FHD?Mu)L(E;wZ)=1Tv$O`uACR^?BOondDi)euubGp3K=aG z+7wFgX@w=`nAC6KGW(kF4Hfn1)}5RYWWc-#v!&ieNjz!KO_F`V0JVh}86Hxp%@VBC z?oYi=XjI8O_3XRJMydC&JP^muUMY$3iKhCdQc8a@yV;Y2zvE}*m-N+0r(6y1Ep?h{ zv-!Q9%e&NP__?uF-?&w)1TBZOq1|m;lQ^_HPQ)e(@hVwgUjamQyN$T)6=y*K<9|^a z@U%y4h8HQ{xECMTYUwj3iQ4V0Re z&o}+ozEoj2vzbA8PL))rY`dF^nW%8H79U%&OQgFOQ>rTdiam6?Yp}3h^efWhjbi?b zu6nd>^USTs8INi@4j%<0!vV` zG*w?%^3D~Tz?(><%&~0J_*E+wvUOe(cFq8AjO}Tor?pBLvY4p41;UruM?o zVLIp@)7*_(SB>*!Gw<2ZeC=o5u@RSyu?M$cUxLr^ZRzVN`aL}~19EB%yfzMgslXMS z3I2^I3JplxO{7_`Del9{k=%wk>f0%~ewjwJehBhRUMC9}HMrdiYr(Xa!fF-Zjd`3X z?I7P7Y$niCilKbrVP5PZ*y|3N#YoF;;!16rWtBv)QL|&;M#-(eJf_$UL0NJ`OcFU> ze;=BD!C0q$sNI~g_*4gr2kl|lX5Wjd#?45jBu2COxeN0f1T2xA520pQ;H@rp6D@i- z5g*VRg4&-vhDbJ-p3qMc1%1h}EVVgedD4d6JUaW&(aPd+1Yn$4G~_0&H1irJpE5l7 z=gZLp2fEzM{<)T(Tu;gVyMxXK~lluv&QNV;&1YZ*E8%r zmclDP-a6P3rF4*&`;{K}g6rPq3Pf8fbgqJM*O`8E2)d0|)!}AxEO&rMs*n7f{pB>i zQMb#?!EbGK@r{oDT!&HUeA@Pqesh;;efS46_Nszmf#*du$(DAPr#1})yQYPZY4#@2S>aO*gjm28!VCDEXixxt zr4*24nhD=^DEg1fYUIpTKb+6Tuha}zKkp0|!swJr+>HI^O;X{NdBs=pX|LAeSc86Q z#l(6?81(XDiP~w!2fn~QDgDR8T$Oj_etw&pEPh)RLX5|~5C-7G$e;o1ttj?Oz@_dR z6PP5;-iLY+!dUz=^v7-^EpjW1DSaZ=W2s@5UYl|&%?|x4O}BB^{+X9QmBG&X$Yj5o z`}JO7eK9NP>ApFTGZa5=!$7-*<1l5pebXsM4zSHy_`DjSls0sFD08Zv{ZbOmj!Z4{n0xPa zo786=xk(By%vUne+(#^+_iV9ni#$lQf@1AESYrCxsL~YCY~{=9jsx9-kG}~g;jGQ? zS?|0=D|9RklH!|6s~gp5PPOpD{$pstPDN09)`@EbKU*6!+BGA_^NfT2U=9qQTy{ry zDxQ>ZeRp&>Y0;~jGVkG_>t^&4gViC2GM?QvB6y@KeJuhx5>@&fqciYkPii+f+YP8d zG)PVp{oU)x>6#?~*WumM9}n4u<^$FQwL8QouuxDHOmb}MRe>j@z$9aBYVm{4;<%3>M>WO( zPN7{&vApAVB}s0~Qo0Jt@uMXUElJOC*=Ha5aHZS(OriUG*X)%|-tygvH(;^lU;DyJ z2{}PGif=o8eNTr-`6P_jPu|}Vtme|rEIsrR_c%-*u8y68$Qs9gNSSS;`S-D6^!Z6l zy+qR=OYe`1v7&_J*p*ri@9Q{FCz01|86(*4v~bkzb)F$g z&^~I`Z$2FBxFzD)0T<(0FW53m&~<>XdI1m)P`(~hC9VbvTw<=tlHx1x?w`0ycQw`j zI&MXmw^TQW+nOltm}t73U4=VVM*Lm#Ne%P5W9`&v8FMP8)6{jMJ|p6W{UWjvEl|8J7aRqiOVcL&712nADEn(qXb2PM*%i8U=^{H_ zz4isZWS61vyc-08k7CZ~ey^`1-CpC199|J_)(N&K{MqsE@tM>&d_uxf0_k5#d53t?7u3!&6k^jPoHwWOTH`Qv*WZLV90XWgLP9hu{-U5{ser# zAMSQVoP{U6GTy}_BP?!2-K?wFHtL{QNA22V(;sCUW<|JZXO7%V{e}S45k0Sr%LQ;wk~u&^^_0G7uV3uk>lcjBE+KNcf~OxO_=EVyFX}=x(X~=`xp%+r`YSo zc@901+e9K72_}_{X;Cs`)M#d z-Jcze>u^QZ7|Y$nhLK0wAx#d{>}&9H8#UHzRQF=$kja z{OXP=oCz)HTn zV+OcC|IRfBaC7A5&&&J61{!XUlu-aFx4a)k7N|jpNTYJJ0;bDsnIw23TqPe+= z0q5|x0a`DT?c4v}8S-{7wA7tKPgpk6x(J>`VU~afdl7OL?rbdH^k~-$FF0IUkiuI> zMKZA^OL9ozUoQ# z5w{;VOxbi|UO*?1?){S~dBr~5y5RPDt%c9r0ak{Dz%u)eTTb~hmzO(grZSMu0cB*V zvDlr9=e^uy4u5O^gv7JIEnWmabG!$BH*9MQu}t4ai$)$lP$aNFVf{vL<*OU{7LDWU zASp+3`WHa{P6OdPVBZI9O{^DNa?4S$T|y31%q-i?6HDGiYKAHvVP;jc+E>z(%G}+> zyWfJ0{ZM|z(o@gT(e^mGnRm*vZhwG0@z~8I#p~Bwety-PGbE+XSt7qUu`RN~X zkvdHLd(&toMnIO)o_+PH(dzDvQC_s2ixfAMU!4Rx`sY4HCw<&}8pYEMpD!Ij?!@ew zv`wyF=>+c>U5vb}H+#+dt@+IT-8YnN_siLR?_GKM!trxa^p`ZD*416+BYw0tf3v-^ z&$;}28ngE04@pI6^+UL>@^SNH&%JZnsj>v^IEs8vu66bT6n3vg>|eGfMxxhA0lfv_ zA%+3wEPx1FF0{vljkxQn%w6RnXMnetlQVWaykTGzpjEK=i6WV$%J`s;JxO&{bZ+ov zSbN#6L*9f5QqH0e$EZj-1!#z=p=b);Q(uTu1i4!zmlL)njxgU(A~|fnYR+Z zZBIttOY{1?lqvUC{IyslB4*RwzPJHdY|Yr`WnAKvVxPJhJEIfbRk1r}{-_AP57U6a z-V-^|&V|&|V!=UyXQi|Yv-p~l-c2Rd?XF<;$hJxL3}9xVY|`UvPD--`HX_KPRRwt) zLNMw~klA6EG}OQwbbzadNc@<)K!zS>PD$P zTd8)VokM;5QDcp>qLnN^nxD`2>HjvoJqYNa#jCM#YcnL&K%v*`xeqHMRyZ8+$?ae<~VT0fYBT6Wv|7n21E25O?!Oqy&! z?8bHb1HbrHXSis%`q%JA+~v`Ng&PQ-gy*~4-MNC`##f~3iqZB3E=T^^{>ZJnO>=hT zmh9By_mFgIks`~}v6McsaH=RzX*?MAMn=%|HD&_Z`TO_O0-E2wQ``O8_Z|i+cftIg zAGL#mf;LRjG^F`#nTsvFf4YJM;2KoB2|s_Weo3~Q1byxqrJj?Z++ruv>2G@$4W(Y( zjb?EG85**_G56x`l@h;a!`BS{3wr0au;*AoA6+NHHsEhx0)!0L@PM+$f>JTHT+m;K z>?0tiNB+vU_c}E!YztIKM+x#xlR+K{eR{fGN(X2NYDo_`;K)_&(gbq0o|gbv zW~e9g?n|IG+f9&wt>;5E4cHB=p>8H$O5LEKL$q6ikGS1!ug~pRRqZ_{>07obAe>po zUP;OqhHAzs7iYI47H!9P8NAUj8h#^XxK_nB7{@F3I)7if2S1k%OaGzsPPSt>XLL?g8p6KOuCfE3F#Azt}L z&LLcv2H+UqO*>N_(9we5a~r%ecIK|4MGsrp?Tyex=xSV)qKQL~!!|#vAHDWR*#WOH zD#9A$puagiUD4nRvUsWlb*y7<^t?GUEwfi0Q)|a?CtdVf)u; zL?pRUQS5YGc)sW@CVtwAJ~LTgW8(z#FS?52JftZteYU;?N~F8q-tI&^z(y|Z8C;{u znsO}pH~NCiC%jL0eD-#@ixanP|)7NtAwYkV|%-!^Ma$N%B3 za>V{gN6MWNUc-0Lk$MU2pm^0la6zn-kL|7eBWnp)3obuX_JHxEpQYH}Qr z?GE>6>oj~ci`{$Pn%;KTS$VkE^Vd-hm(l|5o{7Ue8d9KeifPbs#UKV3s- z#Qwvu6?f&Zd(rM^?1v? z)2O|V+qPZdF3OS4VI+6Tzj<`Q92@A)GV3Joo^<_T#M{hE5HJs2R&DfQgrxN2H<52B(2cI!As=92tQ|*kGSmJ%1+rq$>ufaGxK{NgPYNHChLXIS;fB#j=D>WdpIlP z-^S__7uL)n#@}7tRHZ%f&Rgl)mXEX(%iNR43_lWo-ew{jnBoAheY+K5zS`wq+tzS> z`;Ssq;P)f3i8nXWihmEmw5uIT0a~pa0({fYx={!K_x)G(4(_KWXHo#VE@}X2p%8Nv z6|oaxT|!%X?$+cY&DUgX$s9GaoS*4ZAc-%hOFu9az?%gux5JJ>h=-|;9B9PfI3_`_ z9NSeV)|0ZAV9PZd9c{wRkxFs34cslC(SjW>!banBv)FU&C9nwiW9YxR>p7L>Y)>amN&Ebbw5YH0*$9u_ zn@hTU2D*F-YEXZb0F0vm1{H|4I~z`*GX(qV1!f-v9%7<-$s*d#W%Mh^S-9vMKlT(m z_LPJ8GMf{5Q7h2|+Qkk|=ZLLy`uJk!8#3C;aQ0~_e<0+2TjVbG6BKUy21VAuflhzuOUntaMhub33-z}GlS-lu7pL`*(6yzCSHjqPCN-?%a1*_lXbS(`UD) z0u~jGxX|Q=J`$gOg}_Q3m(FO@?sAJHG#7l!_wo5|2-5#-7Z%g#_Q0H%tei#(FXPmZPN#=N3x)B0aosxbY{ug`fxaVRESWlywAx1~G z+jH+5yxsEAfb3X>+&BZW;$G%L0lCM}IG*rswNWgINUBxVv-|sox?MD}LqBV0(NC9^ zPQINYHU9(7!KM1|1zvfDS(PAegnp(V1yQfPp#^Uw3cKH2bZ%`)pi{NZ5jd7sI#O0o zP~lki#9njw7l+xXLIkIF4=Ig)9(kcY`)Yr}elQ2FWf}4>4lvW3$$86&RuQ-?~1d zvvQf%KT5&JV#W|ySw`u!LL(;U#u5*ZT+C+;(q5-1Dkbdg21533Lj8XH=_r*7Iet7^ zq|uKYM@O#CRyI|UM>bAo*pVmqaS5!}1prHx$mdcstU|6r0l)oj(EM}4q}%^UP7z`( zbB8WITS?DDsatF`&-WFj<};X$MEcasu}u1>=~>x?>?0LFuDZ~eAGftM?|XhyzeYgc za~vp+0fCmCDtFF{<-L-D^`WtyIryE2O#8ow@V{i70lLKcF!d5wO>Wv=lsS=oKNo&2 z5zDN6zSiQb0yYv25mLMRm6SwVGp$Zz%8(CdJFC~P_(L=WpOB~A^OpFtdSGeQ7F+H?yeKkh(^?2(DId|^Tn1{Q{*L(fW6xl$T@rfwJf>vg)9dAXdBMcU=47JPA*fn*U{HK-0#-a z`fjLv_NPOgubxWGGi~PoSg!&nLH$o5?p6njFssNMQTQD&LaZ5?>JvPyK!U+moM9Ko zq6%`H;!K0~>+aYJ(z@nB$F;N;acVZ5@O6~zJ#suc4-x0e>ui}cKGzxLPN0!-VSpQ3dLbF(W_1RamXM84wsk_ zlzCB5RHLo?Ks>v6*@(Z|6=A4+ zM7#EWw$d)xPd?Jxh(yQDAFSQ}Ij+U~&6n<2P3(?Y-*2;mTR+WwH^B-K#(hOXg`6mb zGCzze=uULyfTdv#rDhNCG-tyO-c@lHDXOhw|4>O(&uIQyEpussx!1lC?nftRI)pc(V5wZfnEx#Nv>DQjF=@yR*EX z@G=*f)NQ^dKe$&P5F^G#YfEuqEhOMCYrZS2s`=jX=H=jRHT z7LxfX7Zg{D_lrUz$iA;?r5-P8q;r_*tsydx^FgfSOtqHK00shd-jzFqcY(D!gYsUbsT3&j{(&I2vovFPP74$_s zw&kjd8j$!!ltLb&G~FRA#B*LMLBLelN?z3j)LB>PX*nM{m;#1pEa8*qyayv`j&7a- zb^Gfy+*y;jsaO7t_SsS^MLVVk(R`*M2~TBLHg*slYL!#!wZi2`!%k$chPEe6R5m|M z_h+HNf%m;~m;N`OAXw>6G~9UUu6Kaf6`XZUlvZrs)6EVWUpS_*F3LVvP=?s~K%Vy! z$$wb;EizQ}RK6qHmF)|&{?Qo$V_z5g0a8{nC|Z-`n6pOpFh)Aa1Pc8h=juxWr`?=(=y>4Z#NP=P+U$La3CWaW<&!Cqgrdw(7|r zQX;o2TlfDe^V-GcitkwZ5J|6%U^t>2(X8OrElB)A3#(A!X5OMb*Oz0PAMg>7&f`j3 zLa_@L^M)ByspYlfcRAQtC=yLt$JJ>`v6Z{nDJE5esLn%%Q~nCO!mq&4*#c0Q{S{(Hv9WX*0(-7foChFT+Sv+Hxq{wB?t+~%sb?yh9|8On_IIoF6R0{~@LkOD z-XF?1$M&>x{XO@i_^^p8B<*=QdS#UAVbWC{EI3GxCI*qa_eE*M_N86FmG*($5F?e@ zQT(=qs$?jX?SwuvHoW$7@?jLrMbJimJ_3zF_GG`L`!^f2Y<@n+B|o2IQ&zQ;)}{sb z9bm!qRb{yVUw7fJ{*Gg-o@xCuX&@>8upozdHhc28rV9VvYSvLzL0mEHbgpA-UWa9@ ztqaX@6E5o}SX}>1!TvS@y~{Szt8No*m=6^m_-5Aqs2ziu6eGToR)^u1LT+Z!4s}!0 z7{K|*V0Qp6G@s`5&8npk|9q6>GJN#R-ijEkad8*U8)ve^&gNxCh=1neRlGI04HBg4 z7K6x`?%vI_i^z+*FAq!TvrT6q1v8}q``>&QLGUktAjHHPmV0IT;hKU_09axAv|LCP zQl|%bNf)N4#s-yB=5f5{3$nN3fy=T)o9Y2CVeK+1o?cc_XSK$wD6IHoidX+P(uVq( z>`~C^xqB?^sa&zdyM;MBcbA|i{p%aSH)$QNjYx?1aQm*0Jx{@ByQIKgEdm4i5_#e5 zN-vqT4)sh0++FsG)of0R;)EatFov2Wke5rjtWN^x?pRFE#?=&MbCJ5psqxFVGSu^z zAkfpC`&Br`jR!|j(IotlEu!STlo@hsQD*Xvfz!ev;~((+>RreNufLFT|;s+$!MlbF=-=6 zN7IBU^<^?Np-_g-=tmH=VCxi{8{}p``omi#5MXZa*`n7CdPDulcI>{lNfTAD@?wi?!E~ z6^;!T7aVAQdgiLcZ_|L&VoOeK1ye%f1xA?Px1_j@xF&ZJ&s9*CS;Qf!<_QLq_%*x9 zS1(5pyc$J4T+hOiy^>fjcYAS{>v^ZBmaQ@p@Fp9p>a3@fq#1K5vn-XL9Lg zGIKuh64~>UU}u=exoaQ>6DO*y8%7eX3N1}GB$wfje}!9hGwX^!W0SN@F!^_m0#?|l zqmEW&35M@>0BUd4o6vhU%9|R&iU)e{s_j*L@v4@e6I1sn05ptp6rmPXhvrX_Cio>KB?0w0ttmz{ zZXnxjmf$XlkQgvkyqF7liz6vXyIIN3uCZ0LZN=`Y&$;U()jRKlS6_8ku*m(5nYwzh zW^+ZT$hBfPnOzQklpwectxH=l#V^@(oYUhY63r4YL8O10x+oZ%*kvI)80D&50K*zp z*BkuZ%X7`{T_ZIj5h8kCmP;^Q>v%Zgp_T|zf6T!Vv&Ym5CYIet32z#k4iP|~)%;H=%QW?ZJRkpHU24Fv0e^A5k#~>emD48ea|8~K zd{k?ubQX11(n>ef=c6)w65kC9Z09KE(BNyryGw+e-NNWr{w+v8*5Uf7Asi@5c|lwKB%45ELf z5Kav6>Cvl)c||u(0kVh$v{_%8m_zdzL$Sl_&8qm)0zj=2WC>E_?F$IsCG@B--ya_E zYW|_kq2IR-HQr};ytHUL^vX0942yV4L6cp%TkuAC z)4JS(W$bX(%xwn(3@JF)y7r2vrS?duI7^Rv(CiQ?@(Hd7=6$<=iEH1(%=@xdE4`!7 zJ|c5tYUX~_|5zD5Ag|0#I&sfp_fnjN1Ad(=l6Z&iH>;Re3b-ChbGF4fM}WC8Wtl5R zi;&zuAS22;o{7QZA>|ZB%M|%%+wW0(qF>-!>EjZOD>Fz^eZ&CP3oEJt%(2VNGlBnKN>e_;;?a^K4gW zO_Gdsfd?yZG#&4MgTQj8=~*s0nG(VfKUce*J;I_%;6;Q~?P~VO96w8C&AeHg39~$U zlyhPEQ%ufwS1*>J^pcd`3F@&qC?}b%&qY~2;oDDDAW1Lth{^;xK^}wrg(&vF7L>h% zz21#y9HMtI&e0v*~3zp%my9<#i<{Y>u3T&)H~$71xHfknM&>Nb#{oQS8^L zA{}6uV(`6B$Ly29nED&|SC1c2e&H)TstB1NBJ!%XC=*MpqWtR2XT*1f*o7E&NBZ=2 zy{l+gy5TmoYkn>yf8+CURW)B?9|o3?}`WoB5pBfg#g6M?^om& zoN(HXQ#Or83E~Oh_04(WsIQkMZ~Lyc$;*{MDMX*j0~iigx3BcL2ED?w-@@6joDiUK zAawRwiqAHaeO}i*6d!hCsmNJ99S-xygsDZ^Xchj$j2hgFRP2G)u0?#Wo{c~0Zv%Oa z5YYn3Z;aDE4kF!rY+?TUBl2V^D6rN+4>2)x2kv##sW+tDxs9sv>KVu`G(y4$sP25^ zY0)^w^oLBY)*w4)qqfv&*Nb2hF@w$5$neMu|#4xT#|vS%*TjlAgtmU~IFr=hz1O2gOyB z_oB9Rl96$S43Co6UMI)vcyn12z^k9Aji#x6u~6f4dWzv4VVi9!YUqkm-CVI=qzApx zfi+k|>dqgF17^qEF^Tk8n3YSzZ9MDKj$zVdGq~p^7w{8A1>007JlOF;e&*NXY_DIS zRi*{1#3S3v8# z;D=-%Owvj$B zn&UrAXVA#5V1~%4`{e6J4pazc*>^laBjtnHT>({_MV)3hZ!kuyt@L+K82xe%p_wb@ zZgcU|6TUcJyK)>!{zu9F2M&w>bwqf z*+k`7O~?mt`R!+WW5L6hH}#w)_lh`2F-gtmn;1=L~MIMVi7yXN*q^BlD{NhXRPyCYGVTC{|eL|p7Han zR!7hpL~~m|npr|wOXps=AWY7^TaIr&w>!p1rA4cj+_wo>HDMxI6fznq5X^)F>3+-) zx$w>j%4xt6X!f|#y|C{VlJmX~IZ=^SzVg{-B>2q&-f{z&Vc`wC^_Z@+pv;0{0P?b( z2OK=gUSkmkvx_Y$YmN=EN+*A@;8=jS!p4$wOmJQLe#`hvj&)DhG!Q)rei}&p%C6gs zx~Lo9P`tLR+dEaNQ>*MpHh55;c;Gn8vLcpR4+isA5}ZSZ9>F-&dgUHpmqvXJn6>m%x#&G5>oZ&vq) zWL7QM8$!4_chsS!E6HTd!ofpl@;erFM##%80vEHJURh4Hi1&Gk+y2ZDCBSweTd?YN zbHqolPZe8#^$dFJ37D*>?qi&|M1~HHqhGq~prwchHv67FRSjd+F)qpt^4F?K2ze{S zpo4VqeBt=Q_wdVIPv93rX024@0=ge3@-TzOC*+|XW3)`{1z3G>7OdrL~CH1Ir8yfgP0c|E4A{eNU=={`Z`Iz4TRp;!ot7KeI5~v9OY6p zp1=L}ZMrPD%S6U7=YSYVOf!Hd|m-&l`w7t+@`eXdv!J8 z>yPT{@XzY%mn;oU2iut>n^(n~K2@fuwhS+^a7u4U!uh&d_$;ZBV&!OoXL$w3 zs|Y+M<*r(HLkNQ%Gs=VB-^B{n`7)+2-En8YRqePBY|c+D%plp=v?Uf7qDj53qb7E5 zM&Mav`^<6;1Ur(RSUn4CaCgu=L_Z<70H^QDq@_o=h3=*M~g7HQkv*Q^hz6Hhtdg{GLq7Fi~)Vr`400u$C3 zs48oXX7&ZZ7mSJR?B$5JeBl%elNA8E`{b@oen9j(jK7c%VpdhWuCa~ zgR9(660YiJKGc}TH%{Wl6CE~;9uv~-0#sCi%IC90`-mN#oiC~meIst&v3Vm9=V4gmSYg`?44K+@FD(P1*xFrN)|*T?fw>WhiSKdERu`)4`S>%U_=KlfUOCe(8C`b zV>w!HD3WR$-${Heh-n$SDFbH5zxr-a?6fbwHfSCwOBld)cnb_HP4|;H?i`i)?=TDH z-~LS4M{O}Et^SSk>JffJF6OmIPrTDf2A{pXPk(x>ezRLL?#lUHq^j-oXZWkTUMjU) zo!%rQlaQzP1%C*3MW2`USWb8m_&X?AqitQ%Zc7K(A97nG(vq^@ub1-TH`-@ZgE`b$ z#e3Zg@x4Av2v?Y`P&}~>=S4UV+;HpuyfYJyXV?K> z%PF?hG4DN>nI$Eg+KS_|(gBWWy1an;k=HYPzG?kcDVjv+w)sUNEcQH-7yT>l#LiIq z0_m;XlX$PzKc!B8QLB6fdlm%JwVW{4!up_cB0q*uj+lN(~fQ?Cqx_P*!Y5T;bM3i= zM4A(>bpYqP^o^Ie>ccecK2HXlYWE)B&cz>BK^tlKMT7X727}BsWrR?4vmDYmO(F)_9Q2Nz(Jhi zh8WTYou4;(Hr!|wF7yQq+8oQhbdeX5v>e6sde1sy3%Fe$y6yI$GmwuE%@n zQg{Z^3%zaWIB@2+@e$hgQBosls*fl!gVCF2B-}lC!lX%*zToK%Xe+RGMHJ_TZO64) zCW}12WdA42-2NWBPW-XPy17y)WV4JZS%Yo7sBnLa6-dcWzt02(5|vbFf-4Yyavj+C z$5# zOKc@Gq_9B3U98Lr#&5cytH-rP;$Ot#eZxtaM#9AoBjEwazhD#fjtZY{m;6v{BgfX9 zu(&+}xA0nO>_pAZyME*IQJ>@c{})*M@5=hWh4|k>{6Cf4`+xl7p0@`C7n6TnSwPED zVTvx5?}Vcj`!_I{^bo0sJ2NjmK1O4>Zb#PxG$)X=P|{J5Uj+xhape2JH#R`EHr#9N&cx z;8iBY!bjt(FcGI06FI-fs#KM1YJ7aZLrS8ct9_Sz=CsAE{8M(3)VXAsd?;`>_l3y* z@!KCSrNWm*^~Ju~jv? zbTt3H?O8l!BeCDT3_t*Pq?E^m(7v|zwXK}&vGe*4Y0vddBGI3zr5_z#A&d|)7-?dkLhXx3tp z^3VbDtT7K&dLZ=c0liTFnEiEdrp)ep)i*dvdGU`L^O8fYTgLOb&(VTyaxnVs97B4r zP7slX(tS)f80mpG=JH|}oh1E#?Y(JOQt2Q64;(m<9t5)zLjHGbfMYR#{>-MdgCoVvC7ZN{aBiwfX*^{C`h> z&!+2|uCAE}WA{1dbAPt?`&Ezar$Pl-xzpyOgrM%!kf|OB{UZ z;us)tCH*F9)V;MI3WI$U@1n%@Y!3tU&_qj-I38j*K?z?r zdl;gqeEkFAg+vP=Lk*G5%vr6S4@TH7QX0q~Z&GHIgbTt-SDpgR(AxbFWtXdW!0f)? zPklYeUF&Nbhk8tR8CQ7S!tzSI@7E73VZlU!(}izlA2Ed~+xeb{#@?f_@9foS-y78Y zKvv+X;|`5x5B1T3>kX2UG}C4r@dj6J&$rC-1h|up7x09F;Q0YnI!IyFP-__6g)1>7 zEa1>@j|^9%(I>QuTfq;jUw8P)LXO2Vj@z43bZ>5o^bCOkv2gvN=u>=wgFJ0=OU`{s zcfsz+K2 z``>Y(UMCo4UiPsVIo(cu%5^)K#Mc}U7Io&GfPzlWY-!PTxiN)b7E7uxBon1)>K4jE z&iBw*kE+oYcl|at1SQz+vjZdXnvNNl-2EwYn}iorAZgjhDYB1=Yv49Vv+$m_eB<#G zo2ngU_u_2PzMw{YKL?(wn7@F_D4?agUvbkt`)Q7bpqx_hK6ShPOZTAasVm){@744) z(#UM#W_?`yGd-7M+G9h}))&>J>*|@Bp~X6Pj5?G}3VJHZc!(FwJhQI^Qi=HgY#$h? zZYdmFv*o6bNwAkTk3E;PAXIwoc=f#sNvEGMv&Tm$XKVoiHRZmnRvqL$05p9J5m4Ky z77IZAsfWDvz6yCjm}7nq(FH=T;-1YwWezT3_A>_d@2w78Qrp>oaTl@Z?}iqxBn#tr z6em3siBnlm9Njs-mI8FQRjyp0G}wDy0L1vAXf};jg<+(x1qgM{B)((*I8AqS6jk3( z$reF%>F&bRSA5^kFKenBI3x|>%GH`(0V=Clf-E8Wk1p*CtB5fT@R9UE+T^B0x74)h zcXb5N^|KM@)Zd`r{&p;;+#}vyWnOd@`9*ZwZNZ*vaq79Ve*fn|?6@l0xznjpLGPrN7tMq?7$B=5hB0RX-bEoN;q##crt|eNq(dW6M>oYcV4A z+g+?O-rGx+cTunJl&#xiPAlLY6)6fVJ=-ic8b%1)VR5Gg2(!^z(hPMoGBn2m+|%;5 z&pu#Vs`&L&0V)4G>hhGw*otKpRfzetWjlQ7+wh47FyYmd50Ni?6k%PAMO*_E{!AJ? z4A?s+E*K{PiMXpa{0RkY_4+;}CTK64@bUpHBdud4(0tE85;%wHzUdxrLPJ!P7C-A= zmtlkw3ib6?A+{V7z=r1_k??Qh-hTSqSN}z2BKpp~!162VES2F@D+s`_)<<#cHm2<> z!PjeCg24^L5ap}|!x7ge#IUwNOyLn>Y8=gY+1RaDyM z$4iBLJ>wCoJ{z2*ukxQ#kHQFJO>+qHyggp>NQ)qgo3T%42Kq?BMl0vix_JF1Q4xUW z3V#}*mGio@pBp5S60u_bS6COk3W}+W%5V(I`E-jJ1m4G&`ll@R=1v+ch`n z)_CDtA2yi{xmlg*B-Ws8lX)iXn>yz`ow}^NJAgyka%r zd0BopaQyzfim3V6S^a~{R-?M5OpV?O8wK*8$K6n_&Vch)^5s=)^WR0Nvzbsi*s3sK z-GH{|o8PI<1|y`=4c8%wIte2k7|}x@M_@X`r$hkjiZ#V+!4kFPvy*W5htjp&As6ZR z!ChHiD?~GD-$lmV!OMzPnIT}vfx4nCcU-wQB;cEbA6YAIi5QwwC|gf>K_Wx!q)Jk0;_+xAwV@{1K}sg^lW9M&@t@S&qV3T2aZ4^ zOhgPXnKb(~%cAs8=N{^;(pmGvp{Kv#7@~^!O!~=5ce~2A1X`G@TrBz5Fg9x-Z=(_F zW3r6o1Ox!!Oe+<|88Z-5elVW5zox1{LyOo#a?5s6I;WJU|5Pq|*<8J%R4hlcuRzEJ z8$|K-@E()NL;urR-wU3^MB>@y0zSsaz}+xIqUW&Z8X#Z=LD@*h{4$!N=%b;i<$Tql zphqMPDJDk0_3J}{qp-}DLB@{%o+ihPrODk^xK{MtuRrd^gZHK$Z2mm2=s+!xuSMY} zi>Yw#7qN}lxi}qdIbHy>#`^=WqU%Tgiwiq6&^w)O3TCzs_rF1+{chgz$!jX(%qc{M);htKF>5}>Vv=Cp zKOW+erS!;K{t~iFuzJ~Ksz=79UD7C+HNx~=bBFYtfcTl=w@pB{LGMKBS-yEr zWqlGrA2QaGTIJ@2Ir!sNK!-W!Bq3AMP-}RLUnJXtN&bKf=@l3Mya1IJZmcb^&8-Z4 zacxy?cyrjfhp2ipw*153G~x8G7^pX3DICd{?xv(HyZcxEa^08dzKXDc%kJ*}*DCG` zAHA8N`t;HdVeGZXG{Z4*I)6p4cB8(bv$>i>FOlI?8^-#zSu@9=` z<8M8+OA&ls1oo9;B^6I^(try3Wm(c;Yj(tKNX0m1pYp^3y0;dFC-HqfqynwQs}3ON zSgE1izB&@6ufAKav+}jOhdn7NuyQsY%{tcUh?|O zi-6nn*=z$YHw>3|JaQ@V(!1!Pde+xoinRVUP6qw{BT~9(gOstHxipDwAbNB2;uA)h z7!?yWy2zBoX5CvRL%9BnkLpKxDe?Ux#WXS-hiZdupbx234<(beUT;SYd3?h=kT%4E65qFo|4*SR^CV4gb!q7%xEO@l0t*>$r@@* zY`p#sT+6ZnnIfUiXYpL%DRUl5n1@phaAK~!^HW|nj@Pgr@A#`ef3tRm3Snq>)^UIf zFxyW2WT^V|P6<%a$^%$&SzbmlfXPSa5uRgWjH+79It*y0!t@4Pp`)&@{oN=d*nOiX zJ{xq`0a@Ptf8ULA{v5VA>0!o$WXRqDpkX(Dtk!4&!=3g;9UUCjhu?sy$@Rf{4RXmg zp-{dA+v1#wv;d!Q?(QNn_+sgx7Fn2#1F3^&x9w~#NioeyN3)b&l_OYmA&Ce6=@2*k z4K6JsO)RgfLZ{7No_!2#MFdZM(~JI@2+CkndQ5iWnrhvbj2~3LoBxF5;TF56;*JsY zaM^JS-(L|=>uqb=L`mvuHP>MB)7jRPA|2_WZq8@s`*|jBYG1qB%x>I)f0V?c(gnp~ z@wi2KSJPt�ERv;Vct8TiL=Zn=v7r^(5hhy%PGXsZ#~J#%na-#xV{LW=SX-(u6M4UEKpkW-ACmKe4!m%TreUVA!ulXw7|_b^giKgbDI`T@(2%~fu09+ktcjnt&$MUe-m3aqHz zl_5#+RNYX3H|(tj+QyB{Gc656j23+~?1PaMr&T#PrY}H&v_zoF>vLttil5~a-~7J& z)c9R7@#nuw+8CFjxhkim#vXe>z5vMTRZ6dPKuo9{l^#jGF?35uvG(A7(JLur!t zmdRuy*e^pWdj>e&^{W9XqC*rKq-*9hR@dBJeqp#beYrGYfDa$vJ;?O^r4Bg&waux< zuM&~`bu_^%Qx#g@TGfHVZSjhmg+NBjVGAI}iCtU(01Vp83poUG2orDVGcHHm`n8v% zs;Ux+ZyZj;o{Iskj~J{sUgUnNV75=IzVA_|hVb0`m&AaWXrQZHcH6>iJnKo?-5SNP zm>h5G>VeBmO~+pR3V9h71%$J1q(r^MM#M%ECV+xU0kfQK!FJ#oHxk%#g@#;&o?ySP z{LyglYHjEbf+1_0S=>#~idc68roNA;-RR1s{YZbfxGJ{b;>mITtw+g~`wxToDCM78 zQneQB_k^kP4r3p7gIZ22=gd=49)c_?-)q(xQEF06x2H~U6I=xN?@qS!#xf}Z6KBc- z;*bQj#~z;CZ*r5^^S*gvH}5qqKg1Nq5SvUvHcL>e52(*l1FUaDR)8LTBZc0YFuiykNNc?437 zPn7b$dR&=>@AU@M;x|fpm#cDLEq($Yx9F%lua^{uTevl2&r*ecZT^OIZ1No(LxHe- z*lq?R}$WhxqPfs_`kvv0qVc-fw+dwLH;w5dhLEpDk8dsdoc zH?zF>i1kA~^eHNi@Tnh;oCHi9&UAvTu^aNzi)rm(lszzl1zRSa31!Pj96!avKRs_g?x8Lk z13qG(CE_F}5Al;bJfI$Yv4>8VIPNg9l1JRJA=WF6(2C0=@TERz?MfKnn@dDsZ+%p- zCRl%je8#RD=Br-03U&^e7Rx$J;txob@Zpqel3;Ad|KTj9rh87OfiSQ-7=hvg?ELh9nw6ak}DNtm2;>6HCr>NN4Qc zjieQW_0ZSP1tjYCt8)DR4izNs&$(nvAXwPhMfsg_>p_m?%@zQH2_E4;JvQocwM*1V zdrmT#pBm*K^S&@auag7bfv{+5Y>@{ z+$dPRlN(lS;d^c{Z#VC4Z@laS@Ws&HOhUBL3F4hJ2M~nz%~!vns=KG8m`(ESC$9Iz zod(8*N5hP5FHiowJ{m8(VWBJe<3mS*?s@WIE8iiazta(Hs|@ziiSP1?#S1`T8yDjp zMn1zM*^}{?c}uI=$T1t(%Q(50&F;oN#o7db?+8gqD0+&$)pbB_SavMS|1j-myiNJP|C1^1pr z{$F3vAW|i4f2&`Gy>b=T>W*_a1(hSFeIHGWGgd3!aKC!EvyNmea2{L+b^}JZdh2}S z1K}4}p|sXRy>p&3`2V#_yf?E0lUdSWOS&;=Aztns_=IYN5~oJOiJ$o5jZxT*;gS!M zMOdf@zV(q43OX90ESDHZGhzIUuEkR;PF?>sIhH9Vq3e1?~_)30Jq7oIsKW`(;%+iUEJ9~ z+K9=3`G3aV{m>im&UVzM=tXc4X7O0#Y(D^3fpvJhK_Wcw^y>A|sl3`%L0V@A=&>IHKy+VZtRa%a1zxuQ+`{G6r~>y` z{|`x{vx?*!W}v8f3o)Tc^}w9jl4sgRgd`;CN9aKi#&4QydS%}ao zd-lGj(>U4gIuQt+0sU;D2zQ*K&pIZVm{QMj)J?B)0;2Ux|3DX2uiz4*b`JWqmq3d! z&vpwPx7V!_NvYSKJKiAtD|rr-QcIaI7bNKO`Z1+np*_<0?&=oeHrpH%^W>t;J5M?- zf*QI>EMT%v#Ov{8JH`J`K_Rs@BB&K3Ed4${z|mLhsW^-gXg)+>}pE1ydJWS@T&Rjok~?Kmwb z{}_toTh5!Rn0>GMs6T%oBIt?J=&Q9tnlmbAqt)WC#J{)Ic=XDMfgN%JJwIC~I8P6BwU zm!iI%!Xg*$jL|o$YcLfDdyMI@cAa|E+3HQkE1qYJV|{mGq25r=G+|d!G5^S4ViLc zLZxLRD)x5IK4sx;b7pI{w-)MHY+Eg|^(SCg^moNjgf1u5?AtahG0_ z_Hgax_-B+Cc$_=&m8*8U5DjK}sECSVMYIL?J~e z>cS#xiC-ztQKHb|2!7=tqxMMR7jD7%5i8NNF_t@IjQ%-@&%<7~QwhiK>*6A(Lo?oY zJ{Zb-b=y>6OtG;25X<*`2ZIMSgfs3oF^kBP-Wx*F}JS{bRk~OMnAt(1fySu^wtW z96A5y!Z4~hcmnT@*uqt|V77_)yzl!=dA0$ntrC-Y1Xxo!JzJ)^hwf;H?&ts3RCL6tR_$~n2%vSZlC`B@8@(vq^s-S!^b)5myE z8?dE8(JAA$-J2*|i8zS|zWwva<>rsLjcY8f=UC?bX}YuJ0Ri@snIl{28p&?K&$xzp zS@cZtLjEE})k;ZMIWU@J-N7f0cXulsXR6Uf*t~?pa?CWT(D4fW(at+d)Fk#6N9Gd@ zG3#B3;+8$YccM`pvi{i@L+49cW&yOh0xdGn^9To@5q$(b|BN4LSkk*m2oLWUXSr z_}6MkH~t`O6*sTg2V>f=4qt$gRa?r42$6mqr;`84!)X>+MPWXT#A-1zs+Er0^TAR? z54eM2)SJSq-()Nx)?GODl>)DO=870h>24oa5%xr@m(6v)z=5_05EixfV<_)76HC=G z7-pZe_3?0CtRH!veaZVCLD#0TWuS?i@%@IJJa&j*5Ulo0(@MT$7%=?uy@2|2}Ke~i|}l#>gyV=&(9xwELzp^;iBS27Y`ZdORU4JBZX zLGL4p0C_FvhIza-S51*clT(ouv|Kkf%WIA+c4SlN=V^R9{uu$ZMl`W?SyYWxl_~#~ z(#xp452lwhR#Mq>XU^ z4(L8GU`fR^(+|4Y3c#-XAv7^e-8fkwKZ#N6l2Kh4F|jQl&gI^5Z-o|xr^hPAGRwxq zP>;+!-cjBW9>Mq1S8{oCBn1*a{+*ZENys-5G`_9d75SZhll)ddbtf4t^4jMFKf$qA zX21%?%L@B5m&{F&`{#SVlG#Ilm?F1ucWltk`RT(3l)jCkotiLC#+jkmweP0n1Z9qx zn)VYjX^Ugbf?ii$`C%~TIZ-gfFDM7cl+ubl*#-?g(^wUy9ZK65IXsToT@lzgJt({j z6bCoqzavRGdt1JW{w*GXOq2RQiO$e&l*1>CU<4Qag`P;+fW>1fRt~PPQ|jhtQrm_a z#P)tPG0H+{)kTCdjkr@BsE^2wBj(=eWBW&G61A(o%RTNT+@m?jqn5uobg0u;^@*^X zP7`_ta^>#N6Y+O&y}udFTYLKR9QH^io*q2p7V5@2604Mb70rlh?1SWt^S>g9x07VO z+vE@L$ z_^*rk0#Yi*yU79*qT>2&73+Rhctl|P7%bRsBJ|uDSEIN;i7AfK=onh(mJPrzqaHy@ z#a4HHBp+Rn53~WV3o$9rLyvTDZ%H{pJ-d5!gqFtmNhgo51w$UcWU9N_9g_c0EC;~N z(*lQFg)v{5(5vjiScJ2Al}#PS=IcC84r3%WINuaW+c|LJbs)bBaHwvW3u^~B!p9WN zmpFdr#n+j3r^x3cXq~5r#77TuUoss9HnfzTj@fX;=|OW%sNrjoyz{9jiNE!TwA0$r zNqX^_m4cG)CN9yLz)<3<38xyOObF75!~s8QMcnomE$=#7aHEZSv#~~f;8^#8hEmIk z2?{%+H?9cVhIxK$7oaRC&cR-Bd?%M6i{E7l{@(zJ(|HJ(A3W_1k+Y!sE=r{D?MSZxoZ* z;@oPim&S-mb~Ryhe@`b~B1}NnADboYYI2A3ZTl;J{$k1N-k#=eEe1YkSnsLYBOL8P zvdokLv={d8!94d1cI_~6wTal)Hp1MQNm0&hL{>qhZ3MppBQfWO2-OcaphL_?_!1No zZGc_@OR-T=*B9(jDbmXk#rS>>pXh&f#9H&%)F2k*M_r;Ah^=Ky11gN0$`*jj{Rc21 z#tS_UkLA+HNh+qNkPxZH-W}w93Y_i!+Eto4;-d|3=J2=f{aw<~IahTa0!AY@{1E0D z--|;;P0eh?w$3U++^WMKG0U>kH(@s-84p-^d0@takzIgqy9;SO*l(Yr`JDbk+h)3; z!Cmof$uj0l19aSTgkX=Y9M>L8{=GdGow{YhnHJfU>&3JPV42B#`Z<#ERl4y3_TloQ zEO0cBz-a7NF+KmZXw*Yg{9%a3Uy7bNeU*)th#g)m6o0_*HegIa-5sdxV;<4pFc-s%#(PLZaJC*3PGOJ232gG)jBQTYsYFDP;5RRrijT9)W6O37Zv4k{sHWz z(wuNyYma$lbAe?FL8ykhy`_bJBPZHJN-MK&?o8Z>pkY9kPXZSk+e! zS1Y&9QDPf$8}aVZqkQl}Kb_d&{$|ga-}~d%xZ!HGUj)2CTULswf@OGE?fIU=0&RfnH>DDub!&cI97Ax9Hre9Xr&w`|x=n5GGKx67 z=o_rISqMUf@VTC;T!I`Kip4D&b`LzAPT$v@h+pnz;_YMsV6jxHn0V|XS`29C3`hVB z)`WKlIVm;;Ofvob~wT?G8z(62eBOiB7|mGI;5Q=u3eT3PcqS192py^HD@v{*vc zwPb!b<4GmufM}RS!-4f98(>I%@3^IAawoxiZi+;H=`>Pw*7NHEW2nMY zXct3OtE(g7{y7~iP@48hfc;P7z_7J+#_)JJ>p=v- zNt#0mGj!IfE3#f>FC)aNZ>(*)?z_il)L1%uuP!EvcB%5ziyX4Py<>M*kFP^7a39E>L>DH$fW3Kddalqdlu#V-xfn_J1ck3@6 zE$JHbl{NuZPo)Mww&Z%V4#_R&^fzFNB}aK&#|-5Xu2x2E3}xwrK>xI813!BI{!V{@ zJD%tp0G8Z`h+xI557aE4#5@^>{=H`L9=i^}Z_a_*Ny?Rz$F zIkO}L1B@gUk8OeoKStfr(Dud zujD2pd!ghFzEH!6t+?Ti0dK!~>!T5>ipdLeq-b=}nP99{EHX*nn%pF{Cmh8Jm$$Ti zAtr^7lywmsBla?I9mVQ>96fkYt9&OZXf8s0{>1J{z}E(BkYOvRnJeic3`5$4B$zg_ z3sbg0<+I~Ik3P4z0OUzeH2|7AW-G+$B4kr z5WJs*w$$f|9@EVd4za&5MV#k)#(jV`;evW55l3Gb_`g>zArQ6Kg!_g5eN`72JK*8m z=*MQ`Hkn1@!H^K5h>et10#GPUqHg%vUj^F-V1ymu%DA`@81MJB@a{#vi5%~25{L6$4R7*=aT4;f!%=3Vf-f@ zL2h&tCkqd z5`E93{U{?M-9rgAV=GPim%KOy%_FSsb;DrrrXkwG^Z$DsqnG*r2x0&I>A%zX?`8P! zgZM8V{1*xTi-iA0!v7-Sf06LNNcjIe5=tHLm|2N`l3%=3zQ%xG^M714?@}N?XK!tEnU@mBJvD2C;2^pL33W_Pg%i?~nU+|9AJ#c{Rs5pNH$ZKG$`< z-`92Q5iH>m$5Y2+Fc{(@{sMmt1}DZ~uw4XwaK}Z{-iyJoEfy{CUcPPZ`sFj)hJFd2 zlp$4%2>-rhlY~^+3k``vl>Fn)`K*uJy~7YJ7w$tb1I7u4q}R-XFL8S zH1KmJA;T5JJ23q9Jm7ZIe_7JeMYh7VY|a9&kJS-#SB{ za!*rh30C*E#5V2Nc z?gX5Y2Xegac78tI^+wnTS)Zn0z+ljHx{RG|2Fa>5Go8VMv+&&GVqU;o*sEafGxGMX zZ+`ANj=7XGeQsRM0t#h`;8kFt>j?X_Ue3~RCaL$H-LDUoFYgaVvdoM)r<+_Nl5Tc} z2!ASZ&Ao`Y;Mf$zyN74Ak}7%ExO+{B#jo`vua=m0uLyNv<~#A11chsyZmavMTrtGW zf*zAe^Br>^600@S5LblRLC9EwRTO8C&2aBU0HrR>Frw1yQvj4v156-hGY($^OScGgYAwu_JAAdhLRoe zM@Fbih~D4Na9b(;j!9alN6IQ~ph*IgV{U zH!3b0J<5}7=i^@y8>A`S4TR-I%b*SJES#YWCKDcEo6PnknO}k>yfK+0V+RGOE5};~ zF?Tmk+>t)xS4%6u)wL{JVNO9(?mFkdkHA}|1E&tcu0ExO5gQ{;fQ%ml5y@!woJ(ZB zuUpViAn8ttWNfkTttlaQ+;ltgL_}#r++HUAz7a#cVi(+2WNEuPGBe~1g zR7ra!6El}_%gJE`qoO)`{oCZ*m+~?>B%AXCyp7btiVx8C^(?%8Bocv|o|H|HRJUrW z5i<7obA4BxFz$giO9OjMejpfe6Jj!t-Ne+SjGqw|aHT%6|AxX9$NRP>lY#_@c(0Q_ zLPs|hm#4?$hS5&QyaHLcMQc8#%}OObAX&Q|lu#uQu!ZrPtkERllF82`$_ywfx#Q>w zrdALc@y$s7!y(!&ro{2L;7Ecg_3z|o)43fYW~|EJ+zyrX3(kDJ^ih4Awu;R^M~jY< zPhs~;G4?z>56s&1m`^~&H<#YXaLl6lLjg5VP7DigYl01FF_`wir%%M--_eS?MB^<$ z4g-h%(X4}=N}@P4T`9|>EFQVg_+n`}YhD|{+}=_eNhr(Uz65E?T@vLe*CIPRfYJT% zfyYYY#}>CY0YlnH!nokJ>~%BUz!FUoNK)dBBJuKLX70IL(*n>`mqxEr6gsTeSr z@Pl%GRHFAgVfnt+I<2Ut=qIqI@aPb##DvQ`&MR*qm>`>^Xa=w$_ z=WJlbR&FTCpI>Fz)`zWyQaca_G!4&90HaQa|8f2OM z3bBdattIrRc)@XnM3QAuZI$fZq=r0p^S-^4Z;2QgYaVcG?s#cWvt9ktPrLx2m@Wb~ zNamFtw{pEnbAR${>LKnCCZGRFqz1<+)=;9c>(Z#eTgle=63=ssHufmiG6S<(XII%M zFYnpvE|1$y-Q7yvq53^!qpHk;D5;)=Or&!!^by8?Okh%f3C+7&#fWchrL3}LSt;8Ux!>ykQbMCgLDjJNGgz^CEMcl6H^X6WClV^5$Bt~ zWV%XfG(rBuM2M*P;*$U!aI>7M9O4n=?7R(k?BlUzEej0{PU`e$hv; zzAur)l!Iv|;lrImE9X;Uq#!NcB@_U`)t0Cxbbb$ z+-tNO?{0i>$u+W?mrDVDv;?)c+u$vrOQ0y%LMaz#ero_vlQF-s4mRKfG!pRlJ=#d- z_I%z~`JbHQyMMHPnBUMaeG8RxPfIT$^P@N<)jLuOFF{Z7 z1C!%~NbK3x`V>qN5z>^P8S6s^+m}gd?q`NQpSq4oYUxi-ebO|%UsLEp#c>?)T!qBU zPxU3m2X2H!boDy%VO;2wgKLv2x2vk6Ls=hWQZ*YW0wls!G@`_N5-vG7YjgY>TDW0I zW!gPKKfTCfo8dM0kLjJF{5il98R%NJ@l(}Wmg6Rk%cPb%+38O-`<*3ZoND7R**OWe zAqx}OdEhMlE`k;K0<{rB&1D@xlf?}73m}ymGoqv$7&rh2;UKE(FCrKfYy29t=Jv-& zqz|;6u}AeSPmUBM^eEb%j+0NR0;5n+Xk?rg1Y)Y*MEZuTCF44u4MGtgF*$B?-+BaU z1*W*<@ZK1BetVP02wExb1am%Nuw`5;7wT@u*~@L+pT_FiuVfxwV{mT34V>)2?~Q&# zAAJTM#e?N7^NXV{(Gp$aXcDWRw23#u@y74!I%9vFNW=BOxWG9H{ zH5Jv*9YPM&$L8o;dK#H0WGGI9EWug&9qND|!)FF7m6(UqEFRPR#Fak6GWm#X$tQX7 z{caM9$+p!?)!I#t(4GWGsainyq|JOqzZG!h%HtSW*k$nk8`Ng60?~`XpXnCIZp7HS z;=DInMi0xTq=DOUs7Bh-;t67^fKx$sX&a(F%!zSyDIuilgb`)N2mR;}B!&(?6`-D) zYB`1B*h~#bzJKXAUc!n1`=#}hqeCiP(`zU8p0Dn`tg*NPO>Pts8bBTg4qj<=Yl>PR z!W%y(e-~(-mD$*89!0bl1Wj`rW)ts990<~oo|yPau_~O!ALweY)Xu=`Z`O;9|05xE zgKL!RM747pSME`KGLchGFt_+XJC)Amh)2+ex70f0^;fTtEO8mpIyt-fAI~+2W08L8 z&~qA3h!`Tit?Pt6-1NE2QC)9MizXOJx%ULe-dL=ez+c;faVbm>_torRDJg$x?}Opr z(oXFJ1|j4KbyixAP8XFyJT9|TiAspS)zQx~cMUmHPjU6^ zoDNe*YMwmpZXKe5<8q3h7J|O>fIJbWqY%yI(5^iFpJyE8mPpt4C<4tyWtLO*A_)HL zS+S}T)UgJkyv8(M5TW5jrt6X8JH3f+i>WbL&*`^|YngcIVDoEO2o4s&g~1F+7%!BN zarzE(R@)6TqIrj}b71`_#nFZGDkscgmu+Q-Z=l6%n`$BA-L)_I)UBGmGj^H3BC=c3BA`_w7GAm>3A_{gJ~IUk z?m%gr%s|=P2>l1bC@Z<^bM8JV%rt<|^Z(!mKolP1Eyj3@F`5i#)<%AMSxMp@$2%*|F`C(cBb|qX8E206V@xUrSx;F!|%hSCqMxWwR?XcdLJn8v!4EX_D{QvBun=%(;caLzrS~;sncWY z+P&t3nv(zzBg;v4MxvkLW)?n=!Tz<5K2!YcF2TBDfcHXbRf0`F)6M%;YE??~3Qee= z5==j+!nzv$wX1@B@JBY0t*p^-yF}#K$XFB<5IFES7zzw}t8qCkGWKF>lB1jdW>$Y! zc-Y>isdJdgS*#JEaot@)%Ju2TmU*uPQ~=gJ@OL!Yw4k8#HkppoMGR}I$b4BHy@D!f z77cYT&Q77GG>e9-`_?i%59hOj@G+LvuAUj~7<{-Tpo8s22sy34nvn4dVC)0Txp-~I zklr{~`@X`k9z`SG`zD}0qbrLKcoV%M0NuTH;XJ=E?b;9eG0JSaJy1R5Hp1PPJu2=D z6b>C`y5jW#r#_)iqWU?T@Xc@Di(b^xU4LsT=uV3=0jz}WEx-|LpYv#`&^SOtfqe); z%D-O7ZR$-ol2kWf^e#xKkvM}UE&Y<|MA0OmEVGLC!OAZ<7>wjhn zual<&%&v6HWyIf z(l#yCj>hp{+!-wMa+!9)IC zFl->8UZ{X&gLxiXJe%m{BlC)S=)IA&o4RXpXogTi-L2hf()(wpB*=iTjTHqg8t*!N zUe%OXRVzSWKt5X3^s0j`aGXt>$2qtiXzJ(4g9J?F5pcT9ESK&#v)yuCbO;baqtYBg zU#S7VaWI=QwPb)xJR^6-nNe(4B@w9OvT$;>T#l1Z@kGR=XNJNtP%}uLhc9t?beiPa~6I<{HGtQ@8c=-ic~sRD3F|gghRK?BV4QvFA8euD$kX_mp%k!DKH3j(Xi z1@sZ14RJteWK&#o)UZsaxuWq!JtQzqPgF$P0K2!HaO>F=YP^Ga#zyLR!<=l5m(pum z@e%XehY@1|@V^NWl}#B~3~XQeQ!BVH*#TFWo*Lz5BjQ=v6^#*KACaeZpDP};7I0ec z=v{prwwNY~P*?o;UVPE_^|G?2NtXtGjQNWhkYK*S#}_hbCeaMtHfMxo!P; z!c4Aia@2Fd@&6c@)tvp&!qYTNr9>#*yoG4B@K?b3aDwf-1edR5Ka`!#cl_I<>Q#&? z7Igr(P;dPU(*|L>Y~4oKhT84wlbRzblMpokCeSYs6)a4z0t2%J-nq4bdQ#>Uay%(` zna>@IYQ2gl%Ka}oxwBt?#z01Z^oN^L6if%aen4_$iDH--`e;tmQ{IXfd%}k$+!2w} zTMw8p6(B)bfYxNgBNl)#AlkO#(XEOWJ%c56hc?Gy`EHz)1$@-cttL zRywy!_{+N@)d272GIo^AODDB*naC3LnslC`t8(91*dIa;6i^#5jznY7%|jz%g@lF| zN7#XGBPE+`tXz1XY(42pL9)q;M=p#GIX7gh9s6^ zPSGSf>IbNh%->hqd3@_?$}8Q+iAVpekJbg3i`%7Er|UX}?hlaI9*TGexUmK9U}>#X+Q((A)qs*1f*I9chpCb>o`iwpFNc{v6ko^=sIk>sI@U|CwK7LsB~YThp2zl48OQ< z&zJ1(@w?|#@ebfb`-A~?RT$byI($o7kXrqBl zRUo@SCJc4s)XN|;|BTeKlsv!9 z(cIn|gtsA({yTJOmZM#e0LktHSdWvH{ar+lNhp0zqJBW*#d}Y$i!;t%IJIf+1JOn_ z>9;}gP!@_DXW~V7hdA#@bC{AW){}Y*L)PZu`mQ(DW=w}yZ$He&+>2N*V=B#yG7Tbh z-LpBRqKU~iQxYV)<{w9O#}yp=lF9qmt++ zdetfz?T6(n^b3}Lsu^k)sbw%KIRi>zUPvZf`s3$xzr-AOHN)C}eXq&S<-w37>!e8` zH@1sLEDWoS2J6lJiN_KDj_&ygy5|(Na7~)Q;PA&431*=ZkF~+s&FndiFYaJ!tuC2A zwTPuIE227U{ViO$pBg+yTL_wU=8dy8~K z+$Pj>!Ds3{aq2%ZPbbE?43&+uTp5(;!0G)EDy2&exB(OkA5gtF_na2SDg}ZZK+Px+ z&9jyhtP~4ss7Y7xn7Cxp_Ck|i9zIrct?K2~mTDE{?*O|tenN~w4x|_cB>&H*W3d~a zA3j`dgmb}dl6~whH@ZM}ryNf*m{uy-LEXl>faI7;0E|EuWQVW@;wKEp)|OA1O+(4! zOhr}MM=-RLObM8UcH19OYw~9~$0KsSnu@s~a~H5B#anI=9b2pK=m`Cu&YO7wh*5#; ztjh=iosZB{xQvm9X@BNHeXJx=cXcJ7E(#|{s5BUveL*T_deaqXQEDu~ecqxP0scY1q}_Hw*!rf~)D~p5 zDv+IlX68u{m`#bJfVG(De!XqS!n8$X^m3O#+Q; z2HCLL>*=ggfTx)u+zBOM)PMGw=h=b+ zbAB%iM}Pkzvriw8Ywm0AaDAEmhVt6HJ>mFA9zTS!Xb9IPKpRa;K{5@bvytJbgv6D7 zHs{Hp%3n=Qa=k{|V_e?NdXx4leCN+D$4Hfi_-4Y@yQISS<~x_S)QL_b=*)_Q%UHaS z_DLZH4GPG(fJFHCt?C)I>#FO#b=TiH)rVa8HoKvuGjnZ{(WkD6q3=tj%HH=o)Y2?d zvwOwl*=>B;Me+Bd_#)c$71v|{B-{je-U?)&E2?G1`$yedi8uEQ*Qykf_xcVLCZv0W#0fKQ;A9#g|S#7Hjvd^@3Ohj zx5MAGTLIgQ2LuzatVrM~M&mz;fDMf4%d5*}2Qhc$al1U7U(Mng z@7Jtf$1Sf1q{9^yW8XzQ0Jso*#QQVZK24YMxK>6zgU6Cj0g4OLR+$4K6yi-GqM4fb)4MClkeFL(Fo5hbOvuRgh^_lVjH z(hsJ_%{R26NTGdw3<}?h9E4z)_9Tox&BBWrn233&`(;IeD`!4#pKn{c1%99%jQoZ~ zS)=EkyLa^2>=cX(Eh%{pUq7-op2Y-+RWM$naRDECY(Z2FUoeq`JcWuFUmFQ`GUbD2 z%D1Td${igAXbQZg-zxHfo53dHpa3;g3iS8o-_gIuYLa6$Nzi#X_Fi;Q`7<%u?vgE5=2E#h-I-jIu?uF!gGdi0?BK)SuEw9s0rcmSs%}g zAJWwMb)tKL!GiN%|0oe^#KxaVp-7;A?PKj59713r-N%bLge;)z2cP&U9ag z`daY%E-7pHcZDJ^wlw+%W2<9JKSXHEY^CXT_jRbRo&U75%@D(UUO^$NaNDETyaxYF zlm#@gq|uMNuS0$9)ctEQr+PFOQ?u0d&$!{wdrxA-FB=4uc-JAr$t&tp{#B>_(AZ54-gg z)1G2V*VzB5nCfOJvKbBJtMc92(TsChD$SI?*WpT`8z=evL86t**T?0!78$B>UW_}3 zh_euVa7X=*%(LLP(iLTe2G$cqJ0^#Ea$XAR;}2}WJ-9WPmJWkc9k()nb(bimpg_pu zBsWCNX>g@gyAa`X-XVuWW%8BW`LdwX0;JmsZWMmp+no2iB7B;EcwK-zCpo*;U zq>LzyrX^Ke<6am2_Jtp=d|K2Y`Ev4~x?ZLiFeQ+i6mk2~ko z5R^WM`-`c@LP|juCFQe*iE{!@kL?9_5XqFSx`n9tf28u~;-t0u&hxd6LaCNp=)uVi zggxnrl=%uS{w5v1%Gq`Ktiy5N6=(C4A7y+c_SSY9lb213&}|@ch!LY`lYc|fc~))+ z*Lg>KzI2d0aYBZ9gfcr`D}{5Vvl7N_+E>@YR1;Z_iQhKLfh`ccJJj zj(7CQ+#y`&CAVBXrm9YUb$Q^T%#QTVPqN#lWl!CmDA67=dUVpt8m0KQ72yLos$K5~ z7EAPp1}-(vRgM(rt7D?0~2(Ls7d}%F~xMm55UxdTU#Z$(?qU&5ofjsISuH zTVi~oBy;3?!gzv=NVH+Wkb@rZ9I!0o8Y1Kw=EPuAL%1w#m(jO_UrWwz#p)lzkK<_! zRi=iiG)m)U!Q00Rf;{pURt30A784WODILyQs-oMEn-I9wvVf@&9>I~d8_(|x&EDIAw~i2VRFI(1 zk;GBA_;Q`k4QjDkZ`4FyKO~-^I;IZ_c@dm2w#dMGfRg-()te)q_25QE`(0c<&%DO+ z2FEN-lxklZw;cs%Ymu)mLon+B{D+MG+Uz`w69eIj*1j{Kczx5O)mOIB%(cj}cuNdIB$)GFOLg!&X32NNL2iFp}s z7gq(m@ouFAljIO9NZ8DOaj_!3XS5bBIuFK|1=#0jd@tG3X-y zK|-#izY;a|nbR@dLUM913oVyKfin+!32JDZumR13TSz~pn4{>&&JM~}t6yR3f3^2k ztP#kdw`qg?z##d2MHSPV*4cIiols(bpymB!`B;046_$qJca{#*8F53Bym(!%FSkyzv}Q`g28otm=zj^~aD_IvmQ6Ej>B%ek01)DgM<}-~@a5hW9+9EP z#Cnl@EkBfhVWLDWpGzk&RJBY&3;q}&1^AoDckDiTQW9R{`jj*@;@h?+^XhiEMeaOI7@F ze=^8>^tgc+qp54Qq${{qAG$%WoCE%+cxErQ{+(eFI+L-c>awp_bRg}q5)_6voIE)4 zL~)kilm$gWvFg5`GZgg_{k|10o&Z2j3^c{(!%$+1QxP?kC{0HmyrzQ=-diR)Bl!rE zd_(j)XNxocA=*wIJdOiTDiud>s}AL2KLMBD0$1KZKObVd>RXkuLD}a8PSrTEz??xB zJ($*1N$9OMj23fp#{!&UiKya6Sy-(k9NSYOiQWTdDG)it_MXV&Z+F{IlH(_=6KlV_ zFm8$9l=GXFbHrc$;k9ceu-+eND+_XgoFr39-XGDV6W5lSslmfhQUMepw^2k+%nD0P zI=3)rhFY@EX>FO|G0jW(TM9A9X#i&^LGfVjFm9N!0%|e#>4^g1zdO;f5v&HD-*cCP zFZ-LEN6xEuzoI3K-;-t-X*k(Jkr89C#7LtgUcXm=Rg6jYcbrKsFW_ES(jZLo;TL%v zr9)!BxDGBB_bFd^E8SeBFpW4PU{5FJ`2LDr`pvlQ8!A9-q+;rS0PRv%$CG+Jmk;lw z7ax$FyHs>X83MWk%Hm;Kf3&#JEMgvERcQi(_u{PwDc+k5ex=uhSp1A)u}|j4DK#`| zQhEJ?p7B3V8ryWpYgh)j@3Bz%q%7iZSoZJ{iV5Pb;Oy};^w?Lzc)%J3=A zH@L1MaELObNqsd*KhA}h%H3N0y`B8g$Wdxac-iRdF66I8LSk;OM91LOBJR96S%w zbSh7HwPefP8rcDHR>Njz@8M%sGrhdpW8-^oL?2Y)Ab@o%%nxz6j?y_fEqj&(T$Cm z*3@^Z4wl6JPLNP#z-ynPvEv5X71RfNH4uj&xMUhZ=!sQeDh`PW)4#!8RO>HL<_}1s z$HJ}@C^qvLnXlm1xUdsI@Jcq=?*`-D86UtcgWwi7r6~X^ETb!JPKHwAN7aWk1qt<` z4v9OLE~7n4o7YJhZB7j=ciIiNk1k1wLT+4Y!B z$2nRBYBstX^%qPZty6Ur_n3)2Ddi@I0gdESZOs&0!;9J99xP5gDz=affplivROvj31x^RB zwVRFp2~D*ADghokh{z|=wrv()um5;YaJ)PbRF-Kecp3-Zql8r<-FI1qqWf{jb7hY! znt4)fe4)oAupc@N%KmR@U$}wOjpOf63_TzQ!ah!NQlNGYptGwO0d$~B=Y2F&-85}Q z@uuL&RoBU(G)BU*c?A!lXF!!y4t?CE-%0=biA2^3Y4oU&o52Yz;9f@Op*HXkv>7k9 zzE@ln^bqU25!U|>P9LC~3_+<9&#ODy9-KX^8FxkrT7Y)Dk>0J`pKDz_<~05-)0kEv z66ioQz6GM!d;?!@JN#ff8z`b1f`Zv7V|}^Y%eo+kAc_c2Ee*^71m{rXsg*)e&D!JS z`=`mtXxo=jW%YMtF@xhj9gOg)zD+NQzHN($4#GzzH|TrYH-Kbh|GzoP{~*J0%z#Td zPII|}-Al66dp?mwKcpXAisG5eq&+6nebd_e*MXClnPp1TFR%ehVFD<6GYT_+$Bqz; z&-||o`(-O@wS=IKOamr$Liy)Tv!E^iv@gkXM?0?thV&n8dH@d4fT(-34R?`J+zGyQ zlXA@X*yZQ_8n0C~WqH-QgGJYDwTbZ@FP{}Cj&W+{NuWJWt^(m?YwVhBi3k1JMez2B zU=u)GgCkkJ6~%>yvF+oZ95}Rr_eV>k^8nV2oTBZLNjL`CCC{+@p+#7$W0@2Ls1df% zgjEYgD?bb~%*ZR;+*fH50R4WCu9$1P0^AS}DQvig&j8q!xuL{>DGB|%oKj_4Vj6V} z^Dz>Gzcb>mRVXSj2FErlnpj@7%fY@^C`?C~Fx`}eMLDIK+XGE6sSp_~){iX2;2b+? z>h8-}v!~u1bA6V%eYB|!Jkx?8`GNtWD34V!V&eU2*&Vn}c9lKv22P|ajzX%n@aQT( z2}S8KkiUnopUW!G1x}UH3hXkBkIZ|aI#;1QZ$JSrSFtih9k}}z@V08UVj>L|At-@p zUm_*RZkGMXsrwL#@$YZ?e{NFo+?n z1-GB;%AqZ$I>Kc&2G#-bvO^rrq4zvaT2yln!%e@Y{)K>2uc|LeUOmWm(HZ z($I`2J08F&4!#NMm^`IA#V^CWPni(F@K~Eo4*9st0;Y@K%f09WV;!e zu#TF`8Hql$6a*L>Z2j9am_KD)oiO6^%TY~hB()5a!#!3+1_S71R|2iID@{tq`Yhz3 zS*{>2PFEL)vqPr73~bU#YFixKVJjlT>3iDX2KhXN-flh820OfAp0=CF*~{|6Um1h0 zVWS*J)U4eoN=Aw_*vrA35^1y_^Zf4+A8hIE$2I(B^%)w|`|Q_*;2>GxI7ikY(A`7w zw*sCPU+7=VP>^k!QwtA7gBnvgL)r>14@J*d2QBN_jz<}j6A0rul4JLtZGP|=20luz z^-7DEw$$isuDLnL;Wp0?3W`#+n? zP%k;8!Yt|Owj8x;(ZT87!6GLxQ)Q{fW}4)pw>u|6QJWpR@<7Sh0u9Gy%jx? zYBP-fR~@dNgj~Ihc2NaPx{MddJp0{mBi>m+w^#*1W^Da0cIIMjMG#lf3sI%+)IGY? z(GO?p-K1wiQPdcH<%3J4b0cnm!IW+7Qp5rEF!h5X{sBa4ZHTFqiBy{{zoBV1f;#I+ zSEL{v2%F_mQ*BCy)>6YBr?UJ-KS*H6J!~p-a|XJ3MZc-=S_wvtM)6aO@`KgSBfGz* z?N-1e-nWo>NIS!L!Zv)HPfdiOWu+#xFp*~1v&x$WpMoyqVf#Tsz(i&`6AUWPAzCAQ zkL4Qb(d@&}WnmYz@OG%^Tj4C^N>{Wl*N(ri?nj(hNLO}xulDkeqp8QegQVdCzKxM?pu-l>3|@a3CMZ>nJn0Z( zeQsc^TJm?I*N@C@3ej#(g!^!E%iJRO7;fNBDGHTCoYl!u#-&B(v39btN2gk>D}A1< zKaI;5nd_Kz*V_iM(s{D5J(%Y)$(MwHAkQ;O6MVS`t#bf`n;GZzYlyrR`L2O5Hj~R? zOhRMAIfy$IlT*B%%@c|%$7Gp2Pkxp=cTqc@iz|G(7=#8{_q3PcSV6gG&*YK%#Bv2E ze3@76LMFzqiQTYYVf7B9KWd4J{PU7&9^14v(D&lUh*;+2E*E%#Z)#l^>>kmJj5f zFFvvF#jg#=Hp+u~Mb3$=Zu{+5-85qK3_FQxxS*z>p-dV#RK@yhuItyI-lu z+rex1* z5E&w{0tU{b>8UKeiV#f-GDrHsFi<|9h&x^qHPfsgouFZiXtRwRyuX!&opWxAne&p| zu{MZ0HXh0t(UqsF_m zb@od<;T*~h4n?bFT#Ye!)LV1c9UHaj(u*o_#yZJ`NSBQy$dtoOL9Mpc>QASxV9lFZ z7&9}&Py5*SpiJ4+CK)DVtV^eEXxA_@sSlZams|<5t`-y4eOj-+W-In literal 14572 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 diff --git a/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLHighlight.cpp b/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLHighlight.cpp index 3b642b3766..8e1d1fe0bb 100644 --- a/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLHighlight.cpp +++ b/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLHighlight.cpp @@ -338,7 +338,6 @@ My_TestGLDrawing::Pick(GfVec2i const &startPos, GfVec2i const &endPos) frustum.SetWindow(GfRange2d(min, max)); UsdImagingGLRenderParams params; - params.enableIdRender = true; GfVec3d outHitPoint; GfVec3d outHitNormal; diff --git a/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLPickAndHighlight.cpp b/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLPickAndHighlight.cpp index 46f86a494a..19b1138cd2 100644 --- a/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLPickAndHighlight.cpp +++ b/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLPickAndHighlight.cpp @@ -454,7 +454,6 @@ My_TestGLDrawing::DeepSelect(GfVec2i const& startPos, GfVec2i const& endPos, // XXX: For a timevarying test need to set timecode for frame param UsdImagingGLRenderParams params; - params.enableIdRender = true; SdfPathVector selection; @@ -505,7 +504,6 @@ My_TestGLDrawing::Pick(GfVec2i const &startPos, GfVec2i const &endPos, // XXX: For a timevarying test need to set timecode for frame param UsdImagingGLRenderParams params; - params.enableIdRender = true; UsdImagingGLEngine::IntersectionResultVector outResults; From 6120e2581c45eaa907a6a39fea428b212915f6ab Mon Sep 17 00:00:00 2001 From: gitamohr Date: Tue, 29 Oct 2024 11:15:36 -0700 Subject: [PATCH 076/300] tf: Sort libs by name when the SML is requested to load all libs to eliminate a source of nondeterminism. We already sort individual lib predecessors by name for the same reason. Also separate the "already loaded" SML debug messages to a new TF_SCRIPT_MODULE_LOADER_EXTRA debug code. These messages can vary by build configuration, causing test output differences. E.g. in monolithic builds, "modules" load in coarse-grained groups, while in shared library builds, they load individually. (Internal change: 2345975) --- pxr/base/tf/debugCodes.cpp | 7 +++++-- pxr/base/tf/debugCodes.h | 1 + pxr/base/tf/scriptModuleLoader.cpp | 10 ++++++++-- .../TfDebugTestEnv/non-specific/debugTestEnv.out | 2 ++ .../testTfScriptModuleLoader/scriptModuleLoader.out | 10 ++++------ pxr/base/tf/testenv/testTfScriptModuleLoader.py | 2 -- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/pxr/base/tf/debugCodes.cpp b/pxr/base/tf/debugCodes.cpp index 936ca5c6ec..8328112627 100644 --- a/pxr/base/tf/debugCodes.cpp +++ b/pxr/base/tf/debugCodes.cpp @@ -13,8 +13,11 @@ PXR_NAMESPACE_OPEN_SCOPE TF_REGISTRY_FUNCTION(TfDebug) { TF_DEBUG_ENVIRONMENT_SYMBOL(TF_SCRIPT_MODULE_LOADER, - "show script module loading activity"); - TF_DEBUG_ENVIRONMENT_SYMBOL(TF_TYPE_REGISTRY, "show changes to the TfType registry"); + "show script module loading activity"); + TF_DEBUG_ENVIRONMENT_SYMBOL(TF_SCRIPT_MODULE_LOADER_EXTRA, + "show more script module loading activity"); + TF_DEBUG_ENVIRONMENT_SYMBOL(TF_TYPE_REGISTRY, + "show changes to the TfType registry"); TF_DEBUG_ENVIRONMENT_SYMBOL(TF_ATTACH_DEBUGGER_ON_ERROR, "attach/stop in a debugger for all errors"); TF_DEBUG_ENVIRONMENT_SYMBOL(TF_ATTACH_DEBUGGER_ON_FATAL_ERROR, diff --git a/pxr/base/tf/debugCodes.h b/pxr/base/tf/debugCodes.h index 7025b0c1a7..e6d0aa3eb8 100644 --- a/pxr/base/tf/debugCodes.h +++ b/pxr/base/tf/debugCodes.h @@ -26,6 +26,7 @@ TF_DEBUG_CODES( TF_DLCLOSE, TF_SCRIPT_MODULE_LOADER, + TF_SCRIPT_MODULE_LOADER_EXTRA, TF_TYPE_REGISTRY, diff --git a/pxr/base/tf/scriptModuleLoader.cpp b/pxr/base/tf/scriptModuleLoader.cpp index b5590eac3e..399a6d2309 100644 --- a/pxr/base/tf/scriptModuleLoader.cpp +++ b/pxr/base/tf/scriptModuleLoader.cpp @@ -269,13 +269,19 @@ TfScriptModuleLoader::LoadModules() toLoad.push_back(std::addressof(*iter)); } else { - TF_DEBUG(TF_SCRIPT_MODULE_LOADER) + TF_DEBUG(TF_SCRIPT_MODULE_LOADER_EXTRA) .Msg("SML: Skipping already-loaded %s\n", iter->first.GetText()); } } lock.Release(); + // Sort modules by lib name to provide a consistent load order. This isn't + // required for correctness but eliminates a source of nondeterminism. + std::sort(toLoad.begin(), toLoad.end(), + [](_LibAndInfo const *l, _LibAndInfo const *r) { + return l->first < r->first; + }); _LoadLibModules(toLoad); TF_DEBUG(TF_SCRIPT_MODULE_LOADER).Msg("SML: End loading all modules\n"); @@ -301,7 +307,7 @@ ::_LoadLibModules(vector<_LibAndInfo const *> const &toLoad) const continue; } if (info.isLoaded) { - TF_DEBUG(TF_SCRIPT_MODULE_LOADER) + TF_DEBUG(TF_SCRIPT_MODULE_LOADER_EXTRA) .Msg("SML: Lib %s's module '%s' is already loaded\n", lib.GetText(), info.moduleName.GetText()); continue; diff --git a/pxr/base/tf/testenv/baseline/TfDebugTestEnv/non-specific/debugTestEnv.out b/pxr/base/tf/testenv/baseline/TfDebugTestEnv/non-specific/debugTestEnv.out index d14ee35e96..bfe77dbc3f 100644 --- a/pxr/base/tf/testenv/baseline/TfDebugTestEnv/non-specific/debugTestEnv.out +++ b/pxr/base/tf/testenv/baseline/TfDebugTestEnv/non-specific/debugTestEnv.out @@ -23,5 +23,7 @@ TF_LOG_STACK_TRACE_ON_WARNING: TF_PRINT_ALL_POSTED_ERRORS_TO_STDERR: print all posted errors immediately, meaning that even errors that are expected and handled will be printed, producing possibly confusing output TF_SCRIPT_MODULE_LOADER : show script module loading activity +TF_SCRIPT_MODULE_LOADER_EXTRA: + show more script module loading activity TF_TYPE_REGISTRY : show changes to the TfType registry diff --git a/pxr/base/tf/testenv/baseline/testTfScriptModuleLoader/scriptModuleLoader.out b/pxr/base/tf/testenv/baseline/testTfScriptModuleLoader/scriptModuleLoader.out index c517705788..aec6b56480 100644 --- a/pxr/base/tf/testenv/baseline/testTfScriptModuleLoader/scriptModuleLoader.out +++ b/pxr/base/tf/testenv/baseline/testTfScriptModuleLoader/scriptModuleLoader.out @@ -13,15 +13,13 @@ SML: Begin loading LoadsAll's predecessors SML: End loading LoadsAll's predecessors SML: Request to load modules for empty lib name -> load all SML: Begin loading all modules -SML: Skipping already-loaded tf -SML: Loading lib Other's module 'pxr.Tf.testenv.testTfScriptModuleLoader_Other' -SML: Begin loading Other's predecessors -SML: Loading lib LoadsAll's module 'pxr.Tf.testenv.testTfScriptModuleLoader_LoadsAll' -SML: End loading Other's predecessors SML: Loading lib DepLoadsAll's module 'pxr.Tf.testenv.testTfScriptModuleLoader_DepLoadsAll' SML: Begin loading DepLoadsAll's predecessors +SML: Loading lib LoadsAll's module 'pxr.Tf.testenv.testTfScriptModuleLoader_LoadsAll' SML: End loading DepLoadsAll's predecessors -SML: Lib LoadsAll's module 'pxr.Tf.testenv.testTfScriptModuleLoader_LoadsAll' is already loaded +SML: Loading lib Other's module 'pxr.Tf.testenv.testTfScriptModuleLoader_Other' +SML: Begin loading Other's predecessors +SML: End loading Other's predecessors SML: End loading all modules SML: End loading DepLoadsAll's predecessors # Registering a library that is totally independent, and raises an diff --git a/pxr/base/tf/testenv/testTfScriptModuleLoader.py b/pxr/base/tf/testenv/testTfScriptModuleLoader.py index a88f7a00ce..092f9e7429 100644 --- a/pxr/base/tf/testenv/testTfScriptModuleLoader.py +++ b/pxr/base/tf/testenv/testTfScriptModuleLoader.py @@ -5,8 +5,6 @@ # Licensed under the terms set forth in the LICENSE.txt file available at # https://openusd.org/license. # -from __future__ import print_function - from pxr import Tf import sys From 65472cf5bb3358e3101abc1f81913d15eca95224 Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Tue, 29 Oct 2024 15:04:39 -0700 Subject: [PATCH 077/300] Add UsdzValidator keyword to usdUtils:PackageEncapsulationValidator (Internal change: 2346021) --- pxr/usd/usdUtils/plugInfo.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pxr/usd/usdUtils/plugInfo.json b/pxr/usd/usdUtils/plugInfo.json index 4d429b639a..1962a094a6 100644 --- a/pxr/usd/usdUtils/plugInfo.json +++ b/pxr/usd/usdUtils/plugInfo.json @@ -4,7 +4,10 @@ "Info": { "Validators": { "PackageEncapsulationValidator": { - "doc": "If the root layer is a package, then its recommended for the composed stage to not contain references to files outside the package. The package should be self-contained, warn if not." + "doc": "If the root layer is a package, then its recommended for the composed stage to not contain references to files outside the package. The package should be self-contained, warn if not.", + "keywords": [ + "UsdzValidators" + ] }, "keywords": [ "UsdUtilsValidators" From d1ac1d0d1fd401cfd67d6cf8647e2c472d9a5f10 Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Tue, 29 Oct 2024 15:04:46 -0700 Subject: [PATCH 078/300] Prevent processing of invalid layers in a package. usdz could contain invalid layers (like abc files), which is invalid, and we should guard against processing them. The code here will issue a validation error if an invalid layer is encountered. (Internal change: 2346022) --- pxr/usd/usdUtils/validatorTokens.h | 3 ++- pxr/usd/usdUtils/validators.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pxr/usd/usdUtils/validatorTokens.h b/pxr/usd/usdUtils/validatorTokens.h index ac5424e131..cc0b7ac1df 100644 --- a/pxr/usd/usdUtils/validatorTokens.h +++ b/pxr/usd/usdUtils/validatorTokens.h @@ -25,7 +25,8 @@ PXR_NAMESPACE_OPEN_SCOPE #define USD_UTILS_VALIDATION_ERROR_NAME_TOKENS \ ((layerNotInPackage, "LayerNotInPackage")) \ - ((assetNotInPackage, "AssetNotInPackage")) + ((assetNotInPackage, "AssetNotInPackage")) \ + ((invalidLayerInPackage, "InvalidLayerInPackage")) ///\def /// Tokens representing validator names. Note that for plugin provided diff --git a/pxr/usd/usdUtils/validators.cpp b/pxr/usd/usdUtils/validators.cpp index 513f2aa5fc..64e4cd33c3 100644 --- a/pxr/usd/usdUtils/validators.cpp +++ b/pxr/usd/usdUtils/validators.cpp @@ -45,6 +45,19 @@ _PackageEncapsulationValidator(const UsdStagePtr& usdStage) { if (!packagePath.empty()) { for (const SdfLayerRefPtr& referencedLayer : layers) { + if (!referencedLayer) { + errors.emplace_back( + UsdUtilsValidationErrorNameTokens->invalidLayerInPackage, + UsdValidationErrorType::Error, + UsdValidationErrorSites { + UsdValidationErrorSite( + rootLayer, SdfPath()) + }, + "Found invalid layer reference in package. This could be " + "due to a layer that failed to load or a layer that is not " + "a valid layer to be bundled in a package."); + continue; + } const std::string& realPath = referencedLayer->GetRealPath(); // We don't want to validate in-memory or session layers From f03094691a20521ad34fccb418997a4e40078bd7 Mon Sep 17 00:00:00 2001 From: tcauchois Date: Tue, 29 Oct 2024 15:04:59 -0700 Subject: [PATCH 079/300] [Hdx] Add missing API tag to HdxSelectionTracker. (Internal change: 2346030) --- pxr/imaging/hdx/selectionTracker.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pxr/imaging/hdx/selectionTracker.h b/pxr/imaging/hdx/selectionTracker.h index c8fcb865b3..7233dfd046 100644 --- a/pxr/imaging/hdx/selectionTracker.h +++ b/pxr/imaging/hdx/selectionTracker.h @@ -94,6 +94,8 @@ class HdxSelectionTracker public: HDX_API HdxSelectionTracker(); + + HDX_API virtual ~HdxSelectionTracker(); /// Optional override to update the selection (either compute HdSelection and From 1930e0b44e9972f10dfc6f3cc609a4e8a39e9b2d Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Tue, 29 Oct 2024 15:05:09 -0700 Subject: [PATCH 080/300] Disable testUsdValidationContext for static builds, as these rely on test plugin build specifically for the test, and build system currently does not support this for static builds. (Internal change: 2346048) --- pxr/usd/usd/CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pxr/usd/usd/CMakeLists.txt b/pxr/usd/usd/CMakeLists.txt index 7c77c2dea7..02793db940 100644 --- a/pxr/usd/usd/CMakeLists.txt +++ b/pxr/usd/usd/CMakeLists.txt @@ -1078,24 +1078,24 @@ pxr_register_test(testUsdValidator EXPECTED_RETURN_CODE 0 ) -pxr_register_test(testUsdValidationContext - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationContext" - EXPECTED_RETURN_CODE 0 -) - pxr_register_test(testUsdValidationRegistry COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationRegistry" EXPECTED_RETURN_CODE 0 ) -# This test relies on a plugin built specifically for this test. -# The build system currently doesn't support this for static library -# builds, so we only enable this test on shared library builds. +#The following tests rely on plugins built specifically for them. +#The build system currently doesn't support test-specific plugins +#for static library builds, so we only enable these tests for +#shared library builds. if (BUILD_SHARED_LIBS) pxr_register_test(testUsdResolverChanged COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdResolverChanged" EXPECTED_RETURN_CODE 0 ) + pxr_register_test(testUsdValidationContext + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationContext" + EXPECTED_RETURN_CODE 0 + ) endif() pxr_register_test(testUsdStageNoPython From e45ffe68575b67017c682816f75a4cf5b51a94e8 Mon Sep 17 00:00:00 2001 From: pixar-oss Date: Tue, 29 Oct 2024 15:05:33 -0700 Subject: [PATCH 081/300] Doc updates for namespace editor for 24.11 changes (Internal change: 2346056) --- docs/user_guides/namespace_editing.rst | 312 ++++++++++++++++++++++--- 1 file changed, 276 insertions(+), 36 deletions(-) diff --git a/docs/user_guides/namespace_editing.rst b/docs/user_guides/namespace_editing.rst index ec201d3ffa..c5ca55dd26 100644 --- a/docs/user_guides/namespace_editing.rst +++ b/docs/user_guides/namespace_editing.rst @@ -10,19 +10,26 @@ A namespace edit is an operation that removes or changes the namespace path of a **composed** prim or property on a stage. Edit operations currently include deleting and moving (renaming and/or reparenting) a composed prim or property. -While it is possible to do some of these operations using Sdf or UsdStage APIs, -these APIs can only edit prims or properties on a single layer. Namespace -editing handles edits for prims and properties that are composed from multiple -layers or other composition arcs. Using namespace editing lets you robustly -delete and move prims that have opinions throughout a LayerStack that you have -the authority to edit. Namespace editing also allows "non-destructive" -deletion and moving of prims defined in LayerStacks that you don't have the -authority to edit. +While it is possible to do some of these operations using Sdf or UsdStage APIs, +these APIs can only edit prims or properties on a single layer. Additionally, +any paths targeting the moved or deleted objects will need to be manually fixed. +Use namespace editing to easily and safely delete or move prims and properties +across the :ref:`LayerStack `. Namespace editing handles +edits for objects composed from multiple layers and handles changing +:ref:`EditTargets ` or fixing paths targeting the +edited objects, automatically. + +Namespace also provides non-destructive editing of prims defined across +composition arcs by adding the **relocates** composition arc if needed. +By using relocates, namespace editing ensures non-destructive edits by *not* +modifying the source of a composition arc. This is necessary for workflows where +you might not be able to make changes to the source of the composition +arc directly (e.g. you're referencing prims from assets maintained by a +different department that are also being referenced elsewhere). As a simple example, if you had :filename:`model.usda` with various prims: .. code-block:: usda - :caption: model.usda #usda 1.0 ( @@ -39,10 +46,9 @@ As a simple example, if you had :filename:`model.usda` with various prims: } And :filename:`main.usda`, which has :filename:`model.usda` as a sublayer and -overs for :sdfpath:`/modelScope` and :sdfpath:`/modelScope/model1`: +overrides for :sdfpath:`/modelScope` and :sdfpath:`/modelScope/model1`: .. code-block:: usda - :caption: main.usda #usda 1.0 ( @@ -60,15 +66,16 @@ overs for :sdfpath:`/modelScope` and :sdfpath:`/modelScope/model1`: } After loading :filename:`main.usda` into your stage, if you wanted to fully -remove :sdfpath:`/modelScope/model1` from your composed stage, using UsdStage +remove :sdfpath:`/modelScope/model1` from your composed stage using UsdStage APIs, you'd have to delete it twice: once in :filename:`main.usda`, and then, -after changing edit targets, again in the :filename:`model.usda` layer: +after changing :ref:`EditTargets `, again in the +:filename:`model.usda` layer: .. code-block:: python stage = Usd.Stage.Open("main.usda") - # This only removes model1 in model.usda, not + # This only removes model1 in main.usda, not # model1 in the model.usda layer removeResult = stage.RemovePrim("/modelScope/model1") @@ -77,8 +84,8 @@ after changing edit targets, again in the :filename:`model.usda` layer: # set the edit target to the model.usda layer and call RemovePrim() again Whereas using namespace editing will properly handle removing the prim from -both :filename:`main.usda` and :filename:`model.usda`, handling edit target -changes for you: +both :filename:`main.usda` and :filename:`model.usda` in a single edit +operation, handling edit target changes for you: .. code-block:: python @@ -86,19 +93,19 @@ changes for you: removeResult = editor.DeletePrimAtPath("/modelScope/model1") editor.ApplyEdits() -Namespace editing also handles issues such as making sure that paths to -and overrides of edited objects are still valid after renaming or reparenting +Namespace editing handles issues such as making sure that paths targeting +edited objects and overrides are still valid after renaming or reparenting prims. Namespace editing tries to fix any existing composition arcs, relationship targets, attribute connections, and overrides that used paths to renamed or reparented prims to use the new paths. -Namespace editing in a future update will also use **relocates** for more -complex edit scenarios. Relocates are another composition arc that maps a prim -path in a namespace to a new path location. For example, if you were referencing -a prim from :filename:`refModel.usda`: +Namespace editing will also use **relocates** for more complex edit scenarios. +Relocates are another composition arc that maps a prim path defined in a remote +:ref:`LayerStack ` (i.e. across a composition arc) to a +new path location in the local namespace. For an example of how namespace +editing uses relocates, if you had :filename:`refModel.usda`: .. code-block:: usda - :caption: refModel.usda def "modelA" () { @@ -107,16 +114,19 @@ a prim from :filename:`refModel.usda`: } } +Which is referenced in :filename:`main.usda`: + .. code-block:: usda - :caption: main.usda def "mainModelA" ( prepend references = @refModel.usda@ ) { -You will be able to use namespace editing to move or rename -:sdfpath:`/mainModelA/modelAChild` using relocates. +You might want to use namespace editing to move or rename +:sdfpath:`/mainModelA/modelAChild`. Because :sdfpath:`/mainModelA/modelAChild` +is composed across a reference composition arc, it can't be directly edited, +so namespace editing will use relocates to create the edit. .. code-block:: python @@ -125,6 +135,30 @@ You will be able to use namespace editing to move or rename removeResult = editor.MovePrimAtPath("/mainModelA/modelAChild", "/mainModelA/renamedChild") editor.ApplyEdits() +The resulting stage root layer for :file:`main.usda` will look like: + +.. code-block:: usda + + #usda 1.0 + ( + relocates = { + : + } + ) + + def "mainModelA" ( + prepend references = @refModel.usda@ + ) + { + } + +.. note:: + + **relocates** is a new composition arc for USD that is a separate feature + from namespace editing, and can be used independently of namespace editing. + +.. _nsedit_using_usdnamespaceeditor: + ************************ Using UsdNamespaceEditor ************************ @@ -147,7 +181,7 @@ rename or reparent prims and properties using :usdcpp:`UsdPrim` and When you call a :usdcpp:`UsdNamespaceEditor` edit operation, the operation paths are validated (e.g. the paths passed to :code:`MovePrimAtPath()` are checked to make sure they are valid paths), and then the operation is queued (to support -batches of operations, see :ref:`namespace_editing_batch_edits` below). To +batches of operations, see :ref:`nsedit_batch_edits` below). To execute individual edit operations, as the following examples do, call :code:`ApplyEdits()` after each operation call. @@ -204,6 +238,82 @@ Note that after renaming or reparenting a :usdcpp:`UsdPrim` or :usdcpp:`UsdProperty`, the :usdcpp:`UsdPrim` or :usdcpp:`UsdProperty` reference used in the operation will no longer be valid, as the path has changed. +.. _nsedit_setting_editor_options: + +Setting Editor Options +====================== + +When you create a namespace editor, you can optionally provide edit options +that control editor behavior. The current set of options are: + +* **allowRelocatesAuthoring**: If :code:`True` the namespace editor will use + relocates when needed to make edits. If :code:`False`, the namespace editor + will not use relocates and will issue errors when applying or validating edits + that require relocates. The default is :code:`True`. + +The following example creates the :code:`noRelocatesEditOptions` edit options, +disables :code:`noRelocatesEditOptions.allowRelocatesAuthoring`, and creates +a namespace editor for :code:`stage` with these options. + +.. code-block:: python + + noRelocatesEditOptions = Usd.NamespaceEditor.EditOptions() + noRelocatesEditOptions.allowRelocatesAuthoring = False + + # Create/use namespace editor that will not use relocates + noRelocatesEditor = Usd.NamespaceEditor(stage, noRelocatesEditOptions) + +.. _nsedit_working_with_relocates: + +Working With Relocates +====================== + +As mentioned earlier, namespace editing will use **relocates** if necessary +for edit operations across composition arcs. Namespace editing will add or +update relocates in the appropriate layer's metadata relocates list. The +following example shows layer metadata with a relocate added by a namespace +editing operation to rename :sdfpath:`/mainModelA/modelAChild` to +:sdfpath:`/mainModelA/renamedChild`: + +.. code-block:: usda + + #usda 1.0 + ( + relocates = { + : + } + ) + +For delete operations that require using relocates, namespace editing will +create a relocates mapping that maps a prim or property to a "deleted" target: + +.. code-block:: python + + # Delete a referenced prim, which will add a new relocates + editor.DeletePrimAtPath('/RootPrim/ChildInRef') + editor.ApplyEdits() + +.. code-block:: + + #usda 1.0 + ( + relocates = { + : <> + } + ) + +Note that the way in which relocates must "transfer" composed opinions prevents +you from re-defining a new prim at the deleted or moved target location: + +.. code-block:: python + + # Continuing from the earlier Python code, now try and define a prim at the + # deleted /RootPrim/ChildInRef path. This will result in a + # "Failed to define UsdPrim" error. + stage.DefinePrim('/RootPrim/ChildInRef') + +.. _nsedit_fixing_paths_for_moved_objects: + Fixing Paths For Moved Objects ============================== @@ -318,16 +428,108 @@ With the flattened results looking like: } } -.. note:: - Currently, direct edits across composition arcs, such as renaming just - :sdfpath:`/Shot1/shotAsset/assetChild` in the above example, is not supported - via namespace editing and will result in the following error (from - :code:`CanApplyEdits()` or :code:`ApplyEdits()`): "The prim to move requires - authoring relocates since it composes opinions introduced by ancestral - composition arcs; authoring relocates is not yet supported". Relocates will - be available in a future update. +.. _nsedit_fixing_edits_with_dependent_stages: -.. _namespace_editing_batch_edits: +Applying Edits to Dependent Stages +================================== + +In some situations, a namespace edit applied to one stage can impact other +**dependent stages**. A dependent stage is any additional stage open in the +current session that has a composition dependency on any layer edits made for +the editor's primary stage. For example, you might have a stage that has +references to prims in the editor's primary stage, and you might have edits +that rename or delete the referenced prims. + +By default, an editor only makes edits and fixes to the editor's primary stage. +However, you can add dependent stages to an editor via +:code:`AddDependentStage()` and the editor will make any necessary additional +edits in those dependent stages to update the composition dependencies +appropriately. + +For example, we might have the layer :filename:`layer1.usda`, which will get +composed into the stage for which we'll create a namespace editor. + +.. code-block:: usda + + #usda 1.0 + ( + ) + + def "Prim1" { + def "Child" { + } + } + + def "InternalRef1" ( + references = + ) { + over "Child" { + int overChildAttr + } + } + +We also have an additional layer :filename:`layer2.usda` that references prims +in :filename:`layer1.usda`: + +.. code-block:: usda + + #usda 1.0 + ( + ) + + def "OtherStageRef2" ( + references = @layer1.usda@ + ) { + int overChildAttr + } + +We can open both layers in separate stages, create a namespace editor for the +stage containing layer1, and add the stage containing layer2 as a dependent +stage. + +.. code-block:: python + + stage1 = Usd.Stage.Open("layer1.usda") + stage2 = Usd.Stage.Open("layer2.usda") + + # Create a namespace editor for stage1 + editor = Usd.NamespaceEditor(stage1) + + # Add stage2 as a dependent stage for our stage1 editor + editor.AddDependentStage(stage2) + + # Move /Prim1/Child to /Prim1/RenamedChild. This will not only + # update the prims and references in stage1, but also update the + # OtherStageRef2 reference in stage2 + editor.MovePrimAtPath('/Prim1/Child', '/Prim1/RenamedChild') + editor.ApplyEdits() + +After the edit, the root layer of stage2 looks like: + +.. code-block:: usda + + #usda 1.0 + + def "OtherStageRef2" ( + references = @layer1.usda@ + ) + { + int overChildAttr + } + +You can use :code:`RemoveDependentStage()` to remove any added dependent stages +before making a namespace edit, when you do not want the dependent stage +dependencies updated. + +If you have several dependent stages, you can set a list of dependent stages on +an editor using :code:`SetDependentStages()`. + +Note that namespace editing finds dependencies in dependent stages based on +what is currently loaded in those stages. If a stage has dependencies in +unloaded payloads, load mask filtered prims, unselected variants, or children of +inactive prims, the namespace editor cannot find and update those dependencies. + +.. _nsedit_batch_edits: Batch Edits =========== @@ -370,12 +572,16 @@ Executing batches of edits will usually be more efficient than applying each edit individually. USD will process the list of edits in a batch to determine the most efficient way to apply them. +.. _nsedit_editing_best_practices: + ******************************** Namespace Editing Best Practices ******************************** The following are some general best practices and caveats for namespace editing. +.. _nsedit_canapplyedits_validate_operations: + Use CanApplyEdits() To Validate Edit Operations =============================================== @@ -404,6 +610,8 @@ indicating the path does not resolve to a valid prim. else: # Handle error, using canApplyResult.whyNot as needed, etc. +.. _nsedit_builtin_properties_not_editable: + Built-In Properties From Schemas Are Not Editable ================================================= @@ -429,3 +637,35 @@ would fail. editor.DeletePropertyAtPath("/testSphere/customProp") # This is allowed editor.DeletePropertyAtPath("/testSphere/radius") # This is not allowed and will cause an error + +.. _nsedit_relocates_performance_impact: + +Be Aware of Relocates Performance Impact +======================================== + +If your namespace editing operations result in adding **relocates** to your +stage, this can increase the number of composition arcs in your stage, which +could impact stage composition performance. + +If you want to test whether a namespace edit will add relocates, you can +use an editor configured to disallow authoring relocates, and use +:code:`CanApplyEdits()` looking for any errors that indicate relocates would +be needed. + +.. code-block:: python + + # Create/use namespace editor that will not use relocates + noRelocatesEditOptions = Usd.NamespaceEditor.EditOptions() + noRelocatesEditOptions.allowRelocatesAuthoring = False + noRelocatesEditor = Usd.NamespaceEditor(stage, noRelocatesEditOptions) + + # Rename /mainModelA/modelAChild to /mainModelA/renamedChild + # This editor is configured to not use relocates, so an error will be shown + removeResult = noRelocatesEditor.MovePrimAtPath("/mainModelA/modelAChild", "/mainModelA/renamedChild") + applyResult = noRelocatesEditor.CanApplyEdits() + if applyResult is not True: + # We should get a "The prim to edit requires authoring relocates since + # it composes opinions introduced by ancestral composition arcs; + # relocates authoring must be enabled to perform this edit" error + print ("noRelocatesEditor: Cannot apply edits, reason: " + applyResult.whyNot) + \ No newline at end of file From 7dfa6f62a64f2f3592765c22afc4bb25238bd5ed Mon Sep 17 00:00:00 2001 From: aszabo Date: Fri, 9 Aug 2024 16:00:44 -0600 Subject: [PATCH 082/300] Display the selected prim's computed taxonomies and corresponding lables in the attributes editor --- .../testUsdviewPropertySearch.py | 2 +- pxr/usdImaging/usdviewq/customAttributes.py | 29 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/pxr/usdImaging/bin/testusdview/testenv/testUsdviewPropertySearch/testUsdviewPropertySearch.py b/pxr/usdImaging/bin/testusdview/testenv/testUsdviewPropertySearch/testUsdviewPropertySearch.py index 5d6b51f7ec..dafb6090ea 100644 --- a/pxr/usdImaging/bin/testusdview/testenv/testUsdviewPropertySearch/testUsdviewPropertySearch.py +++ b/pxr/usdImaging/bin/testusdview/testenv/testUsdviewPropertySearch/testUsdviewPropertySearch.py @@ -38,7 +38,7 @@ def _search(appController, searchTerm, expectedItems): def _testSearchBasic(appController): _search(appController, 'a', ['Local to World Xform', 'Resolved Preview Material', - 'Resolved Full Material', 'a']) + 'Resolved Full Material', 'Resolved Labels', 'a']) _search(appController, 'myR', ['myRel']) _search(appController, 'y', ['myRel', 'proxyPrim', 'visibility', 'y']) diff --git a/pxr/usdImaging/usdviewq/customAttributes.py b/pxr/usdImaging/usdviewq/customAttributes.py index b29ab1cd5a..ba641c7f60 100644 --- a/pxr/usdImaging/usdviewq/customAttributes.py +++ b/pxr/usdImaging/usdviewq/customAttributes.py @@ -5,7 +5,7 @@ # https://openusd.org/license. # -from pxr import Usd, UsdGeom, UsdShade +from pxr import UsdGeom, UsdShade, UsdSemantics from pxr.UsdUtils.constantsGroup import ConstantsGroup @@ -15,6 +15,7 @@ class ComputedPropertyNames(ConstantsGroup): LOCAL_WORLD_XFORM = "Local to World Xform" RESOLVED_PREVIEW_MATERIAL = "Resolved Preview Material" RESOLVED_FULL_MATERIAL = "Resolved Full Material" + RESOLVED_LABELS = "Resolved Labels" # # Edit the following to alter the set of custom attributes. @@ -35,9 +36,10 @@ def _GetCustomAttributes(currentPrim, rootDataModel): LocalToWorldXformAttribute(currentPrim, rootDataModel), ResolvedPreviewMaterial(currentPrim, rootDataModel), - ResolvedFullMaterial(currentPrim, rootDataModel)] - - return [] + ResolvedFullMaterial(currentPrim, rootDataModel), + ResolvedLabelsAttribute(currentPrim, rootDataModel), + ] + return [ResolvedLabelsAttribute(currentPrim, rootDataModel)] # # The base class for per-prim custom attributes. @@ -137,6 +139,23 @@ def __init__(self, currentPrim, rootDataModel): ResolvedBoundMaterial.__init__(self, currentPrim, rootDataModel, UsdShade.Tokens.preview) +# +# Displays a prim's inherited labels +# +class ResolvedLabelsAttribute(CustomAttribute): + def GetName(self): + return ComputedPropertyNames.RESOLVED_LABELS + + def Get(self, frame): + inheritedTaxonomies = UsdSemantics.LabelsAPI.ComputeInheritedTaxonomies(self._currentPrim) + resolvedLabels: dict[str, list[str]] = {} + for taxonomy in inheritedTaxonomies: + query = UsdSemantics.LabelsQuery(taxonomy, frame) + labels = query.ComputeUniqueInheritedLabels(self._currentPrim) + resolvedLabels[taxonomy] = list(labels) + return resolvedLabels + + class ComputedPropertyFactory: """Creates computed properties.""" @@ -155,6 +174,8 @@ def getComputedProperty(self, prim, propName): return ResolvedFullMaterial(prim, self._rootDataModel) elif propName == ComputedPropertyNames.RESOLVED_PREVIEW_MATERIAL: return ResolvedPreviewMaterial(prim, self._rootDataModel) + elif propName == ComputedPropertyNames.RESOLVED_LABELS: + return ResolvedLabelsAttribute(prim, self._rootDataModel) else: raise ValueError("Cannot create computed property '{}'.".format( propName)) From d038a0fc59f27ecaa666acba71eeb52e1c832322 Mon Sep 17 00:00:00 2001 From: cvj Date: Fri, 1 Nov 2024 09:41:00 -0700 Subject: [PATCH 083/300] Make previewSurface apply opacity/alpha to the final color, not only to the diffuse component. (Internal change: 2346084) --- .../usdShaders/shaders/previewSurface.glslfx | 19 +++++++++++------- ...testPreviewSurfacePrimvarReaderOpacity.png | Bin 18363 -> 16024 bytes 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pxr/usdImaging/plugin/usdShaders/shaders/previewSurface.glslfx b/pxr/usdImaging/plugin/usdShaders/shaders/previewSurface.glslfx index 2d048a6c2b..a553ccac54 100644 --- a/pxr/usdImaging/plugin/usdShaders/shaders/previewSurface.glslfx +++ b/pxr/usdImaging/plugin/usdShaders/shaders/previewSurface.glslfx @@ -62,22 +62,24 @@ surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) vec3 clearcoatColor = vec3(1.0); float specularAmount = 1.0; -#ifdef HD_MATERIAL_TAG_MASKED +#ifdef HD_MATERIAL_TAG_MASKED if (opacity < opacityThreshold) { discard; return vec4(1.0); } opacity = 1.0; -#endif +#endif // Selection highlighting. vec4 colorAndOpacity = vec4(diffuseColor, opacity); diffuseColor = ApplyColorOverrides(colorAndOpacity).rgb; - // Pre-multiply diffuse color by opacity if not done so already -#ifndef diffuseColor_IS_PREMULTIPLIED - diffuseColor *= opacity; -#endif + // We want to undo pre-multiplication of alpha of just the diffuse color so + // we can compute a color based on all the material parameters which we can + // then apply opacity to. +#ifdef diffuseColor_IS_PREMULTIPLIED + diffuseColor.rgb /= opacity; +#endif // Evaluate all lights. vec3 c = evaluateLights( @@ -96,7 +98,10 @@ surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) Peye, perturbFragmentNormal(Peye.xyz, Neye)); - return vec4(c, colorAndOpacity.a); + // Now we can multiply the final color by opacity. + c *= opacity; + + return vec4(c, opacity); } diff --git a/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLPreviewSurface/baseline/testPreviewSurfacePrimvarReaderOpacity.png b/pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLPreviewSurface/baseline/testPreviewSurfacePrimvarReaderOpacity.png index a3c714a1177960e946266142deff4efeef590f5e..511ff1778c11ba7c3703c5351911d93c7f0fd580 100644 GIT binary patch delta 6242 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 S)Oi^AS@MtNi)$ldv;PIe-Per( delta 8624 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 MzSZrfD?9mr0L~mJ5&!@I From 86d523bf6ed6c54b9ecac4b948ef23560d4cb46e Mon Sep 17 00:00:00 2001 From: anwang2009 Date: Fri, 1 Nov 2024 09:41:06 -0700 Subject: [PATCH 084/300] Add SdfCreateAttributeInLayer and SdfCreateRelationshipInLayer to be consistent with SdfCreatePrimInLayer and SdfCreateVariantInLayer (Internal change: 2346097) --- pxr/usd/sdf/attributeSpec.cpp | 15 ++++++ pxr/usd/sdf/attributeSpec.h | 23 ++++++++ pxr/usd/sdf/relationshipSpec.cpp | 55 +++++++++++++++++++ pxr/usd/sdf/relationshipSpec.h | 41 +++++++++++++++ pxr/usd/sdf/testenv/testSdfAttribute.py | 33 ------------ pxr/usd/sdf/testenv/testSdfLayer.py | 70 +++++++++++++++++++++++++ pxr/usd/sdf/wrapAttributeSpec.cpp | 3 ++ pxr/usd/sdf/wrapRelationshipSpec.cpp | 9 +++- 8 files changed, 215 insertions(+), 34 deletions(-) diff --git a/pxr/usd/sdf/attributeSpec.cpp b/pxr/usd/sdf/attributeSpec.cpp index bbe18e782e..52d1416847 100644 --- a/pxr/usd/sdf/attributeSpec.cpp +++ b/pxr/usd/sdf/attributeSpec.cpp @@ -238,6 +238,21 @@ SDF_DEFINE_CLEAR(DisplayUnit, SdfFieldKeys->DisplayUnit) bool Sdf_UncheckedCreatePrimInLayer(SdfLayer *layer, SdfPath const &primPath); +SdfAttributeSpecHandle +SdfCreatePrimAttributeInLayer( + const SdfLayerHandle &layer, + const SdfPath &attrPath, + const SdfValueTypeName &typeName, + SdfVariability variability, + bool isCustom) +{ + if (SdfJustCreatePrimAttributeInLayer(layer, attrPath, typeName, + variability, isCustom)) { + return layer->GetAttributeAtPath(attrPath); + } + return TfNullPtr; +} + bool SdfJustCreatePrimAttributeInLayer( const SdfLayerHandle &layer, diff --git a/pxr/usd/sdf/attributeSpec.h b/pxr/usd/sdf/attributeSpec.h index af00eadab3..7f703e569a 100644 --- a/pxr/usd/sdf/attributeSpec.h +++ b/pxr/usd/sdf/attributeSpec.h @@ -207,6 +207,26 @@ class SdfAttributeSpec : public SdfPropertySpec /// @} }; +/// Convenience function to create an attributeSpec on a primSpec at the given +/// path, and any necessary parent primSpecs, in the given layer. +/// +/// If an attributeSpec already exists at the given path, +/// author typeName, variability, and custom according to passed arguments +/// and return an attribute spec handle. +/// +/// Any newly created prim specs have SdfSpecifierOver and an empty type (as if +/// created by SdfJustCreatePrimInLayer()). attrPath must be a valid prim +/// property path (see SdfPath::IsPrimPropertyPath()). Return false and issue +/// an error if we fail to author the required scene description. +SDF_API +SdfAttributeSpecHandle +SdfCreatePrimAttributeInLayer( + const SdfLayerHandle &layer, + const SdfPath &attrPath, + const SdfValueTypeName &typeName, + SdfVariability variability = SdfVariabilityVarying, + bool isCustom = false); + /// Convenience function to create an attributeSpec on a primSpec at the given /// path, and any necessary parent primSpecs, in the given layer. /// @@ -217,6 +237,9 @@ class SdfAttributeSpec : public SdfPropertySpec /// created by SdfJustCreatePrimInLayer()). attrPath must be a valid prim /// property path (see SdfPath::IsPrimPropertyPath()). Return false and issue /// an error if we fail to author the required scene description. +/// +/// Differs only from SdfCreatePrimAttributeInLayer only in that a bool, not +/// a handle, is returned. SDF_API bool SdfJustCreatePrimAttributeInLayer( diff --git a/pxr/usd/sdf/relationshipSpec.cpp b/pxr/usd/sdf/relationshipSpec.cpp index 66546418fa..82ac6922d9 100644 --- a/pxr/usd/sdf/relationshipSpec.cpp +++ b/pxr/usd/sdf/relationshipSpec.cpp @@ -281,4 +281,59 @@ SDF_DEFINE_GET_SET(NoLoadHint, SdfFieldKeys->NoLoadHint, bool); #undef SDF_ACCESSOR_READ_PREDICATE #undef SDF_ACCESSOR_WRITE_PREDICATE +// Defined in primSpec.cpp. +bool +Sdf_UncheckedCreatePrimInLayer(SdfLayer *layer, SdfPath const &primPath); + +SdfRelationshipSpecHandle +SdfCreateRelationshipInLayer( + const SdfLayerHandle &layer, + const SdfPath &relPath, + SdfVariability variability, + bool isCustom) +{ + if (SdfJustCreateRelationshipInLayer(layer, relPath, + variability, isCustom)) { + return layer->GetRelationshipAtPath(relPath); + } + return TfNullPtr; +} + +bool +SdfJustCreateRelationshipInLayer( + const SdfLayerHandle &layer, + const SdfPath &relPath, + SdfVariability variability, + bool isCustom) +{ + if (!relPath.IsPrimPropertyPath()) { + TF_CODING_ERROR("Cannot create prim relationship at path '%s' because " + "it is not a prim property path", + relPath.GetText()); + return false; + } + + SdfLayer *layerPtr = get_pointer(layer); + + SdfChangeBlock block; + + if (!Sdf_UncheckedCreatePrimInLayer(layerPtr, relPath.GetParentPath())) { + return false; + } + + if (!Sdf_ChildrenUtils::CreateSpec( + layer, relPath, SdfSpecTypeRelationship, + /*hasOnlyRequiredFields=*/!isCustom)) { + TF_RUNTIME_ERROR("Failed to create relationship at path '%s' in " + "layer @%s@", relPath.GetText(), + layerPtr->GetIdentifier().c_str()); + return false; + } + + layerPtr->SetField(relPath, SdfFieldKeys->Custom, isCustom); + layerPtr->SetField(relPath, SdfFieldKeys->Variability, variability); + + return true; +} + PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usd/sdf/relationshipSpec.h b/pxr/usd/sdf/relationshipSpec.h index 36f5f8a804..d207473c84 100644 --- a/pxr/usd/sdf/relationshipSpec.h +++ b/pxr/usd/sdf/relationshipSpec.h @@ -116,6 +116,47 @@ class SdfRelationshipSpec : public SdfPropertySpec friend class Sdf_PyRelationshipAccess; }; +/// Convenience function to create a relationshipSpec on a primSpec at the +/// given path, and any necessary parent primSpecs, in the given layer. +/// +/// If a relationshipSpec already exists at the given path, author +/// variability and custom according to passed arguments and return +/// a relationship spec handle. +/// +/// Any newly created prim specs have SdfSpecifierOver and an empty type (as if +/// created by SdfJustCreatePrimInLayer()). relPath must be a valid prim +/// property path (see SdfPath::IsPrimPropertyPath()). Return false and issue +/// an error if we fail to author the required scene description. +SDF_API +SdfRelationshipSpecHandle +SdfCreateRelationshipInLayer( + const SdfLayerHandle &layer, + const SdfPath &relPath, + SdfVariability variability = SdfVariabilityVarying, + bool isCustom = false); + +/// Convenience function to create a relationshipSpec on a primSpec at the +/// given path, and any necessary parent primSpecs, in the given layer. +/// +/// If a relationshipSpec already exists at the given path, author +/// variability and custom according to passed arguments and return +/// a relationship spec handle. +/// +/// Any newly created prim specs have SdfSpecifierOver and an empty type (as if +/// created by SdfJustCreatePrimInLayer()). relPath must be a valid prim +/// property path (see SdfPath::IsPrimPropertyPath()). Return false and issue +/// an error if we fail to author the required scene description. +/// +/// Differs only from SdfCreateRelationshipInLayer only in that a +/// bool, not a handle, is returned. +SDF_API +bool +SdfJustCreateRelationshipInLayer( + const SdfLayerHandle &layer, + const SdfPath &relPath, + SdfVariability variability = SdfVariabilityVarying, + bool isCustom = false); + PXR_NAMESPACE_CLOSE_SCOPE #endif // PXR_USD_SDF_RELATIONSHIP_SPEC_H diff --git a/pxr/usd/sdf/testenv/testSdfAttribute.py b/pxr/usd/sdf/testenv/testSdfAttribute.py index c4cf5888d6..3f0ad3b743 100644 --- a/pxr/usd/sdf/testenv/testSdfAttribute.py +++ b/pxr/usd/sdf/testenv/testSdfAttribute.py @@ -32,39 +32,6 @@ def test_Creation(self): self.assertEqual(prim.properties[ attr.name ], attr) self.assertEqual(prim.properties[0].custom, False) - # Test SdfJustCreatePrimAttributeInLayer - self.assertTrue(Sdf.JustCreatePrimAttributeInLayer( - layer=layer, attrPath='/just/an.attributeSpec', - typeName=Sdf.ValueTypeNames.Float)) - attr2 = layer.GetAttributeAtPath('/just/an.attributeSpec') - self.assertEqual(attr2.name, 'attributeSpec') - self.assertEqual(attr2.typeName, Sdf.ValueTypeNames.Float) - prim = layer.GetPrimAtPath('/just/an') - self.assertEqual(attr2.owner, prim) - self.assertTrue(attr2 in prim.properties) - self.assertTrue(attr2.name in prim.properties) - self.assertEqual(prim.properties[0], attr2) - self.assertEqual(prim.properties[attr2.name], attr2) - self.assertEqual(attr2.variability, Sdf.VariabilityVarying) - self.assertEqual(prim.properties[0].custom, False) - - self.assertTrue(Sdf.JustCreatePrimAttributeInLayer( - layer=layer, attrPath='/just/another.attributeSpec', - typeName=Sdf.ValueTypeNames.Int, - variability=Sdf.VariabilityUniform, - isCustom=True)) - attr3 = layer.GetAttributeAtPath('/just/another.attributeSpec') - self.assertEqual(attr3.name, 'attributeSpec') - self.assertEqual(attr3.typeName, Sdf.ValueTypeNames.Int) - prim = layer.GetPrimAtPath('/just/another') - self.assertEqual(attr3.owner, prim) - self.assertTrue(attr3 in prim.properties) - self.assertTrue(attr3.name in prim.properties) - self.assertEqual(prim.properties[0], attr3) - self.assertEqual(prim.properties[attr2.name], attr3) - self.assertEqual(attr3.variability, Sdf.VariabilityUniform) - self.assertEqual(prim.properties[0].custom, True) - # create a duplicate attribute: error expected with self.assertRaises(RuntimeError): dupe = Sdf.AttributeSpec( diff --git a/pxr/usd/sdf/testenv/testSdfLayer.py b/pxr/usd/sdf/testenv/testSdfLayer.py index 42d2e0b046..9f4402ab03 100644 --- a/pxr/usd/sdf/testenv/testSdfLayer.py +++ b/pxr/usd/sdf/testenv/testSdfLayer.py @@ -773,6 +773,76 @@ def test_CreatePrimInLayer(self): self.assertTrue('x' in rootSpec.variantSetNameList.prependedItems) self.assertTrue(len(rootSpec.variantSetNameList.addedItems) == 0) + def test_CreatePropertyInLayer(self): + layer = Sdf.Layer.CreateAnonymous() + + # Test creating attribute in layer + attr = Sdf.CreatePrimAttributeInLayer(layer=layer, + attrPath='/prim.attr', typeName=Sdf.ValueTypeNames.Float) + self.assertEqual(attr.name, "attr") + prim = layer.GetPrimAtPath('/prim') + self.assertEqual(attr.owner, prim) + self.assertTrue(attr in prim.properties) + self.assertEqual(attr.variability, Sdf.VariabilityVarying) + self.assertEqual(attr.custom, False) + + # Test creating attribute (no handle) in layer + self.assertTrue(Sdf.JustCreatePrimAttributeInLayer( + layer=layer, attrPath='/just/an.attributeSpec', + typeName=Sdf.ValueTypeNames.Float)) + attr2 = layer.GetAttributeAtPath('/just/an.attributeSpec') + self.assertEqual(attr2.name, 'attributeSpec') + self.assertEqual(attr2.typeName, Sdf.ValueTypeNames.Float) + prim = layer.GetPrimAtPath('/just/an') + self.assertEqual(attr2.owner, prim) + self.assertTrue(attr2 in prim.properties) + self.assertTrue(attr2.name in prim.properties) + self.assertEqual(prim.properties[0], attr2) + self.assertEqual(prim.properties[attr2.name], attr2) + self.assertEqual(attr2.variability, Sdf.VariabilityVarying) + self.assertEqual(prim.properties[0].custom, False) + + self.assertTrue(Sdf.JustCreatePrimAttributeInLayer( + layer=layer, attrPath='/just/another.attributeSpec', + typeName=Sdf.ValueTypeNames.Int, + variability=Sdf.VariabilityUniform, + isCustom=True)) + attr3 = layer.GetAttributeAtPath('/just/another.attributeSpec') + self.assertEqual(attr3.name, 'attributeSpec') + self.assertEqual(attr3.typeName, Sdf.ValueTypeNames.Int) + prim = layer.GetPrimAtPath('/just/another') + self.assertEqual(attr3.owner, prim) + self.assertTrue(attr3 in prim.properties) + self.assertTrue(attr3.name in prim.properties) + self.assertEqual(prim.properties[0], attr3) + self.assertEqual(prim.properties[attr2.name], attr3) + self.assertEqual(attr3.variability, Sdf.VariabilityUniform) + self.assertEqual(prim.properties[0].custom, True) + + # Test creating relationship in layer + rel = Sdf.CreateRelationshipInLayer(layer=layer, + relPath='/prim.rel') + self.assertEqual(rel.name, "rel") + prim = layer.GetPrimAtPath('/prim') + self.assertEqual(rel.owner, prim) + self.assertTrue(rel in prim.properties) + self.assertEqual(rel.variability, Sdf.VariabilityVarying) + self.assertEqual(rel.custom, False) + + # Test creating relationship (no handle) in layer + self.assertTrue(Sdf.JustCreateRelationshipInLayer(layer=layer, + relPath="/just/prim.rel")) + rel2 = layer.GetRelationshipAtPath('/just/prim.rel') + self.assertEqual(rel2.name, 'rel') + prim = layer.GetPrimAtPath('/just/prim') + self.assertEqual(rel2.owner, prim) + self.assertTrue(rel2 in prim.properties) + self.assertTrue(rel2.name in prim.properties) + self.assertEqual(prim.properties[0], rel2) + self.assertEqual(prim.properties[rel2.name], rel2) + self.assertEqual(rel2.variability, Sdf.VariabilityVarying) + self.assertEqual(prim.properties[0].custom, False) + def test_ReloadAfterSetIdentifier(self): layer = Sdf.Layer.CreateNew('TestReloadAfterSetIdentifier.sdf') diff --git a/pxr/usd/sdf/wrapAttributeSpec.cpp b/pxr/usd/sdf/wrapAttributeSpec.cpp index 964250c5de..fa6e73ef58 100644 --- a/pxr/usd/sdf/wrapAttributeSpec.cpp +++ b/pxr/usd/sdf/wrapAttributeSpec.cpp @@ -97,6 +97,9 @@ _EraseTimeSample(SdfAttributeSpec &self, double time) void wrapAttributeSpec() { + def("CreatePrimAttributeInLayer", SdfCreatePrimAttributeInLayer, + (arg("layer"), arg("attrPath"), arg("typeName"), + arg("variability")=SdfVariabilityVarying, arg("isCustom")=false)); def("JustCreatePrimAttributeInLayer", SdfJustCreatePrimAttributeInLayer, (arg("layer"), arg("attrPath"), arg("typeName"), arg("variability")=SdfVariabilityVarying, arg("isCustom")=false)); diff --git a/pxr/usd/sdf/wrapRelationshipSpec.cpp b/pxr/usd/sdf/wrapRelationshipSpec.cpp index 73bd00de60..3b0e258a30 100644 --- a/pxr/usd/sdf/wrapRelationshipSpec.cpp +++ b/pxr/usd/sdf/wrapRelationshipSpec.cpp @@ -20,7 +20,14 @@ PXR_NAMESPACE_USING_DIRECTIVE using namespace pxr_boost::python; void wrapRelationshipSpec() -{ +{ + def("CreateRelationshipInLayer", SdfCreateRelationshipInLayer, + (arg("layer"), arg("relPath"), + arg("variability")=SdfVariabilityVarying, arg("isCustom")=false)); + def("JustCreateRelationshipInLayer", SdfJustCreateRelationshipInLayer, + (arg("layer"), arg("relPath"), + arg("variability")=SdfVariabilityVarying, arg("isCustom")=false)); + typedef SdfRelationshipSpec This; class_, From d4880f549b948e947497198124ecaea58bf07e7b Mon Sep 17 00:00:00 2001 From: aszabo Date: Fri, 1 Nov 2024 13:25:02 -0600 Subject: [PATCH 085/300] Example of using the UsdSemantics schema --- .../usdSemanticsExamples/bookshelf.usda | 164 ++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 extras/usd/examples/usdSemanticsExamples/bookshelf.usda diff --git a/extras/usd/examples/usdSemanticsExamples/bookshelf.usda b/extras/usd/examples/usdSemanticsExamples/bookshelf.usda new file mode 100644 index 0000000000..d06aa38e23 --- /dev/null +++ b/extras/usd/examples/usdSemanticsExamples/bookshelf.usda @@ -0,0 +1,164 @@ +#usda 1.0 +( + doc = "This layer represents an example of using UsdSemantics" + upAxis = "Y" + startTimeCode = 0 + endTimeCode = 200 +) + +def Xform "Bookshelf" ( + apiSchemas = ["SemanticsLabelsAPI:category", "SemanticsLabelsAPI:style"] +) +{ + token[] semantics:labels:category = ["furniture", "cabinet"] + token[] semantics:labels:style = ["modern", "chic"] + double3 xformOp:translate = (0, 100.87384788680441, 0) + uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] + + def Xform "Shelves" ( + apiSchemas = ["SemanticsLabelsAPI:category"] + ) + { + token[] semantics:labels:category = ["horizontal shelving"] + double3 xformOp:translate = (113, 0, 0) + uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] + + def Cube "shelf_geo_01" ( + apiSchemas = ["MaterialBindingAPI", "SemanticsLabelsAPI:state"] + ) + { + token[] semantics:labels:state.timeSamples = { + 0: ["empty"], + 50: ["partially full"], + 100: ["full"] + } + float3[] extent = [(-50, -50, -50), (50, 50, 50)] + rel material:binding = ( + bindMaterialAs = "weakerThanDescendants" + ) + double size = 100 + double3 xformOp:scale = (0.9999999999999999, 0.0773693394230031, 0.7625704657327257) + double3 xformOp:translate = (-113, 70.05470741643151, 0) + uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] + } + + def Cube "shelf_geo_02" ( + apiSchemas = ["MaterialBindingAPI", "SemanticsLabelsAPI:state"] + ) + { + token[] semantics:labels:state = ["partially full"] + float3[] extent = [(-50, -50, -50), (50, 50, 50)] + rel material:binding = ( + bindMaterialAs = "weakerThanDescendants" + ) + double size = 100 + double3 xformOp:scale = (0.9999999999999999, 0.0773693394230031, 0.7625704657327257) + double3 xformOp:translate = (-113, 28.205436432969066, 0) + uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] + } + + def Cube "shelf_geo_03" ( + apiSchemas = ["MaterialBindingAPI", "SemanticsLabelsAPI:state"] + ) + { + token[] semantics:labels:state = ["full"] + float3[] extent = [(-50, -50, -50), (50, 50, 50)] + rel material:binding = ( + bindMaterialAs = "weakerThanDescendants" + ) + double size = 100 + double3 xformOp:scale = (0.9999999999999999, 0.0773693394230031, 0.7625704657327257) + double3 xformOp:translate = (-113, -14.418843141218574, 0) + uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] + } + + def Cube "shelf_geo_04" ( + apiSchemas = ["MaterialBindingAPI"] + ) + { + float3[] extent = [(-50, -50, -50), (50, 50, 50)] + rel material:binding = ( + bindMaterialAs = "weakerThanDescendants" + ) + double size = 100 + double3 xformOp:scale = (0.9999999999999999, 0.0773693394230031, 0.7625704657327257) + double3 xformOp:translate = (-113, -57.934833429151425, 0) + uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] + } + + def Cube "shelf_geo_05" ( + apiSchemas = ["MaterialBindingAPI"] + ) + { + float3[] extent = [(-50, -50, -50), (50, 50, 50)] + rel material:binding = ( + bindMaterialAs = "weakerThanDescendants" + ) + double size = 100 + double3 xformOp:scale = (0.9999999999999999, 0.0773693394230031, 0.7625704657327257) + double3 xformOp:translate = (-113, -99.27174085182759, 0) + uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] + } + } + + def Cube "bookshelf_geo" ( + apiSchemas = ["MaterialBindingAPI"] + ) + { + float3[] extent = [(-50, -50, -50), (50, 50, 50)] + rel material:binding = ( + bindMaterialAs = "weakerThanDescendants" + ) + double size = 100 + double3 xformOp:scale = (1.0484495248498045, 1.991987664077115, 0.13958063483880567) + uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] + } +} + +def Scope "looks" +{ + def Material "wood" ( + apiSchemas = ["SemanticsLabelsAPI:material"] + ) + { + token[] semantics:labels:material = ["wood", "oak", "American White Oak"] + token outputs:displacement.connect = + token outputs:surface.connect = + + def Shader "Shader" + { + uniform token info:id = "UsdPreviewSurface" + float inputs:clearcoat = 0 + float inputs:clearcoatRoughness = 0.01 + color3f inputs:diffuseColor = (0.5145, 0.3639, 0.229) ( + renderType = "color" + ) + float inputs:displacement = 0 + color3f inputs:emissiveColor = (0, 0, 0) ( + renderType = "color" + ) + float inputs:ior = 1.5 + float inputs:metallic = 0 + normal3f inputs:normal = (0, 0, 1) + float inputs:occlusion = 1 + float inputs:opacity = 1 + float inputs:opacityThreshold = 0 ( + connectability = "interfaceOnly" + ) + float inputs:roughness = 0.5 + color3f inputs:specularColor = (0, 0, 0) ( + renderType = "color" + ) + int inputs:useSpecularWorkflow = 0 ( + connectability = "interfaceOnly" + ) + token outputs:displacement ( + renderType = "material" + ) + token outputs:surface ( + renderType = "material" + ) + } + } +} + From 614e1467f73883314158f23485c287b1044ba82c Mon Sep 17 00:00:00 2001 From: ttrently <41705925+ttrently@users.noreply.github.com> Date: Sun, 3 Nov 2024 13:02:39 -0800 Subject: [PATCH 086/300] Update tut_generating_new_schema.rst Add documentation for an issue with Python 3.8+ and Windows where schema DLL's need to be manually added to trusted locations in order to import. --- docs/tut_generating_new_schema.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/tut_generating_new_schema.rst b/docs/tut_generating_new_schema.rst index 701d4bdfdd..38bbba76fc 100644 --- a/docs/tut_generating_new_schema.rst +++ b/docs/tut_generating_new_schema.rst @@ -377,6 +377,11 @@ Using the Schema Classes * Copying :filename:`usdSchemaExamples.so` (on Windows, :filename:`usdSchemaExamples.dll` and :filename:`.lib`) and the :filename:`usdSchemaExamples` directory to :filename`/plugin/usd` + + * You may encounter an :filename:`ImportError DLL load failed` when running from + Python 3.8+ on Windows. This is due to the DLL directory not being added to + trusted locations and can be resolved by manually adding the :filename:`resources` + directory before import via :filename:`os.add_dll_directory`. Create a usd file named Test.usda with the following content: From 41eaf64275fe3f37303f21aef917852cba608abd Mon Sep 17 00:00:00 2001 From: ttrently <41705925+ttrently@users.noreply.github.com> Date: Sun, 3 Nov 2024 13:04:05 -0800 Subject: [PATCH 087/300] Update tut_generating_new_schema.rst Fixed some wording on the ImportError note. --- docs/tut_generating_new_schema.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tut_generating_new_schema.rst b/docs/tut_generating_new_schema.rst index 38bbba76fc..02cc2406cf 100644 --- a/docs/tut_generating_new_schema.rst +++ b/docs/tut_generating_new_schema.rst @@ -378,7 +378,7 @@ Using the Schema Classes :filename:`usdSchemaExamples.dll` and :filename:`.lib`) and the :filename:`usdSchemaExamples` directory to :filename`/plugin/usd` - * You may encounter an :filename:`ImportError DLL load failed` when running from + * You may encounter :filename:`ImportError DLL load failed` when running from Python 3.8+ on Windows. This is due to the DLL directory not being added to trusted locations and can be resolved by manually adding the :filename:`resources` directory before import via :filename:`os.add_dll_directory`. From fcbd734195502a5adff34b9612f476008ced3ca7 Mon Sep 17 00:00:00 2001 From: freesonwang Date: Mon, 4 Nov 2024 11:28:28 -0800 Subject: [PATCH 088/300] Adding \code tags to pxr usdVol overview.dox to fix synatx errors found in __DOC.py generation (Internal change: 2346107) --- pxr/usd/usdVol/overview.dox | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pxr/usd/usdVol/overview.dox b/pxr/usd/usdVol/overview.dox index 92036549bd..19bd05ee4c 100644 --- a/pxr/usd/usdVol/overview.dox +++ b/pxr/usd/usdVol/overview.dox @@ -58,7 +58,7 @@ Learn about Field3D at [https://sites.google.com/site/field3d/](https://sites.go \section usdVol_example Example Usage Here is a simple example of a Volume prim, representing a static wisp of smoke: - +\code def Volume "wisp" { float3[] extent = [(-57, -91, -44), (57, 31, -23)] @@ -71,10 +71,10 @@ Here is a simple example of a Volume prim, representing a static wisp of smoke: token fieldName = "density" } } - +\endcode Volumes are generally not static. For volumes with OpenVDBAsset fields, volume animation is represented by setting time samples on the filePath attribute: - +\code def Volume "wisp" { float3[] extent = [(-57, -91, -44), (57, 31, -23)] @@ -92,7 +92,7 @@ animation is represented by setting time samples on the filePath attribute: token fieldName = "density" } } - +\endcode \section usdVol_usage Usage Notes \subsection usdVol_namespace_org Namespace Organization and Transformation From ebd5b69efb470b2512581de1c994c2d5c27f7296 Mon Sep 17 00:00:00 2001 From: davidgyu Date: Mon, 4 Nov 2024 11:28:36 -0800 Subject: [PATCH 089/300] [arch] Improved testArchDemangle Updated testArchDemangle to avoid compile-time dependent behavior. (Internal change: 2346139) --- pxr/base/arch/testenv/testDemangle.cpp | 57 ++++++++++++++++++-------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/pxr/base/arch/testenv/testDemangle.cpp b/pxr/base/arch/testenv/testDemangle.cpp index c94d9915f7..03e287b8d8 100644 --- a/pxr/base/arch/testenv/testDemangle.cpp +++ b/pxr/base/arch/testenv/testDemangle.cpp @@ -38,6 +38,37 @@ typedef Mangled Remangled; enum MangleEnum { ONE, TWO, THREE }; +static std::string +GetAlternativeTemplateTypename(std::string typeName) +{ + // Since C++11, the parser specification has been improved to be + // able to interpret successive right angle brackets in nested template + // declarations. The implementation of the C++ ABI has been updated + // accordingly on some systems, e.g. starting with Clang 14 on macOS 13.3. + // We accept a demangled result without additional white space between + // successive right angle brackets. + + const std::string oldStyle = "> >"; + const std::string newStyle = ">>"; + + std::string::size_type pos = 0; + while ((pos = typeName.find(oldStyle, pos)) != std::string::npos) { + typeName.replace(pos, oldStyle.size(), newStyle); + pos += newStyle.size() - 1; + } + + printf("\texpected alternative: '%s'\n", typeName.c_str()); + + return typeName; +} + +static bool +TypeNamesMatch(const std::string& demangledName, const std::string& expected) +{ + return (demangledName == expected) || + (demangledName == GetAlternativeTemplateTypename(expected)); +} + template static bool TestDemangle(const std::string& typeName) @@ -51,10 +82,10 @@ TestDemangle(const std::string& typeName) printf("ArchDemangle('%s') => '%s', expected '%s'\n", mangledName.c_str(), toBeDemangledName.c_str(), typeName.c_str()); - ARCH_AXIOM(toBeDemangledName == typeName); - ARCH_AXIOM(ArchGetDemangled(mangledName) == typeName); - ARCH_AXIOM(ArchGetDemangled(typeInfo) == typeName); - ARCH_AXIOM(ArchGetDemangled() == typeName); + ARCH_AXIOM(TypeNamesMatch(toBeDemangledName, typeName)); + ARCH_AXIOM(TypeNamesMatch(ArchGetDemangled(mangledName), typeName)); + ARCH_AXIOM(TypeNamesMatch(ArchGetDemangled(typeInfo), typeName)); + ARCH_AXIOM(TypeNamesMatch(ArchGetDemangled(), typeName)); return true; } @@ -82,20 +113,10 @@ int main() TestDemangle("unsigned long"); TestDemangle >("MangledAlso"); - // Since C++11, the parser specification has been improved to be able - // to interpret multiple right angle brackets in nested template - // declarations. The implementation of the C++ ABI has been updated - // accordingly starting with Clang 14 on macOS 13.3 -#if defined(MAC_OS_VERSION_13_3) - const bool improvedAngleBracketDemangling = true; -#else - const bool improvedAngleBracketDemangling = false; -#endif - const char* const nestedTemplateTypeName = - improvedAngleBracketDemangling - ? "MangledAlso>" - : "MangledAlso >"; - TestDemangle > >(nestedTemplateTypeName); + TestDemangle > >( + "MangledAlso >"); + TestDemangle > > >( + "MangledAlso > >"); const char* const badType = "type_that_doesnt_exist"; #if defined(ARCH_OS_WINDOWS) From 3f9939739808bfd6fbe7403eb399ed317538ae69 Mon Sep 17 00:00:00 2001 From: cvj Date: Mon, 4 Nov 2024 11:28:40 -0800 Subject: [PATCH 090/300] Avoid division by zero in previewSurface. (Internal change: 2346141) --- .../plugin/usdShaders/shaders/previewSurface.glslfx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pxr/usdImaging/plugin/usdShaders/shaders/previewSurface.glslfx b/pxr/usdImaging/plugin/usdShaders/shaders/previewSurface.glslfx index a553ccac54..76d9854ce6 100644 --- a/pxr/usdImaging/plugin/usdShaders/shaders/previewSurface.glslfx +++ b/pxr/usdImaging/plugin/usdShaders/shaders/previewSurface.glslfx @@ -78,7 +78,9 @@ surfaceShader(vec4 Peye, vec3 Neye, vec4 color, vec4 patchCoord) // we can compute a color based on all the material parameters which we can // then apply opacity to. #ifdef diffuseColor_IS_PREMULTIPLIED - diffuseColor.rgb /= opacity; + if (opacity > 0) { + diffuseColor.rgb /= opacity; + } #endif // Evaluate all lights. From bb38a72cf2974ffb49551ddc989a94b56eca4c23 Mon Sep 17 00:00:00 2001 From: comand Date: Mon, 4 Nov 2024 11:28:45 -0800 Subject: [PATCH 091/300] Changing range-for loop variables to be references instead of copies. (Internal change: 2346254) --- pxr/imaging/plugin/hioOiio/oiioImage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pxr/imaging/plugin/hioOiio/oiioImage.cpp b/pxr/imaging/plugin/hioOiio/oiioImage.cpp index c3dffcce77..394fe07ddd 100644 --- a/pxr/imaging/plugin/hioOiio/oiioImage.cpp +++ b/pxr/imaging/plugin/hioOiio/oiioImage.cpp @@ -805,7 +805,7 @@ HioOIIO_Image::Write(StorageSpec const & storage, TypeDesc format = _GetOIIOBaseType(storage.format); ImageSpec spec(storage.width, storage.height, nchannels, format); - for (const std::pair& m : metadata) { + for (const auto& m : metadata) { _SetAttribute(&spec, m.first, m.second); } From 5649cb84a5a3cd0846f16741f2eea27a272327da Mon Sep 17 00:00:00 2001 From: comand Date: Mon, 4 Nov 2024 11:32:41 -0800 Subject: [PATCH 092/300] Add ignores for GCC 11 compiler warnings. (Internal change: 2346268) --- pxr/base/arch/pragmas.h | 7 +++++++ pxr/base/vt/testenv/testVtCpp.cpp | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/pxr/base/arch/pragmas.h b/pxr/base/arch/pragmas.h index 1d15ab7434..39af797a66 100644 --- a/pxr/base/arch/pragmas.h +++ b/pxr/base/arch/pragmas.h @@ -48,6 +48,9 @@ #define ARCH_PRAGMA_UNUSED_FUNCTION \ _Pragma("GCC diagnostic ignored \"-Wunused-function\"") + #define ARCH_PRAGMA_STRINGOP_OVERFLOW \ + _Pragma("GCC diagnostic ignored \"-Wstringop-overflow=\"") + #elif defined(ARCH_COMPILER_CLANG) #define ARCH_PRAGMA_PUSH \ @@ -181,6 +184,10 @@ #define ARCH_PRAGMA_UNUSED_FUNCTION #endif +#if !defined ARCH_PRAGMA_STRINGOP_OVERFLOW + #define ARCH_PRAGMA_STRINGOP_OVERFLOW +#endif + #if !defined ARCH_PRAGMA_UNUSED_PRIVATE_FIELD #define ARCH_PRAGMA_UNUSED_PRIVATE_FIELD #endif diff --git a/pxr/base/vt/testenv/testVtCpp.cpp b/pxr/base/vt/testenv/testVtCpp.cpp index 2942d367c3..53570d6a6c 100644 --- a/pxr/base/vt/testenv/testVtCpp.cpp +++ b/pxr/base/vt/testenv/testVtCpp.cpp @@ -53,6 +53,7 @@ #include "pxr/base/arch/defines.h" #include "pxr/base/arch/fileSystem.h" +#include "pxr/base/arch/pragmas.h" #include #include @@ -505,6 +506,9 @@ static void testArray() { // Test that attempts to create overly large arrays throw // std::bad_alloc +ARCH_PRAGMA_PUSH +ARCH_PRAGMA_STRINGOP_OVERFLOW + VtIntArray ia; try { ia.resize(std::numeric_limits::max()); @@ -530,6 +534,8 @@ static void testArray() { catch (std::bad_alloc const &) { // pass } + +ARCH_PRAGMA_POP } } From 433709387e3b16bd9e272bcc3f69a8a4a8d54c9b Mon Sep 17 00:00:00 2001 From: clach Date: Mon, 4 Nov 2024 11:33:34 -0800 Subject: [PATCH 093/300] [hdSt] Fixes some test crash issues in the open source build. I believe it's potentially problematic to declare an HdStRenderDelegate or HdStResourceRegistrySharedPtr as static in the way some of these tests did. The _HgiToResourceRegistryMap is a static singleton that includes a custom deleter for HdStResourceRegistry. If _HgiToResourceRegistryMap is deleted first, the custom deleter for HdStResourceRegistry might do a heap-use-after-free as the deleter modifies a member of _HgiToResourceRegistryMap. (Internal change: 2346349) --- pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp | 31 +-- .../hdSt/testenv/testHdStDrawBatching.cpp | 62 +++--- .../hdSt/testenv/testHdStMeshTopology.cpp | 195 +++++++++--------- .../hdSt/testenv/testHdStPrimitiveParam.cpp | 70 ++++--- .../hdSt/testenv/testHdStQuadrangulation.cpp | 72 +++---- .../hdSt/testenv/testHdStSubdivision.cpp | 140 +++++++------ 6 files changed, 300 insertions(+), 270 deletions(-) diff --git a/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp b/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp index 9cffd2b109..c44c5867fb 100644 --- a/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStCodeGen.cpp @@ -65,7 +65,8 @@ TF_DEFINE_PRIVATE_TOKENS( ); static bool -CodeGenTest(HdSt_ShaderKey const &key, bool instance, bool smoothNormals) +CodeGenTest(HdStResourceRegistrySharedPtr const ®istry, + HdSt_ShaderKey const &key, bool instance, bool smoothNormals) { TfErrorMark mark; @@ -74,14 +75,6 @@ CodeGenTest(HdSt_ShaderKey const &key, bool instance, bool smoothNormals) sharedData.instancerLevels = 0; HdStDrawItem drawItem(&sharedData); - static HgiUniquePtr hgi = Hgi::CreatePlatformDefaultHgi(); - static HdDriver driver{HgiTokens->renderDriver, VtValue(hgi.get())}; - static HdStRenderDelegate renderDelegate; - static std::unique_ptr index( - HdRenderIndex::New(&renderDelegate, {&driver})); - HdStResourceRegistrySharedPtr const & registry = - std::static_pointer_cast( - index->GetResourceRegistry()); HdDrawingCoord *drawingCoord = drawItem.GetDrawingCoord(); @@ -309,10 +302,11 @@ CodeGenTest(HdSt_ShaderKey const &key, bool instance, bool smoothNormals) } bool -TestShader(HdSt_ShaderKey const &key, bool instance, bool smoothNormals) +TestShader(HdStResourceRegistrySharedPtr const ®istry, + HdSt_ShaderKey const &key, bool instance, bool smoothNormals) { bool success = true; - success &= CodeGenTest(key, instance, smoothNormals); + success &= CodeGenTest(registry, key, instance, smoothNormals); return success; } @@ -358,9 +352,19 @@ int main(int argc, char *argv[]) } } + HgiUniquePtr const hgi = Hgi::CreatePlatformDefaultHgi(); + HdDriver driver{HgiTokens->renderDriver, VtValue(hgi.get())}; + HdStRenderDelegate renderDelegate; + std::unique_ptr const index( + HdRenderIndex::New(&renderDelegate, {&driver})); + HdStResourceRegistrySharedPtr const registry = + std::static_pointer_cast( + index->GetResourceRegistry()); + // mesh if (mesh) { success &= TestShader( + registry, HdSt_MeshShaderKey( HdSt_GeometricShader::PrimitiveType::PRIM_MESH_COARSE_TRIANGLES, /* shadingTerminal */ TfToken(), @@ -386,6 +390,7 @@ int main(int argc, char *argv[]) /* surfaceEdgeIds */ true), instance, smoothNormals); success &= TestShader( + registry, HdSt_MeshShaderKey( HdSt_GeometricShader::PrimitiveType::PRIM_MESH_COARSE_QUADS, /* shadingTerminal */ TfToken(), @@ -414,6 +419,7 @@ int main(int argc, char *argv[]) // curves if (curves) { success &= TestShader( + registry, HdSt_BasisCurvesShaderKey(HdTokens->cubic, HdTokens->bezier, HdSt_BasisCurvesShaderKey::WIRE, @@ -427,7 +433,8 @@ int main(int argc, char *argv[]) // points if (points) { - success &= TestShader(HdSt_PointsShaderKey(), + success &= TestShader(registry, + HdSt_PointsShaderKey(), instance, false); } diff --git a/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp b/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp index 3c86714807..7f5e9ef24a 100644 --- a/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStDrawBatching.cpp @@ -57,17 +57,7 @@ static HdSt_MaterialNetworkShaderSharedPtr _GetFallbackShader() return _fallbackMaterialNetworkShader; } -static HdStResourceRegistrySharedPtr _GetResourceRegistry() -{ - static HgiUniquePtr _hgi = Hgi::CreatePlatformDefaultHgi(); - static HdDriver _driver{HgiTokens->renderDriver, VtValue(_hgi.get())}; - static HdStRenderDelegate _renderDelegate; - static std::unique_ptr _index( - HdRenderIndex::New(&_renderDelegate, {&_driver})); - - return std::static_pointer_cast( - _index->GetResourceRegistry()); -} + template static VtValue @@ -80,6 +70,7 @@ _BuildArrayValue(T values[], int numValues) HdStDrawItem _RegisterDrawItem( + HdStResourceRegistrySharedPtr const ®istry, HdSt_GeometricShader::PrimitiveType primType, HdRprimSharedData *sharedData, VtValue const & indicesValue, @@ -89,8 +80,6 @@ _RegisterDrawItem( VtValue const & normalsValue = VtValue(), VtValue const & colorsValue = VtValue()) { - HdStResourceRegistrySharedPtr const& registry = _GetResourceRegistry(); - HdBufferSourceSharedPtrVector sources; HdBufferSpecVector bufferSpecs; @@ -247,7 +236,9 @@ _RegisterDrawItem( } static std::vector -_GetDrawItems(std::vector &sharedData) +_GetDrawItems( + HdStResourceRegistrySharedPtr const ®istry, + std::vector &sharedData) { std::vector result; @@ -308,7 +299,7 @@ _GetDrawItems(std::vector &sharedData) }; // tris w/o color result.push_back(_RegisterDrawItem( - primTypeTris, &sharedData[0], + registry, primTypeTris, &sharedData[0], _BuildArrayValue(trisI, sizeof(trisI)/sizeof(trisI[0])), _BuildArrayValue(trisI, sizeof(trisI)/sizeof(trisI[0])), /* dummy pparam*/ _BuildArrayValue(triEdges, sizeof(triEdges)/sizeof(triEdges[0])), @@ -316,7 +307,7 @@ _GetDrawItems(std::vector &sharedData) _BuildArrayValue(trisN, sizeof(trisN)/sizeof(trisN[0])))); result.push_back(_RegisterDrawItem( - primTypeTris, &sharedData[1], + registry, primTypeTris, &sharedData[1], _BuildArrayValue(trisI, sizeof(trisI)/sizeof(trisI[0])), _BuildArrayValue(trisI, sizeof(trisI)/sizeof(trisI[0])), /* dummy pparam*/ _BuildArrayValue(triEdges, sizeof(triEdges)/sizeof(triEdges[0])), @@ -325,7 +316,7 @@ _GetDrawItems(std::vector &sharedData) // quads w/o color result.push_back(_RegisterDrawItem( - primTypeQuads, &sharedData[2], + registry, primTypeQuads, &sharedData[2], _BuildArrayValue(quadsI, sizeof(quadsI)/sizeof(quadsI[0])), _BuildArrayValue(quadPP, sizeof(quadPP)/sizeof(quadPP[0])), /* dummy pparam*/ _BuildArrayValue(quadEdges, sizeof(quadEdges)/sizeof(quadEdges[0])), @@ -333,7 +324,7 @@ _GetDrawItems(std::vector &sharedData) _BuildArrayValue(quadsN, sizeof(quadsN)/sizeof(quadsN[0])))); result.push_back(_RegisterDrawItem( - primTypeQuads, &sharedData[3], + registry, primTypeQuads, &sharedData[3], _BuildArrayValue(quadsI, sizeof(quadsI)/sizeof(quadsI[0])), _BuildArrayValue(quadPP, sizeof(quadPP)/sizeof(quadPP[0])), /* dummy pparam*/ _BuildArrayValue(quadEdges, sizeof(quadEdges)/sizeof(quadEdges[0])), @@ -342,7 +333,7 @@ _GetDrawItems(std::vector &sharedData) // quads w/ color result.push_back(_RegisterDrawItem( - primTypeQuads, &sharedData[4], + registry, primTypeQuads, &sharedData[4], _BuildArrayValue(quadsI, sizeof(quadsI)/sizeof(quadsI[0])), _BuildArrayValue(quadPP, sizeof(quadPP)/sizeof(quadPP[0])), /* dummy pparam*/ _BuildArrayValue(quadEdges, sizeof(quadEdges)/sizeof(quadEdges[0])), @@ -351,7 +342,7 @@ _GetDrawItems(std::vector &sharedData) _BuildArrayValue(quadsC, sizeof(quadsC)/sizeof(quadsC[0])))); result.push_back(_RegisterDrawItem( - primTypeQuads, &sharedData[5], + registry, primTypeQuads, &sharedData[5], _BuildArrayValue(quadsI, sizeof(quadsI)/sizeof(quadsI[0])), _BuildArrayValue(quadPP, sizeof(quadPP)/sizeof(quadPP[0])), /* dummy pparam*/ _BuildArrayValue(quadEdges, sizeof(quadEdges)/sizeof(quadEdges[0])), @@ -361,7 +352,7 @@ _GetDrawItems(std::vector &sharedData) // tris w/ color result.push_back(_RegisterDrawItem( - primTypeTris, &sharedData[6], + registry, primTypeTris, &sharedData[6], _BuildArrayValue(trisI, sizeof(trisI)/sizeof(trisI[0])), _BuildArrayValue(trisI, sizeof(trisI)/sizeof(trisI[0])), /* dummy pparam*/ _BuildArrayValue(triEdges, sizeof(triEdges)/sizeof(triEdges[0])), @@ -370,7 +361,7 @@ _GetDrawItems(std::vector &sharedData) _BuildArrayValue(trisC, sizeof(trisC)/sizeof(trisC[0])))); result.push_back(_RegisterDrawItem( - primTypeTris, &sharedData[7], + registry, primTypeTris, &sharedData[7], _BuildArrayValue(trisI, sizeof(trisI)/sizeof(trisI[0])), _BuildArrayValue(trisI, sizeof(trisI)/sizeof(trisI[0])), /* dummy pparam*/ _BuildArrayValue(triEdges, sizeof(triEdges)/sizeof(triEdges[0])), @@ -380,7 +371,7 @@ _GetDrawItems(std::vector &sharedData) // tris w/o color result.push_back(_RegisterDrawItem( - primTypeTris, &sharedData[8], + registry, primTypeTris, &sharedData[8], _BuildArrayValue(trisI, sizeof(trisI)/sizeof(trisI[0])), _BuildArrayValue(trisI, sizeof(trisI)/sizeof(trisI[0])), /* dummy pparam*/ _BuildArrayValue(triEdges, sizeof(triEdges)/sizeof(triEdges[0])), @@ -388,14 +379,13 @@ _GetDrawItems(std::vector &sharedData) _BuildArrayValue(trisN, sizeof(trisN)/sizeof(trisN[0])))); result.push_back(_RegisterDrawItem( - primTypeTris, &sharedData[9], + registry, primTypeTris, &sharedData[9], _BuildArrayValue(trisI, sizeof(trisI)/sizeof(trisI[0])), _BuildArrayValue(trisI, sizeof(trisI)/sizeof(trisI[0])), /* dummy pparam*/ _BuildArrayValue(triEdges, sizeof(triEdges)/sizeof(triEdges[0])), _BuildArrayValue(trisP, sizeof(trisP)/sizeof(trisP[0])), _BuildArrayValue(trisN, sizeof(trisN)/sizeof(trisN[0])))); - HdStResourceRegistrySharedPtr const& registry = _GetResourceRegistry(); registry->Commit(); return result; @@ -431,12 +421,10 @@ Dump(std::string const &message, VtDictionary dict, HdPerfLog &perfLog) } static void -IndirectDrawBatchTest() +IndirectDrawBatchTest(HdStResourceRegistrySharedPtr const ®istry) { std::cout << "==== IndirectDrawBatchTest:\n"; - HdStResourceRegistrySharedPtr const& registry = _GetResourceRegistry(); - HdPerfLog& perfLog = HdPerfLog::GetInstance(); perfLog.Enable(); perfLog.ResetCounters(); @@ -450,7 +438,7 @@ IndirectDrawBatchTest() sd.instancerLevels = 0; } - std::vector drawItems = _GetDrawItems(sharedData); + std::vector drawItems = _GetDrawItems(registry, sharedData); std::vector drawItemInstances; { TF_FOR_ALL(drawItemIt, drawItems) { @@ -613,13 +601,12 @@ IndirectDrawBatchMigrationTest() } static void -EmptyDrawBatchTest() +EmptyDrawBatchTest(HdStResourceRegistrySharedPtr const ®istry) { std::cout << "==== EmptyDrawBatchTest:\n"; // This test covers bug 120354. // - HdStResourceRegistrySharedPtr const& registry = _GetResourceRegistry(); registry->GarbageCollect(); HdPerfLog& perfLog = HdPerfLog::GetInstance(); @@ -770,9 +757,18 @@ int main() TfErrorMark mark; - IndirectDrawBatchTest(); + HgiUniquePtr const hgi = Hgi::CreatePlatformDefaultHgi(); + HdDriver driver{HgiTokens->renderDriver, VtValue(hgi.get())}; + HdStRenderDelegate renderDelegate; + std::unique_ptr const index( + HdRenderIndex::New(&renderDelegate, {&driver})); + HdStResourceRegistrySharedPtr const registry = + std::static_pointer_cast( + index->GetResourceRegistry()); + + IndirectDrawBatchTest(registry); IndirectDrawBatchMigrationTest(); - EmptyDrawBatchTest(); + EmptyDrawBatchTest(registry); if (mark.IsClean()) { std::cout << "OK" << std::endl; diff --git a/pxr/imaging/hdSt/testenv/testHdStMeshTopology.cpp b/pxr/imaging/hdSt/testenv/testHdStMeshTopology.cpp index a24387c41f..7d9a0eb6c5 100644 --- a/pxr/imaging/hdSt/testenv/testHdStMeshTopology.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStMeshTopology.cpp @@ -40,8 +40,6 @@ PXR_NAMESPACE_USING_DIRECTIVE -HdStResourceRegistrySharedPtr registry; - TF_DEFINE_PRIVATE_TOKENS( _tokens, ((bilinear, "bilinear")) @@ -59,7 +57,8 @@ _BuildArray(T values[], int numValues) } static bool -_CompareIndices(std::string const & name, +_CompareIndices(HdStResourceRegistrySharedPtr const ®istry, + std::string const & name, std::string const & orientation, VtIntArray numVerts, VtIntArray verts, VtIntArray holes, VtVec3iArray expected) @@ -97,7 +96,8 @@ _CompareIndices(std::string const & name, } static bool -_CompareFaceVarying(std::string const &name, +_CompareFaceVarying(HdStResourceRegistrySharedPtr const ®istry, + std::string const &name, std::string const &orientation, VtIntArray numVerts, VtIntArray verts, VtIntArray holes, VtFloatArray fvarValues, @@ -139,15 +139,15 @@ _CompareFaceVarying(std::string const &name, return true; } -#define COMPARE_INDICES(name, orientation, numVerts, verts, expected) \ - _CompareIndices(name, orientation, \ +#define COMPARE_INDICES(registry, name, orientation, numVerts, verts, expected) \ + _CompareIndices(registry, name, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), \ _BuildArray(verts, sizeof(verts)/sizeof(int)), \ /*holes=*/VtIntArray(), \ _BuildArray(expected, sizeof(expected)/sizeof(expected[0]))) -#define COMPARE_INDICES_HOLE(name, orientation, numVerts, verts, holes, expected) \ - _CompareIndices(name, orientation, \ +#define COMPARE_INDICES_HOLE(registry, name, orientation, numVerts, verts, holes, expected) \ + _CompareIndices(registry, name, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), \ _BuildArray(verts, sizeof(verts)/sizeof(int)), \ _BuildArray(holes, sizeof(holes)/sizeof(int)), \ @@ -173,7 +173,8 @@ _CompareArrays(VtArray const & result, template bool -_CompareSmoothNormals(std::string const & name, +_CompareSmoothNormals(HdStResourceRegistrySharedPtr const ®istry, + std::string const & name, std::string const & orientation, VtIntArray numVerts, VtIntArray verts, VtArray points, @@ -213,8 +214,8 @@ _CompareSmoothNormals(std::string const & name, return true; } -#define COMPARE_SMOOTH_NORMALS(name, orientation, numVerts, verts, points, expected) \ - _CompareSmoothNormals(name, orientation, \ +#define COMPARE_SMOOTH_NORMALS(registry, name, orientation, numVerts, verts, points, expected) \ + _CompareSmoothNormals(registry, name, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ _BuildArray(points, sizeof(points)/sizeof(points[0])), \ @@ -259,7 +260,8 @@ _CompareFlatNormals(std::string const & name, template bool -_CompareGpuSmoothNormals(std::string const & name, +_CompareGpuSmoothNormals(HdStResourceRegistrySharedPtr const ®istry, + std::string const & name, std::string const & orientation, VtIntArray numVerts, VtIntArray verts, VtArray points, @@ -337,8 +339,8 @@ _CompareGpuSmoothNormals(std::string const & name, return true; } -#define COMPARE_GPU_SMOOTH_NORMALS(name, orientation, numVerts, verts, points, expected) \ - _CompareGpuSmoothNormals(name, orientation, \ +#define COMPARE_GPU_SMOOTH_NORMALS(registry, name, orientation, numVerts, verts, points, expected) \ + _CompareGpuSmoothNormals(registry, name, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ _BuildArray(points, sizeof(points)/sizeof(points[0])), \ @@ -346,7 +348,8 @@ _CompareGpuSmoothNormals(std::string const & name, template bool -_CompareGpuFlatNormals(std::string const & name, +_CompareGpuFlatNormals(HdStResourceRegistrySharedPtr const ®istry, + std::string const & name, std::string const & orientation, VtIntArray numVerts, VtIntArray verts, VtArray points, @@ -441,28 +444,28 @@ _CompareGpuFlatNormals(std::string const & name, return true; } -#define COMPARE_GPU_FLAT_NORMALS_TRI(name, orientation, numVerts, verts, points, expected) \ - _CompareGpuFlatNormals(name, orientation, \ +#define COMPARE_GPU_FLAT_NORMALS_TRI(registry, name, orientation, numVerts, verts, points, expected) \ + _CompareGpuFlatNormals(registry, name, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ _BuildArray(points, sizeof(points)/sizeof(points[0])), \ _BuildArray(expected, sizeof(expected)/sizeof(expected[0])), false) -#define COMPARE_GPU_FLAT_NORMALS_QUAD(name, orientation, numVerts, verts, points, expected) \ - _CompareGpuFlatNormals(name, orientation, \ +#define COMPARE_GPU_FLAT_NORMALS_QUAD(registry, name, orientation, numVerts, verts, points, expected) \ + _CompareGpuFlatNormals(registry, name, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ _BuildArray(points, sizeof(points)/sizeof(points[0])), \ _BuildArray(expected, sizeof(expected)/sizeof(expected[0])), true) bool -BasicTest() +BasicTest(HdStResourceRegistrySharedPtr const ®istry) { { int numVerts[] = {}; int verts[] = {}; GfVec3i expected[] = { }; - if (!COMPARE_INDICES("empty", + if (!COMPARE_INDICES(registry, "empty", _tokens->rightHanded, numVerts, verts, expected)) { return false; } @@ -472,7 +475,7 @@ BasicTest() int numVerts[] = { 0, 3 }; int verts[] = { 1 , 2 , 3 }; GfVec3i expected[] = { GfVec3i(1,2,3) }; - if (!COMPARE_INDICES("identity_no_vert_face", + if (!COMPARE_INDICES(registry, "identity_no_vert_face", _tokens->rightHanded, numVerts, verts, expected)) { return false; } @@ -483,7 +486,7 @@ BasicTest() int numVerts[] = { 1, 3 }; int verts[] = { 1, 1, 2 , 3 }; GfVec3i expected[] = { GfVec3i(1,2,3) }; - if (!COMPARE_INDICES("identity_one_vert_face", + if (!COMPARE_INDICES(registry, "identity_one_vert_face", _tokens->rightHanded, numVerts, verts, expected)) { return false; } @@ -494,7 +497,7 @@ BasicTest() int numVerts[] = { 2, 3 }; int verts[] = { 1, 1, 1, 2 , 3 }; GfVec3i expected[] = { GfVec3i(1,2,3) }; - if (!COMPARE_INDICES("identity_two_vert_face", + if (!COMPARE_INDICES(registry, "identity_two_vert_face", _tokens->rightHanded, numVerts, verts, expected)) { return false; } @@ -505,7 +508,7 @@ BasicTest() int verts[] = { 1, 2, 3, 4 }; GfVec3i expected[] = { GfVec3i(1, 2, 3), GfVec3i(1, 3, 4) }; - if (!COMPARE_INDICES("quad_no_vet_face", + if (!COMPARE_INDICES(registry, "quad_no_vet_face", _tokens->rightHanded, numVerts, verts, expected)) { return false; } @@ -516,7 +519,7 @@ BasicTest() int verts[] = { 1, 1, 1, 2, 3, 4 }; GfVec3i expected[] = { GfVec3i(1, 2, 3), GfVec3i(1, 3, 4) }; - if (!COMPARE_INDICES("quad_two_vert_face", + if (!COMPARE_INDICES(registry, "quad_two_vert_face", _tokens->rightHanded, numVerts, verts, expected)) { return false; } @@ -528,7 +531,7 @@ BasicTest() GfVec3i(4, 5, 6), GfVec3i(4, 6, 7), GfVec3i(8, 9, 10) }; - if (!COMPARE_INDICES("3 4 3", + if (!COMPARE_INDICES(registry, "3 4 3", _tokens->rightHanded, numVerts, verts, expected)) { return false; } @@ -537,7 +540,7 @@ BasicTest() } bool -HoleTest() +HoleTest(HdStResourceRegistrySharedPtr const ®istry) { /* 0-----3-------4-----7 @@ -567,21 +570,22 @@ HoleTest() GfVec3i(2, 9, 5), GfVec3i(5, 9, 10), GfVec3i(5, 10, 6) }; - if (!COMPARE_INDICES_HOLE("hole", _tokens->rightHanded, numVerts, verts, hole, expected)) { + if (!COMPARE_INDICES_HOLE(registry, "hole", _tokens->rightHanded, numVerts, + verts, hole, expected)) { return false; } return true; } bool -ComputeNormalsTest() +ComputeNormalsTest(HdStResourceRegistrySharedPtr const ®istry) { { int numVerts[] = {}; int verts[] = {}; GfVec3f points[] = {}; GfVec3f expectedNormals[] = {}; - if (!COMPARE_SMOOTH_NORMALS("empty", _tokens->rightHanded, + if (!COMPARE_SMOOTH_NORMALS(registry, "empty", _tokens->rightHanded, numVerts, verts, points, expectedNormals)) { return false; } @@ -596,7 +600,7 @@ ComputeNormalsTest() }; GfVec3f expectedNormals[] = {}; if (!COMPARE_SMOOTH_NORMALS( - "missing_faceVertexIndices",_tokens->rightHanded, + registry, "missing_faceVertexIndices",_tokens->rightHanded, numVerts, verts, points, expectedNormals)) { return false; } @@ -622,26 +626,28 @@ ComputeNormalsTest() GfVec3f( 0.0, 0.0, 0.0 ), GfVec3f( 0.0, 0.0, 1.0 ), }; - if (!COMPARE_SMOOTH_NORMALS("triangle_cpu", _tokens->rightHanded, - numVerts, verts, points, expectedSmoothNormals)) { + if (!COMPARE_SMOOTH_NORMALS(registry, "triangle_cpu", + _tokens->rightHanded, numVerts, verts, points, + expectedSmoothNormals)) { return false; } - if (!COMPARE_GPU_SMOOTH_NORMALS("triangle_gpu", _tokens->rightHanded, - numVerts, verts, points, expectedSmoothNormals)) { + if (!COMPARE_GPU_SMOOTH_NORMALS(registry, "triangle_gpu", + _tokens->rightHanded,numVerts, verts, points, + expectedSmoothNormals)) { return false; } if (!COMPARE_FLAT_NORMALS("triangle_flat_cpu", _tokens->rightHanded, numVerts, verts, points, expectedFlatNormals)) { return false; } - if (!COMPARE_GPU_FLAT_NORMALS_TRI("triangle_flat_gpu_tri", - _tokens->rightHanded, - numVerts, verts, points, expectedFlatNormals)) { + if (!COMPARE_GPU_FLAT_NORMALS_TRI(registry, "triangle_flat_gpu_tri", + _tokens->rightHanded, numVerts, verts, points, + expectedFlatNormals)) { return false; } - if (!COMPARE_GPU_FLAT_NORMALS_QUAD("triangle_flat_gpu_quad", - _tokens->rightHanded, - numVerts, verts, points, expectedFlatNormals)) { + if (!COMPARE_GPU_FLAT_NORMALS_QUAD(registry, "triangle_flat_gpu_quad", + _tokens->rightHanded, numVerts, verts, points, + expectedFlatNormals)) { return false; } } @@ -663,26 +669,27 @@ ComputeNormalsTest() GfVec3f expectedFlatNormals[] = { GfVec3f( 0.0f, 0.0f, 1.0f ), }; - if (!COMPARE_SMOOTH_NORMALS("quad_cpu", _tokens->rightHanded, + if (!COMPARE_SMOOTH_NORMALS(registry, "quad_cpu", _tokens->rightHanded, numVerts, verts, points, expectedSmoothNormals)) { return false; } - if (!COMPARE_GPU_SMOOTH_NORMALS("quad_gpu", _tokens->rightHanded, - numVerts, verts, points, expectedSmoothNormals)) { + if (!COMPARE_GPU_SMOOTH_NORMALS(registry, "quad_gpu", + _tokens->rightHanded, numVerts, verts, points, + expectedSmoothNormals)) { return false; } if (!COMPARE_FLAT_NORMALS("quad_flat_cpu", _tokens->rightHanded, numVerts, verts, points, expectedFlatNormals)) { return false; } - if (!COMPARE_GPU_FLAT_NORMALS_TRI("quad_flat_gpu_tri", - _tokens->rightHanded, - numVerts, verts, points, expectedFlatNormals)) { + if (!COMPARE_GPU_FLAT_NORMALS_TRI(registry, "quad_flat_gpu_tri", + _tokens->rightHanded, numVerts, verts, points, + expectedFlatNormals)) { return false; } - if (!COMPARE_GPU_FLAT_NORMALS_QUAD("quad_flat_gpu_quad", - _tokens->rightHanded, - numVerts, verts, points, expectedFlatNormals)) { + if (!COMPARE_GPU_FLAT_NORMALS_QUAD(registry, "quad_flat_gpu_quad", + _tokens->rightHanded, numVerts, verts, points, + expectedFlatNormals)) { return false; } } @@ -724,27 +731,28 @@ ComputeNormalsTest() GfVec3f( 1.0, 0.0, 0.0 ), GfVec3f(-1.0, 0.0, 0.0 ), }; - if (!COMPARE_SMOOTH_NORMALS("cube float ccw_cpu", _tokens->rightHanded, - numVerts, verts, points, expectedSmoothNormals)) { + if (!COMPARE_SMOOTH_NORMALS(registry, "cube float ccw_cpu", + _tokens->rightHanded, numVerts, verts, points, + expectedSmoothNormals)) { return false; } - if (!COMPARE_GPU_SMOOTH_NORMALS("cube float ccw_gpu", + if (!COMPARE_GPU_SMOOTH_NORMALS(registry, "cube float ccw_gpu", _tokens->rightHanded, numVerts, verts, points, expectedSmoothNormals)) { return false; } if (!COMPARE_FLAT_NORMALS("cube float ccw_flat_cpu", - _tokens->rightHanded, - numVerts, verts, points, expectedFlatNormals)) { + _tokens->rightHanded, numVerts, verts, points, + expectedFlatNormals)) { return false; } - if (!COMPARE_GPU_FLAT_NORMALS_TRI("cube float ccw_flat_gpu_tri", - _tokens->rightHanded, + if (!COMPARE_GPU_FLAT_NORMALS_TRI(registry, + "cube float ccw_flat_gpu_tri", _tokens->rightHanded, numVerts, verts, points, expectedFlatNormals)) { return false; } - if (!COMPARE_GPU_FLAT_NORMALS_QUAD("cube float ccw_flat_gpu_quad", - _tokens->rightHanded, + if (!COMPARE_GPU_FLAT_NORMALS_QUAD(registry, + "cube float ccw_flat_gpu_quad", _tokens->rightHanded, numVerts, verts, points, expectedFlatNormals)) { return false; } @@ -787,26 +795,27 @@ ComputeNormalsTest() GfVec3f( 1.0, 0.0, 0.0 ), GfVec3f(-1.0, 0.0, 0.0 ), }; - if (!COMPARE_SMOOTH_NORMALS("cube float cw_cpu", _tokens->leftHanded, - numVerts, verts, points, expectedSmoothNormals)) { + if (!COMPARE_SMOOTH_NORMALS(registry, "cube float cw_cpu", + _tokens->leftHanded, numVerts, verts, points, + expectedSmoothNormals)) { return false; } - if (!COMPARE_GPU_SMOOTH_NORMALS("cube float cw_gpu", - _tokens->leftHanded, - numVerts, verts, points, expectedSmoothNormals)) { + if (!COMPARE_GPU_SMOOTH_NORMALS(registry, "cube float cw_gpu", + _tokens->leftHanded, numVerts, verts, points, + expectedSmoothNormals)) { return false; } if (!COMPARE_FLAT_NORMALS("cube float cw_flat_cpu", _tokens->leftHanded, numVerts, verts, points, expectedFlatNormals)) { return false; } - if (!COMPARE_GPU_FLAT_NORMALS_TRI("cube float cw_flat_gpu_tri", - _tokens->leftHanded, + if (!COMPARE_GPU_FLAT_NORMALS_TRI(registry, + "cube float cw_flat_gpu_tri", _tokens->leftHanded, numVerts, verts, points, expectedFlatNormals)) { return false; } - if (!COMPARE_GPU_FLAT_NORMALS_QUAD("cube float cw_flat_gpu_quad", - _tokens->leftHanded, + if (!COMPARE_GPU_FLAT_NORMALS_QUAD(registry, + "cube float cw_flat_gpu_quad", _tokens->leftHanded, numVerts, verts, points, expectedFlatNormals)) { return false; } @@ -849,24 +858,26 @@ ComputeNormalsTest() GfVec3d( 1.0, 0.0, 0.0 ), GfVec3d(-1.0, 0.0, 0.0 ), }; - if (!COMPARE_SMOOTH_NORMALS("cube double_cpu", _tokens->rightHanded, - numVerts, verts, points, expectedSmoothNormals)) { + if (!COMPARE_SMOOTH_NORMALS(registry, "cube double_cpu", + _tokens->rightHanded, numVerts, verts, points, + expectedSmoothNormals)) { return false; } - if (!COMPARE_GPU_SMOOTH_NORMALS("cube double_gpu", _tokens->rightHanded, - numVerts, verts, points, expectedSmoothNormals)) { + if (!COMPARE_GPU_SMOOTH_NORMALS(registry, "cube double_gpu", + _tokens->rightHanded, numVerts, verts, points, + expectedSmoothNormals)) { return false; } if (!COMPARE_FLAT_NORMALS("cube double_flat_cpu", _tokens->rightHanded, numVerts, verts, points, expectedFlatNormals)) { return false; } - if (!COMPARE_GPU_FLAT_NORMALS_TRI("cube double_flat_gpu_tri", + if (!COMPARE_GPU_FLAT_NORMALS_TRI(registry, "cube double_flat_gpu_tri", _tokens->rightHanded, numVerts, verts, points, expectedFlatNormals)) { return false; } - if (!COMPARE_GPU_FLAT_NORMALS_QUAD("cube double_flat_gpu_quad", + if (!COMPARE_GPU_FLAT_NORMALS_QUAD(registry, "cube double_flat_gpu_quad", _tokens->rightHanded, numVerts, verts, points, expectedFlatNormals)) { return false; @@ -876,7 +887,7 @@ ComputeNormalsTest() } bool -FaceVaryingTest() +FaceVaryingTest(HdStResourceRegistrySharedPtr const ®istry) { /* 0-----3-------4-----7 @@ -909,7 +920,7 @@ FaceVaryingTest() 13, 14, 15, 13, 15, 16, 17, 18, 19, 17, 19, 20 }; - if (!_CompareFaceVarying("FaceVarying", _tokens->rightHanded, + if (!_CompareFaceVarying(registry, "FaceVarying", _tokens->rightHanded, _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), _BuildArray(verts, sizeof(verts)/sizeof(int)), _BuildArray(hole, sizeof(hole)/sizeof(int)), @@ -921,7 +932,7 @@ FaceVaryingTest() } bool -InvalidTopologyTest() +InvalidTopologyTest(HdStResourceRegistrySharedPtr const ®istry) { int numVerts[] = { 4, 4, 4, 4, 4}; int verts[] = { 0, 1, 2, 3, @@ -954,14 +965,14 @@ InvalidTopologyTest() 0, 0, 0, 0, 0, 0, // missing }; - if (!_CompareIndices("Invalid", _tokens->rightHanded, + if (!_CompareIndices(registry, "Invalid", _tokens->rightHanded, _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), _BuildArray(verts, sizeof(verts)/sizeof(int)), _BuildArray(hole, sizeof(hole)/sizeof(int)), _BuildArray(expected, sizeof(expected)/sizeof(expected[0])))) { return false; } - if (!_CompareFaceVarying("InvalidFaceVarying", _tokens->rightHanded, + if (!_CompareFaceVarying(registry, "InvalidFaceVarying", _tokens->rightHanded, _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), _BuildArray(verts, sizeof(verts)/sizeof(int)), _BuildArray(hole, sizeof(hole)/sizeof(int)), @@ -981,24 +992,22 @@ int main() TfErrorMark mark; - static HgiUniquePtr _hgi = Hgi::CreatePlatformDefaultHgi(); - HdDriver driver{HgiTokens->renderDriver, VtValue(_hgi.get())}; + HgiUniquePtr const hgi = Hgi::CreatePlatformDefaultHgi(); + HdDriver driver{HgiTokens->renderDriver, VtValue(hgi.get())}; HdStRenderDelegate renderDelegate; - std::unique_ptr index( + std::unique_ptr const index( HdRenderIndex::New(&renderDelegate, {&driver})); - registry = std::static_pointer_cast( + HdStResourceRegistrySharedPtr const registry = + std::static_pointer_cast( index->GetResourceRegistry()); bool success = true; - success &= BasicTest(); - success &= HoleTest(); - success &= ComputeNormalsTest(); - success &= FaceVaryingTest(); - success &= InvalidTopologyTest(); - - registry->GarbageCollect(); - registry.reset(); - + success &= BasicTest(registry); + success &= HoleTest(registry); + success &= ComputeNormalsTest(registry); + success &= FaceVaryingTest(registry); + success &= InvalidTopologyTest(registry); + TF_VERIFY(mark.IsClean()); if (success && mark.IsClean()) { diff --git a/pxr/imaging/hdSt/testenv/testHdStPrimitiveParam.cpp b/pxr/imaging/hdSt/testenv/testHdStPrimitiveParam.cpp index a12555a4ef..ed76a63d73 100644 --- a/pxr/imaging/hdSt/testenv/testHdStPrimitiveParam.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStPrimitiveParam.cpp @@ -35,7 +35,6 @@ PXR_NAMESPACE_USING_DIRECTIVE -HdStResourceRegistrySharedPtr registry; TF_DEFINE_PRIVATE_TOKENS( _tokens, @@ -72,7 +71,8 @@ _CompareArrays(VtArray const & result, } bool -_ComparePrimitiveIDMap(std::string const & name, +_ComparePrimitiveIDMap(HdStResourceRegistrySharedPtr const ®istry, + std::string const & name, std::string const & orientation, VtIntArray numVerts, VtIntArray verts, VtIntArray expectedMapping, @@ -137,7 +137,8 @@ _ComparePrimitiveIDMap(std::string const & name, } bool -_ComparePtexFaceIndex(std::string const & name, +_ComparePtexFaceIndex(HdStResourceRegistrySharedPtr const ®istry, + std::string const & name, std::string const & orientation, VtIntArray numVerts, VtIntArray verts, VtIntArray expectedMapping) @@ -194,27 +195,27 @@ _ComparePtexFaceIndex(std::string const & name, return true; } -#define COMPARE_PRIMITIVE_ID_MAP_TRI(name, orientation, numVerts, verts, expectedMapping) \ - _ComparePrimitiveIDMap(name, orientation, \ +#define COMPARE_PRIMITIVE_ID_MAP_TRI(registry, name, orientation, numVerts, verts, expectedMapping) \ + _ComparePrimitiveIDMap(registry, name, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ _BuildArray(expectedMapping, sizeof(expectedMapping)/sizeof(expectedMapping[0])), \ false) -#define COMPARE_PRIMITIVE_ID_MAP_QUAD(name, orientation, numVerts, verts, expectedMapping) \ - _ComparePrimitiveIDMap(name, orientation, \ +#define COMPARE_PRIMITIVE_ID_MAP_QUAD(registry, name, orientation, numVerts, verts, expectedMapping) \ + _ComparePrimitiveIDMap(registry, name, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ _BuildArray(expectedMapping, sizeof(expectedMapping)/sizeof(expectedMapping[0])), \ true) -#define COMPARE_PTEX_FACE_INDEX(name, orientation, numVerts, verts, expectedMapping) \ - _ComparePtexFaceIndex(name, orientation, \ +#define COMPARE_PTEX_FACE_INDEX(registry, name, orientation, numVerts, verts, expectedMapping) \ + _ComparePtexFaceIndex(registry, name, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ _BuildArray(expectedMapping, sizeof(expectedMapping)/sizeof(expectedMapping[0]))) bool -PrimitiveIDMapTest() +PrimitiveIDMapTest(HdStResourceRegistrySharedPtr const ®istry) { HdPerfLog& perfLog = HdPerfLog::GetInstance(); perfLog.Enable(); @@ -240,12 +241,14 @@ PrimitiveIDMapTest() int expectedTri[] = { 0 }; int expectedQuad[] = { 0, 0, 0 }; - if (!COMPARE_PRIMITIVE_ID_MAP_TRI("triangle", _tokens->rightHanded, - numVerts, verts, expectedTri)) { + if (!COMPARE_PRIMITIVE_ID_MAP_TRI( + registry, "triangle", _tokens->rightHanded, + numVerts, verts, expectedTri)) { return false; } - if (!COMPARE_PRIMITIVE_ID_MAP_QUAD("triangle", _tokens->rightHanded, - numVerts, verts, expectedQuad)) { + if (!COMPARE_PRIMITIVE_ID_MAP_QUAD( + registry, "triangle", _tokens->rightHanded, + numVerts, verts, expectedQuad)) { return false; } } @@ -266,12 +269,14 @@ PrimitiveIDMapTest() int expectedTri[] = { 0, 0 }; int expectedQuad[] = { 0 }; - if (!COMPARE_PRIMITIVE_ID_MAP_TRI("quad", _tokens->rightHanded, - numVerts, verts, expectedTri)) { + if (!COMPARE_PRIMITIVE_ID_MAP_TRI( + registry, "quad", _tokens->rightHanded, + numVerts, verts, expectedTri)) { return false; } - if (!COMPARE_PRIMITIVE_ID_MAP_QUAD("quad", _tokens->rightHanded, - numVerts, verts, expectedQuad)) { + if (!COMPARE_PRIMITIVE_ID_MAP_QUAD( + registry, "quad", _tokens->rightHanded, + numVerts, verts, expectedQuad)) { return false; } } @@ -296,12 +301,14 @@ PrimitiveIDMapTest() int expectedTri[] = { 0, 1, 1, 2, 2, 2 }; int expectedQuad[] = { 0, 0, 0, 1, 2, 2, 2, 2, 2 }; - if (!COMPARE_PRIMITIVE_ID_MAP_TRI("polygons", _tokens->rightHanded, - numVerts, verts, expectedTri)) { + if (!COMPARE_PRIMITIVE_ID_MAP_TRI( + registry, "polygons", _tokens->rightHanded, + numVerts, verts, expectedTri)) { return false; } - if (!COMPARE_PRIMITIVE_ID_MAP_QUAD("polygons", _tokens->rightHanded, - numVerts, verts, expectedQuad)) { + if (!COMPARE_PRIMITIVE_ID_MAP_QUAD( + registry, "polygons", _tokens->rightHanded, + numVerts, verts, expectedQuad)) { return false; } } @@ -309,7 +316,7 @@ PrimitiveIDMapTest() } bool -PtexFaceIndexTest() +PtexFaceIndexTest(HdStResourceRegistrySharedPtr const ®istry) { HdPerfLog& perfLog = HdPerfLog::GetInstance(); perfLog.Enable(); @@ -338,7 +345,7 @@ PtexFaceIndexTest() 4, 3, 5, 6, 7 }; int expectedQuad[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; - if (!COMPARE_PTEX_FACE_INDEX("polygons", _tokens->rightHanded, + if (!COMPARE_PTEX_FACE_INDEX(registry, "polygons", _tokens->rightHanded, numVerts, verts, expectedQuad)) { return false; } @@ -353,22 +360,21 @@ int main() TfErrorMark mark; - HgiUniquePtr hgi = Hgi::CreatePlatformDefaultHgi(); + HgiUniquePtr const hgi = Hgi::CreatePlatformDefaultHgi(); HdDriver driver{HgiTokens->renderDriver, VtValue(hgi.get())}; HdStRenderDelegate renderDelegate; - std::unique_ptr index( + std::unique_ptr const index( HdRenderIndex::New(&renderDelegate, {&driver})); - registry = std::static_pointer_cast( - index->GetResourceRegistry()); + HdStResourceRegistrySharedPtr const registry = + std::static_pointer_cast( + index->GetResourceRegistry()); bool success = true; - success &= PrimitiveIDMapTest(); - success &= PtexFaceIndexTest(); + success &= PrimitiveIDMapTest(registry); + success &= PtexFaceIndexTest(registry); TF_VERIFY(mark.IsClean()); - registry.reset(); - if (success && mark.IsClean()) { std::cout << "OK" << std::endl; return EXIT_SUCCESS; diff --git a/pxr/imaging/hdSt/testenv/testHdStQuadrangulation.cpp b/pxr/imaging/hdSt/testenv/testHdStQuadrangulation.cpp index 9fc247972e..c3f6eeb73f 100644 --- a/pxr/imaging/hdSt/testenv/testHdStQuadrangulation.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStQuadrangulation.cpp @@ -67,7 +67,8 @@ _CompareArrays(VtArray const & result, template bool -_CompareQuadPoints(std::string const & name, +_CompareQuadPoints(HdStResourceRegistrySharedPtr const ®istry, + std::string const & name, std::string const & orientation, VtIntArray numVerts, VtIntArray verts, VtArray points, @@ -78,15 +79,6 @@ _CompareQuadPoints(std::string const & name, { std::cout << "GPU quadrangulate = " << gpu << "\n"; - static HgiUniquePtr _hgi = Hgi::CreatePlatformDefaultHgi(); - static HdDriver driver{HgiTokens->renderDriver, VtValue(_hgi.get())}; - static HdStRenderDelegate renderDelegate; - static std::unique_ptr index( - HdRenderIndex::New(&renderDelegate, {&driver})); - HdStResourceRegistrySharedPtr const& registry = - std::static_pointer_cast( - index->GetResourceRegistry()); - HdMeshTopology m(_tokens->bilinear, TfToken(orientation), numVerts, verts); m.SetHoleIndices(holes); @@ -94,7 +86,6 @@ _CompareQuadPoints(std::string const & name, // Convert topology to render delegate version HdSt_MeshTopologySharedPtr rdTopology = HdSt_MeshTopology::New(m, 0); - HdBufferArrayRangeSharedPtr indexRange; // build quadinfo @@ -204,8 +195,8 @@ _CompareQuadPoints(std::string const & name, return true; } -#define COMPARE_QUAD_POINTS(name, orientation, numVerts, verts, points, expectedIndices, expectedPoints) \ - _CompareQuadPoints(name, orientation, \ +#define COMPARE_QUAD_POINTS(registry, name, orientation, numVerts, verts, points, expectedIndices, expectedPoints) \ + _CompareQuadPoints(registry, name, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ _BuildArray(points, sizeof(points)/sizeof(points[0])), \ @@ -214,8 +205,8 @@ _CompareQuadPoints(std::string const & name, _BuildArray(expectedPoints, sizeof(expectedPoints)/sizeof(expectedPoints[0])), \ false) -#define COMPARE_GPU_QUAD_POINTS(name, orientation, numVerts, verts, points, expectedIndices, expectedPoints) \ - _CompareQuadPoints(name, orientation, \ +#define COMPARE_GPU_QUAD_POINTS(registry, name, orientation, numVerts, verts, points, expectedIndices, expectedPoints) \ + _CompareQuadPoints(registry, name, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ _BuildArray(points, sizeof(points)/sizeof(points[0])), \ @@ -224,8 +215,8 @@ _CompareQuadPoints(std::string const & name, _BuildArray(expectedPoints, sizeof(expectedPoints)/sizeof(expectedPoints[0])), \ true) -#define COMPARE_QUAD_POINTS_HOLE(name, orientation, numVerts, verts, points, holes, expectedIndices, expectedPoints) \ - _CompareQuadPoints(name, orientation, \ +#define COMPARE_QUAD_POINTS_HOLE(registry, name, orientation, numVerts, verts, points, holes, expectedIndices, expectedPoints) \ + _CompareQuadPoints(registry, name, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ _BuildArray(points, sizeof(points)/sizeof(points[0])), \ @@ -234,8 +225,8 @@ _CompareQuadPoints(std::string const & name, _BuildArray(expectedPoints, sizeof(expectedPoints)/sizeof(expectedPoints[0])), \ false) -#define COMPARE_GPU_QUAD_POINTS_HOLE(name, orientation, numVerts, verts, points, holes, expectedIndices, expectedPoints) \ - _CompareQuadPoints(name, orientation, \ +#define COMPARE_GPU_QUAD_POINTS_HOLE(registry, name, orientation, numVerts, verts, points, holes, expectedIndices, expectedPoints) \ + _CompareQuadPoints(registry, name, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ _BuildArray(points, sizeof(points)/sizeof(points[0])), \ @@ -245,7 +236,8 @@ _CompareQuadPoints(std::string const & name, true) bool -QuadrangulationTest() +QuadrangulationTest( + HdStResourceRegistrySharedPtr const ®istry) { HdPerfLog& perfLog = HdPerfLog::GetInstance(); perfLog.Enable(); @@ -290,7 +282,7 @@ QuadrangulationTest() 2, 5, 6, 4 }; - if (!COMPARE_QUAD_POINTS("triangle", _tokens->rightHanded, + if (!COMPARE_QUAD_POINTS(registry, "triangle", _tokens->rightHanded, numVerts, verts, points, expectedIndices, expectedPoints)) { return false; } @@ -303,7 +295,7 @@ QuadrangulationTest() TF_VERIFY(perfLog.GetCounter(HdPerfTokens->computationsCommited) == 0); perfLog.ResetCounters(); - if (!COMPARE_GPU_QUAD_POINTS("triangle", _tokens->rightHanded, + if (!COMPARE_GPU_QUAD_POINTS(registry, "triangle", _tokens->rightHanded, numVerts, verts, points, expectedIndices, expectedPoints)) { return false; } @@ -350,7 +342,7 @@ QuadrangulationTest() 2, 4, 6, 5 }; - if (!COMPARE_QUAD_POINTS("triangle", _tokens->leftHanded, + if (!COMPARE_QUAD_POINTS(registry, "triangle", _tokens->leftHanded, numVerts, verts, points, expectedIndices, expectedPoints)) { return false; } @@ -363,7 +355,7 @@ QuadrangulationTest() TF_VERIFY(perfLog.GetCounter(HdPerfTokens->computationsCommited) == 0); perfLog.ResetCounters(); - if (!COMPARE_GPU_QUAD_POINTS("triangle", _tokens->leftHanded, + if (!COMPARE_GPU_QUAD_POINTS(registry, "triangle", _tokens->leftHanded, numVerts, verts, points, expectedIndices, expectedPoints)) { return false; } @@ -396,7 +388,7 @@ QuadrangulationTest() 0, 1, 2, 3 }; - if (!COMPARE_QUAD_POINTS("quad", _tokens->rightHanded, + if (!COMPARE_QUAD_POINTS(registry, "quad", _tokens->rightHanded, numVerts, verts, points, expectedIndices, expectedPoints)) { return false; } @@ -408,7 +400,7 @@ QuadrangulationTest() TF_VERIFY(perfLog.GetCounter(HdPerfTokens->computationsCommited) == 0); perfLog.ResetCounters(); - if (!COMPARE_GPU_QUAD_POINTS("quad", _tokens->rightHanded, + if (!COMPARE_GPU_QUAD_POINTS(registry, "quad", _tokens->rightHanded, numVerts, verts, points, expectedIndices, expectedPoints)) { return false; } @@ -479,7 +471,7 @@ QuadrangulationTest() 6, 15, 17, 14, 7, 16, 17, 15 }; - if (!COMPARE_QUAD_POINTS("quad", _tokens->rightHanded, + if (!COMPARE_QUAD_POINTS(registry, "quad", _tokens->rightHanded, numVerts, verts, points, expectedIndices, expectedPoints)) { return false; } @@ -491,7 +483,7 @@ QuadrangulationTest() TF_VERIFY(perfLog.GetCounter(HdPerfTokens->computationsCommited) == 0); perfLog.ResetCounters(); - if (!COMPARE_GPU_QUAD_POINTS("quad", _tokens->rightHanded, + if (!COMPARE_GPU_QUAD_POINTS(registry, "quad", _tokens->rightHanded, numVerts, verts, points, expectedIndices, expectedPoints)) { return false; } @@ -563,7 +555,7 @@ QuadrangulationTest() 7, 16, 17, 15 }; - if (!COMPARE_QUAD_POINTS_HOLE("quad", _tokens->rightHanded, + if (!COMPARE_QUAD_POINTS_HOLE(registry, "quad", _tokens->rightHanded, numVerts, verts, points, holes, expectedIndices, expectedPoints)) { return false; } @@ -575,7 +567,7 @@ QuadrangulationTest() TF_VERIFY(perfLog.GetCounter(HdPerfTokens->computationsCommited) == 0); perfLog.ResetCounters(); - if (!COMPARE_GPU_QUAD_POINTS_HOLE("quad", _tokens->rightHanded, + if (!COMPARE_GPU_QUAD_POINTS_HOLE(registry, "quad", _tokens->rightHanded, numVerts, verts, points, holes, expectedIndices, expectedPoints)) { return false; } @@ -592,7 +584,8 @@ QuadrangulationTest() } bool -QuadrangulationInvalidTopologyTest() +QuadrangulationInvalidTopologyTest( + HdStResourceRegistrySharedPtr const ®istry) { HdPerfLog& perfLog = HdPerfLog::GetInstance(); perfLog.Enable(); @@ -662,7 +655,7 @@ QuadrangulationInvalidTopologyTest() 0, 0, 0, 0, // missing 0, 0, 0, 0 // missing }; - if (!COMPARE_QUAD_POINTS("quad", _tokens->rightHanded, + if (!COMPARE_QUAD_POINTS(registry, "quad", _tokens->rightHanded, numVerts, verts, points, expectedIndices, expectedPoints)) { return false; } @@ -674,7 +667,7 @@ QuadrangulationInvalidTopologyTest() TF_VERIFY(perfLog.GetCounter(HdPerfTokens->computationsCommited) == 0); perfLog.ResetCounters(); - if (!COMPARE_GPU_QUAD_POINTS("quad", _tokens->rightHanded, + if (!COMPARE_GPU_QUAD_POINTS(registry, "quad", _tokens->rightHanded, numVerts, verts, points, expectedIndices, expectedPoints)) { return false; } @@ -697,9 +690,18 @@ int main() TfErrorMark mark; + HgiUniquePtr const hgi = Hgi::CreatePlatformDefaultHgi(); + HdDriver driver{HgiTokens->renderDriver, VtValue(hgi.get())}; + HdStRenderDelegate renderDelegate; + std::unique_ptr const index( + HdRenderIndex::New(&renderDelegate, {&driver})); + HdStResourceRegistrySharedPtr const registry = + std::static_pointer_cast( + index->GetResourceRegistry()); + bool success = true; - success &= QuadrangulationTest(); - success &= QuadrangulationInvalidTopologyTest(); + success &= QuadrangulationTest(registry); + success &= QuadrangulationInvalidTopologyTest(registry); TF_VERIFY(mark.IsClean()); diff --git a/pxr/imaging/hdSt/testenv/testHdStSubdivision.cpp b/pxr/imaging/hdSt/testenv/testHdStSubdivision.cpp index 7662359005..9281227654 100644 --- a/pxr/imaging/hdSt/testenv/testHdStSubdivision.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStSubdivision.cpp @@ -34,8 +34,6 @@ PXR_NAMESPACE_USING_DIRECTIVE -HdStResourceRegistrySharedPtr registry; - TF_DEFINE_PRIVATE_TOKENS( _tokens, ((leftHanded, "leftHanded")) @@ -53,7 +51,8 @@ _BuildArray(T values[], int numValues) template bool -_DumpRefinedPoints(std::string const & name, +_DumpRefinedPoints(HdStResourceRegistrySharedPtr const ®istry, + std::string const & name, TfToken const & scheme, TfToken const & orientation, VtIntArray numVerts, VtIntArray verts, @@ -167,8 +166,8 @@ _DumpRefinedPoints(std::string const & name, return true; } -#define DUMP_REFINED_POINTS(name, scheme, orientation, numVerts, verts, points, holes, subdivTags) \ - _DumpRefinedPoints(name, scheme, orientation, \ +#define DUMP_REFINED_POINTS(registry, name, scheme, orientation, numVerts, verts, points, holes, subdivTags) \ + _DumpRefinedPoints(registry, name, scheme, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ _BuildArray(points, sizeof(points)/sizeof(points[0])), \ @@ -176,8 +175,8 @@ _DumpRefinedPoints(std::string const & name, subdivTags, \ /*level=*/1, false) -#define DUMP_GPU_REFINED_POINTS(name, scheme, orientation, numVerts, verts, points, holes, subdivTags) \ - _DumpRefinedPoints(name, scheme, orientation, \ +#define DUMP_GPU_REFINED_POINTS(registry, name, scheme, orientation, numVerts, verts, points, holes, subdivTags) \ + _DumpRefinedPoints(registry, name, scheme, orientation, \ _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ _BuildArray(points, sizeof(points)/sizeof(points[0])), \ @@ -186,7 +185,8 @@ _DumpRefinedPoints(std::string const & name, /*level=*/1, true) bool -SubdivisionTest(TfToken const &scheme) +SubdivisionTest(HdStResourceRegistrySharedPtr const ®istry, + TfToken const &scheme) { HdPerfLog& perfLog = HdPerfLog::GetInstance(); perfLog.Enable(); @@ -217,8 +217,9 @@ SubdivisionTest(TfToken const &scheme) }; int holes[] = {}; - if (!DUMP_REFINED_POINTS("triangle", scheme, _tokens->rightHanded, - numVerts, verts, points, holes, PxOsdSubdivTags())) { + if (!DUMP_REFINED_POINTS( + registry, "triangle", scheme, _tokens->rightHanded, + numVerts, verts, points, holes, PxOsdSubdivTags())) { return false; } @@ -229,8 +230,9 @@ SubdivisionTest(TfToken const &scheme) TF_VERIFY(perfLog.GetCounter(HdPerfTokens->computationsCommited) == 0); perfLog.ResetCounters(); - if (!DUMP_GPU_REFINED_POINTS("triangle", scheme, _tokens->rightHanded, - numVerts, verts, points, holes, PxOsdSubdivTags())) { + if (!DUMP_GPU_REFINED_POINTS( + registry, "triangle", scheme, _tokens->rightHanded, + numVerts, verts, points, holes, PxOsdSubdivTags())) { return false; } @@ -263,8 +265,9 @@ SubdivisionTest(TfToken const &scheme) }; int holes[] = {}; - if (!DUMP_REFINED_POINTS("triangle", scheme, _tokens->leftHanded, - numVerts, verts, points, holes, PxOsdSubdivTags())) { + if (!DUMP_REFINED_POINTS( + registry, "triangle", scheme, _tokens->leftHanded, + numVerts, verts, points, holes, PxOsdSubdivTags())) { return false; } @@ -275,8 +278,9 @@ SubdivisionTest(TfToken const &scheme) TF_VERIFY(perfLog.GetCounter(HdPerfTokens->computationsCommited) == 0); perfLog.ResetCounters(); - if (!DUMP_GPU_REFINED_POINTS("triangle", scheme, _tokens->leftHanded, - numVerts, verts, points, holes, PxOsdSubdivTags())) { + if (!DUMP_GPU_REFINED_POINTS( + registry, "triangle", scheme, _tokens->leftHanded, + numVerts, verts, points, holes, PxOsdSubdivTags())) { return false; } @@ -310,8 +314,9 @@ SubdivisionTest(TfToken const &scheme) }; int holes[] = {}; - if (!DUMP_REFINED_POINTS("quad", scheme, _tokens->rightHanded, - numVerts, verts, points, holes, PxOsdSubdivTags())) { + if (!DUMP_REFINED_POINTS( + registry, "quad", scheme, _tokens->rightHanded, + numVerts, verts, points, holes, PxOsdSubdivTags())) { return false; } TF_VERIFY(perfLog.GetCounter(HdPerfTokens->subdivisionRefineCPU) == 1); @@ -320,8 +325,9 @@ SubdivisionTest(TfToken const &scheme) TF_VERIFY(perfLog.GetCounter(HdPerfTokens->computationsCommited) == 0); perfLog.ResetCounters(); - if (!DUMP_GPU_REFINED_POINTS("quad", scheme, _tokens->rightHanded, - numVerts, verts, points, holes, PxOsdSubdivTags())) { + if (!DUMP_GPU_REFINED_POINTS( + registry, "quad", scheme, _tokens->rightHanded, + numVerts, verts, points, holes, PxOsdSubdivTags())) { return false; } TF_VERIFY(perfLog.GetCounter(HdPerfTokens->subdivisionRefineCPU) == 0); @@ -360,8 +366,9 @@ SubdivisionTest(TfToken const &scheme) }; int holes[] = {}; - if (!DUMP_REFINED_POINTS("polygons", scheme, _tokens->rightHanded, - numVerts, verts, points, holes, PxOsdSubdivTags())) { + if (!DUMP_REFINED_POINTS( + registry, "polygons", scheme, _tokens->rightHanded, + numVerts, verts, points, holes, PxOsdSubdivTags())) { return false; } TF_VERIFY(perfLog.GetCounter(HdPerfTokens->subdivisionRefineCPU) == 1); @@ -370,8 +377,9 @@ SubdivisionTest(TfToken const &scheme) TF_VERIFY(perfLog.GetCounter(HdPerfTokens->computationsCommited) == 0); perfLog.ResetCounters(); - if (!DUMP_GPU_REFINED_POINTS("polygons", scheme, _tokens->rightHanded, - numVerts, verts, points, holes, PxOsdSubdivTags())) { + if (!DUMP_GPU_REFINED_POINTS( + registry, "polygons", scheme, _tokens->rightHanded, + numVerts, verts, points, holes, PxOsdSubdivTags())) { return false; } TF_VERIFY(perfLog.GetCounter(HdPerfTokens->subdivisionRefineCPU) == 0); @@ -385,7 +393,7 @@ SubdivisionTest(TfToken const &scheme) } bool -LoopSubdivisionTest() +LoopSubdivisionTest(HdStResourceRegistrySharedPtr const ®istry) { std::cout << "\nLoop Subdivision Test\n"; @@ -418,9 +426,10 @@ LoopSubdivisionTest() }; int holes[] = {}; - if (!DUMP_REFINED_POINTS("triangle", PxOsdOpenSubdivTokens->loop, - _tokens->rightHanded, - numVerts, verts, points, holes, PxOsdSubdivTags())) { + if (!DUMP_REFINED_POINTS( + registry, "triangle", PxOsdOpenSubdivTokens->loop, + _tokens->rightHanded, numVerts, verts, points, holes, + PxOsdSubdivTags())) { return false; } @@ -431,9 +440,10 @@ LoopSubdivisionTest() TF_VERIFY(perfLog.GetCounter(HdPerfTokens->computationsCommited) == 0); perfLog.ResetCounters(); - if (!DUMP_GPU_REFINED_POINTS("triangle", PxOsdOpenSubdivTokens->loop, - _tokens->rightHanded, - numVerts, verts, points, holes, PxOsdSubdivTags())) { + if (!DUMP_GPU_REFINED_POINTS( + registry, "triangle", PxOsdOpenSubdivTokens->loop, + _tokens->rightHanded, numVerts, verts, points, holes, + PxOsdSubdivTags())) { return false; } @@ -449,7 +459,8 @@ LoopSubdivisionTest() } bool -PrimitiveIDMappingTest(bool usePtexIndex) +PrimitiveIDMappingTest(HdStResourceRegistrySharedPtr const ®istry, + bool usePtexIndex) { std::cout << "\nPrimitiveIDMap Test\n"; @@ -545,7 +556,7 @@ PrimitiveIDMappingTest(bool usePtexIndex) } bool -SubdivTagTest() +SubdivTagTest(HdStResourceRegistrySharedPtr const ®istry) { std::cout << "\nSubdiv Tag Test\n"; /* @@ -611,21 +622,21 @@ SubdivTagTest() subdivTags.SetFaceVaryingInterpolationRule(PxOsdOpenSubdivTokens->edgeOnly); - if (!DUMP_REFINED_POINTS("subdivTag", - PxOsdOpenSubdivTokens->catmullClark, _tokens->rightHanded, - numVerts, verts, points, holes, subdivTags)) { + if (!DUMP_REFINED_POINTS( + registry, "subdivTag", PxOsdOpenSubdivTokens->catmullClark, + _tokens->rightHanded, numVerts, verts, points, holes, subdivTags)) { return false; } - if (!DUMP_GPU_REFINED_POINTS("subdivTag", - PxOsdOpenSubdivTokens->catmullClark,_tokens->rightHanded, - numVerts, verts, points, holes, subdivTags)) { + if (!DUMP_GPU_REFINED_POINTS( + registry, "subdivTag", PxOsdOpenSubdivTokens->catmullClark, + _tokens->rightHanded, numVerts, verts, points, holes, subdivTags)) { return false; } return true; } bool -SubdivTagTest2() +SubdivTagTest2(HdStResourceRegistrySharedPtr const ®istry) { std::cout << "\nSubdiv Tag Test 2\n"; @@ -684,13 +695,13 @@ SubdivTagTest2() subdivTags.SetVertexInterpolationRule(PxOsdOpenSubdivTokens->edgeOnly); subdivTags.SetFaceVaryingInterpolationRule(PxOsdOpenSubdivTokens->edgeOnly); - if (!DUMP_REFINED_POINTS("subdivTag", + if (!DUMP_REFINED_POINTS(registry, "subdivTag", PxOsdOpenSubdivTokens->catmullClark, _tokens->rightHanded, numVerts, verts, points, holes, subdivTags)){ return false; } - if (!DUMP_GPU_REFINED_POINTS("subdivTag", + if (!DUMP_GPU_REFINED_POINTS(registry, "subdivTag", PxOsdOpenSubdivTokens->catmullClark, _tokens->rightHanded, numVerts, verts, points, holes, subdivTags)) { @@ -701,7 +712,7 @@ SubdivTagTest2() } bool -InvalidTopologyTest() +InvalidTopologyTest(HdStResourceRegistrySharedPtr const ®istry) { std::cout << "\nInvalid Topology Test\n"; @@ -744,13 +755,13 @@ InvalidTopologyTest() subdivTags.SetVertexInterpolationRule(PxOsdOpenSubdivTokens->edgeOnly); subdivTags.SetFaceVaryingInterpolationRule(PxOsdOpenSubdivTokens->edgeOnly); - if (!DUMP_REFINED_POINTS("subdivTag", + if (!DUMP_REFINED_POINTS(registry, "subdivTag", PxOsdOpenSubdivTokens->catmullClark, _tokens->rightHanded, numVerts, verts, points, holes, subdivTags)){ return false; } - if (!DUMP_GPU_REFINED_POINTS("subdivTag", + if (!DUMP_GPU_REFINED_POINTS(registry, "subdivTag", PxOsdOpenSubdivTokens->catmullClark, _tokens->rightHanded, numVerts, verts, points, holes, subdivTags)) { @@ -761,7 +772,7 @@ InvalidTopologyTest() } bool -EmptyTopologyTest() +EmptyTopologyTest(HdStResourceRegistrySharedPtr const ®istry) { std::cout << "\nEmpty Topology Test\n"; @@ -770,13 +781,13 @@ EmptyTopologyTest() GfVec3f points[] = {}; int holes[] = {}; - if (!DUMP_REFINED_POINTS("subdivTag", + if (!DUMP_REFINED_POINTS(registry, "subdivTag", PxOsdOpenSubdivTokens->catmullClark, _tokens->rightHanded, numVerts, verts, points, holes, PxOsdSubdivTags())){ return false; } - if (!DUMP_GPU_REFINED_POINTS("subdivTag", + if (!DUMP_GPU_REFINED_POINTS(registry, "subdivTag", PxOsdOpenSubdivTokens->catmullClark, _tokens->rightHanded, numVerts, verts, points, holes, PxOsdSubdivTags())) { @@ -787,7 +798,7 @@ EmptyTopologyTest() } bool -TorusTopologyTest() +TorusTopologyTest(HdStResourceRegistrySharedPtr const ®istry) { std::cout << "\nTorus Topology Test\n"; @@ -821,13 +832,13 @@ TorusTopologyTest() int holes[] = {}; PxOsdSubdivTags subdivTags; - if (!DUMP_REFINED_POINTS("subdivTag", + if (!DUMP_REFINED_POINTS(registry, "subdivTag", PxOsdOpenSubdivTokens->catmullClark, _tokens->rightHanded, numVerts, verts, points, holes, PxOsdSubdivTags())){ return false; } - if (!DUMP_GPU_REFINED_POINTS("subdivTag", + if (!DUMP_GPU_REFINED_POINTS(registry, "subdivTag", PxOsdOpenSubdivTokens->catmullClark, _tokens->rightHanded, numVerts, verts, points, holes, PxOsdSubdivTags())) { @@ -844,31 +855,30 @@ int main() TfErrorMark mark; - HgiUniquePtr hgi = Hgi::CreatePlatformDefaultHgi(); + HgiUniquePtr const hgi = Hgi::CreatePlatformDefaultHgi(); HdDriver driver{HgiTokens->renderDriver, VtValue(hgi.get())}; HdStRenderDelegate renderDelegate; - std::unique_ptr index( + std::unique_ptr const index( HdRenderIndex::New(&renderDelegate, {&driver})); - registry = std::static_pointer_cast( + HdStResourceRegistrySharedPtr const registry = + std::static_pointer_cast( index->GetResourceRegistry()); bool success = true; - success &= SubdivisionTest(PxOsdOpenSubdivTokens->catmullClark); + success &= SubdivisionTest(registry, PxOsdOpenSubdivTokens->catmullClark); // skip bilinear test until OpenSubdiv3 is updated to the latest. //success &= SubdivisionTest(PxOsdOpenSubdivTokens->bilinear); - success &= LoopSubdivisionTest(); - success &= PrimitiveIDMappingTest(/*usePtexIndex=*/true); - success &= PrimitiveIDMappingTest(/*usePtexIndex=*/false); - success &= SubdivTagTest(); - success &= SubdivTagTest2(); - success &= InvalidTopologyTest(); - success &= EmptyTopologyTest(); - success &= TorusTopologyTest(); + success &= LoopSubdivisionTest(registry); + success &= PrimitiveIDMappingTest(registry, /*usePtexIndex=*/true); + success &= PrimitiveIDMappingTest(registry, /*usePtexIndex=*/false); + success &= SubdivTagTest(registry); + success &= SubdivTagTest2(registry); + success &= InvalidTopologyTest(registry); + success &= EmptyTopologyTest(registry); + success &= TorusTopologyTest(registry); TF_VERIFY(mark.IsClean()); - registry.reset(); - if (success && mark.IsClean()) { std::cout << "OK" << std::endl; return EXIT_SUCCESS; From 9dc186b0431923094a16e933b424d93cd44ed9f0 Mon Sep 17 00:00:00 2001 From: unhyperbolic Date: Mon, 4 Nov 2024 11:33:52 -0800 Subject: [PATCH 094/300] HdMapContainerDataSource: fixing bug where container data source would produce data sources even though the input container data source has no data source for that key. (Internal change: 2346648) --- pxr/imaging/hd/mapContainerDataSource.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pxr/imaging/hd/mapContainerDataSource.cpp b/pxr/imaging/hd/mapContainerDataSource.cpp index 53f0d48903..4d333cd951 100644 --- a/pxr/imaging/hd/mapContainerDataSource.cpp +++ b/pxr/imaging/hd/mapContainerDataSource.cpp @@ -34,10 +34,14 @@ HdMapContainerDataSource::Get(const TfToken &name) return nullptr; } + HdDataSourceBaseHandle const ds = _src->Get(name); + if (!ds) { + return nullptr; + } if (!_f) { - return _src->Get(name); + return ds; } - return _f(_src->Get(name)); + return _f(ds); } PXR_NAMESPACE_CLOSE_SCOPE From 0ed6bd9935223714a9a3e4a2ccba5839fa45fbea Mon Sep 17 00:00:00 2001 From: anwang2009 Date: Mon, 4 Nov 2024 11:33:58 -0800 Subject: [PATCH 095/300] Un-deprecate SdfLayer time sample methods. Moving time sample methods to SdfAttributeSpec only would incur the additional performance overhead of GetAttributeAtPath anywhere an SdfAttributeSpec handle doesn't already exist (many of the cases exist). (Internal change: 2346655) --- pxr/usd/sdf/layer.h | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/pxr/usd/sdf/layer.h b/pxr/usd/sdf/layer.h index dc1901a67c..8a8b4d261a 100644 --- a/pxr/usd/sdf/layer.h +++ b/pxr/usd/sdf/layer.h @@ -1539,8 +1539,6 @@ class SdfLayer SDF_API std::set ListAllTimeSamples() const; - /// \deprecated - /// Use SdfAttributeSpec::ListTimeSamples instead. SDF_API std::set ListTimeSamplesForPath(const SdfPath& path) const; @@ -1548,32 +1546,22 @@ class SdfLayer SDF_API bool GetBracketingTimeSamples(double time, double* tLower, double* tUpper); - /// \deprecated - /// Use SdfAttributeSpec::GetNumTimeSamples instead. SDF_API size_t GetNumTimeSamplesForPath(const SdfPath& path) const; - /// \deprecated - /// Use SdfAttributeSpec::GetBracketingTimeSamples instead. SDF_API bool GetBracketingTimeSamplesForPath(const SdfPath& path, double time, double* tLower, double* tUpper); - /// \deprecated - /// Use SdfAttributeSpec::QueryTimeSample instead. SDF_API bool QueryTimeSample(const SdfPath& path, double time, VtValue *value=NULL) const; - /// \deprecated - /// Use SdfAttributeSpec::QueryTimeSample instead. SDF_API bool QueryTimeSample(const SdfPath& path, double time, SdfAbstractDataValue *value) const; - /// \deprecated - /// Use SdfAttributeSpec::QueryTimeSample instead. template bool QueryTimeSample(const SdfPath& path, double time, T* data) const @@ -1593,20 +1581,14 @@ class SdfLayer return hasValue && (!outValue.isValueBlock); } - /// \deprecated - /// Use SdfAttributeSpec::SetTimeSample instead. SDF_API void SetTimeSample(const SdfPath& path, double time, const VtValue & value); - /// \deprecated - /// Use SdfAttributeSpec::SetTimeSample instead. SDF_API void SetTimeSample(const SdfPath& path, double time, const SdfAbstractDataConstValue& value); - /// \deprecated - /// Use SdfAttributeSpec::SetTimeSample instead. template void SetTimeSample(const SdfPath& path, double time, const T& value) @@ -1616,8 +1598,6 @@ class SdfLayer return SetTimeSample(path, time, untypedInValue); } - /// \deprecated - /// Use SdfAttributeSpec::EraseTimeSample instead. SDF_API void EraseTimeSample(const SdfPath& path, double time); From 8e14877b0f83f1a850d5eb39bd8a263c471d434d Mon Sep 17 00:00:00 2001 From: anwang2009 Date: Mon, 4 Nov 2024 11:34:10 -0800 Subject: [PATCH 096/300] Remove SdfPropertySpec::GetTimeSampleMap in favor of SdfAttributeSpec::GetTimeSampleMap (Internal change: 2346656) --- pxr/usd/sdf/propertySpec.cpp | 6 ------ pxr/usd/sdf/propertySpec.h | 7 ------- 2 files changed, 13 deletions(-) diff --git a/pxr/usd/sdf/propertySpec.cpp b/pxr/usd/sdf/propertySpec.cpp index 4276c6403a..2d6cb7bfd9 100644 --- a/pxr/usd/sdf/propertySpec.cpp +++ b/pxr/usd/sdf/propertySpec.cpp @@ -233,12 +233,6 @@ SdfPropertySpec::SetDefaultValue(const VtValue &defaultValue) return false; } -SdfTimeSampleMap -SdfPropertySpec::GetTimeSampleMap() const -{ - return GetFieldAs(SdfFieldKeys->TimeSamples); -} - TfType SdfPropertySpec::GetValueType() const { diff --git a/pxr/usd/sdf/propertySpec.h b/pxr/usd/sdf/propertySpec.h index 8fa6f18d59..d26e4c96d0 100644 --- a/pxr/usd/sdf/propertySpec.h +++ b/pxr/usd/sdf/propertySpec.h @@ -249,13 +249,6 @@ class SdfPropertySpec : public SdfSpec /// \name Property value API /// @{ - /// Returns the entire set of time samples. - /// - /// \deprecated - /// Use SdfAttributeSpec::GetTimeSampleMap instead. - SDF_API - SdfTimeSampleMap GetTimeSampleMap() const; - /// Returns the TfType representing the value type this property holds. SDF_API TfType GetValueType() const; From 87fd449a21c13c34949fa8ace0635dc6d7a637f3 Mon Sep 17 00:00:00 2001 From: sunyab Date: Mon, 4 Nov 2024 11:34:15 -0800 Subject: [PATCH 097/300] hgiVulkan: Remove executable bit from source files (Internal change: 2346685) --- pxr/imaging/hgiVulkan/garbageCollector.cpp | 0 pxr/imaging/hgiVulkan/graphicsPipeline.cpp | 0 pxr/imaging/hgiVulkan/hgi.cpp | 0 pxr/imaging/hgiVulkan/instance.cpp | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 pxr/imaging/hgiVulkan/garbageCollector.cpp mode change 100755 => 100644 pxr/imaging/hgiVulkan/graphicsPipeline.cpp mode change 100755 => 100644 pxr/imaging/hgiVulkan/hgi.cpp mode change 100755 => 100644 pxr/imaging/hgiVulkan/instance.cpp diff --git a/pxr/imaging/hgiVulkan/garbageCollector.cpp b/pxr/imaging/hgiVulkan/garbageCollector.cpp old mode 100755 new mode 100644 diff --git a/pxr/imaging/hgiVulkan/graphicsPipeline.cpp b/pxr/imaging/hgiVulkan/graphicsPipeline.cpp old mode 100755 new mode 100644 diff --git a/pxr/imaging/hgiVulkan/hgi.cpp b/pxr/imaging/hgiVulkan/hgi.cpp old mode 100755 new mode 100644 diff --git a/pxr/imaging/hgiVulkan/instance.cpp b/pxr/imaging/hgiVulkan/instance.cpp old mode 100755 new mode 100644 From 695509929ffb1aa883f37ba4a015c3dafbb94e42 Mon Sep 17 00:00:00 2001 From: Aleksi Sapon Date: Thu, 7 Nov 2024 11:00:26 -0500 Subject: [PATCH 098/300] Fix hdSt and usdImagingGL build errors on Windows --- pxr/imaging/hdSt/basisCurvesShaderKey.h | 2 + pxr/imaging/hdSt/basisCurvesTopology.h | 3 + pxr/imaging/hdSt/geometricShader.h | 1 + pxr/imaging/hdSt/materialXFilter.h | 2 + pxr/imaging/hdSt/meshShaderKey.h | 2 + pxr/imaging/hdSt/meshTopology.h | 27 ++++ .../hdSt/testenv/testHdStMeshTopology.cpp | 118 ++++++++++-------- .../hdSt/testenv/testHdStSubdivision.cpp | 95 +++++++------- pxr/imaging/hdSt/textureObject.h | 8 ++ pxr/imaging/hdSt/textureObjectRegistry.h | 2 + pxr/imaging/hdSt/unitTestHelper.h | 7 +- pxr/imaging/hdSt/vboSimpleMemoryManager.h | 2 + pxr/imaging/hgiVulkan/commandQueue.h | 3 +- pxr/imaging/hgiVulkan/garbageCollector.h | 8 ++ 14 files changed, 174 insertions(+), 106 deletions(-) diff --git a/pxr/imaging/hdSt/basisCurvesShaderKey.h b/pxr/imaging/hdSt/basisCurvesShaderKey.h index d99f1e6227..6a23d009dd 100644 --- a/pxr/imaging/hdSt/basisCurvesShaderKey.h +++ b/pxr/imaging/hdSt/basisCurvesShaderKey.h @@ -51,6 +51,7 @@ struct HdSt_BasisCurvesShaderKey : public HdSt_ShaderKey ROUND // Generated camera oriented normal as a tube }; + HDST_API HdSt_BasisCurvesShaderKey(TfToken const &type, TfToken const &basis, DrawStyle drawStyle, NormalStyle normalStyle, bool basisWidthInterpolation, @@ -60,6 +61,7 @@ struct HdSt_BasisCurvesShaderKey : public HdSt_ShaderKey bool pointsShadingEnabled, bool hasMetalTessellation); + HDST_API ~HdSt_BasisCurvesShaderKey(); TfToken const &GetGlslfxFilename() const override { return glslfx; } diff --git a/pxr/imaging/hdSt/basisCurvesTopology.h b/pxr/imaging/hdSt/basisCurvesTopology.h index 89260b92b1..2dd2daa59b 100644 --- a/pxr/imaging/hdSt/basisCurvesTopology.h +++ b/pxr/imaging/hdSt/basisCurvesTopology.h @@ -8,6 +8,7 @@ #define PXR_IMAGING_HD_ST_BASIS_CURVES_TOPOLOGY_H #include "pxr/pxr.h" +#include "pxr/imaging/hdSt/api.h" #include "pxr/imaging/hd/basisCurvesTopology.h" #include @@ -26,8 +27,10 @@ using HdBufferSourceSharedPtr = std::shared_ptr; // class HdSt_BasisCurvesTopology final : public HdBasisCurvesTopology { public: + HDST_API static HdSt_BasisCurvesTopologySharedPtr New(const HdBasisCurvesTopology &src); + HDST_API virtual ~HdSt_BasisCurvesTopology(); HdBufferSourceSharedPtr GetPointsIndexBuilderComputation(); diff --git a/pxr/imaging/hdSt/geometricShader.h b/pxr/imaging/hdSt/geometricShader.h index 4a69824b7b..e5157b495d 100644 --- a/pxr/imaging/hdSt/geometricShader.h +++ b/pxr/imaging/hdSt/geometricShader.h @@ -246,6 +246,7 @@ class HdSt_GeometricShader : public HdStShaderCode { HgiCullMode ResolveCullMode(HdCullStyle const renderStateCullStyle) const; // Factory for convenience. + HDST_API static HdSt_GeometricShaderSharedPtr Create( HdSt_ShaderKey const &shaderKey, HdStResourceRegistrySharedPtr const &resourceRegistry); diff --git a/pxr/imaging/hdSt/materialXFilter.h b/pxr/imaging/hdSt/materialXFilter.h index df2e349eb8..77af70b548 100644 --- a/pxr/imaging/hdSt/materialXFilter.h +++ b/pxr/imaging/hdSt/materialXFilter.h @@ -37,6 +37,7 @@ struct HdSt_MxShaderGenInfo { /// MaterialX Filter /// Converting a MaterialX node to one with a generated MaterialX glslfx file +HDST_API MaterialX::ShaderPtr HdSt_ApplyMaterialXFilter( HdMaterialNetwork2* hdNetwork, SdfPath const& materialPath, @@ -46,6 +47,7 @@ MaterialX::ShaderPtr HdSt_ApplyMaterialXFilter( HdStResourceRegistry *resourceRegistry); // Generates the glsfx shader for the given MaterialX Document +HDST_API MaterialX::ShaderPtr HdSt_GenMaterialXShader( MaterialX::DocumentPtr const& mxDoc, MaterialX::DocumentPtr const& stdLibraries, diff --git a/pxr/imaging/hdSt/meshShaderKey.h b/pxr/imaging/hdSt/meshShaderKey.h index b82af19b13..b73a77887d 100644 --- a/pxr/imaging/hdSt/meshShaderKey.h +++ b/pxr/imaging/hdSt/meshShaderKey.h @@ -29,6 +29,7 @@ struct HdSt_MeshShaderKey : public HdSt_ShaderKey NormalSourceFlatScreenSpace, }; + HDST_API HdSt_MeshShaderKey(HdSt_GeometricShader::PrimitiveType primType, TfToken shadingTerminal, NormalSource normalsSource, @@ -56,6 +57,7 @@ struct HdSt_MeshShaderKey : public HdSt_ShaderKey // when the default destructor is automatically generated at callers. // Having an empty destructor explicitly within this linkage apparently // avoids the issue. + HDST_API ~HdSt_MeshShaderKey(); HdCullStyle GetCullStyle() const override { return cullStyle; } diff --git a/pxr/imaging/hdSt/meshTopology.h b/pxr/imaging/hdSt/meshTopology.h index 87fc5c9a0d..759bd2d437 100644 --- a/pxr/imaging/hdSt/meshTopology.h +++ b/pxr/imaging/hdSt/meshTopology.h @@ -8,6 +8,7 @@ #define PXR_IMAGING_HD_ST_MESH_TOPOLOGY_H #include "pxr/pxr.h" +#include "pxr/imaging/hdSt/api.h" #include "pxr/imaging/hd/version.h" #include "pxr/imaging/hd/meshTopology.h" #include "pxr/imaging/hd/types.h" @@ -70,25 +71,30 @@ class HdSt_MeshTopology final : public HdMeshTopology { INTERPOLATE_FACEVARYING, }; + HDST_API static HdSt_MeshTopologySharedPtr New( const HdMeshTopology &src, int refineLevel, RefineMode refineMode = RefineModeUniform, QuadsMode quadsMode = QuadsUntriangulated); + HDST_API virtual ~HdSt_MeshTopology(); /// Equality check between two mesh topologies. + HDST_API bool operator==(HdSt_MeshTopology const &other) const; /// \name Triangulation /// @{ /// Returns the triangle indices (for drawing) buffer source computation. + HDST_API HdBufferSourceSharedPtr GetTriangleIndexBuilderComputation( SdfPath const &id); /// Returns the CPU face-varying triangulate computation + HDST_API HdBufferSourceSharedPtr GetTriangulateFaceVaryingComputation( HdBufferSourceSharedPtr const &source, SdfPath const &id); @@ -113,22 +119,27 @@ class HdSt_MeshTopology final : public HdMeshTopology { /// quadrangulation. /// If gpu is true, the quadrangulate table will be transferred to GPU /// via the resource registry. + HDST_API HdSt_QuadInfoBuilderComputationSharedPtr GetQuadInfoBuilderComputation( bool gpu, SdfPath const &id, HdStResourceRegistry *resourceRegistry = nullptr); /// Returns the quad indices (for drawing) buffer source computation. + HDST_API HdBufferSourceSharedPtr GetQuadIndexBuilderComputation(SdfPath const &id); /// Returns the CPU quadrangulated buffer source. + HDST_API HdBufferSourceSharedPtr GetQuadrangulateComputation( HdBufferSourceSharedPtr const &source, SdfPath const &id); /// Returns the GPU quadrangulate computation. + HDST_API HdStComputationSharedPtr GetQuadrangulateComputationGPU( TfToken const &name, HdType dataType, SdfPath const &id); /// Returns the CPU face-varying quadrangulate computation + HDST_API HdBufferSourceSharedPtr GetQuadrangulateFaceVaryingComputation( HdBufferSourceSharedPtr const &source, SdfPath const &id); @@ -144,6 +155,7 @@ class HdSt_MeshTopology final : public HdMeshTopology { /// Sets the quadrangulation struct. HdMeshTopology takes an /// ownership of quadInfo (caller shouldn't free) + HDST_API void SetQuadInfo(HdQuadInfo const *quadInfo); /// Returns the quadrangulation struct. @@ -158,6 +170,7 @@ class HdSt_MeshTopology final : public HdMeshTopology { /// @{ /// Returns the point indices buffer source computation. + HDST_API HdBufferSourceSharedPtr GetPointsIndexBuilderComputation(); /// @} @@ -179,36 +192,44 @@ class HdSt_MeshTopology final : public HdMeshTopology { /// Returns true if the subdivision on this mesh produces /// triangles (otherwise quads) + HDST_API bool RefinesToTriangles() const; /// Returns true if the subdivision of this mesh produces bspline patches + HDST_API bool RefinesToBSplinePatches() const; /// Returns true if the subdivision of this mesh produces box spline /// triangle patches + HDST_API bool RefinesToBoxSplineTrianglePatches() const; /// Returns the subdivision topology computation. It computes /// far mesh and produces refined quad-indices buffer. + HDST_API HdBufferSourceSharedPtr GetOsdTopologyComputation(SdfPath const &debugId); /// Returns the refined indices builder computation. /// This just returns index and primitive buffer, and should be preceded by /// topology computation. + HDST_API HdBufferSourceSharedPtr GetOsdIndexBuilderComputation(); /// Returns the refined face-varying indices builder computation. /// This just returns the index and patch param buffer for a face-varying /// channel, and should be preceded by topology computation. + HDST_API HdBufferSourceSharedPtr GetOsdFvarIndexBuilderComputation(int channel); /// Returns the subdivision primvar refine computation on CPU. + HDST_API HdBufferSourceSharedPtr GetOsdRefineComputation( HdBufferSourceSharedPtr const &source, Interpolation interpolation, int fvarChannel = 0); /// Returns the subdivision primvar refine computation on GPU. + HDST_API HdStComputationSharedPtr GetOsdRefineComputationGPU( TfToken const &name, HdType dataType, @@ -217,6 +238,7 @@ class HdSt_MeshTopology final : public HdMeshTopology { int fvarChannel = 0); /// Returns the mapping from base face to refined face indices. + HDST_API HdBufferSourceSharedPtr GetOsdBaseFaceToRefinedFacesMapComputation( HdStResourceRegistry *resourceRegistry); @@ -228,25 +250,30 @@ class HdSt_MeshTopology final : public HdMeshTopology { /// Processes geom subsets to remove those with empty indices or empty /// material id. Will initialize _nonSubsetFaces if there are geom subsets. + HDST_API void SanitizeGeomSubsets(); /// Returns the indices subset computation for unrefined indices. + HDST_API HdBufferSourceSharedPtr GetIndexSubsetComputation( HdBufferSourceSharedPtr indexBuilderSource, HdBufferSourceSharedPtr faceIndicesSource); /// Returns the indices subset computation for refined indices. + HDST_API HdBufferSourceSharedPtr GetRefinedIndexSubsetComputation( HdBufferSourceSharedPtr indexBuilderSource, HdBufferSourceSharedPtr faceIndicesSource); /// Returns the triangulated/quadrangulated face indices computation. + HDST_API HdBufferSourceSharedPtr GetGeomSubsetFaceIndexBuilderComputation( HdBufferSourceSharedPtr geomSubsetFaceIndexHelperSource, VtIntArray const &faceIndices); /// Returns computation creating buffer sources used in mapping authored /// face indices to triangulated/quadrangulated face indices. + HDST_API HdBufferSourceSharedPtr GetGeomSubsetFaceIndexHelperComputation( bool refined, bool quadrangulated); diff --git a/pxr/imaging/hdSt/testenv/testHdStMeshTopology.cpp b/pxr/imaging/hdSt/testenv/testHdStMeshTopology.cpp index a24387c41f..3b8727ebee 100644 --- a/pxr/imaging/hdSt/testenv/testHdStMeshTopology.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStMeshTopology.cpp @@ -49,12 +49,21 @@ TF_DEFINE_PRIVATE_TOKENS( ((rightHanded, "rightHanded")) ); -template +template static VtArray -_BuildArray(T values[], int numValues) +_BuildArray(T (&values)[N]) { - VtArray result(numValues); - std::copy(values, values+numValues, result.begin()); + VtArray result(N); + std::copy(values, values+N, result.begin()); + return result; +} + +template +static VtArray +_BuildArray(const std::array& values) +{ + VtArray result(N); + std::copy(values.begin(), values.end(), result.begin()); return result; } @@ -141,17 +150,17 @@ _CompareFaceVarying(std::string const &name, #define COMPARE_INDICES(name, orientation, numVerts, verts, expected) \ _CompareIndices(name, orientation, \ - _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), \ - _BuildArray(verts, sizeof(verts)/sizeof(int)), \ + _BuildArray(numVerts), \ + _BuildArray(verts), \ /*holes=*/VtIntArray(), \ - _BuildArray(expected, sizeof(expected)/sizeof(expected[0]))) + _BuildArray(expected)) #define COMPARE_INDICES_HOLE(name, orientation, numVerts, verts, holes, expected) \ _CompareIndices(name, orientation, \ - _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), \ - _BuildArray(verts, sizeof(verts)/sizeof(int)), \ - _BuildArray(holes, sizeof(holes)/sizeof(int)), \ - _BuildArray(expected, sizeof(expected)/sizeof(expected[0]))) + _BuildArray(numVerts), \ + _BuildArray(verts), \ + _BuildArray(holes), \ + _BuildArray(expected)) template static bool @@ -215,10 +224,10 @@ _CompareSmoothNormals(std::string const & name, #define COMPARE_SMOOTH_NORMALS(name, orientation, numVerts, verts, points, expected) \ _CompareSmoothNormals(name, orientation, \ - _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ - _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ - _BuildArray(points, sizeof(points)/sizeof(points[0])), \ - _BuildArray(expected, sizeof(expected)/sizeof(expected[0]))) + _BuildArray(numVerts), \ + _BuildArray(verts), \ + _BuildArray(points), \ + _BuildArray(expected)) template bool @@ -252,10 +261,10 @@ _CompareFlatNormals(std::string const & name, #define COMPARE_FLAT_NORMALS(name, orientation, numVerts, verts, points, expected) \ _CompareFlatNormals(name, orientation, \ - _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ - _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ - _BuildArray(points, sizeof(points)/sizeof(points[0])), \ - _BuildArray(expected, sizeof(expected)/sizeof(expected[0]))) + _BuildArray(numVerts), \ + _BuildArray(verts), \ + _BuildArray(points), \ + _BuildArray(expected)) template bool @@ -339,10 +348,10 @@ _CompareGpuSmoothNormals(std::string const & name, #define COMPARE_GPU_SMOOTH_NORMALS(name, orientation, numVerts, verts, points, expected) \ _CompareGpuSmoothNormals(name, orientation, \ - _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ - _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ - _BuildArray(points, sizeof(points)/sizeof(points[0])), \ - _BuildArray(expected, sizeof(expected)/sizeof(expected[0]))) + _BuildArray(numVerts), \ + _BuildArray(verts), \ + _BuildArray(points), \ + _BuildArray(expected)) template bool @@ -443,25 +452,25 @@ _CompareGpuFlatNormals(std::string const & name, #define COMPARE_GPU_FLAT_NORMALS_TRI(name, orientation, numVerts, verts, points, expected) \ _CompareGpuFlatNormals(name, orientation, \ - _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ - _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ - _BuildArray(points, sizeof(points)/sizeof(points[0])), \ - _BuildArray(expected, sizeof(expected)/sizeof(expected[0])), false) + _BuildArray(numVerts), \ + _BuildArray(verts), \ + _BuildArray(points), \ + _BuildArray(expected), false) #define COMPARE_GPU_FLAT_NORMALS_QUAD(name, orientation, numVerts, verts, points, expected) \ _CompareGpuFlatNormals(name, orientation, \ - _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ - _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ - _BuildArray(points, sizeof(points)/sizeof(points[0])), \ - _BuildArray(expected, sizeof(expected)/sizeof(expected[0])), true) + _BuildArray(numVerts), \ + _BuildArray(verts), \ + _BuildArray(points), \ + _BuildArray(expected), true) bool BasicTest() { { - int numVerts[] = {}; - int verts[] = {}; - GfVec3i expected[] = { }; + std::array numVerts = {}; + std::array verts = {}; + std::array expected = { }; if (!COMPARE_INDICES("empty", _tokens->rightHanded, numVerts, verts, expected)) { return false; @@ -577,10 +586,10 @@ bool ComputeNormalsTest() { { - int numVerts[] = {}; - int verts[] = {}; - GfVec3f points[] = {}; - GfVec3f expectedNormals[] = {}; + std::array numVerts = {}; + std::array verts = {}; + std::array points = {}; + std::array expectedNormals = {}; if (!COMPARE_SMOOTH_NORMALS("empty", _tokens->rightHanded, numVerts, verts, points, expectedNormals)) { return false; @@ -588,13 +597,13 @@ ComputeNormalsTest() } { int numVerts[] = {3}; - int verts[] = {}; + std::array verts = {}; GfVec3f points[] = { GfVec3f(-1.0, 0.0, 0.0 ), GfVec3f( 0.0, 0.0, 2.0 ), GfVec3f( 1.0, 0.0, 0.0 ), }; - GfVec3f expectedNormals[] = {}; + std::array expectedNormals = {}; if (!COMPARE_SMOOTH_NORMALS( "missing_faceVertexIndices",_tokens->rightHanded, numVerts, verts, points, expectedNormals)) { @@ -910,11 +919,11 @@ FaceVaryingTest() 17, 18, 19, 17, 19, 20 }; if (!_CompareFaceVarying("FaceVarying", _tokens->rightHanded, - _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), - _BuildArray(verts, sizeof(verts)/sizeof(int)), - _BuildArray(hole, sizeof(hole)/sizeof(int)), - _BuildArray(fvarValues, sizeof(fvarValues)/sizeof(float)), - _BuildArray(expected, sizeof(expected)/sizeof(float)))) { + _BuildArray(numVerts), + _BuildArray(verts), + _BuildArray(hole), + _BuildArray(fvarValues), + _BuildArray(expected))) { return false; } return true; @@ -955,18 +964,18 @@ InvalidTopologyTest() }; if (!_CompareIndices("Invalid", _tokens->rightHanded, - _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), - _BuildArray(verts, sizeof(verts)/sizeof(int)), - _BuildArray(hole, sizeof(hole)/sizeof(int)), - _BuildArray(expected, sizeof(expected)/sizeof(expected[0])))) { + _BuildArray(numVerts), + _BuildArray(verts), + _BuildArray(hole), + _BuildArray(expected))) { return false; } if (!_CompareFaceVarying("InvalidFaceVarying", _tokens->rightHanded, - _BuildArray(numVerts, sizeof(numVerts)/sizeof(int)), - _BuildArray(verts, sizeof(verts)/sizeof(int)), - _BuildArray(hole, sizeof(hole)/sizeof(int)), - _BuildArray(fvarValues, sizeof(fvarValues)/sizeof(float)), - _BuildArray(fvarExpected, sizeof(fvarExpected)/sizeof(float)))) { + _BuildArray(numVerts), + _BuildArray(verts), + _BuildArray(hole), + _BuildArray(fvarValues), + _BuildArray(fvarExpected))) { return false; } @@ -1009,4 +1018,3 @@ int main() return EXIT_FAILURE; } } - diff --git a/pxr/imaging/hdSt/testenv/testHdStSubdivision.cpp b/pxr/imaging/hdSt/testenv/testHdStSubdivision.cpp index 7662359005..bf9706e29d 100644 --- a/pxr/imaging/hdSt/testenv/testHdStSubdivision.cpp +++ b/pxr/imaging/hdSt/testenv/testHdStSubdivision.cpp @@ -42,12 +42,21 @@ TF_DEFINE_PRIVATE_TOKENS( ((rightHanded, "rightHanded")) ); -template +template static VtArray -_BuildArray(T values[], int numValues) +_BuildArray(T (&values)[N]) { - VtArray result(numValues); - std::copy(values, values+numValues, result.begin()); + VtArray result(N); + std::copy(values, values+N, result.begin()); + return result; +} + +template +static VtArray +_BuildArray(const std::array& values) +{ + VtArray result(N); + std::copy(values.begin(), values.end(), result.begin()); return result; } @@ -169,19 +178,19 @@ _DumpRefinedPoints(std::string const & name, #define DUMP_REFINED_POINTS(name, scheme, orientation, numVerts, verts, points, holes, subdivTags) \ _DumpRefinedPoints(name, scheme, orientation, \ - _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ - _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ - _BuildArray(points, sizeof(points)/sizeof(points[0])), \ - _BuildArray(holes, sizeof(holes)/sizeof(holes[0])), \ + _BuildArray(numVerts), \ + _BuildArray(verts), \ + _BuildArray(points), \ + _BuildArray(holes), \ subdivTags, \ /*level=*/1, false) #define DUMP_GPU_REFINED_POINTS(name, scheme, orientation, numVerts, verts, points, holes, subdivTags) \ _DumpRefinedPoints(name, scheme, orientation, \ - _BuildArray(numVerts, sizeof(numVerts)/sizeof(numVerts[0])), \ - _BuildArray(verts, sizeof(verts)/sizeof(verts[0])), \ - _BuildArray(points, sizeof(points)/sizeof(points[0])), \ - _BuildArray(holes, sizeof(holes)/sizeof(holes[0])), \ + _BuildArray(numVerts), \ + _BuildArray(verts), \ + _BuildArray(points), \ + _BuildArray(holes), \ subdivTags, \ /*level=*/1, true) @@ -215,7 +224,7 @@ SubdivisionTest(TfToken const &scheme) GfVec3f(-1.0, 0.0, 0.0 ), GfVec3f( 1.0, 0.0, 0.0 ), }; - int holes[] = {}; + std::array holes = {}; if (!DUMP_REFINED_POINTS("triangle", scheme, _tokens->rightHanded, numVerts, verts, points, holes, PxOsdSubdivTags())) { @@ -261,7 +270,7 @@ SubdivisionTest(TfToken const &scheme) GfVec3f(-1.0, 0.0, 0.0 ), GfVec3f( 1.0, 0.0, 0.0 ), }; - int holes[] = {}; + std::array holes = {}; if (!DUMP_REFINED_POINTS("triangle", scheme, _tokens->leftHanded, numVerts, verts, points, holes, PxOsdSubdivTags())) { @@ -308,7 +317,7 @@ SubdivisionTest(TfToken const &scheme) GfVec3f(-1.0f,-1.0f, 0.0f ), GfVec3f( 1.0f,-1.0f, 0.0f ), }; - int holes[] = {}; + std::array holes = {}; if (!DUMP_REFINED_POINTS("quad", scheme, _tokens->rightHanded, numVerts, verts, points, holes, PxOsdSubdivTags())) { @@ -358,7 +367,7 @@ SubdivisionTest(TfToken const &scheme) GfVec3f( 3.0f, 0.5f, 0.0f), GfVec3f( 3.0f, 1.0f, 0.0f), }; - int holes[] = {}; + std::array holes = {}; if (!DUMP_REFINED_POINTS("polygons", scheme, _tokens->rightHanded, numVerts, verts, points, holes, PxOsdSubdivTags())) { @@ -416,7 +425,7 @@ LoopSubdivisionTest() GfVec3f(-1.0, 0.0, 0.0 ), GfVec3f( 1.0, 0.0, 0.0 ), }; - int holes[] = {}; + std::array holes = {}; if (!DUMP_REFINED_POINTS("triangle", PxOsdOpenSubdivTokens->loop, _tokens->rightHanded, @@ -482,8 +491,8 @@ PrimitiveIDMappingTest(bool usePtexIndex) 0, 2, 3, 4, 4, 3, 5, 6, 7 }; - VtIntArray numVerts = _BuildArray(numVertsSrc, 3); - VtIntArray verts = _BuildArray(vertsSrc, 12); + VtIntArray numVerts = _BuildArray(numVertsSrc); + VtIntArray verts = _BuildArray(vertsSrc); int refineLevel = 1; HdMeshTopology m(PxOsdOpenSubdivTokens->catmullClark, _tokens->rightHanded, @@ -595,17 +604,12 @@ SubdivTagTest() PxOsdSubdivTags subdivTags; - subdivTags.SetCreaseLengths(_BuildArray(creaseLengths, - sizeof(creaseLengths)/sizeof(creaseLengths[0]))); - subdivTags.SetCreaseIndices(_BuildArray(creaseIndices, - sizeof(creaseIndices)/sizeof(creaseIndices[0]))); - subdivTags.SetCreaseWeights(_BuildArray(creaseSharpnesses, - sizeof(creaseSharpnesses)/sizeof(creaseSharpnesses[0]))); + subdivTags.SetCreaseLengths(_BuildArray(creaseLengths)); + subdivTags.SetCreaseIndices(_BuildArray(creaseIndices)); + subdivTags.SetCreaseWeights(_BuildArray(creaseSharpnesses)); - subdivTags.SetCornerIndices(_BuildArray(cornerIndices, - sizeof(cornerIndices)/sizeof(cornerIndices[0]))); - subdivTags.SetCornerWeights( _BuildArray(cornerSharpnesses, - sizeof(cornerSharpnesses)/sizeof(cornerSharpnesses[0]))); + subdivTags.SetCornerIndices(_BuildArray(cornerIndices)); + subdivTags.SetCornerWeights(_BuildArray(cornerSharpnesses)); subdivTags.SetVertexInterpolationRule(PxOsdOpenSubdivTokens->edgeOnly); subdivTags.SetFaceVaryingInterpolationRule(PxOsdOpenSubdivTokens->edgeOnly); @@ -670,16 +674,13 @@ SubdivTagTest2() int creaseLengths[] = { 2, 4 }; int creaseIndices[] = { 2, 3, 1, 2, 5, 6 }; float creaseSharpnesses[] = { 4.0f, 5.0f }; - int holes[] = {}; + std::array holes = {}; PxOsdSubdivTags subdivTags; - subdivTags.SetCreaseLengths(_BuildArray(creaseLengths, - sizeof(creaseLengths)/sizeof(creaseLengths[0]))); - subdivTags.SetCreaseIndices(_BuildArray(creaseIndices, - sizeof(creaseIndices)/sizeof(creaseIndices[0]))); - subdivTags.SetCreaseWeights(_BuildArray(creaseSharpnesses, - sizeof(creaseSharpnesses)/sizeof(creaseSharpnesses[0]))); + subdivTags.SetCreaseLengths(_BuildArray(creaseLengths)); + subdivTags.SetCreaseIndices(_BuildArray(creaseIndices)); + subdivTags.SetCreaseWeights(_BuildArray(creaseSharpnesses)); subdivTags.SetVertexInterpolationRule(PxOsdOpenSubdivTokens->edgeOnly); subdivTags.SetFaceVaryingInterpolationRule(PxOsdOpenSubdivTokens->edgeOnly); @@ -730,16 +731,13 @@ InvalidTopologyTest() int creaseLengths[] = { 2, 4 }; int creaseIndices[] = { 2, 3, 1, 2, 6, 7 }; float creaseSharpnesses[] = { 4.0f, 5.0f }; - int holes[] = {}; + std::array holes = {}; PxOsdSubdivTags subdivTags; - subdivTags.SetCreaseLengths(_BuildArray(creaseLengths, - sizeof(creaseLengths)/sizeof(creaseLengths[0]))); - subdivTags.SetCreaseIndices(_BuildArray(creaseIndices, - sizeof(creaseIndices)/sizeof(creaseIndices[0]))); - subdivTags.SetCreaseWeights(_BuildArray(creaseSharpnesses, - sizeof(creaseSharpnesses)/sizeof(creaseSharpnesses[0]))); + subdivTags.SetCreaseLengths(_BuildArray(creaseLengths)); + subdivTags.SetCreaseIndices(_BuildArray(creaseIndices)); + subdivTags.SetCreaseWeights(_BuildArray(creaseSharpnesses)); subdivTags.SetVertexInterpolationRule(PxOsdOpenSubdivTokens->edgeOnly); subdivTags.SetFaceVaryingInterpolationRule(PxOsdOpenSubdivTokens->edgeOnly); @@ -765,10 +763,10 @@ EmptyTopologyTest() { std::cout << "\nEmpty Topology Test\n"; - int numVerts[] = {}; - int verts[] = {}; - GfVec3f points[] = {}; - int holes[] = {}; + std::array numVerts = {}; + std::array verts = {}; + std::array points = {}; + std::array holes = {}; if (!DUMP_REFINED_POINTS("subdivTag", PxOsdOpenSubdivTokens->catmullClark, @@ -818,7 +816,7 @@ TorusTopologyTest() GfVec3f( 0, -0.5, 1), GfVec3f( 1, -0.5, 0) }; - int holes[] = {}; + std::array holes = {}; PxOsdSubdivTags subdivTags; if (!DUMP_REFINED_POINTS("subdivTag", @@ -877,4 +875,3 @@ int main() return EXIT_FAILURE; } } - diff --git a/pxr/imaging/hdSt/textureObject.h b/pxr/imaging/hdSt/textureObject.h index f6a6e1ed37..adec00037a 100644 --- a/pxr/imaging/hdSt/textureObject.h +++ b/pxr/imaging/hdSt/textureObject.h @@ -138,6 +138,7 @@ class HdStTextureObject : class HdStUvTextureObject : public HdStTextureObject { public: + HDST_API ~HdStUvTextureObject() override; /// Get the handle to the actual GPU resource. @@ -159,18 +160,25 @@ class HdStUvTextureObject : public HdStTextureObject HdStTextureType GetTextureType() const override final; protected: + HDST_API HdStUvTextureObject( const HdStTextureIdentifier &textureId, HdSt_TextureObjectRegistry * textureObjectRegistry); + HDST_API void _SetWrapParameters( const std::pair &wrapParameters); + HDST_API void _SetCpuData(std::unique_ptr &&); + HDST_API HdStTextureCpuData * _GetCpuData() const; + HDST_API void _CreateTexture(const HgiTextureDesc &desc); + HDST_API void _GenerateMipmaps(); + HDST_API void _DestroyTexture(); private: diff --git a/pxr/imaging/hdSt/textureObjectRegistry.h b/pxr/imaging/hdSt/textureObjectRegistry.h index e51949f3a8..50e7a98917 100644 --- a/pxr/imaging/hdSt/textureObjectRegistry.h +++ b/pxr/imaging/hdSt/textureObjectRegistry.h @@ -35,7 +35,9 @@ class HdStTextureIdentifier; class HdSt_TextureObjectRegistry final { public: + HDST_API explicit HdSt_TextureObjectRegistry(HdStResourceRegistry * registry); + HDST_API ~HdSt_TextureObjectRegistry(); /// Allocate texture. diff --git a/pxr/imaging/hdSt/unitTestHelper.h b/pxr/imaging/hdSt/unitTestHelper.h index 61fdc6de45..cef177355f 100644 --- a/pxr/imaging/hdSt/unitTestHelper.h +++ b/pxr/imaging/hdSt/unitTestHelper.h @@ -589,16 +589,21 @@ class HdSt_TestLightingShader : public HdStLightingShader HDST_API void UnbindResources(int program, HdSt_ResourceBinder const &binder) override; + HDST_API void AddBindings(HdStBindingRequestVector *customBindings) override; /// HdStLightingShader overrides + HDST_API void SetCamera(GfMatrix4d const &worldToViewMatrix, GfMatrix4d const &projectionMatrix) override; + HDST_API void SetSceneAmbient(GfVec3f const &color); + HDST_API void SetLight(int light, GfVec3f const &dir, GfVec3f const &color); /// Prepare lighting resource buffers + HDST_API void Prepare(); private: @@ -669,4 +674,4 @@ class HdSt_TextureTestDriver PXR_NAMESPACE_CLOSE_SCOPE -#endif // PXR_IMAGING_HD_ST_UNIT_TEST_HELPER_H \ No newline at end of file +#endif // PXR_IMAGING_HD_ST_UNIT_TEST_HELPER_H diff --git a/pxr/imaging/hdSt/vboSimpleMemoryManager.h b/pxr/imaging/hdSt/vboSimpleMemoryManager.h index 1e306424f1..7b226d3fc6 100644 --- a/pxr/imaging/hdSt/vboSimpleMemoryManager.h +++ b/pxr/imaging/hdSt/vboSimpleMemoryManager.h @@ -52,10 +52,12 @@ class HdStVBOSimpleMemoryManager : public HdStAggregationStrategy HdBufferArrayUsageHint usageHint) const; /// Returns the buffer specs from a given buffer array + HDST_API virtual HdBufferSpecVector GetBufferSpecs( HdBufferArraySharedPtr const &bufferArray) const; /// Returns the size of the GPU memory used by the passed buffer array + HDST_API virtual size_t GetResourceAllocation( HdBufferArraySharedPtr const &bufferArray, VtDictionary &result) const; diff --git a/pxr/imaging/hgiVulkan/commandQueue.h b/pxr/imaging/hgiVulkan/commandQueue.h index 4594083d5b..20537264a0 100644 --- a/pxr/imaging/hgiVulkan/commandQueue.h +++ b/pxr/imaging/hgiVulkan/commandQueue.h @@ -54,6 +54,7 @@ class HgiVulkanCommandQueue final /// After submission the command buffer must not be re-used by client. /// Thread safety: Submission must be externally synchronized. Clients /// should call HgiVulkan::SubmitToQueue. + HGIVULKAN_API void SubmitToQueue( HgiVulkanCommandBuffer* cmdBuffer, HgiSubmitWaitType wait = HgiSubmitWaitTypeNoWait); @@ -130,4 +131,4 @@ class HgiVulkanCommandQueue final PXR_NAMESPACE_CLOSE_SCOPE -#endif \ No newline at end of file +#endif diff --git a/pxr/imaging/hgiVulkan/garbageCollector.h b/pxr/imaging/hgiVulkan/garbageCollector.h index a51bf3f853..5cf44528bd 100644 --- a/pxr/imaging/hgiVulkan/garbageCollector.h +++ b/pxr/imaging/hgiVulkan/garbageCollector.h @@ -62,13 +62,21 @@ class HgiVulkanGarbageCollector final /// Returns a garbage collection vector for a type of handle. /// Thread safety: The returned vector is a thread_local vector so this call /// is thread safe as long as the vector is only used by the calling thread. + HGIVULKAN_API HgiVulkanBufferVector* GetBufferList(); + HGIVULKAN_API HgiVulkanTextureVector* GetTextureList(); + HGIVULKAN_API HgiVulkanSamplerVector* GetSamplerList(); + HGIVULKAN_API HgiVulkanShaderFunctionVector* GetShaderFunctionList(); + HGIVULKAN_API HgiVulkanShaderProgramVector* GetShaderProgramList(); + HGIVULKAN_API HgiVulkanResourceBindingsVector* GetResourceBindingsList(); + HGIVULKAN_API HgiVulkanGraphicsPipelineVector* GetGraphicsPipelineList(); + HGIVULKAN_API HgiVulkanComputePipelineVector* GetComputePipelineList(); private: From 116724acf2db6e42776ec0e218494dfa73aad649 Mon Sep 17 00:00:00 2001 From: blevin Date: Thu, 7 Nov 2024 09:46:55 -0800 Subject: [PATCH 099/300] Add command line option to usdrecord to start tracing and track allocations. These match the same options as provided in usdview, and provide instrumentation for batch rendering. (Internal change: 2346702) --- pxr/usdImaging/bin/usdrecord/usdrecord.py | 79 ++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/pxr/usdImaging/bin/usdrecord/usdrecord.py b/pxr/usdImaging/bin/usdrecord/usdrecord.py index f45f7839ee..19fa8526c6 100644 --- a/pxr/usdImaging/bin/usdrecord/usdrecord.py +++ b/pxr/usdImaging/bin/usdrecord/usdrecord.py @@ -78,6 +78,32 @@ def _SetupOpenGLContext(width=100, height=100): return glWidget +def _DumpMallocTags(stage, contextStr): + if not Tf.MallocTag.IsInitialized(): + _Msg("Unable to accumulate memory usage since the Pxr MallocTag " + "system was not initialized") + return + + callTree = Tf.MallocTag.GetCallTree() + memInMb = Tf.MallocTag.GetTotalBytes() / (1024.0 * 1024.0) + + import os.path as path + import tempfile + layerName = path.basename(stage.GetRootLayer().identifier) + # CallTree.Report() gives us the most informative (and processable) + # form of output, but it only accepts a fileName argument. So we + # use NamedTemporaryFile just to get a filename. + statsFile = tempfile.NamedTemporaryFile( + prefix=layerName+'.', + suffix='.mallocTag', + delete=False) + statsFile.close() + reportName = statsFile.name + callTree.Report(reportName) + _Msg("Memory consumption of %s for %s is %d Mb" % + (contextStr, layerName, memInMb)) + _Msg("For detailed analysis, see " + reportName) + def main() -> int: programName = os.path.basename(sys.argv[0]) parser = argparse.ArgumentParser(prog=programName, @@ -173,12 +199,47 @@ def main() -> int: 'Furthermore any properties authored on the RenderSettings will ' 'override other arguments (imageWidth, camera, outputImagePath)')) + parser.add_argument('--traceToFile', action='store', + type=str, dest='traceToFile', default=None, + help=( + 'Start tracing at application startup and ' + 'write --traceFormat specified format output to the ' + 'specified trace file when the application quits')) + + parser.add_argument('--traceFormat', action='store', + type=str, dest='traceFormat', default='chrome', + choices=['chrome', 'trace'], + help=( + 'Output format for trace file specified by ' + '--traceToFile. \'chrome\' files can be read in ' + 'chrome, \'trace\' files are simple text reports. ' + '(default=%(default)s)')) + + parser.add_argument('--memstats', action='store_true', + default=False, dest='memstats', + help=( + 'Use the Pxr MallocTags memory accounting system to profile ' + 'USD, saving results to a tmp file, with a summary to the console. ' + 'Will have no effect if MallocTags are not supported in the ' + 'USD installation.')) + args = parser.parse_args() args.imageWidth = max(args.imageWidth, 1) purposes = args.purposes.replace(',', ' ').split() + # Track allocations + if args.memstats: + Tf.MallocTag.Initialize() + + # Begin tracing + traceCollector = None + if args.traceToFile: + from pxr import Trace + traceCollector = Trace.Collector() + traceCollector.enabled = True + # Load the root layer. rootLayer = Sdf.Layer.FindOrOpen(args.usdFilePath) if not rootLayer: @@ -277,7 +338,6 @@ def main() -> int: try: frameRecorder.Record(usdStage, usdCamera, timeCode, outputImagePath) except Tf.ErrorException as e: - _Err("Recording aborted due to the following failure at time code " "{0}: {1}".format(timeCode, str(e))) return 1 @@ -285,6 +345,23 @@ def main() -> int: # Release our reference to the frame recorder so it can be deleted before # the Qt stuff. frameRecorder = None + + # End tracing and report results. + if traceCollector: + traceCollector.enabled = False + if args.traceFormat == 'trace': + Trace.Reporter.globalReporter.Report( + args.traceToFile) + elif args.traceFormat == 'chrome': + Trace.Reporter.globalReporter.ReportChromeTracingToFile( + args.traceToFile) + else: + Tf.RaiseCodingError("Invalid trace format option provided: %s -" + "trace/chrome are the valid options" % + args.traceFormat) + if args.memstats: + _DumpMallocTags(usdStage, programName) + return 0 From c324d037dfd115f66b8947b617d54134fb1215e5 Mon Sep 17 00:00:00 2001 From: rajabala Date: Thu, 7 Nov 2024 09:47:00 -0800 Subject: [PATCH 100/300] [hdPrman] Add dependency of the light prim on its targeted light filters. - If the visibility or filterLink collection on the filter is invalidated, we forward the invalidation to the light prim. (Internal change: 2346736) --- .../hdPrman/dependencySceneIndexPlugin.cpp | 128 +++++++++++++++++- .../hdPrman/dependencySceneIndexPlugin.h | 12 +- 2 files changed, 134 insertions(+), 6 deletions(-) diff --git a/third_party/renderman-26/plugin/hdPrman/dependencySceneIndexPlugin.cpp b/third_party/renderman-26/plugin/hdPrman/dependencySceneIndexPlugin.cpp index 95f21ff1b1..478b382259 100644 --- a/third_party/renderman-26/plugin/hdPrman/dependencySceneIndexPlugin.cpp +++ b/third_party/renderman-26/plugin/hdPrman/dependencySceneIndexPlugin.cpp @@ -8,15 +8,19 @@ #include "hdPrman/tokens.h" #include "pxr/imaging/hd/containerDataSourceEditor.h" -#include "pxr/imaging/hd/dependenciesSchema.h" #include "pxr/imaging/hd/filteringSceneIndex.h" -#include "pxr/imaging/hd/mapContainerDataSource.h" #include "pxr/imaging/hd/lazyContainerDataSource.h" +#include "pxr/imaging/hd/mapContainerDataSource.h" #include "pxr/imaging/hd/overlayContainerDataSource.h" #include "pxr/imaging/hd/perfLog.h" #include "pxr/imaging/hd/retainedDataSource.h" #include "pxr/imaging/hd/sceneIndexPluginRegistry.h" #include "pxr/imaging/hd/tokens.h" + +#include "pxr/imaging/hd/collectionsSchema.h" +#include "pxr/imaging/hd/dependenciesSchema.h" +#include "pxr/imaging/hd/lightSchema.h" +#include "pxr/imaging/hd/visibilitySchema.h" #include "pxr/imaging/hd/volumeFieldBindingSchema.h" #include "pxr/imaging/hd/volumeFieldSchema.h" @@ -25,6 +29,7 @@ PXR_NAMESPACE_OPEN_SCOPE TF_DEFINE_PRIVATE_TOKENS( _tokens, ((sceneIndexPluginName, "HdPrman_DependencySceneIndexPlugin")) + (__dependenciesToFilters) ); TF_REGISTRY_FUNCTION(TfType) @@ -54,6 +59,12 @@ namespace /// Given a prim path data source, returns a dependency of volumeFieldBinding /// on volumeField of that given prim. +/// So, if the volume field's file path was modified, the volumeFieldBinding +/// would be invalidated to have the volume prim pick up the new asset. +/// Note: HdPrman_Field currently invalidates *all* Rprims backed by the render +/// index if DirtyParams is set on the field. We should be able to remove +/// that workaround with this scene index plugin in play. +/// HdDataSourceBaseHandle _ComputeVolumeFieldDependency(const HdDataSourceBaseHandle &src) { @@ -116,6 +127,105 @@ _ComputeVolumeFieldBindingDependencies( _ComputeVolumeFieldBindingDependency(primPath)); } +HdContainerDataSourceHandle +_BuildLightFilterDependenciesDs(const SdfPathVector &filterPaths) +{ + if (filterPaths.empty()) { + return nullptr; + } + + TfTokenVector names; + std::vector deps; + const size_t numFilters = filterPaths.size(); + + // For each filter targeted by the light, register 2 dependencies to + // forward light filter linking and visibility invalidation to the light. + const size_t numDeps = + 1 /* __dependencies -> filters */ + 2 * numFilters; + names.reserve(numDeps); + deps.reserve(numDeps); + + static HdLocatorDataSourceHandle filtersLocDs = + HdRetainedTypedSampledDataSource::New( + HdLightSchema::GetDefaultLocator().Append(HdTokens->filters)); + + static HdLocatorDataSourceHandle dependenciesLocDs = + HdRetainedTypedSampledDataSource::New( + HdDependenciesSchema::GetDefaultLocator()); + + names.push_back(_tokens->__dependenciesToFilters); + deps.push_back( + HdDependencySchema::Builder() + .SetDependedOnPrimPath(/* self */ nullptr) + .SetDependedOnDataSourceLocator(filtersLocDs) + .SetAffectedDataSourceLocator(dependenciesLocDs) + .Build()); + + static HdLocatorDataSourceHandle filterLinkLocDs = + HdRetainedTypedSampledDataSource::New( + HdCollectionsSchema::GetDefaultLocator() + .Append(HdTokens->filterLink)); + + static HdLocatorDataSourceHandle filterVisLocDs = + HdRetainedTypedSampledDataSource::New( + HdVisibilitySchema::GetDefaultLocator()); + + static HdLocatorDataSourceHandle affectedLocatorDs = + HdRetainedTypedSampledDataSource::New( + // XXX This should be more targeted. + HdLightSchema::GetDefaultLocator()); + + for (const auto &filterPath : filterPaths) { + names.push_back(TfToken(filterPath.GetAsString() + "_linkDep")); + deps.push_back( + HdDependencySchema::Builder() + .SetDependedOnPrimPath( + HdRetainedTypedSampledDataSource::New(filterPath)) + .SetDependedOnDataSourceLocator(filterLinkLocDs) + .SetAffectedDataSourceLocator(affectedLocatorDs) + .Build()); + + names.push_back(TfToken(filterPath.GetAsString() + "_visDep")); + deps.push_back( + HdDependencySchema::Builder() + .SetDependedOnPrimPath( + HdRetainedTypedSampledDataSource::New(filterPath)) + .SetDependedOnDataSourceLocator(filterVisLocDs) + .SetAffectedDataSourceLocator(affectedLocatorDs) + .Build()); + } + + return HdRetainedContainerDataSource::New( + numDeps, names.data(), deps.data()); +} + +HdContainerDataSourceHandle +_ComputeLightFilterDependencies( + const SdfPath &lightPrimPath, + const HdContainerDataSourceHandle &lightPrimSource) +{ + const HdLightSchema ls = HdLightSchema::GetFromParent(lightPrimSource); + + // XXX + // HdLightSchema is barebones at the moment, so we need to explicitly use + // the 'filters' token below. + const HdContainerDataSourceHandle lightDs = ls.GetContainer(); + if (lightDs) { + HdDataSourceBaseHandle filtersDs = lightDs->Get(HdTokens->filters); + if (HdSampledDataSourceHandle valDs = + HdSampledDataSource::Cast(filtersDs)) { + + VtValue val = valDs->GetValue(0.0f); + if (val.IsHolding()) { + return _BuildLightFilterDependenciesDs( + val.UncheckedGet()); + } + } + } + + return nullptr; +} + TF_DECLARE_REF_PTRS(_SceneIndex); /////////////////////////////////////////////////////////////////////////////// @@ -123,7 +233,7 @@ TF_DECLARE_REF_PTRS(_SceneIndex); /// \class _SceneIndex /// -/// The scene index that adds dependencies for volume prims. +/// The scene index that adds dependencies for volume and light prims. /// class _SceneIndex : public HdSingleInputFilteringSceneIndexBase { @@ -148,6 +258,18 @@ class _SceneIndex : public HdSingleInputFilteringSceneIndexBase primPath, prim.dataSource))) .Finish() }; } + + if (HdPrimTypeIsLight(prim.primType)) { + return + { prim.primType, + HdContainerDataSourceEditor(prim.dataSource) + .Overlay( + HdDependenciesSchema::GetDefaultLocator(), + HdLazyContainerDataSource::New( + std::bind(_ComputeLightFilterDependencies, + primPath, prim.dataSource))) + .Finish() }; + } return prim; } diff --git a/third_party/renderman-26/plugin/hdPrman/dependencySceneIndexPlugin.h b/third_party/renderman-26/plugin/hdPrman/dependencySceneIndexPlugin.h index 2985862351..6df231957b 100644 --- a/third_party/renderman-26/plugin/hdPrman/dependencySceneIndexPlugin.h +++ b/third_party/renderman-26/plugin/hdPrman/dependencySceneIndexPlugin.h @@ -17,15 +17,21 @@ PXR_NAMESPACE_OPEN_SCOPE /// Plugin adds a scene index that declares hdprman-specific dependencies to /// trigger the necessary invalidation. /// -/// Currently, the lone usage is for volume prims. -/// -/// Specfically, the declaration allows the volumeFieldBinding data source +/// It currently declares 2 dependencies: +/// (a -> b to be read as "a depends on b") +/// 1. Volume -> Volume Field Binding +/// This declaration registers the volumeFieldBinding data source /// locator of a volume prim to be invalidated if any of the targeted volume /// fields changes. /// That is, if, e.g., the filePath of a volume field changes, then the volume /// using that volume field will be dirtied so that HdPrmanVolume will update /// which 3d textures it will use. /// +/// 2. Light -> Light Filter +/// This declaration registers the light data source locator of a light prim +/// to be invalidated if the visibility or filter link collection of a +/// targeted light filter changes. +/// class HdPrman_DependencySceneIndexPlugin : public HdSceneIndexPlugin { public: From d6a6a92a90ef5b9b83dca63c5c71910fe4a0c713 Mon Sep 17 00:00:00 2001 From: blevin Date: Thu, 7 Nov 2024 09:47:06 -0800 Subject: [PATCH 101/300] Hd: Add some diagnostics when rejecting primvars for want of valid interpolation values. (Internal change: 2346787) --- pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp b/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp index ec00c7a70a..f38b15957c 100644 --- a/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp +++ b/pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp @@ -1779,6 +1779,9 @@ HdSceneIndexAdapterSceneDelegate::_ComputePrimvarDescriptors( primvar.GetInterpolation(); if (!interpolationDataSource) { + TF_WARN("HdSceneIndexAdapterSceneDelegate: Skipping primvar " + "'%s' due to missing interpolation data source", + name.GetText()); continue; } @@ -1788,6 +1791,9 @@ HdSceneIndexAdapterSceneDelegate::_ComputePrimvarDescriptors( Hd_InterpolationAsEnum(interpolationToken); if (interpolation >= HdInterpolationCount) { + TF_WARN("HdSceneIndexAdapterSceneDelegate: Skipping primvar " + "'%s' due to invalid interpolation value %i", + name.GetText(), interpolation); continue; } From de73dbfa1244ab85bc0098bc858285eb42be1daa Mon Sep 17 00:00:00 2001 From: sunyab Date: Thu, 7 Nov 2024 09:47:13 -0800 Subject: [PATCH 102/300] pcp: Improve recovery when TF_VERIFY fails Pcp_ComposeExpressionVariables should always return a pointer to a PcpExpressionVariables object whose lifetime is managed externally. This is checked via a TF_VERIFY, but if that failed due to a bug this function could return a pointer to a temporary instead. This change avoids that by making that temporary static. This allows client code to recover gracefully if the TF_VERIFY is tripped. It also avoids a return-local-addr warning that is emitted under gcc11. (Internal change: 2346790) --- pxr/usd/pcp/expressionVariables.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pxr/usd/pcp/expressionVariables.cpp b/pxr/usd/pcp/expressionVariables.cpp index e79aced15c..271980b542 100644 --- a/pxr/usd/pcp/expressionVariables.cpp +++ b/pxr/usd/pcp/expressionVariables.cpp @@ -107,7 +107,7 @@ Pcp_ComposeExpressionVariables( const PcpLayerStackIdentifier& rootLayerStackId, CachePolicy* cache) { - PcpExpressionVariables localExpressionVars; + static const PcpExpressionVariables localExpressionVars; const PcpExpressionVariables* expressionVars = &localExpressionVars; // Traverse the variable override sources to collect the expression variable @@ -150,7 +150,11 @@ Pcp_ComposeExpressionVariables( sources[i], std::move(newExpressionVars)); } } - + + // expressionVars should be set to a cached entry at this point. + // If this fails for some reason, expressionVars will be set to a + // pointer to a static instance to avoid returning a pointer to a + // temporary. TF_VERIFY(expressionVars != &localExpressionVars); return expressionVars; } From d696f1249d3dea209d5070ed0debaa28273482f2 Mon Sep 17 00:00:00 2001 From: unhyperbolic Date: Thu, 7 Nov 2024 09:47:18 -0800 Subject: [PATCH 103/300] HdsiMaterialPrimvarTransferSceneIndex: addressing some bugs and some re-factoring. Bugs fixed: 1. The dependencies were only added if it had a path data source for the all-purpose material binding. This meant that if a prim started off without such a data source and then added it, the scene index do not pick up the new dependency. 2. If a material binding data source returned an empty path, the scene index was trying to call GetPrim for the empty path on the input scene index and added an unnecessary self-dependencies. There is one (hopefully reasonable) assumption that that the new implementation makes (for performance): if we got a null pointer for material bindings, no dependencies are created (for performance) and if a client adds a material bindings data source later, it won't be picked up. We also simplified the code using: 1. _GetInputSceneIndex() is never null. 2. The helper HdOverlayContainerDataSource::OverlayedContainerDataSources. (Internal change: 2346826) --- .../materialPrimvarTransferSceneIndex.cpp | 285 ++++++++++-------- 1 file changed, 154 insertions(+), 131 deletions(-) diff --git a/pxr/imaging/hdsi/materialPrimvarTransferSceneIndex.cpp b/pxr/imaging/hdsi/materialPrimvarTransferSceneIndex.cpp index e5c4351fe4..e5bde477f2 100644 --- a/pxr/imaging/hdsi/materialPrimvarTransferSceneIndex.cpp +++ b/pxr/imaging/hdsi/materialPrimvarTransferSceneIndex.cpp @@ -11,48 +11,51 @@ #include "pxr/imaging/hd/primvarsSchema.h" #include "pxr/imaging/hd/retainedDataSource.h" -#include - PXR_NAMESPACE_OPEN_SCOPE TF_DEFINE_PRIVATE_TOKENS( _tokens, - (materialPrimvarTransfer_dep) - (materialPrimvarTransfer_primvarsToBinding) - (materialPrimvarTransfer_primvarsToMaterial) + (materialPrimvarTransfer_materialBindingsToPrimvars) + (materialPrimvarTransfer_materialPrimvarsToPrimvars) + (materialPrimvarTransfer_materialBindingsToDependency) ); namespace { +void _AddIfNecessary(const TfToken &name, TfTokenVector * const names) +{ + if (std::find(names->begin(), names->end(), name) == names->end()) { + names->push_back(name); + } +} + +SdfPath _GetMaterialPath(const HdMaterialBindingsSchema &materialBindings) +{ + HdPathDataSourceHandle const ds = + materialBindings + .GetMaterialBinding() + .GetPath(); + if (!ds) { + return {}; + } + return ds->GetTypedValue(0.0f); +} + class _PrimDataSource final : public HdContainerDataSource { public: HD_DECLARE_DATASOURCE(_PrimDataSource); - _PrimDataSource( - const HdSceneIndexBaseRefPtr &inputScene, - const HdContainerDataSourceHandle &inputDs) - : _inputScene(inputScene) - , _inputDs(inputDs) - { - } - TfTokenVector GetNames() override { - TfTokenVector result; - if (_inputDs) { - result = _inputDs->GetNames(); - if (HdMaterialBindingsSchema::GetFromParent(_inputDs)) { - for (const TfToken &name : { - HdPrimvarsSchema::GetSchemaToken(), - HdDependenciesSchema::GetSchemaToken() }) { - if (std::find(result.begin(), result.end(), name) - == result.end()) { - result.push_back(name); - } - } + TfTokenVector result = _inputDs->GetNames(); + if (const HdMaterialBindingsSchema materialBindings = + HdMaterialBindingsSchema::GetFromParent(_inputDs)) { + _AddIfNecessary(HdDependenciesSchema::GetSchemaToken(), &result); + if (!_GetMaterialPath(materialBindings).IsEmpty()) { + _AddIfNecessary(HdPrimvarsSchema::GetSchemaToken(), &result); } } return result; @@ -60,109 +63,135 @@ class _PrimDataSource final : public HdContainerDataSource HdDataSourceBaseHandle Get(const TfToken& name) override { - HdDataSourceBaseHandle inputResult; - if (_inputDs) { - inputResult = _inputDs->Get(name); + HdDataSourceBaseHandle const ds = _inputDs->Get(name); + + if (name == HdPrimvarsSchema::GetSchemaToken()) { + return + HdOverlayContainerDataSource::OverlayedContainerDataSources( + // local primvars have stronger opinion + HdContainerDataSource::Cast(ds), + _GetPrimvarsFromMaterial()); } - if (name == HdDependenciesSchema::GetSchemaToken()) { - if (HdPathDataSourceHandle pathDs = _GetMaterialBindingPath()) { - - // We need to create three dependencies here: - // 1) Our primvars potentially depend on the value of the - // material binding changing - // 2) Our primvars depend on the primvars of the bound material - // prim. - // 3) Dependency (2) itself depends on the value of the bound - // material prim! - - const static HdLocatorDataSourceHandle primvarsLocDs = - HdRetainedTypedSampledDataSource::New( - HdPrimvarsSchema::GetDefaultLocator()); - - const static HdLocatorDataSourceHandle materialBindingsLocDs = - HdRetainedTypedSampledDataSource::New( - HdMaterialBindingsSchema::GetDefaultLocator()); - - static const HdLocatorDataSourceHandle primvarsToMaterialLocDs = - HdRetainedTypedSampledDataSource::New( - HdDependenciesSchema::GetDefaultLocator() - .Append(_tokens-> - materialPrimvarTransfer_primvarsToMaterial)); - - HdContainerDataSourceHandle depsDs = - HdRetainedContainerDataSource::New( - // primvars -> bound material primvars - _tokens->materialPrimvarTransfer_primvarsToMaterial, - HdDependencySchema::Builder() - .SetDependedOnPrimPath(pathDs) - .SetDependedOnDataSourceLocator(primvarsLocDs) - .SetAffectedDataSourceLocator(primvarsLocDs) - .Build(), - - // above dependency -> material binding - _tokens->materialPrimvarTransfer_dep, - HdDependencySchema::Builder() - .SetDependedOnPrimPath(nullptr) // self - .SetDependedOnDataSourceLocator( - materialBindingsLocDs) - .SetAffectedDataSourceLocator(primvarsLocDs) - .Build(), - - // primvars -> material binding - _tokens->materialPrimvarTransfer_primvarsToBinding, - HdDependencySchema::Builder() - .SetDependedOnPrimPath(nullptr) // self - .SetDependedOnDataSourceLocator( - materialBindingsLocDs) - .SetAffectedDataSourceLocator( - primvarsToMaterialLocDs) - .Build()); - - if (HdContainerDataSourceHandle inputResultContainer = - HdContainerDataSource::Cast(inputResult)) { - return HdOverlayContainerDataSource::New( - depsDs, inputResultContainer); - } else { - return depsDs; - } - } - } else if (name == HdPrimvarsSchema::GetSchemaToken()) { - - if (HdPathDataSourceHandle pathDs = _GetMaterialBindingPath()) { - const SdfPath materialPath = pathDs->GetTypedValue(0.0f); - HdSceneIndexPrim prim = _inputScene->GetPrim(materialPath); - - if (HdPrimvarsSchema pvSchema = - HdPrimvarsSchema::GetFromParent(prim.dataSource)) - { - if (HdContainerDataSourceHandle inputResultContainer = - HdContainerDataSource::Cast(inputResult)) { - // local primvars have stronger opinion - return HdOverlayContainerDataSource::New( - inputResultContainer, pvSchema.GetContainer()); - } else { - return pvSchema.GetContainer(); - } - } - } + return + HdOverlayContainerDataSource::OverlayedContainerDataSources( + HdContainerDataSource::Cast(ds), + _GetDependencies()); } - return inputResult; + return ds; } private: - - HdPathDataSourceHandle _GetMaterialBindingPath() + _PrimDataSource( + const HdSceneIndexBaseRefPtr &inputScene, + const HdContainerDataSourceHandle &inputDs) + : _inputScene(inputScene) + , _inputDs(inputDs) { - HdMaterialBindingsSchema materialBindings = + } + + HdContainerDataSourceHandle _GetPrimvarsFromMaterial() const { + const SdfPath materialPath = _GetMaterialPath( + HdMaterialBindingsSchema::GetFromParent(_inputDs)); + if (materialPath.IsEmpty()) { + return nullptr; + } + const HdSceneIndexPrim materialPrim = + _inputScene->GetPrim(materialPath); + return + HdPrimvarsSchema::GetFromParent(materialPrim.dataSource) + .GetContainer(); + } + + HdContainerDataSourceHandle _GetDependencies() const { + const HdMaterialBindingsSchema materialBindings = HdMaterialBindingsSchema::GetFromParent(_inputDs); - HdMaterialBindingSchema materialBinding = - materialBindings.GetMaterialBinding(); - return materialBinding.GetPath(); + if (!materialBindings) { + // Note: while we support the case that the content of the + // container data source at materialBindings change, we do + // not support the case where a prim started with no + // data source for materialBindings and adds that data source + // later. + return nullptr; + } + + // We need to create three dependencies here: + // 1) Our primvars potentially depend on the value of the + // material binding changing + // 2) Our primvars depend on the primvars of the bound material + // prim. + // 3) Dependency 2) itself depends on the value of the bound + // material prim! + + TfToken names[3]; + HdDataSourceBaseHandle dataSources[3]; + size_t count = 0; + + static HdLocatorDataSourceHandle const materialBindingsLocDs = + HdRetainedTypedSampledDataSource::New( + HdMaterialBindingsSchema::GetDefaultLocator()); + static HdLocatorDataSourceHandle const primvarsLocDs = + HdRetainedTypedSampledDataSource::New( + HdPrimvarsSchema::GetDefaultLocator()); + + { + static HdDataSourceBaseHandle const dependencyDs = + HdDependencySchema::Builder() + // Prim depends on itself. + .SetDependedOnDataSourceLocator(materialBindingsLocDs) + .SetAffectedDataSourceLocator(primvarsLocDs) + .Build(); + names[count] = + _tokens->materialPrimvarTransfer_materialBindingsToPrimvars; + dataSources[count] = + dependencyDs; + count++; + } + + if (HdPathDataSourceHandle const pathDs = + materialBindings.GetMaterialBinding().GetPath()) { + if (!pathDs->GetTypedValue(0.0f).IsEmpty()) { + HdDataSourceBaseHandle const dependencyDs = + HdDependencySchema::Builder() + .SetDependedOnPrimPath(pathDs) + .SetDependedOnDataSourceLocator(primvarsLocDs) + .SetAffectedDataSourceLocator(primvarsLocDs) + .Build(); + names[count] = + _tokens->materialPrimvarTransfer_materialPrimvarsToPrimvars; + dataSources[count] = + dependencyDs; + count++; + } + } + + { + static const HdLocatorDataSourceHandle dependencyLocDs = + HdRetainedTypedSampledDataSource::New( + HdDependenciesSchema::GetDefaultLocator().Append( + _tokens-> + materialPrimvarTransfer_materialPrimvarsToPrimvars + )); + + static HdDataSourceBaseHandle const dependencyDs = + HdDependencySchema::Builder() + // Prim depends on itself. + .SetDependedOnDataSourceLocator(materialBindingsLocDs) + .SetAffectedDataSourceLocator(dependencyLocDs) + .Build(); + names[count] = + _tokens->materialPrimvarTransfer_materialBindingsToDependency; + dataSources[count] = + dependencyDs; + count++; + } + + return HdRetainedContainerDataSource::New( + count, names, dataSources); } - HdSceneIndexBaseRefPtr _inputScene; - HdContainerDataSourceHandle _inputDs; + HdSceneIndexBaseRefPtr const _inputScene; + HdContainerDataSourceHandle const _inputDs; }; } // anonymous namespace @@ -188,26 +217,20 @@ HdsiMaterialPrimvarTransferSceneIndex::New( HdSceneIndexPrim HdsiMaterialPrimvarTransferSceneIndex::GetPrim(const SdfPath& primPath) const { - if (HdSceneIndexBaseRefPtr input = _GetInputSceneIndex()) { - HdSceneIndexPrim prim = input->GetPrim(primPath); - - // won't have any bindings if we don't have a data source - if (prim.dataSource) { - prim.dataSource = _PrimDataSource::New(input, prim.dataSource); - } - return prim; + HdSceneIndexPrim prim = _GetInputSceneIndex()->GetPrim(primPath); + // won't have any bindings if we don't have a data source + if (prim.dataSource) { + prim.dataSource = + _PrimDataSource::New(_GetInputSceneIndex(), prim.dataSource); } - return { TfToken(), nullptr }; + return prim; } SdfPathVector HdsiMaterialPrimvarTransferSceneIndex::GetChildPrimPaths( const SdfPath& primPath) const { - if (HdSceneIndexBaseRefPtr input = _GetInputSceneIndex()) { - return input->GetChildPrimPaths(primPath); - } - return {}; + return _GetInputSceneIndex()->GetChildPrimPaths(primPath); } void From 9fc5b2cb9c383a1f0264bc66c4b76797ee13ea3c Mon Sep 17 00:00:00 2001 From: Mark Tucker Date: Thu, 7 Nov 2024 13:06:07 -0500 Subject: [PATCH 104/300] Implementing a vectorized version of FromPickHit called FromPickHits. This amortizes the high cost of computing instancer information when generating pick hit information for multiple hits with one function call. --- pxr/imaging/hdx/pickTask.cpp | 150 +++++++++++++++++++++++++---------- pxr/imaging/hdx/pickTask.h | 9 +++ 2 files changed, 117 insertions(+), 42 deletions(-) diff --git a/pxr/imaging/hdx/pickTask.cpp b/pxr/imaging/hdx/pickTask.cpp index ffa03df24e..3a16ea7627 100644 --- a/pxr/imaging/hdx/pickTask.cpp +++ b/pxr/imaging/hdx/pickTask.cpp @@ -53,6 +53,17 @@ TF_DEFINE_PRIVATE_TOKENS( (widgetDepthStencil) ); +namespace { + // Struct for holding instancing info generated by FromPickHit and + // FromPickHits. + struct _InstanceInfo { + SdfPath path; + HdContainerDataSourceHandle primSource; + VtArray instanceIndices; + VtArray instanceLocations; + }; +}; + static const int PICK_BUFFER_HEADER_SIZE = 8; static const int PICK_BUFFER_SUBBUFFER_CAPACITY = 32; static const int PICK_BUFFER_ENTRY_SIZE = 3; @@ -1042,51 +1053,49 @@ _ComputeInstancedByPath( // instantiating the prototype containing the given prim. // static -std::tuple, VtArray> +_InstanceInfo _ComputeInstancerAndInstanceIndicesAndLocations( HdSceneIndexBaseRefPtr const &sceneIndex, const SdfPath &primPath, HdContainerDataSourceHandle const &primSource) { + _InstanceInfo result({SdfPath(), nullptr, {}, {}}); const SdfPath instancerPath = _ComputeInstancedByPath(primSource); - if (instancerPath.IsEmpty()) { - return { SdfPath(), nullptr, {}, {} }; - } - HdContainerDataSourceHandle const instancerSource = - sceneIndex->GetPrim(instancerPath).dataSource; - - HdInstancerTopologySchema schema = - HdInstancerTopologySchema::GetFromParent(instancerSource); - if (!schema) { - return { SdfPath(), nullptr, {}, {} }; + if (!instancerPath.IsEmpty()) { + HdContainerDataSourceHandle const instancerSource = + sceneIndex->GetPrim(instancerPath).dataSource; + + HdInstancerTopologySchema schema = + HdInstancerTopologySchema::GetFromParent(instancerSource); + if (schema) { + HdPathArrayDataSourceHandle const instanceLocationsDs = + schema.GetInstanceLocations(); + + result.path = instancerPath; + result.primSource = instancerSource; + result.instanceIndices = + schema.ComputeInstanceIndicesForProto(primPath); + if (instanceLocationsDs) + result.instanceLocations = + instanceLocationsDs->GetTypedValue(0.0f); + } } - HdPathArrayDataSourceHandle const instanceLocationsDs = - schema.GetInstanceLocations(); - - return { instancerPath, - instancerSource, - schema.ComputeInstanceIndicesForProto(primPath), - instanceLocationsDs - ? instanceLocationsDs->GetTypedValue(0.0f) - : VtArray() }; + return result; } +// Implements the bulk of the FromPickHit[s] logic. The infoCache parameter +// can be set to null if no caching is desired. Otherwise the same cache +// object can be passed in to repeated calls to this function to prevent +// duplicate calls to _ComputeInstancerAndInstanceIndicesAndLocations. +static HdxPrimOriginInfo -HdxPrimOriginInfo::FromPickHit(HdRenderIndex * const renderIndex, - const HdxPickHit &hit) +_FromPickHitWithCache(HdSceneIndexBaseRefPtr const &sceneIndex, + const HdxPickHit &hit, + std::map *infoCache) { HdxPrimOriginInfo result; - - HdSceneIndexBaseRefPtr const sceneIndex = - renderIndex->GetTerminalSceneIndex(); - // Fallback value. - - if (!sceneIndex) { - return result; - } - SdfPath path = hit.objectId; HdContainerDataSourceHandle primSource = sceneIndex->GetPrim(path).dataSource; @@ -1109,13 +1118,30 @@ HdxPrimOriginInfo::FromPickHit(HdRenderIndex * const renderIndex, // Starting with the prim itself, ask for the instancer instancing // it and the instancer instancing that instancer and so on. while (true) { - VtArray instanceIndices; - VtArray instanceLocations; + _InstanceInfo instanceInfo; + + if (infoCache) { + auto it = infoCache->find(path); - // Get data from the instancer. - std::tie(path, primSource, instanceIndices, instanceLocations) = - _ComputeInstancerAndInstanceIndicesAndLocations( - sceneIndex, path, primSource); + if (it == infoCache->end()) { + // Get data from the instancer. + instanceInfo = + _ComputeInstancerAndInstanceIndicesAndLocations( + sceneIndex, path, primSource); + infoCache->emplace(path, instanceInfo); + } + else { + instanceInfo = it->second; + } + } + else { + // Get data from the instancer. + instanceInfo = + _ComputeInstancerAndInstanceIndicesAndLocations( + sceneIndex, path, primSource); + } + path = instanceInfo.path; + primSource = instanceInfo.primSource; if (!primSource) { break; @@ -1123,7 +1149,7 @@ HdxPrimOriginInfo::FromPickHit(HdRenderIndex * const renderIndex, // How often does the current instancer instantiate the // prototype containing the given prim (or inner instancer). - const size_t n = instanceIndices.size(); + const size_t n = instanceInfo.instanceIndices.size(); if (n == 0) { break; } @@ -1136,11 +1162,13 @@ HdxPrimOriginInfo::FromPickHit(HdRenderIndex * const renderIndex, const size_t i = instanceIndex % n; instanceIndex /= n; - ctx.instanceId = instanceIndices[i]; + ctx.instanceId = instanceInfo.instanceIndices[i]; - if ( ctx.instanceId >= 0 && - ctx.instanceId < static_cast(instanceLocations.size())) { - ctx.instanceSceneIndexPath = instanceLocations[ctx.instanceId]; + if (ctx.instanceId >= 0 && + ctx.instanceId < static_cast( + instanceInfo.instanceLocations.size())) { + ctx.instanceSceneIndexPath = + instanceInfo.instanceLocations[ctx.instanceId]; HdPrimOriginSchema schema = HdPrimOriginSchema::GetFromParent( @@ -1158,6 +1186,44 @@ HdxPrimOriginInfo::FromPickHit(HdRenderIndex * const renderIndex, return result; } +HdxPrimOriginInfo +HdxPrimOriginInfo::FromPickHit(HdRenderIndex * const renderIndex, + const HdxPickHit &hit) +{ + HdSceneIndexBaseRefPtr const sceneIndex = + renderIndex->GetTerminalSceneIndex(); + + // Fallback value. + if (!sceneIndex) { + return HdxPrimOriginInfo(); + } + + return _FromPickHitWithCache(sceneIndex, hit, nullptr); +} + +std::vector +HdxPrimOriginInfo::FromPickHits(HdRenderIndex * const renderIndex, + const std::vector &hits) +{ + std::vector resultVec; + std::map infoCache; + + resultVec.resize(hits.size()); + HdSceneIndexBaseRefPtr const sceneIndex = + renderIndex->GetTerminalSceneIndex(); + + // Fallback value. + if (!sceneIndex) { + return resultVec; + } + + for (int i = 0, n = hits.size(); i < n; i++) { + resultVec[i] = _FromPickHitWithCache(sceneIndex, hits[i], &infoCache); + } + + return resultVec; +} + // Consults given prim source for origin path to either replace // the given path (if origin path is absolute) or append to given // path (if origin path is relative). If no prim origin data source, diff --git a/pxr/imaging/hdx/pickTask.h b/pxr/imaging/hdx/pickTask.h index 92c78c4126..30a3968118 100644 --- a/pxr/imaging/hdx/pickTask.h +++ b/pxr/imaging/hdx/pickTask.h @@ -168,6 +168,15 @@ struct HdxPrimOriginInfo FromPickHit(HdRenderIndex * renderIndex, const HdxPickHit &hit); + /// Vectorized implementation of function to query terminal scene index + /// of render index for information about picked prim. Amortizes the cost + /// of computing the array of all instace indices and locations for + /// instancers. + HDX_API + static std::vector + FromPickHits(HdRenderIndex * renderIndex, + const std::vector &hits); + /// Combines instance scene paths and prim scene path to obtain the full /// scene path. /// From dfab98b8f1ae091dfc26815ad01ee8f2742e62df Mon Sep 17 00:00:00 2001 From: unhyperbolic Date: Fri, 8 Nov 2024 12:18:38 -0800 Subject: [PATCH 105/300] testUsdviewPrimvarEdits: adding test case where the varname of a primvar reader is changed. (Internal change: 2346866) --- pxr/usdImaging/bin/testusdview/CMakeLists.txt | 2 ++ .../add_primvars_for_varname_edit.png | Bin 0 -> 23366 bytes .../baseline/primvar_reader_varname_edit.png | Bin 0 -> 23075 bytes .../testUsdviewPrimvarEdits.py | 28 ++++++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 pxr/usdImaging/bin/testusdview/testenv/testUsdviewPrimvarEdits/baseline/add_primvars_for_varname_edit.png create mode 100644 pxr/usdImaging/bin/testusdview/testenv/testUsdviewPrimvarEdits/baseline/primvar_reader_varname_edit.png diff --git a/pxr/usdImaging/bin/testusdview/CMakeLists.txt b/pxr/usdImaging/bin/testusdview/CMakeLists.txt index 4c7d8799e9..810d4c96bb 100644 --- a/pxr/usdImaging/bin/testusdview/CMakeLists.txt +++ b/pxr/usdImaging/bin/testusdview/CMakeLists.txt @@ -1037,6 +1037,8 @@ pxr_register_test(testUsdviewPrimvarEdits remove_fallback_primvar_wireOnSurf.png add_unused_primvars.png remove_unused_primvars.png + add_primvars_for_varname_edit.png + primvar_reader_varname_edit.png FAIL 0.05 FAIL_PERCENT 0.03 PERCEPTUAL diff --git a/pxr/usdImaging/bin/testusdview/testenv/testUsdviewPrimvarEdits/baseline/add_primvars_for_varname_edit.png b/pxr/usdImaging/bin/testusdview/testenv/testUsdviewPrimvarEdits/baseline/add_primvars_for_varname_edit.png new file mode 100644 index 0000000000000000000000000000000000000000..c1e125e5c89de20010e235ab444dd087f9126258 GIT binary patch literal 23366 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 literal 0 HcmV?d00001 diff --git a/pxr/usdImaging/bin/testusdview/testenv/testUsdviewPrimvarEdits/baseline/primvar_reader_varname_edit.png b/pxr/usdImaging/bin/testusdview/testenv/testUsdviewPrimvarEdits/baseline/primvar_reader_varname_edit.png new file mode 100644 index 0000000000000000000000000000000000000000..23406f7b9005da6f5954fa3e4cf7b37279e7145f GIT binary patch literal 23075 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
  • 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 literal 0 HcmV?d00001 diff --git a/pxr/usdImaging/bin/testusdview/testenv/testUsdviewPrimvarEdits/testUsdviewPrimvarEdits.py b/pxr/usdImaging/bin/testusdview/testenv/testUsdviewPrimvarEdits/testUsdviewPrimvarEdits.py index 1bbdeda69c..0c288c2c0a 100644 --- a/pxr/usdImaging/bin/testusdview/testenv/testUsdviewPrimvarEdits/testUsdviewPrimvarEdits.py +++ b/pxr/usdImaging/bin/testusdview/testenv/testUsdviewPrimvarEdits/testUsdviewPrimvarEdits.py @@ -96,8 +96,36 @@ def _testAddRemovePrimvarNotUsedByMaterial(appController): _RemovePrimvar(prim, 'bar') appController._takeShot("remove_unused_primvars.png") +def _testPrimvarReaderVarnameEdit(appController): + # Test editing the inputs:varname of a primvar reader. + # + # In particular, there was a bug in Storm where the other primvar was + # pruned and thus changing the primvar reader to that other primvar + # resulted in the primvar not being picked up. + # + # https://github.com/PixarAnimationStudios/OpenUSD/issues/2382 + + # Setup the stage with two primvars and making the primvar reader + # consume one of the primvars. + stage = appController._dataModel.stage + prim = stage.GetPrimAtPath("/Scene/Geom/Plane") + mesh = UsdGeom.Imageable(prim) + _CreatePrimvar(mesh, 'myColorGreen', Sdf.ValueTypeNames.Float3, 'constant', + Gf.Vec3f(0.0, 1.0, 0.0)) + _CreatePrimvar(mesh, 'myColorBlue', Sdf.ValueTypeNames.Float3, 'constant', + Gf.Vec3f(0.0, 0.0, 1.0)) + varnameAttr = stage.GetAttributeAtPath("/Scene/Looks/MainMaterial/Primvar.inputs:varname") + varnameAttr.Set('myColorGreen') + # Take a snap shot to see whether the setup is correct. + appController._takeShot('add_primvars_for_varname_edit.png') + + # Now switch to the other primvar. + varnameAttr.Set('myColorBlue') + appController._takeShot('primvar_reader_varname_edit.png') + # This test adds and removes primvars that are used/unused by the material. def testUsdviewInputFunction(appController): _modifySettings(appController) _testAddRemovePrimvarUsedByMaterial(appController) _testAddRemovePrimvarNotUsedByMaterial(appController) + _testPrimvarReaderVarnameEdit(appController) From 15e1cdc2e8e5ef1ea6cebf1c920215c4997b9a0b Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Fri, 8 Nov 2024 12:18:46 -0800 Subject: [PATCH 106/300] cpp usdchecker - usdchecker.py has been removed and converted to usdchecker.cpp, which currently just forwards to the existing UsdUtils.ComplianceChecker python utility. - A subsequent change adds an option to use the new Usd Validation Framework instead, which will run ALL available UsdValidators, via UsdValidationContext, and report appropriate warnings/errors. Note that as all UsdUtilsCompliant tests are ported over to the new framework, this option will be the default. (Internal change: 2346881) --- pxr/usd/bin/usdchecker/CMakeLists.txt | 30 +-- .../baseline/variants_failedChecks.txt | 2 + pxr/usd/bin/usdchecker/usdchecker.cpp | 254 ++++++++++++++++++ pxr/usd/bin/usdchecker/usdchecker.py | 132 --------- 4 files changed, 270 insertions(+), 148 deletions(-) create mode 100644 pxr/usd/bin/usdchecker/usdchecker.cpp delete mode 100644 pxr/usd/bin/usdchecker/usdchecker.py diff --git a/pxr/usd/bin/usdchecker/CMakeLists.txt b/pxr/usd/bin/usdchecker/CMakeLists.txt index 18e489c09b..a63464b5b5 100644 --- a/pxr/usd/bin/usdchecker/CMakeLists.txt +++ b/pxr/usd/bin/usdchecker/CMakeLists.txt @@ -1,12 +1,22 @@ set(PXR_PREFIX pxr/usd) set(PXR_PACKAGE usd) -pxr_python_bin(usdchecker - DEPENDENCIES +pxr_cpp_bin(usdchecker + LIBRARIES + arch + tf + sdf usd - usdGeom + usdUtils ) +# Disable testing of the usdchecker on non python builds, until new validation +# framework is in place. +if (NOT PXR_ENABLE_PYTHON_SUPPORT) + message(STATUS "Skipping usdchecker tests because python is disabled") + return() +endif() + pxr_install_test_dir( SRC testenv/testUsdChecker DEST testUsdChecker1 @@ -28,26 +38,22 @@ pxr_install_test_dir( ) pxr_register_test(testUsdChecker1 - PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/bin/usdchecker clean/clean.usd" EXPECTED_RETURN_CODE 0 ) pxr_register_test(testUsdChecker2 - PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/bin/usdchecker clean/clean_flat.usdc" EXPECTED_RETURN_CODE 0 ) pxr_register_test(testUsdChecker3 - PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/bin/usdchecker clean/clean.usdz" EXPECTED_RETURN_CODE 0 ) pxr_register_test(testUsdChecker4 - PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/bin/usdchecker clean/clean_flat.usdz" EXPECTED_RETURN_CODE 0 ) @@ -74,26 +80,23 @@ pxr_install_test_dir( ) pxr_register_test(testUsdChecker5 - PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/bin/usdchecker --arkit clean/clean_arkit.usdz" EXPECTED_RETURN_CODE 0 ) pxr_register_test(testUsdChecker6 - PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/bin/usdchecker --arkit clean/clean_flat.usdc" EXPECTED_RETURN_CODE 1 ) +# Adding a "rootPackageOnly" option to the command line will make the clean files pxr_register_test(testUsdChecker7 - PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/bin/usdchecker --arkit --rootPackageOnly clean/clean_flat.usdz" EXPECTED_RETURN_CODE 0 ) pxr_register_test(testUsdChecker8 - PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/bin/usdchecker --arkit clean/clean_flat.usdz" EXPECTED_RETURN_CODE 1 ) @@ -119,27 +122,23 @@ pxr_install_test_dir( ) pxr_register_test(testUsdChecker9 - PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/bin/usdchecker bad/badUsdz.usdz" EXPECTED_RETURN_CODE 1 ) pxr_register_test(testUsdChecker10 - PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/bin/usdchecker --arkit --dumpRules bad/variants.usdc -o variants_failedChecks.txt" DIFF_COMPARE variants_failedChecks.txt EXPECTED_RETURN_CODE 1 ) pxr_register_test(testUsdChecker11 - PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/bin/usdchecker bad/brokenRef.usd" EXPECTED_RETURN_CODE 1 ) pxr_register_test(testUsdChecker12 - PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/bin/usdchecker --arkit bad/badShaderUnsupportedTexture.usdc" EXPECTED_RETURN_CODE 1 ) @@ -150,7 +149,6 @@ pxr_install_test_dir( ) pxr_register_test(testUsdChecker13 - PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/bin/usdchecker clean/cleanNormalMapReader.usda" EXPECTED_RETURN_CODE 0 ) diff --git a/pxr/usd/bin/usdchecker/testenv/testUsdChecker/baseline/variants_failedChecks.txt b/pxr/usd/bin/usdchecker/testenv/testUsdChecker/baseline/variants_failedChecks.txt index a4e1798ae2..bf6259eb28 100644 --- a/pxr/usd/bin/usdchecker/testenv/testUsdChecker/baseline/variants_failedChecks.txt +++ b/pxr/usd/bin/usdchecker/testenv/testUsdChecker/baseline/variants_failedChecks.txt @@ -10,3 +10,5 @@ Prim has unsupported type 'PointInstancer'. (fails 'ARKitPrimTypeC Prim has unsupported type 'PointInstancer'. (fails 'ARKitPrimTypeChecker') Prim has unsupported type 'PointInstancer'. (fails 'ARKitPrimTypeChecker') Prim has unsupported type 'PointInstancer'. (fails 'ARKitPrimTypeChecker') +Failed! + diff --git a/pxr/usd/bin/usdchecker/usdchecker.cpp b/pxr/usd/bin/usdchecker/usdchecker.cpp new file mode 100644 index 0000000000..c55adf1597 --- /dev/null +++ b/pxr/usd/bin/usdchecker/usdchecker.cpp @@ -0,0 +1,254 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// + +#include "pxr/pxr.h" + +#include "pxr/base/tf/fileUtils.h" +#include "pxr/base/tf/pxrCLI11/CLI11.h" + +#include "pxr/base/arch/fileSystem.h" + +#include +#include +#include +#include +#include + +#ifdef PXR_PYTHON_SUPPORT_ENABLED +#include "pxr/base/tf/pyInvoke.h" +#endif + +PXR_NAMESPACE_USING_DIRECTIVE + +using namespace pxr_CLI; + +#ifdef PXR_PYTHON_SUPPORT_ENABLED +using namespace pxr_boost::python; +#endif + +struct Args { + std::string inputFile; + bool skipVariants = false; + bool rootPackageOnly = false; + std::string outFile = "stdout"; + bool noAssetChecks = false; + bool arkit = false; + bool dumpRules = false; + bool verbose = false; + bool strict = false; +}; + +static +void Configure(CLI::App* app, Args& args) { + app->add_option( + "inputFile", args.inputFile, + "Name of the input file to inspect.") + ->type_name("FILE"); + app->add_flag( + "-s, --skipVariants", args.skipVariants, + "If specified, only the prims that are present in the default (i.e. " + "selected) variants are checked. When this option is not specified, " + "prims in all possible combinations of variant selections are " + "checked."); + app->add_flag( + "-p, --rootPackageOnly", args.rootPackageOnly, + "Check only the specified package. Nested packages, dependencies and " + "their contents are not validated."); + app->add_option( + "-o, --out", args.outFile, + "The file to which all the failed checks are output. If unspecified, " + "the failed checks are output to stdout; if \"stderr\", terminal " + "coloring will be suppressed.") + ->type_name("FILE"); + app->add_flag( + "--noAssetChecks", args.noAssetChecks, + "If specified, do NOT perform extra checks to help ensure the stage or " + "package can be easily and safely referenced into aggregate stages."); + app->add_flag( + "--arkit", args.arkit, + "Check if the given USD stage is compatible with RealityKit's " + "implementation of USDZ as of 2023. These assets operate under greater " + "constraints that usdz files for more general in-house uses, and this " + "option attempts to ensure that these constraints are met."); + app->add_flag( + "-d, --dumpRules", args.dumpRules, "Dump the enumerated set of rules " + "being checked for the given set of options."); + app->add_flag( + "-v, --verbose", args.verbose, + "Enable verbose output mode."); + app->add_flag( + "-t, --strict", args.strict, + "Return failure code even if only warnings are issued, for stricter " + "compliance."); +} + +static +bool ValidateArgs(const Args& args) { + // Check conflicting options + if (args.rootPackageOnly && args.skipVariants) { + std::cerr<<"Error: The options --rootPackageOnly and --skipVariants " + "are mutually exclusive.\n"; + return false; + } + + if (!args.dumpRules && args.inputFile.empty()) { + std::cerr<<"Error: Either an inputFile or the --dumpRules option " + "must be specified.\n"; + return false; + } + + return true; +} + +using StringVector = std::vector; + +static +int +UsdChecker(const Args& args) { + if (!ValidateArgs(args)) { + return 1; + } + + #ifndef PXR_PYTHON_SUPPORT_ENABLED + + std::cerr<<"usdchecker using UsdUtilsComplianceChecker requires Python " + "support to be enabled in the OpenUSD build. Please rebuild USD with " + "Python support enabled.\n"; + return 1; + + #else + + try { + TfPyInitialize(); + TfPyLock gil; + + TfPyKwArg arkitArg("arkit", args.arkit); + TfPyKwArg skipARKitRootLayerCheck("skipARKitRootLayerCheck", false); + TfPyKwArg rootPackageOnlyArg("rootPackageOnly", args.rootPackageOnly); + TfPyKwArg skipVariantsArg("skipVariants", args.skipVariants); + TfPyKwArg verboseArg("verbose", args.verbose); + TfPyKwArg assetLevelChecks("assetLevelChecks", !args.noAssetChecks); + + object checker; + if (!TfPyInvokeAndReturn( + "pxr.UsdUtils", "ComplianceChecker", &checker, arkitArg, + skipARKitRootLayerCheck, rootPackageOnlyArg, + skipVariantsArg, verboseArg, assetLevelChecks)) { + std::cerr<<"Error: Failed to initialize ComplianceChecker.\n"; + return 1; + } + + if (!checker) { + std::cerr<<"Error: Failed to initialize ComplianceChecker.\n"; + return 1; + } + + if (args.dumpRules) { + checker.attr("DumpRules")(); + // If there's no input file to check, exit after dumping the rules. + if (args.inputFile.empty()) { + return 0; + } + } + + // We must have an input file to check, based on the validation above + checker.attr("CheckCompliance")(args.inputFile); + + // Extract warnings, errors, and failed checks from ComplianceChecker. + StringVector warnings = extract( + checker.attr("GetWarnings")()); + StringVector errors = extract( + checker.attr("GetErrors")()); + StringVector failedChecks = extract( + checker.attr("GetFailedChecks")()); + + std::ofstream outFileStream; + std::ostream &output = [&]() -> std::ostream & { + if (args.outFile == "stderr") { + return std::cerr; + } + if (args.outFile == "stdout") { + return std::cout; + } + outFileStream.open(args.outFile); + if (!outFileStream) { + std::cerr<<"Error: Failed to open output file "< 0: - print("Success with warnings...") - else: - print("Success!") - return 0 - -if __name__ == '__main__': - sys.exit(main()) From dac626e4dc242077db8fe2ff3ecd6bc7905e9881 Mon Sep 17 00:00:00 2001 From: unhyperbolic Date: Fri, 8 Nov 2024 12:19:01 -0800 Subject: [PATCH 107/300] HdStDependencySceneIndex: 1. Adding a dependency of the material binding of a prim on the material's data source of the bound material. 2. Fixing a bug where HdContainerDataSourceEditor::Overlay was called twice for the dependencies locator. This resulted in the data source given in the second call to be overlayed over the the dependencies of the input container data source and the data source given in the first call to be ignored. 3. Removing dependencies that are already added by the HdsiMaterialPrimvarTransferSceneIndex. (Internal change: 2346925) --- .../hdSt/dependencySceneIndexPlugin.cpp | 325 +++++++++--------- pxr/imaging/hdSt/dependencySceneIndexPlugin.h | 20 +- 2 files changed, 178 insertions(+), 167 deletions(-) diff --git a/pxr/imaging/hdSt/dependencySceneIndexPlugin.cpp b/pxr/imaging/hdSt/dependencySceneIndexPlugin.cpp index 34498488d2..aaff9eaff5 100644 --- a/pxr/imaging/hdSt/dependencySceneIndexPlugin.cpp +++ b/pxr/imaging/hdSt/dependencySceneIndexPlugin.cpp @@ -15,7 +15,6 @@ #include "pxr/imaging/hd/materialSchema.h" #include "pxr/imaging/hd/overlayContainerDataSource.h" #include "pxr/imaging/hd/perfLog.h" -#include "pxr/imaging/hd/primvarsSchema.h" #include "pxr/imaging/hd/retainedDataSource.h" #include "pxr/imaging/hd/sceneIndexPluginRegistry.h" @@ -28,9 +27,11 @@ PXR_NAMESPACE_OPEN_SCOPE TF_DEFINE_PRIVATE_TOKENS( _tokens, ((sceneIndexPluginName, "HdSt_DependencySceneIndexPlugin")) - (primvarsToMaterial) - (primvarsToMaterialDependencyToMaterialBindings) - (primvarsToMaterialBindings) + + (storm_volumeFieldBindingToDependency) + + (storm_materialToMaterialBindings) + (storm_materialBindingsToDependency) ); static const char * const _pluginDisplayName = "GL"; @@ -58,159 +59,204 @@ TF_REGISTRY_FUNCTION(HdSceneIndexPlugin) namespace { -/// Given a prim path data source, returns a dependency of volumeFieldBinding -/// on volumeField of that given prim. -HdDataSourceBaseHandle -_ComputeVolumeFieldDependency(const HdDataSourceBaseHandle &src) +void _AddIfNecessary(const TfToken &name, TfTokenVector * const names) { - HdDependencySchema::Builder builder; + if (std::find(names->begin(), names->end(), name) == names->end()) { + names->push_back(name); + } +} - builder.SetDependedOnPrimPath(HdPathDataSource::Cast(src)); +HdContainerDataSourceHandle +_ComputeMaterialBindingsDependency( + HdContainerDataSourceHandle const &inputDs) +{ + const HdMaterialBindingsSchema materialBindings = + HdMaterialBindingsSchema::GetFromParent(inputDs); + + TfToken names[2]; + HdDataSourceBaseHandle dataSources[2]; + size_t count = 0; - static HdLocatorDataSourceHandle dependedOnLocatorDataSource = + static HdLocatorDataSourceHandle const materialLocDs = HdRetainedTypedSampledDataSource::New( - HdVolumeFieldSchema::GetDefaultLocator()); - builder.SetDependedOnDataSourceLocator(dependedOnLocatorDataSource); - - static HdLocatorDataSourceHandle affectedLocatorDataSource = + HdMaterialSchema::GetDefaultLocator()); + static HdLocatorDataSourceHandle const materialBindingsLocDs = HdRetainedTypedSampledDataSource::New( - HdVolumeFieldBindingSchema::GetDefaultLocator()); - builder.SetAffectedDataSourceLocator(affectedLocatorDataSource); - return builder.Build(); -} + HdMaterialBindingsSchema::GetDefaultLocator()); -/// Given a prim path, returns a dependency of __dependencies -/// on volumeFieldBinding of the given prim. + // HdsiMaterialBindingResolvingSceneIndex already ran, so we can just + // call GetMaterialBinding here (which uses the allPurpose binding). + if (HdPathDataSourceHandle const pathDs = + materialBindings.GetMaterialBinding().GetPath()) { + if (!pathDs->GetTypedValue(0.0f).IsEmpty()) { + HdDataSourceBaseHandle const dependencyDs = + HdDependencySchema::Builder() + .SetDependedOnPrimPath(pathDs) + .SetDependedOnDataSourceLocator(materialLocDs) + .SetAffectedDataSourceLocator(materialBindingsLocDs) + .Build(); + names[count] = _tokens->storm_materialToMaterialBindings; + dataSources[count] = dependencyDs; + count++; + } + } -HdContainerDataSourceHandle -_ComputeVolumeFieldBindingDependency(const SdfPath &primPath) + { + static const HdLocatorDataSourceHandle dependencyLocDs = + HdRetainedTypedSampledDataSource::New( + HdDependenciesSchema::GetDefaultLocator().Append( + _tokens->storm_materialToMaterialBindings)); + static HdDataSourceBaseHandle const dependencyDs = + HdDependencySchema::Builder() + // Prim depends on itself. + .SetDependedOnDataSourceLocator(materialBindingsLocDs) + .SetAffectedDataSourceLocator(dependencyLocDs) + .Build(); + names[count] = _tokens->storm_materialBindingsToDependency; + dataSources[count] = dependencyDs; + count++; + } + + return HdRetainedContainerDataSource::New( + count, names, dataSources); +} + +/// Given a prim path data source, returns a dependency of volumeFieldBinding +/// on volumeField of that given prim. +HdDataSourceBaseHandle +_ComputeVolumeFieldDependency(const HdDataSourceBaseHandle &pathDs) { - HdDependencySchema::Builder builder; - - builder.SetDependedOnPrimPath( - HdRetainedTypedSampledDataSource::New( - primPath)); - static HdLocatorDataSourceHandle dependedOnLocatorDataSource = HdRetainedTypedSampledDataSource::New( - HdVolumeFieldBindingSchema::GetDefaultLocator()); - builder.SetDependedOnDataSourceLocator(dependedOnLocatorDataSource); - + HdVolumeFieldSchema::GetDefaultLocator()); static HdLocatorDataSourceHandle affectedLocatorDataSource = HdRetainedTypedSampledDataSource::New( - HdDependenciesSchema::GetDefaultLocator()); - builder.SetAffectedDataSourceLocator(affectedLocatorDataSource); + HdVolumeFieldBindingSchema::GetDefaultLocator()); - return - HdRetainedContainerDataSource::New( - HdVolumeFieldBindingSchemaTokens->volumeFieldBinding, - builder.Build()); + return + HdDependencySchema::Builder() + .SetDependedOnPrimPath(HdPathDataSource::Cast(pathDs)) + .SetDependedOnDataSourceLocator(dependedOnLocatorDataSource) + .SetAffectedDataSourceLocator(affectedLocatorDataSource) + .Build(); } HdContainerDataSourceHandle _ComputeVolumeFieldBindingDependencies( - const SdfPath &primPath, const HdContainerDataSourceHandle &primSource) { - return HdOverlayContainerDataSource::New( + return HdMapContainerDataSource::New( _ComputeVolumeFieldDependency, - HdContainerDataSource::Cast( - HdContainerDataSource::Get( - primSource, - HdVolumeFieldBindingSchema::GetDefaultLocator()))), - _ComputeVolumeFieldBindingDependency(primPath)); + HdVolumeFieldBindingSchema::GetFromParent(primSource) + .GetContainer()); } -/// Given a material prim path data source, returns a dependency of primvars -/// on material of that given prim. +/// Given a prim path, returns a dependency of __dependencies +/// on volumeFieldBinding of the given prim. + HdContainerDataSourceHandle -_ComputePrimvarsToMaterialDependency(const SdfPath &materialPrimPath) +_ComputeVolumeFieldBindingDependencyDependencies() { - HdDependencySchema::Builder builder; - - builder.SetDependedOnPrimPath( - HdRetainedTypedSampledDataSource::New( - materialPrimPath)); - static HdLocatorDataSourceHandle dependedOnLocatorDataSource = HdRetainedTypedSampledDataSource::New( - HdMaterialSchema::GetDefaultLocator()); - builder.SetDependedOnDataSourceLocator(dependedOnLocatorDataSource); - + HdVolumeFieldBindingSchema::GetDefaultLocator()); static HdLocatorDataSourceHandle affectedLocatorDataSource = HdRetainedTypedSampledDataSource::New( - HdPrimvarsSchema::GetDefaultLocator()); - builder.SetAffectedDataSourceLocator(affectedLocatorDataSource); + HdDependenciesSchema::GetDefaultLocator()); return HdRetainedContainerDataSource::New( - _tokens->primvarsToMaterial, - builder.Build()); + _tokens->storm_volumeFieldBindingToDependency, + HdDependencySchema::Builder() + .SetDependedOnDataSourceLocator(dependedOnLocatorDataSource) + .SetAffectedDataSourceLocator(affectedLocatorDataSource) + .Build()); } - -/// Returns a dependency of the above (primvars -> material) dependency -/// on material bindings. -HdContainerDataSourceHandle -_ComputeDependencyToMaterialBindingsDependency() + +class _PrimDataSource : public HdContainerDataSource { - HdDependencySchema::Builder builder; - - static HdLocatorDataSourceHandle dependedOnLocatorDataSource = - HdRetainedTypedSampledDataSource::New( - HdMaterialBindingsSchema::GetDefaultLocator()); - builder.SetDependedOnDataSourceLocator(dependedOnLocatorDataSource); - - static HdLocatorDataSourceHandle affectedLocatorDataSource = - HdRetainedTypedSampledDataSource::New( - HdDependenciesSchema::GetDefaultLocator().Append( - _tokens->primvarsToMaterial)); - builder.SetAffectedDataSourceLocator(affectedLocatorDataSource); +public: + HD_DECLARE_DATASOURCE(_PrimDataSource) - return - HdRetainedContainerDataSource::New( - _tokens->primvarsToMaterialDependencyToMaterialBindings, - builder.Build()); -} + TfTokenVector GetNames() override + { + TfTokenVector result = _inputPrim.dataSource->GetNames(); + if ( _inputPrim.primType == HdPrimTypeTokens->volume + || HdMaterialBindingsSchema::GetFromParent( + _inputPrim.dataSource)) { + _AddIfNecessary(HdDependenciesSchema::GetSchemaToken(), &result); + } + return result; + } -/// Returns a dependency of primvars on material bindings. -HdContainerDataSourceHandle -_ComputePrimvarsToMaterialBindingsDependency() -{ - HdDependencySchema::Builder builder; + HdDataSourceBaseHandle Get(const TfToken &name) override + { + if (name == HdDependenciesSchema::GetSchemaToken()) { + return _GetDependencies(); + } + return _inputPrim.dataSource->Get(name); + } - static HdLocatorDataSourceHandle dependedOnLocatorDataSource = - HdRetainedTypedSampledDataSource::New( - HdMaterialBindingsSchema::GetDefaultLocator()); - builder.SetDependedOnDataSourceLocator(dependedOnLocatorDataSource); +private: + _PrimDataSource( + const HdSceneIndexPrim &inputPrim) + : _inputPrim(inputPrim) + { + } - static HdLocatorDataSourceHandle affectedLocatorDataSource = - HdRetainedTypedSampledDataSource::New( - HdPrimvarsSchema::GetDefaultLocator()); - builder.SetAffectedDataSourceLocator(affectedLocatorDataSource); + HdContainerDataSourceHandle _GetDependencies() const { + HdContainerDataSourceHandle dataSources[10]; + size_t count = 0; - return - HdRetainedContainerDataSource::New( - _tokens->primvarsToMaterialBindings, - builder.Build()); -} + if (HdContainerDataSourceHandle const ds = + HdDependenciesSchema::GetFromParent(_inputPrim.dataSource) + .GetContainer()) { + dataSources[count] = + ds; + count++; + } -HdContainerDataSourceHandle -_ComputePrimvarsToMaterialDependencies( - const SdfPath &materialPrimPath, - const HdContainerDataSourceHandle &primSource) -{ - return HdOverlayContainerDataSource::New( - _ComputePrimvarsToMaterialDependency(materialPrimPath), - _ComputeDependencyToMaterialBindingsDependency(), - _ComputePrimvarsToMaterialBindingsDependency()); -} + if (_inputPrim.primType == HdPrimTypeTokens->mesh) { + // TODO: We need to add dependencies on the material's + // bound by geomSubset's since geomSubset's could bind a + // material with a ptex. + // Note that, along similar lines, adding or removing a geomSubset + // can also mean we need to trigger the prim. + // Unfortunately, the dependencies schema does not allow us to + // say that we want to dirty a locator in response to child prims + // being added or removed. + dataSources[count] = + _ComputeMaterialBindingsDependency( + _inputPrim.dataSource); + count++; + } + + if (_inputPrim.primType == HdPrimTypeTokens->volume) { + dataSources[count] = + _ComputeVolumeFieldBindingDependencies( + _inputPrim.dataSource); + count++; + dataSources[count] = + _ComputeVolumeFieldBindingDependencyDependencies(); + count++; + } -TF_DECLARE_REF_PTRS(_SceneIndex); + switch(count) { + case 0: return nullptr; + case 1: return dataSources[0]; + default: return HdOverlayContainerDataSource::New(count, dataSources); + } + } + + const HdSceneIndexPrim _inputPrim; +}; /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// +TF_DECLARE_REF_PTRS(_SceneIndex); + /// \class _SceneIndex /// /// The scene index that adds dependencies for volume prims. @@ -226,34 +272,11 @@ class _SceneIndex : public HdSingleInputFilteringSceneIndexBase HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override { - const HdSceneIndexPrim prim = _GetInputSceneIndex()->GetPrim(primPath); - - HdContainerDataSourceEditor editedDs = - HdContainerDataSourceEditor(prim.dataSource); - - if (prim.primType == HdPrimTypeTokens->volume) { - editedDs.Overlay( - HdDependenciesSchema::GetDefaultLocator(), - HdLazyContainerDataSource::New( - std::bind(_ComputeVolumeFieldBindingDependencies, - primPath, prim.dataSource))); + HdSceneIndexPrim prim = _GetInputSceneIndex()->GetPrim(primPath); + if (prim.dataSource) { + prim.dataSource = _PrimDataSource::New(prim); } - - // If prim has material binding, overlay dependencies from material to - // prim's primvars. - if (HdPathDataSourceHandle materialPrimPathDs = _GetMaterialBindingPath( - prim.dataSource)) { - const SdfPath materialPrimPath = - materialPrimPathDs->GetTypedValue(0.f); - - editedDs.Overlay( - HdDependenciesSchema::GetDefaultLocator(), - HdLazyContainerDataSource::New( - std::bind(_ComputePrimvarsToMaterialDependencies, - materialPrimPath, prim.dataSource))); - } - - return { prim.primType, editedDs.Finish() }; + return prim; } SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override @@ -273,10 +296,6 @@ class _SceneIndex : public HdSingleInputFilteringSceneIndexBase const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries) override { - if (!_IsObserved()) { - return; - } - _SendPrimsAdded(entries); } @@ -284,10 +303,6 @@ class _SceneIndex : public HdSingleInputFilteringSceneIndexBase const HdSceneIndexBase &sender, const HdSceneIndexObserver::RemovedPrimEntries &entries) override { - if (!_IsObserved()) { - return; - } - _SendPrimsRemoved(entries); } @@ -295,24 +310,8 @@ class _SceneIndex : public HdSingleInputFilteringSceneIndexBase const HdSceneIndexBase &sender, const HdSceneIndexObserver::DirtiedPrimEntries &entries) override { - HD_TRACE_FUNCTION(); - - if (!_IsObserved()) { - return; - } - _SendPrimsDirtied(entries); } - - HdPathDataSourceHandle - _GetMaterialBindingPath(const HdContainerDataSourceHandle &ds) const - { - HdMaterialBindingsSchema materialBindings = - HdMaterialBindingsSchema::GetFromParent(ds); - HdMaterialBindingSchema materialBinding = - materialBindings.GetMaterialBinding(); - return materialBinding.GetPath(); - } }; } diff --git a/pxr/imaging/hdSt/dependencySceneIndexPlugin.h b/pxr/imaging/hdSt/dependencySceneIndexPlugin.h index 1cabd01af2..ea3cd3aec8 100644 --- a/pxr/imaging/hdSt/dependencySceneIndexPlugin.h +++ b/pxr/imaging/hdSt/dependencySceneIndexPlugin.h @@ -28,10 +28,22 @@ PXR_NAMESPACE_OPEN_SCOPE /// using that volume field will be dirtied so that HdStVolume will update /// which 3d textures it will use. /// -/// 2) For adding dependencies between a prim's primvars and its material. -/// For render delegates that do primvar filtering, such as Storm, invalidation -/// of a material or material binding should result in invalidation of any -/// associated prim's primvars, so they can be correctly filtered again. +/// 2) For meshes. +/// Adding dependency of the material binding on the material datasource +/// of the bound material. +/// Recall that a mesh has to be quadrangulated if the bound material is using +/// any ptex texture. If there is any change to the material, this scene index +/// will dirty the mesh's materialBindings locator. This causes a +/// HdStMesh::Sync with the HdChangeTracker::DirtyMaterialId dirty bit set so +/// the mesh will re-evaluate whether the bound material is using any ptex +/// texture. +/// Note that this was previously achieved by HdStMaterial::Sync calling +/// HdChangeTracker::MarkAllRprimsDirty when a material has changed in such a +/// way that the _hasPtex flag has changed. +/// HdChangeTracker::MarkAllRprimsDirty, however, only works for prims +/// originating from a scene delegate (that is, being added to the legacy +/// retained scene index used by emulation). Furthermore, that call did +/// do a potentially massive overinvalidation. /// class HdSt_DependencySceneIndexPlugin : public HdSceneIndexPlugin { From 7d01c2c96cd64ab3429e1e55135f334af5ec07df Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Fri, 8 Nov 2024 12:19:12 -0800 Subject: [PATCH 108/300] Disable usdchecker for static builds and for nopy builds Note that usdchecker as of right now depends on calling UsdUtils.ComplianceChecker python module, which are not build in static builds. In a subsequent change, usdchecker will be updated to also work with the new validation framework, which will remove this dependency on ComplianceChecker and make it work with static builds. (Internal change: 2346963) --- pxr/usd/bin/usdchecker/CMakeLists.txt | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/pxr/usd/bin/usdchecker/CMakeLists.txt b/pxr/usd/bin/usdchecker/CMakeLists.txt index a63464b5b5..f9a934ee2a 100644 --- a/pxr/usd/bin/usdchecker/CMakeLists.txt +++ b/pxr/usd/bin/usdchecker/CMakeLists.txt @@ -1,3 +1,19 @@ +# Disable usdchecker on non python builds, until new validation framework is in +# place. +if (NOT PXR_ENABLE_PYTHON_SUPPORT) + message(STATUS "Skipping usdchecker because python is disabled") + return() +endif() + +# usdchecker currently depends on UsdUtilsComplianceChecker python module, which +# are not build and installed on static builds. We disable usdchecker on static +# builds until we introduce the option to use the new validation framework in a +# subsequent change. +if (NOT BUILD_SHARED_LIBS) + message(STATUS "Skipping usdchecker because static build is enabled") + return() +endif() + set(PXR_PREFIX pxr/usd) set(PXR_PACKAGE usd) @@ -10,13 +26,6 @@ pxr_cpp_bin(usdchecker usdUtils ) -# Disable testing of the usdchecker on non python builds, until new validation -# framework is in place. -if (NOT PXR_ENABLE_PYTHON_SUPPORT) - message(STATUS "Skipping usdchecker tests because python is disabled") - return() -endif() - pxr_install_test_dir( SRC testenv/testUsdChecker DEST testUsdChecker1 From 27b75a17eafc47d2766c635d935b2d6f9fedc12b Mon Sep 17 00:00:00 2001 From: matthewcpp Date: Fri, 8 Nov 2024 12:19:37 -0800 Subject: [PATCH 109/300] 2343722 added a new _didChangeSpecsAndChildrenInternal container to PcpCacheChanges for storing specs whose children also changed in order to limit the growth of the _didChangeSpecsInternal container resulting in a performance gain. In the initial implementation, processing of this container was identical to that of _didChangeSpecsInternal. The existing updateSpecStacks function contains code paths which may modify the state of the prim index cache during invocation. Since the index cache is used for processing of _didChangeSpecsAndChildrenInternal, this could result in errors during iteration and processing if one of those branches were to ever be followed. This change provides and more applicable name to this container and streamlines the processing of the items in _didChangePrimSpecsAndChildrenInternal to include only logic which ensures that prim stacks are updated. Relevant property and target path caches are updated due to their parent paths having signficiantly changed due to addional / removal. (Internal change: 2347031) --- pxr/usd/pcp/cache.cpp | 12 +++++++++--- pxr/usd/pcp/changes.cpp | 4 +++- pxr/usd/pcp/changes.h | 6 +++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pxr/usd/pcp/cache.cpp b/pxr/usd/pcp/cache.cpp index e07a52fdcb..9356afbe0b 100644 --- a/pxr/usd/pcp/cache.cpp +++ b/pxr/usd/pcp/cache.cpp @@ -1058,7 +1058,7 @@ PcpCache::Apply(const PcpCacheChanges& changes, PcpLifeboat* lifeboat) _RemovePropertyCache(path, lifeboat); } else if (path.IsTargetPath()) { - // We have potentially aded or removed a relationship target + // We have potentially added or removed a relationship target // spec. This invalidates the property stack for any // relational attributes for this target. _RemovePropertyCaches(path, lifeboat); @@ -1073,10 +1073,16 @@ PcpCache::Apply(const PcpCacheChanges& changes, PcpLifeboat* lifeboat) updateSpecStacks(*i); } - TF_FOR_ALL(i, changes._didChangeSpecsAndChildrenInternal) { + // Ensure that all relevant paths that have been affected by + // sublayer operations have their prim stacks updated + TF_FOR_ALL(i, changes._didChangePrimSpecsAndChildrenInternal) { auto range = _primIndexCache.FindSubtreeRange(*i); for (auto i = range.first; i != range.second; ++i) { - updateSpecStacks(i->first); + if (PcpPrimIndex* primIndex = _GetPrimIndex(i->first)) { + Pcp_RescanForSpecs(primIndex, IsUsd(), + /* updateHasSpecs */ true, + &changes); + } } } diff --git a/pxr/usd/pcp/changes.cpp b/pxr/usd/pcp/changes.cpp index 99528bc1b5..e724adb217 100644 --- a/pxr/usd/pcp/changes.cpp +++ b/pxr/usd/pcp/changes.cpp @@ -2040,6 +2040,8 @@ PcpChanges::_Optimize(PcpCacheChanges* changes) Pcp_SubsumeDescendants(&changes->didChangePrims, *i); Pcp_SubsumeDescendants(&changes->didChangeSpecs, *i); Pcp_SubsumeDescendants(&changes->_didChangeSpecsInternal, *i); + Pcp_SubsumeDescendants( + &changes->_didChangePrimSpecsAndChildrenInternal, *i); } // Subsume spec changes for prims whose indexes will be rebuilt. @@ -2865,7 +2867,7 @@ void PcpChanges::_DidChangeSpecStackAndChildrenInternal( const PcpCache* cache, const SdfPath& path) { - _GetCacheChanges(cache)._didChangeSpecsAndChildrenInternal.insert(path); + _GetCacheChanges(cache)._didChangePrimSpecsAndChildrenInternal.insert(path); } PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usd/pcp/changes.h b/pxr/usd/pcp/changes.h index ad7b5cc9f6..96edfd3a48 100644 --- a/pxr/usd/pcp/changes.h +++ b/pxr/usd/pcp/changes.h @@ -156,9 +156,9 @@ class PcpCacheChanges { // This set serves a similar purpose to _didChangeSpecsInternal above, // however, during processing descendants of the specs in this set will also // be marked as changed. A performance gain is accomplished by placing the - // ancestor specs in this set and marking children iteratively when applying - // changes to the cache. - SdfPathSet _didChangeSpecsAndChildrenInternal; + // ancestor specs in this set and processing children iteratively when + // applying changes to the cache. + SdfPathSet _didChangePrimSpecsAndChildrenInternal; }; /// Structure used to temporarily retain layers and layerStacks within From 1437c38b146163e52328098c4a8b22b50e769f19 Mon Sep 17 00:00:00 2001 From: pixar-oss Date: Fri, 8 Nov 2024 14:41:56 -0800 Subject: [PATCH 110/300] Changed logic in HdPrman_UpdateObjectSettings_DataSource::Get() to check for a 'primvars' token first, avoiding unnecessary computation. (Internal change: 2347061) --- .../hdPrman/updateObjectSettingsSceneIndex.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/third_party/renderman-26/plugin/hdPrman/updateObjectSettingsSceneIndex.cpp b/third_party/renderman-26/plugin/hdPrman/updateObjectSettingsSceneIndex.cpp index 5946e70112..980852c9fb 100644 --- a/third_party/renderman-26/plugin/hdPrman/updateObjectSettingsSceneIndex.cpp +++ b/third_party/renderman-26/plugin/hdPrman/updateObjectSettingsSceneIndex.cpp @@ -151,17 +151,17 @@ class HdPrman_UpdateObjectSettings_DataSource HdDataSourceBaseHandle Get(const TfToken &name) override { - HdDataSourceBaseHandle result; - if (_inputPrimDs) { - result = _inputPrimDs->Get(name); - } if (name == HdPrimvarsSchemaTokens->primvars) { if (HdPrimvarsSchema primvars = HdPrimvarsSchema::GetFromParent(_inputPrimDs)) { - result = _UpdatePrimvars(primvars); + return _UpdatePrimvars(primvars); } } - return result; + if (_inputPrimDs) { + return _inputPrimDs->Get(name); + } + + return nullptr; } protected: From 35471497578fda313fe52bfed52c95d0f3919d8f Mon Sep 17 00:00:00 2001 From: anwang2009 Date: Fri, 8 Nov 2024 14:42:06 -0800 Subject: [PATCH 111/300] BBoxCache in usdview initializes with placeholder "display purposes". We should refresh view settings at AppController initialization so that the actual "display purposes" selection is propagated to the BBoxCache. This fixes a bug where some bboxes are not displayed on usdview startup when "display purpose Render" is set by default. (Internal change: 2347104) --- pxr/usdImaging/usdviewq/appController.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pxr/usdImaging/usdviewq/appController.py b/pxr/usdImaging/usdviewq/appController.py index e09297b8c7..8e66b7f9bf 100644 --- a/pxr/usdImaging/usdviewq/appController.py +++ b/pxr/usdImaging/usdviewq/appController.py @@ -1123,6 +1123,9 @@ def __init__(self, parserData, resolverContextFn): if self._stageView: self._stageView.setUpdatesEnabled(False) + # Update the BBox cache with the initial state's purposes. + self._stageView.updateBboxPurposes() + self._mainWindow.update() QtWidgets.QApplication.processEvents() From c3be376d669d7ce64dd37952cc56e1ab13a10976 Mon Sep 17 00:00:00 2001 From: blevin Date: Fri, 8 Nov 2024 14:42:22 -0800 Subject: [PATCH 112/300] Enable parallel sync for certain prim types in HdPrman, including materials and coordinate systems. The new codepath sites behind the HD_PRMAN_ENABLE_PARALLEL_PRIM_SYNC feature flag, which is enabled by default. (Internal change: 2347140) --- .../plugin/hdPrman/renderDelegate.cpp | 27 +++++++++++++++++++ .../plugin/hdPrman/renderDelegate.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/third_party/renderman-26/plugin/hdPrman/renderDelegate.cpp b/third_party/renderman-26/plugin/hdPrman/renderDelegate.cpp index aa63ab465b..df2b01b374 100644 --- a/third_party/renderman-26/plugin/hdPrman/renderDelegate.cpp +++ b/third_party/renderman-26/plugin/hdPrman/renderDelegate.cpp @@ -57,6 +57,12 @@ PXR_NAMESPACE_OPEN_SCOPE +TF_DEFINE_ENV_SETTING( + HD_PRMAN_ENABLE_PARALLEL_PRIM_SYNC, true, + "Enables parallel prim Sync for supported prim types"); +static bool _enableParallelPrimSync = + TfGetEnvSetting(HD_PRMAN_ENABLE_PARALLEL_PRIM_SYNC); + // \class HdPrmanRenderDelegate::_RileySceneIndices. // // Holds the scene indices and scene index observers past the terminal scene @@ -933,6 +939,27 @@ HdPrmanRenderDelegate::Update() #endif } +bool +HdPrmanRenderDelegate::IsParallelSyncEnabled(const TfToken &primType) const +{ + // The prim types below have been reviewed for Sync thread safety. + // + // Notable exceptions include integrator, renderSettings, + // volume, and lights. These exceptions are generally due + // to interaction with HdChangeTracker state. + return + _enableParallelPrimSync && ( +#if PXR_VERSION >= 2311 + primType == HdPrimTypeTokens->camera || + primType == HdPrimTypeTokens->coordSys || + primType == HdPrimTypeTokens->displayFilter || + primType == HdPrimTypeTokens->lightFilter || + primType == HdPrimTypeTokens->material || + primType == HdPrimTypeTokens->sampleFilter || +#endif + false); +} + #endif PXR_NAMESPACE_CLOSE_SCOPE diff --git a/third_party/renderman-26/plugin/hdPrman/renderDelegate.h b/third_party/renderman-26/plugin/hdPrman/renderDelegate.h index 13ed0b18f5..9b31b8bd3b 100644 --- a/third_party/renderman-26/plugin/hdPrman/renderDelegate.h +++ b/third_party/renderman-26/plugin/hdPrman/renderDelegate.h @@ -235,6 +235,9 @@ class HdPrmanRenderDelegate : public HdRenderDelegate HDPRMAN_API void Update() override; + HDPRMAN_API + virtual bool IsParallelSyncEnabled(const TfToken &primType) const override; + #endif // ------------------------------------------------------------------------ From 64c8a397e3a9c7a48dd0dee48901a04913ee16b3 Mon Sep 17 00:00:00 2001 From: blevin Date: Fri, 8 Nov 2024 14:42:31 -0800 Subject: [PATCH 113/300] In an attempt to reduce variability of editing light parameters in common workflows, HdPrman now only deletes the light instance in the case that the light either was or is visible to camera. Also, remove a stray TODO that no longer applies. (Internal change: 2347265) --- third_party/renderman-26/plugin/hdPrman/light.cpp | 10 +++++++--- third_party/renderman-26/plugin/hdPrman/light.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/third_party/renderman-26/plugin/hdPrman/light.cpp b/third_party/renderman-26/plugin/hdPrman/light.cpp index f439483de8..2f54037ac9 100644 --- a/third_party/renderman-26/plugin/hdPrman/light.cpp +++ b/third_party/renderman-26/plugin/hdPrman/light.cpp @@ -61,6 +61,7 @@ PXR_NAMESPACE_OPEN_SCOPE HdPrmanLight::HdPrmanLight(SdfPath const& id, TfToken const& lightType) : HdLight(id) , _hdLightType(lightType) + , _visibleToCamera(true) // This is the RenderMan fallback for visibility:camera. { /* NOTHING */ } @@ -693,8 +694,6 @@ HdPrmanLight::Sync(HdSceneDelegate *sceneDelegate, static_cast(filterNodes.size()), filterNodes.data() }; - - // TODO: portals if (_shaderId == riley::LightShaderId::InvalidId()) { const riley::UserId userId( @@ -943,13 +942,18 @@ HdPrmanLight::Sync(HdSceneDelegate *sceneDelegate, } // XXX: Temporary workaround for RMAN-20704 + // If this light either is or was previously visible to camera: // Destroy the light instance so it will be recreated instead // of being updated, since ModifyLightInstance may crash. - if (_instanceId != riley::LightInstanceId::InvalidId()) { + int32_t visibleToCamera = true; + attrs.GetInteger(RixStr.k_visibility_camera, visibleToCamera); + if (_instanceId != riley::LightInstanceId::InvalidId() && + (visibleToCamera || _visibleToCamera)) { riley->DeleteLightInstance( riley::GeometryPrototypeId::InvalidId(), _instanceId); _instanceId = riley::LightInstanceId::InvalidId(); } + _visibleToCamera = visibleToCamera; // XXX: End of RMAN-20704 workaround if (_instanceId == riley::LightInstanceId::InvalidId()) { diff --git a/third_party/renderman-26/plugin/hdPrman/light.h b/third_party/renderman-26/plugin/hdPrman/light.h index 846ec0bba2..2f77480b28 100644 --- a/third_party/renderman-26/plugin/hdPrman/light.h +++ b/third_party/renderman-26/plugin/hdPrman/light.h @@ -55,6 +55,7 @@ class HdPrmanLight final : public HdLight const TfToken _hdLightType; riley::LightShaderId _shaderId; riley::LightInstanceId _instanceId; + bool _visibleToCamera; RtUString _lightShaderType; TfToken _lightLink; From 29a46f7752485351cb9ffa9ef27218d20fbeaca4 Mon Sep 17 00:00:00 2001 From: tgvarik Date: Fri, 8 Nov 2024 14:46:48 -0800 Subject: [PATCH 114/300] [hdPrman] Fix legacyGeomSubsetSceneIndex prim removal legacyGeomSubsetSceneIndex was not properly cleaning up its cache of subsets upon ancestor removal. (Internal change: 2347373) --- pxr/imaging/hd/legacyGeomSubsetSceneIndex.cpp | 46 ++++++++----------- pxr/imaging/hd/legacyGeomSubsetSceneIndex.h | 20 ++++---- 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/pxr/imaging/hd/legacyGeomSubsetSceneIndex.cpp b/pxr/imaging/hd/legacyGeomSubsetSceneIndex.cpp index 9b615aa0ac..495308f751 100644 --- a/pxr/imaging/hd/legacyGeomSubsetSceneIndex.cpp +++ b/pxr/imaging/hd/legacyGeomSubsetSceneIndex.cpp @@ -99,32 +99,32 @@ class _HdDataSourceLegacyGeomSubset { public: HD_DECLARE_DATASOURCE(_HdDataSourceLegacyGeomSubset); - + TfTokenVector GetNames() override; HdDataSourceBaseHandle Get(const TfToken& name) override; - + private: _HdDataSourceLegacyGeomSubset( const SdfPath& id, const SdfPath& parentId, const TfToken& parentType, HdSceneDelegate* sceneDelegate); - + struct _Subset { TfToken type; VtIntArray indices; bool visibility = false; SdfPath materialBinding; - + operator bool() const { return (!type.IsEmpty() && !indices.empty()); } }; - + _Subset _FindSubset() const; - + SdfPath _parentId; TfToken _parentType; }; @@ -166,7 +166,7 @@ _HdDataSourceLegacyGeomSubset::Get(const TfToken& name) .Build(); } } - + // We must intercept visibility and materialBindings because the // base class does not know how to compute these for geom subsets. if (name == HdVisibilitySchema::GetSchemaToken()) { @@ -202,14 +202,14 @@ _HdDataSourceLegacyGeomSubset::Get(const TfToken& name) HdPrimvarsSchema::BuildRetained(0, nullptr, nullptr); return emptyPrimvarsDs; } - + // To block everything else, and so prevent calling something on the // sceneDelegate for a geom subset path about which it knows nothing, we // only defer to base class for sceneDelegate. if (name == HdSceneIndexEmulationTokens->sceneDelegate) { return HdDataSourceLegacyPrim::Get(name); } - + return nullptr; } @@ -313,7 +313,7 @@ void HdLegacyGeomSubsetSceneIndex::_PrimsAdded( const HdSceneIndexBase& /*sender*/, const HdSceneIndexObserver::AddedPrimEntries& entries) -{ +{ HdSceneIndexObserver::AddedPrimEntries newEntries; for (const HdSceneIndexObserver::AddedPrimEntry& entry : entries) { if (!HdPrimTypeSupportsGeomSubsets(entry.primType)) { @@ -326,7 +326,7 @@ HdLegacyGeomSubsetSceneIndex::_PrimsAdded( continue; } // Only add prims with subsets to _parentPrims to save on memory. - _parentPrims.insert({ entry.primPath, paths }); + _parentPrims.insert({ entry.primPath, paths }); for (const SdfPath& path : paths) { newEntries.push_back({ path, HdPrimTypeTokens->geomSubset }); } @@ -343,21 +343,13 @@ HdLegacyGeomSubsetSceneIndex::_PrimsRemoved( const HdSceneIndexBase& /*sender*/, const HdSceneIndexObserver::RemovedPrimEntries& entries) { - HdSceneIndexObserver::RemovedPrimEntries removedEntries; for (const HdSceneIndexObserver::RemovedPrimEntry& entry : entries) { - auto it = _parentPrims.find(entry.primPath); - if (it != _parentPrims.end()) { - for (const SdfPath& path : it->second) { - removedEntries.push_back({ path }); - } - _parentPrims.erase(it); + auto it = _parentPrims.lower_bound(entry.primPath); + while (it != _parentPrims.end() && + it->first.HasPrefix(entry.primPath)) { + it = _parentPrims.erase(it); } } - if (!removedEntries.empty()) { - removedEntries.insert( - removedEntries.begin(), entries.cbegin(), entries.cend()); - return _SendPrimsRemoved(removedEntries); - } _SendPrimsRemoved(entries); } @@ -378,11 +370,11 @@ HdLegacyGeomSubsetSceneIndex::_PrimsDirtied( HdMeshTopologySchema::GetDefaultLocator() }; static const HdDataSourceLocatorSet emptyLocatorSet { HdDataSourceLocator::EmptyLocator() }; - + HdSceneIndexObserver::AddedPrimEntries addedEntries; HdSceneIndexObserver::RemovedPrimEntries removedEntries; HdSceneIndexObserver::DirtiedPrimEntries dirtiedEntries; - + for (const HdSceneIndexObserver::DirtiedPrimEntry& entry : entries) { if (!entry.dirtyLocators.Intersects(topologyLocators)) { // If the change didn't affect topology, we can continue. This is @@ -453,7 +445,7 @@ HdLegacyGeomSubsetSceneIndex::_PrimsDirtied( SdfPathVector HdLegacyGeomSubsetSceneIndex::_ListDelegateSubsets( const SdfPath& parentPath, - const HdSceneIndexPrim& parentPrim) + const HdSceneIndexPrim& parentPrim) { SdfPathVector paths; if (!parentPrim.dataSource || @@ -487,7 +479,7 @@ HdLegacyGeomSubsetSceneIndex::_ListDelegateSubsets( paths.push_back(parentPath.AppendChild( _tokens->invisiblePoints)); } - + } } return paths; diff --git a/pxr/imaging/hd/legacyGeomSubsetSceneIndex.h b/pxr/imaging/hd/legacyGeomSubsetSceneIndex.h index 6db85e6f45..804c668997 100644 --- a/pxr/imaging/hd/legacyGeomSubsetSceneIndex.h +++ b/pxr/imaging/hd/legacyGeomSubsetSceneIndex.h @@ -18,7 +18,7 @@ #include "pxr/pxr.h" -#include +#include PXR_NAMESPACE_OPEN_SCOPE @@ -45,42 +45,42 @@ class HdLegacyGeomSubsetSceneIndex HD_API static HdLegacyGeomSubsetSceneIndexRefPtr New( const HdSceneIndexBaseRefPtr& inputSceneIndex); - + HD_API ~HdLegacyGeomSubsetSceneIndex() override; - + HD_API HdSceneIndexPrim GetPrim(const SdfPath& primPath) const override; - + HD_API SdfPathVector GetChildPrimPaths(const SdfPath& primPath) const override; protected: HdLegacyGeomSubsetSceneIndex( const HdSceneIndexBaseRefPtr& inputSceneIndex); - + void _PrimsAdded( const HdSceneIndexBase& sender, const HdSceneIndexObserver::AddedPrimEntries& entries) override; - + void _PrimsRemoved( const HdSceneIndexBase& sender, const HdSceneIndexObserver::RemovedPrimEntries& entries) override; - + void _PrimsDirtied( const HdSceneIndexBase& sender, const HdSceneIndexObserver::DirtiedPrimEntries& entries) override; -private: +private: static SdfPathVector _ListDelegateSubsets( const SdfPath& parentPath, const HdSceneIndexPrim& parentPrim); - + // Unordered map of parent path -> [subset paths...] // XXX: Do not use SdfPathTable because we do not want it // to implicitly include the extra ancestor paths. - std::unordered_map _parentPrims; + std::map _parentPrims; }; PXR_NAMESPACE_CLOSE_SCOPE From 8b1451e2cfb78641085b20800a40b79e46fa9260 Mon Sep 17 00:00:00 2001 From: pixar-oss Date: Fri, 8 Nov 2024 14:49:09 -0800 Subject: [PATCH 115/300] - In GetPrim(), we check for a prim data source before creating a HdPrman_UpdateObjectSettings_DataSource. This avoids the need to do the same check in the new data source. - In _UpdatePrimvars(), we don't need to check the result of primvars.GetPrimvar(), which removes one level of nesting. (Internal change: 2347503) --- .../updateObjectSettingsSceneIndex.cpp | 155 +++++++++--------- 1 file changed, 74 insertions(+), 81 deletions(-) diff --git a/third_party/renderman-26/plugin/hdPrman/updateObjectSettingsSceneIndex.cpp b/third_party/renderman-26/plugin/hdPrman/updateObjectSettingsSceneIndex.cpp index 980852c9fb..988a8aed3f 100644 --- a/third_party/renderman-26/plugin/hdPrman/updateObjectSettingsSceneIndex.cpp +++ b/third_party/renderman-26/plugin/hdPrman/updateObjectSettingsSceneIndex.cpp @@ -57,50 +57,48 @@ _UpdatePrimvars(HdPrimvarsSchema primvars) // boolean attributes that migrated from string to int // XXX array loop - if (HdPrimvarSchema primvar = - primvars.GetPrimvar(_tokens->riAttributesDiceRasterOrient)) { - if (HdStringDataSourceHandle strDs = - HdStringDataSource::Cast(primvar.GetPrimvarValue())) { - std::string strVal = strDs->GetTypedValue(0.0f); - bool boolVal = (strVal == "Yes"); - // Overlay boolean value - primvarsEditor.Overlay( - HdDataSourceLocator( - _tokens->riAttributesDiceRasterOrient), - HdPrimvarSchema::Builder() - .SetPrimvarValue( - HdRetainedTypedSampledDataSource::New(boolVal)) - .Build()); - } + HdPrimvarSchema primvar = + primvars.GetPrimvar(_tokens->riAttributesDiceRasterOrient); + if (HdStringDataSourceHandle strDs = + HdStringDataSource::Cast(primvar.GetPrimvarValue())) { + std::string strVal = strDs->GetTypedValue(0.0f); + bool boolVal = (strVal == "Yes"); + // Overlay boolean value + primvarsEditor.Overlay( + HdDataSourceLocator( + _tokens->riAttributesDiceRasterOrient), + HdPrimvarSchema::Builder() + .SetPrimvarValue( + HdRetainedTypedSampledDataSource::New(boolVal)) + .Build()); } // shade:shadingrate -> dice:micropolygonlength - if (HdPrimvarSchema shadingRate = - primvars.GetPrimvar(_tokens->riAttributesShadeShadingRate)) { - if (primvars.GetPrimvar(_tokens->riAttributesDiceMicropolyonLength)) { - // If micropolygonlength is already set, leave as-is. - } else { - // Convert shadingrate to micropolygonlength - if (HdFloatArrayDataSourceHandle rateDs = - HdFloatArrayDataSource::Cast(shadingRate.GetPrimvarValue())) { - VtArray rateVal = rateDs->GetTypedValue(0.0f); - if (rateVal.size() == 2) { - // Use 1st component only - float shadingRate_0 = rateVal[0]; - // micropolygonlength = sqrt(shadingRate[0]) - float micropolygonLength = sqrt(shadingRate_0); - primvarsEditor.Overlay( - HdDataSourceLocator( - _tokens->riAttributesDiceMicropolyonLength), - HdPrimvarSchema::Builder() - .SetPrimvarValue( - HdRetainedTypedSampledDataSource::New( - micropolygonLength)) - .SetInterpolation( - HdPrimvarSchema::BuildInterpolationDataSource( - HdPrimvarSchemaTokens->constant)) - .Build()); - } + HdPrimvarSchema shadingRate = + primvars.GetPrimvar(_tokens->riAttributesShadeShadingRate); + if (primvars.GetPrimvar(_tokens->riAttributesDiceMicropolyonLength)) { + // If micropolygonlength is already set, leave as-is. + } else { + // Convert shadingrate to micropolygonlength + if (HdFloatArrayDataSourceHandle rateDs = + HdFloatArrayDataSource::Cast(shadingRate.GetPrimvarValue())) { + VtArray rateVal = rateDs->GetTypedValue(0.0f); + if (rateVal.size() == 2) { + // Use 1st component only + float shadingRate_0 = rateVal[0]; + // micropolygonlength = sqrt(shadingRate[0]) + float micropolygonLength = sqrt(shadingRate_0); + primvarsEditor.Overlay( + HdDataSourceLocator( + _tokens->riAttributesDiceMicropolyonLength), + HdPrimvarSchema::Builder() + .SetPrimvarValue( + HdRetainedTypedSampledDataSource::New( + micropolygonLength)) + .SetInterpolation( + HdPrimvarSchema::BuildInterpolationDataSource( + HdPrimvarSchemaTokens->constant)) + .Build()); } } // Erase shadingrate @@ -108,23 +106,22 @@ _UpdatePrimvars(HdPrimvarsSchema primvars) HdDataSourceLocator(_tokens->riAttributesShadeShadingRate), HdBlockDataSource::New()); } - + // trace:displacements: // Values above 1 are deprecated, and are now equivalent to 1. - if (HdPrimvarSchema traceDisplacements = - primvars.GetPrimvar(_tokens->riAttributesTraceDisplacements)) { - if (HdIntDataSourceHandle intDs = - HdIntDataSource::Cast(traceDisplacements.GetPrimvarValue())) { - if (intDs->GetTypedValue(0) > 1) { - // Overlay a new value of 1 - primvarsEditor.Overlay( - HdDataSourceLocator( - _tokens->riAttributesTraceDisplacements), - HdPrimvarSchema::Builder() - .SetPrimvarValue( - HdRetainedTypedSampledDataSource::New(1)) - .Build()); - } + HdPrimvarSchema traceDisplacements = + primvars.GetPrimvar(_tokens->riAttributesTraceDisplacements); + if (HdIntDataSourceHandle intDs = + HdIntDataSource::Cast(traceDisplacements.GetPrimvarValue())) { + if (intDs->GetTypedValue(0) > 1) { + // Overlay a new value of 1 + primvarsEditor.Overlay( + HdDataSourceLocator( + _tokens->riAttributesTraceDisplacements), + HdPrimvarSchema::Builder() + .SetPrimvarValue( + HdRetainedTypedSampledDataSource::New(1)) + .Build()); } } @@ -141,11 +138,7 @@ class HdPrman_UpdateObjectSettings_DataSource TfTokenVector GetNames() override { - TfTokenVector result; - if (_inputPrimDs) { - result = _inputPrimDs->GetNames(); - } - return result; + return _inputPrimDs->GetNames(); } HdDataSourceBaseHandle @@ -157,11 +150,7 @@ class HdPrman_UpdateObjectSettings_DataSource return _UpdatePrimvars(primvars); } } - if (_inputPrimDs) { - return _inputPrimDs->Get(name); - } - - return nullptr; + return _inputPrimDs->Get(name); } protected: @@ -187,55 +176,59 @@ HdPrman_UpdateObjectSettingsSceneIndex::New( } HdPrman_UpdateObjectSettingsSceneIndex::HdPrman_UpdateObjectSettingsSceneIndex( - const HdSceneIndexBaseRefPtr &inputSceneIndex) + const HdSceneIndexBaseRefPtr &inputSceneIndex) : HdSingleInputFilteringSceneIndexBase(inputSceneIndex) { } HdSceneIndexPrim HdPrman_UpdateObjectSettingsSceneIndex::GetPrim( - const SdfPath &primPath) const + const SdfPath &primPath) const { const HdSceneIndexPrim prim = _GetInputSceneIndex()->GetPrim(primPath); - return { - prim.primType, - HdPrman_UpdateObjectSettings_DataSource::New(prim.dataSource) - }; + + if (prim.dataSource) { + return { + prim.primType, + HdPrman_UpdateObjectSettings_DataSource::New(prim.dataSource) + }; + } + return prim; } SdfPathVector HdPrman_UpdateObjectSettingsSceneIndex::GetChildPrimPaths( - const SdfPath &primPath) const + const SdfPath &primPath) const { return _GetInputSceneIndex()->GetChildPrimPaths(primPath); } void HdPrman_UpdateObjectSettingsSceneIndex::_PrimsAdded( - const HdSceneIndexBase &sender, - const HdSceneIndexObserver::AddedPrimEntries &entries) + const HdSceneIndexBase &sender, + const HdSceneIndexObserver::AddedPrimEntries &entries) { _SendPrimsAdded(entries); } void HdPrman_UpdateObjectSettingsSceneIndex::_PrimsRemoved( - const HdSceneIndexBase &sender, - const HdSceneIndexObserver::RemovedPrimEntries &entries) + const HdSceneIndexBase &sender, + const HdSceneIndexObserver::RemovedPrimEntries &entries) { _SendPrimsRemoved(entries); } void HdPrman_UpdateObjectSettingsSceneIndex::_PrimsDirtied( - const HdSceneIndexBase &sender, - const HdSceneIndexObserver::DirtiedPrimEntries &entries) + const HdSceneIndexBase &sender, + const HdSceneIndexObserver::DirtiedPrimEntries &entries) { // XXX transfer primvar dirtiness _SendPrimsDirtied(entries); } -HdPrman_UpdateObjectSettingsSceneIndex::~HdPrman_UpdateObjectSettingsSceneIndex() -= default; +HdPrman_UpdateObjectSettingsSceneIndex:: +~HdPrman_UpdateObjectSettingsSceneIndex() = default; PXR_NAMESPACE_CLOSE_SCOPE From 29d955f4d6fca0435cd1256b5b7ff1be9159f517 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Mon, 11 Nov 2024 18:08:51 -0500 Subject: [PATCH 116/300] hioOiio: use ParamValue type instead of deprecated ImageIOParameter ImageIOParameter has been a simple alias for ParamValue since at least OpenImageIO 2.0. --- pxr/imaging/plugin/hioOiio/oiioImage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pxr/imaging/plugin/hioOiio/oiioImage.cpp b/pxr/imaging/plugin/hioOiio/oiioImage.cpp index c3dffcce77..6c99dce1bc 100644 --- a/pxr/imaging/plugin/hioOiio/oiioImage.cpp +++ b/pxr/imaging/plugin/hioOiio/oiioImage.cpp @@ -289,7 +289,7 @@ _FindAttribute(ImageSpec const & spec, std::string const & metadataKey) bool convertMatrixTypes = false; std::string key = _TranslateMetadataKey(metadataKey, &convertMatrixTypes); - ImageIOParameter const * param = spec.find_attribute(key); + ParamValue const * param = spec.find_attribute(key); if (!param) { return VtValue(); } From 4983238aaab9da8d18e4159f25ed8baef3162a3e Mon Sep 17 00:00:00 2001 From: Aleksi Sapon Date: Fri, 8 Nov 2024 14:12:23 -0500 Subject: [PATCH 117/300] Fix Vulkan crashes for missing extensions and layers --- pxr/imaging/hgi/hgi.cpp | 12 ++++ pxr/imaging/hgiVulkan/device.cpp | 16 +++-- pxr/imaging/hgiVulkan/diagnostic.cpp | 16 +++++ pxr/imaging/hgiVulkan/hgi.cpp | 23 +++++--- pxr/imaging/hgiVulkan/instance.cpp | 87 +++++++++++++++++----------- pxr/imaging/hgiVulkan/instance.h | 4 ++ 6 files changed, 109 insertions(+), 49 deletions(-) diff --git a/pxr/imaging/hgi/hgi.cpp b/pxr/imaging/hgi/hgi.cpp index 14f7c63b6d..3fbfd507bf 100644 --- a/pxr/imaging/hgi/hgi.cpp +++ b/pxr/imaging/hgi/hgi.cpp @@ -102,6 +102,12 @@ _MakeNewPlatformDefaultHgi() return nullptr; } + if (!instance->IsBackendSupported()) { + TF_DEBUG(HGI_DEBUG_INSTANCE_CREATION).Msg("Hgi %s is not supported\n", + hgiType); + return nullptr; + } + TF_DEBUG(HGI_DEBUG_INSTANCE_CREATION).Msg("Successfully created platform " "default Hgi %s\n", hgiType); @@ -171,6 +177,12 @@ _MakeNamedHgi(const TfToken& hgiToken) return nullptr; } + if (!instance->IsBackendSupported()) { + TF_DEBUG(HGI_DEBUG_INSTANCE_CREATION).Msg("Hgi %s is not supported\n", + hgiType.c_str()); + return nullptr; + } + TF_DEBUG(HGI_DEBUG_INSTANCE_CREATION).Msg("Successfully created named Hgi " "%s\n", hgiType.c_str()); diff --git a/pxr/imaging/hgiVulkan/device.cpp b/pxr/imaging/hgiVulkan/device.cpp index 15b0bef1c8..3513b5a31f 100644 --- a/pxr/imaging/hgiVulkan/device.cpp +++ b/pxr/imaging/hgiVulkan/device.cpp @@ -87,6 +87,7 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) , _vmaAllocator(nullptr) , _commandQueue(nullptr) , _capabilities(nullptr) + , _pipelineCache(nullptr) { // // Determine physical device @@ -112,7 +113,8 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) if (familyIndex == VK_QUEUE_FAMILY_IGNORED) continue; // Assume we always want a presentation capable device for now. - if (!_SupportsPresentation(instance, physicalDevices[i], familyIndex)) { + if (instance->HasPresentation() && + !_SupportsPresentation(instance, physicalDevices[i], familyIndex)) { continue; } @@ -383,10 +385,12 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) HgiVulkanDevice::~HgiVulkanDevice() { - // Make sure device is idle before destroying objects. - HGIVULKAN_VERIFY_VK_RESULT( - vkDeviceWaitIdle(_vkDevice) - ); + if (_vkDevice) { + // Make sure device is idle before destroying objects. + HGIVULKAN_VERIFY_VK_RESULT( + vkDeviceWaitIdle(_vkDevice) + ); + } delete _pipelineCache; delete _commandQueue; @@ -458,4 +462,4 @@ HgiVulkanDevice::IsSupportedExtension(const char* extensionName) const } -PXR_NAMESPACE_CLOSE_SCOPE \ No newline at end of file +PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/imaging/hgiVulkan/diagnostic.cpp b/pxr/imaging/hgiVulkan/diagnostic.cpp index c48af5f41c..fb8d756d6d 100644 --- a/pxr/imaging/hgiVulkan/diagnostic.cpp +++ b/pxr/imaging/hgiVulkan/diagnostic.cpp @@ -207,6 +207,10 @@ HgiVulkanBeginLabel( return; } + if (!TF_VERIFY(device && device->vkCmdBeginDebugUtilsLabelEXT)) { + return; + } + VkCommandBuffer vkCmbuf = cb->GetVulkanCommandBuffer(); VkDebugUtilsLabelEXT labelInfo = {VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT}; labelInfo.pLabelName = label; @@ -222,6 +226,10 @@ HgiVulkanEndLabel( return; } + if (!TF_VERIFY(device && device->vkCmdEndDebugUtilsLabelEXT)) { + return; + } + VkCommandBuffer vkCmbuf = cb->GetVulkanCommandBuffer(); device->vkCmdEndDebugUtilsLabelEXT(vkCmbuf); } @@ -235,6 +243,10 @@ HgiVulkanBeginQueueLabel( return; } + if (!TF_VERIFY(device && device->vkQueueBeginDebugUtilsLabelEXT)) { + return; + } + VkQueue gfxQueue = device->GetCommandQueue()->GetVulkanGraphicsQueue(); VkDebugUtilsLabelEXT labelInfo = {VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT}; labelInfo.pLabelName = label; @@ -248,6 +260,10 @@ HgiVulkanEndQueueLabel(HgiVulkanDevice* device) return; } + if (!TF_VERIFY(device && device->vkQueueEndDebugUtilsLabelEXT)) { + return; + } + VkQueue gfxQueue = device->GetCommandQueue()->GetVulkanGraphicsQueue(); device->vkQueueEndDebugUtilsLabelEXT(gfxQueue); } diff --git a/pxr/imaging/hgiVulkan/hgi.cpp b/pxr/imaging/hgiVulkan/hgi.cpp index 405c0b3b99..d3b0dfa80c 100755 --- a/pxr/imaging/hgiVulkan/hgi.cpp +++ b/pxr/imaging/hgiVulkan/hgi.cpp @@ -50,15 +50,17 @@ HgiVulkan::HgiVulkan() HgiVulkan::~HgiVulkan() { - HgiVulkanCommandQueue* queue = _device->GetCommandQueue(); - - // Wait for command buffers to complete, then reset command buffers for - // each device's queue. - queue->ResetConsumedCommandBuffers(HgiSubmitWaitTypeWaitUntilCompleted); + if (HgiVulkanCommandQueue* queue = _device->GetCommandQueue()) { + // Wait for command buffers to complete, then reset command buffers for + // each device's queue. + queue->ResetConsumedCommandBuffers( + HgiSubmitWaitTypeWaitUntilCompleted); + + // Wait for all devices and perform final garbage collection. + _device->WaitForIdle(); + _garbageCollector->PerformGarbageCollection(_device); + } - // Wait for all devices and perform final garbage collection. - _device->WaitForIdle(); - _garbageCollector->PerformGarbageCollection(_device); delete _garbageCollector; delete _device; delete _instance; @@ -67,6 +69,11 @@ HgiVulkan::~HgiVulkan() bool HgiVulkan::IsBackendSupported() const { + // Check if we at least found a usable device. + if (!_device->GetVulkanDevice()) { + return false; + } + // Want Vulkan 1.2 or higher. const uint32_t apiVersion = GetCapabilities()->GetAPIVersion(); const uint32_t majorVersion = VK_VERSION_MAJOR(apiVersion); diff --git a/pxr/imaging/hgiVulkan/instance.cpp b/pxr/imaging/hgiVulkan/instance.cpp index e50f00b616..7137b97e9b 100755 --- a/pxr/imaging/hgiVulkan/instance.cpp +++ b/pxr/imaging/hgiVulkan/instance.cpp @@ -17,22 +17,38 @@ PXR_NAMESPACE_OPEN_SCOPE static -bool -_CheckInstanceValidationLayerSupport(const char * layerName) +std::vector +_RemoveUnsupportedInstanceLayers( + const std::vector& desiredLayers) { - uint32_t layerCount; - vkEnumerateInstanceLayerProperties(&layerCount, nullptr); - std::vector availableLayers(layerCount); - - vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data()); + // Determine available instance layers. + uint32_t numAvailableLayers = 0u; + HGIVULKAN_VERIFY_VK_RESULT( + vkEnumerateInstanceLayerProperties(&numAvailableLayers, nullptr) + ); + std::vector availableLayers; + availableLayers.resize(numAvailableLayers); + HGIVULKAN_VERIFY_VK_RESULT( + vkEnumerateInstanceLayerProperties( + &numAvailableLayers, + availableLayers.data()) + ); - for (const auto& layerProperties : availableLayers) { - if (strcmp(layerName, layerProperties.layerName) == 0) { - return true; + std::vector layers; + + // Only add layers to the list if they're available. + for (const auto& lay : desiredLayers) { + if (std::find_if(availableLayers.begin(), availableLayers.end(), + [name = lay](const VkLayerProperties& p) + { return strcmp(p.layerName, name) == 0; }) + != availableLayers.end()) { + layers.push_back(lay); + } else { + TF_STATUS("Instance layer %s is not available, skipping it", lay); } } - return false; + return layers; } static @@ -42,13 +58,13 @@ _RemoveUnsupportedInstanceExtensions( { // Determine available instance extensions. uint32_t numAvailableExtensions = 0u; - TF_VERIFY(vkEnumerateInstanceExtensionProperties( - nullptr, &numAvailableExtensions, nullptr) == VK_SUCCESS); + HGIVULKAN_VERIFY_VK_RESULT(vkEnumerateInstanceExtensionProperties( + nullptr, &numAvailableExtensions, nullptr)); std::vector availableExtensions; availableExtensions.resize(numAvailableExtensions); - TF_VERIFY(vkEnumerateInstanceExtensionProperties( + HGIVULKAN_VERIFY_VK_RESULT(vkEnumerateInstanceExtensionProperties( nullptr, &numAvailableExtensions, - availableExtensions.data()) == VK_SUCCESS); + availableExtensions.data())); std::vector extensions; @@ -59,6 +75,9 @@ _RemoveUnsupportedInstanceExtensions( { return strcmp(p.extensionName, name) == 0; }) != availableExtensions.end()) { extensions.push_back(ext); + } else { + TF_STATUS("Instance extension %s is not available, skipping it", + ext); } } @@ -70,10 +89,9 @@ HgiVulkanInstance::HgiVulkanInstance() , vkCreateDebugUtilsMessengerEXT(nullptr) , vkDestroyDebugUtilsMessengerEXT(nullptr) , _vkInstance(nullptr) + , _hasPresentation(false) { - TF_VERIFY( - volkInitialize() == VK_SUCCESS - ); + HGIVULKAN_VERIFY_VK_RESULT(volkInitialize()); VkApplicationInfo appInfo = {VK_STRUCTURE_TYPE_APPLICATION_INFO}; appInfo.apiVersion = VK_API_VERSION_1_3; @@ -105,28 +123,27 @@ HgiVulkanInstance::HgiVulkanInstance() VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, }; - // Enable validation layers extension. - // Requires VK_LAYER_PATH to be set. - const std::vector debugLayers = { - "VK_LAYER_KHRONOS_validation" - }; + std::vector layers; if (HgiVulkanIsDebugEnabled()) { - for (const auto& debugLayer : debugLayers) { - if (!_CheckInstanceValidationLayerSupport(debugLayer)) { - TF_WARN("Instance layer %s is not present, instance " - "creation will fail", debugLayer); - } - } + layers.push_back("VK_LAYER_KHRONOS_validation"); extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); - createInfo.ppEnabledLayerNames = debugLayers.data(); - createInfo.enabledLayerCount = - static_cast(debugLayers.size()); } + layers = _RemoveUnsupportedInstanceLayers(layers); extensions = _RemoveUnsupportedInstanceExtensions(extensions); - + + if (std::find_if(extensions.begin(), extensions.end(), + [](const char* extensionName) { + return strcmp(extensionName, VK_KHR_SURFACE_EXTENSION_NAME) == 0; + }) == extensions.end()) { + _hasPresentation = false; + } + + createInfo.ppEnabledLayerNames = layers.data(); + createInfo.enabledLayerCount = static_cast(layers.size()); createInfo.ppEnabledExtensionNames = extensions.data(); - createInfo.enabledExtensionCount = static_cast(extensions.size()); + createInfo.enabledExtensionCount = + static_cast(extensions.size()); #if defined(VK_USE_PLATFORM_METAL_EXT) if (std::find(extensions.begin(), extensions.end(), @@ -167,4 +184,4 @@ HgiVulkanInstance::GetPFNInstancProcAddr() return vkGetInstanceProcAddr; } -PXR_NAMESPACE_CLOSE_SCOPE \ No newline at end of file +PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/imaging/hgiVulkan/instance.h b/pxr/imaging/hgiVulkan/instance.h index fb1b62caa3..030904d42a 100644 --- a/pxr/imaging/hgiVulkan/instance.h +++ b/pxr/imaging/hgiVulkan/instance.h @@ -40,8 +40,12 @@ class HgiVulkanInstance final HGIVULKAN_API PFN_vkGetInstanceProcAddr GetPFNInstancProcAddr(); + /// Does the instance support presentation? + bool HasPresentation() { return _hasPresentation; } + private: VkInstance _vkInstance; + bool _hasPresentation; }; From d9581283fa2bba76753685be028f7d5b27c996a5 Mon Sep 17 00:00:00 2001 From: Roggie Zhang Date: Wed, 13 Nov 2024 15:51:15 +0800 Subject: [PATCH 118/300] Fix binding of CreateIndicesAttr function for UsdGeomPrimvar --- pxr/usd/usdGeom/testenv/testUsdGeomPrimvar.py | 8 ++++++++ pxr/usd/usdGeom/wrapPrimvar.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pxr/usd/usdGeom/testenv/testUsdGeomPrimvar.py b/pxr/usd/usdGeom/testenv/testUsdGeomPrimvar.py index 6a0996a7f1..001ff73aa5 100644 --- a/pxr/usd/usdGeom/testenv/testUsdGeomPrimvar.py +++ b/pxr/usd/usdGeom/testenv/testUsdGeomPrimvar.py @@ -200,6 +200,14 @@ def test_PrimvarsAPI(self): self.assertEqual(u1.GetTimeSamplesInInterval(Gf.Interval(0.5, 1.5)), [1.0]) self.assertTrue(u1.ValueMightBeTimeVarying()) + self.assertFalse(v1.IsIndexed()) + self.assertTrue(v1.CreateIndicesAttr()) + self.assertTrue(v1.GetIndicesAttr()) + self.assertFalse(v1.IsIndexed()) + self.assertTrue(v1.GetIndicesAttr().Set(Vt.IntArray([0, 1, 2, 2, 1, 0]))) + self.assertTrue(v1.IsIndexed()) + self.assertTrue(v1.GetIndicesAttr()) + # Add more time-samples to u1 indicesAt0 = Vt.IntArray([]) uValAt3 = Vt.FloatArray([4.1,5.1,6.1]) diff --git a/pxr/usd/usdGeom/wrapPrimvar.cpp b/pxr/usd/usdGeom/wrapPrimvar.cpp index 4705cb5600..65a908cf70 100644 --- a/pxr/usd/usdGeom/wrapPrimvar.cpp +++ b/pxr/usd/usdGeom/wrapPrimvar.cpp @@ -196,7 +196,7 @@ void wrapUsdGeomPrimvar() .def("GetIndices", _GetIndices, (arg("time")=UsdTimeCode::Default())) .def("GetIndicesAttr", &Primvar::GetIndicesAttr) - .def("CreateIndicesAttr", &Primvar::GetIndicesAttr) + .def("CreateIndicesAttr", &Primvar::CreateIndicesAttr) .def("IsIndexed", &Primvar::IsIndexed) .def("GetUnauthoredValuesIndex", &Primvar::GetUnauthoredValuesIndex) From 44ff9007d00be61e4b7fc2709587d6777d004de6 Mon Sep 17 00:00:00 2001 From: pixar-oss Date: Fri, 16 Feb 2024 13:46:08 -0800 Subject: [PATCH 119/300] Merge branch 'volk-test' into feature-hgi-vulkan --- pxr/imaging/hgiVulkan/CMakeLists.txt | 1 + pxr/imaging/hgiVulkan/device.cpp | 23 +++++++++++++++++++-- pxr/imaging/hgiVulkan/instance.cpp | 6 ++++++ pxr/imaging/hgiVulkan/volk.cpp | 26 +++++++++++++++++++++++ pxr/imaging/hgiVulkan/volk.h | 31 ++++++++++++++++++++++++++++ pxr/imaging/hgiVulkan/vulkan.h | 2 +- 6 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 pxr/imaging/hgiVulkan/volk.cpp create mode 100644 pxr/imaging/hgiVulkan/volk.h diff --git a/pxr/imaging/hgiVulkan/CMakeLists.txt b/pxr/imaging/hgiVulkan/CMakeLists.txt index 00ad754480..48953c03da 100644 --- a/pxr/imaging/hgiVulkan/CMakeLists.txt +++ b/pxr/imaging/hgiVulkan/CMakeLists.txt @@ -41,6 +41,7 @@ pxr_library(hgiVulkan shaderSection texture vk_mem_alloc + volk PUBLIC_HEADERS api.h diff --git a/pxr/imaging/hgiVulkan/device.cpp b/pxr/imaging/hgiVulkan/device.cpp index 188bcaebf6..58d7ebbd9a 100644 --- a/pxr/imaging/hgiVulkan/device.cpp +++ b/pxr/imaging/hgiVulkan/device.cpp @@ -11,7 +11,6 @@ #include "pxr/imaging/hgiVulkan/hgi.h" #include "pxr/imaging/hgiVulkan/instance.h" #include "pxr/imaging/hgiVulkan/pipelineCache.h" -#include "pxr/imaging/hgiVulkan/vk_mem_alloc.h" #include "pxr/base/tf/diagnostic.h" @@ -42,16 +41,34 @@ _GetGraphicsQueueFamilyIndex(VkPhysicalDevice physicalDevice) static bool _SupportsPresentation( + HgiVulkanInstance* instance, VkPhysicalDevice physicalDevice, uint32_t familyIndex) { + // XXX With volk, these functions weren't loaded correctly for me (would + // crash when called). Loading them like this seems to work. Unsure why. #if defined(VK_USE_PLATFORM_WIN32_KHR) + VkInstance vkInstance = instance->GetVulkanInstance(); + PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR + vkGetPhysicalDeviceWin32PresentationSupportKHR = + (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR) + vkGetInstanceProcAddr( + vkInstance, + "vkGetPhysicalDeviceWin32PresentationSupportKHR"); return vkGetPhysicalDeviceWin32PresentationSupportKHR( physicalDevice, familyIndex); #elif defined(VK_USE_PLATFORM_XLIB_KHR) Display* dsp = XOpenDisplay(nullptr); VisualID visualID = XVisualIDFromVisual( DefaultVisual(dsp, DefaultScreen(dsp))); + + VkInstance vkInstance = instance->GetVulkanInstance(); + PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR + vkGetPhysicalDeviceXlibPresentationSupportKHR = + (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR) + vkGetInstanceProcAddr( + vkInstance, + "vkGetPhysicalDeviceXlibPresentationSupportKHR"); return vkGetPhysicalDeviceXlibPresentationSupportKHR( physicalDevice, familyIndex, dsp, visualID); #elif defined(VK_USE_PLATFORM_METAL_EXT) @@ -94,7 +111,7 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) if (familyIndex == VK_QUEUE_FAMILY_IGNORED) continue; // Assume we always want a presentation capable device for now. - if (!_SupportsPresentation(physicalDevices[i], familyIndex)) { + if (!_SupportsPresentation(instance, physicalDevices[i], familyIndex)) { continue; } @@ -290,6 +307,8 @@ HgiVulkanDevice::HgiVulkanDevice(HgiVulkanInstance* instance) &_vkDevice) ); + volkLoadDevice(_vkDevice); + HgiVulkanSetupDeviceDebug(instance, this); // diff --git a/pxr/imaging/hgiVulkan/instance.cpp b/pxr/imaging/hgiVulkan/instance.cpp index ab3b445578..ae971275d0 100644 --- a/pxr/imaging/hgiVulkan/instance.cpp +++ b/pxr/imaging/hgiVulkan/instance.cpp @@ -71,6 +71,10 @@ HgiVulkanInstance::HgiVulkanInstance() , vkDestroyDebugUtilsMessengerEXT(nullptr) , _vkInstance(nullptr) { + TF_VERIFY( + volkInitialize() == VK_SUCCESS + ); + VkApplicationInfo appInfo = {VK_STRUCTURE_TYPE_APPLICATION_INFO}; appInfo.apiVersion = VK_API_VERSION_1_3; @@ -140,6 +144,8 @@ HgiVulkanInstance::HgiVulkanInstance() &_vkInstance) ); + volkLoadInstance(_vkInstance); + HgiVulkanCreateDebug(this); } diff --git a/pxr/imaging/hgiVulkan/volk.cpp b/pxr/imaging/hgiVulkan/volk.cpp new file mode 100644 index 0000000000..bd4166caed --- /dev/null +++ b/pxr/imaging/hgiVulkan/volk.cpp @@ -0,0 +1,26 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the Apache License, Version 2.0 (the "Apache License") +// with the following modification; you may not use this file except in +// compliance with the Apache License and the following modification to it: +// Section 6. Trademarks. is deleted and replaced with: +// +// 6. Trademarks. This License does not grant permission to use the trade +// names, trademarks, service marks, or product names of the Licensor +// and its affiliates, except as required to comply with Section 4(c) of +// the License and to reproduce the content of the NOTICE file. +// +// You may obtain a copy of the Apache License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the Apache License with the above modification is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the Apache License for the specific +// language governing permissions and limitations under the Apache License. +// +#define VOLK_IMPLEMENTATION + +#include "pxr/imaging/hgiVulkan/volk.h" diff --git a/pxr/imaging/hgiVulkan/volk.h b/pxr/imaging/hgiVulkan/volk.h new file mode 100644 index 0000000000..6e099c125e --- /dev/null +++ b/pxr/imaging/hgiVulkan/volk.h @@ -0,0 +1,31 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the Apache License, Version 2.0 (the "Apache License") +// with the following modification; you may not use this file except in +// compliance with the Apache License and the following modification to it: +// Section 6. Trademarks. is deleted and replaced with: +// +// 6. Trademarks. This License does not grant permission to use the trade +// names, trademarks, service marks, or product names of the Licensor +// and its affiliates, except as required to comply with Section 4(c) of +// the License and to reproduce the content of the NOTICE file. +// +// You may obtain a copy of the Apache License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the Apache License with the above modification is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the Apache License for the specific +// language governing permissions and limitations under the Apache License. +// +#ifndef PXR_IMAGING_HGIVULKAN_VOLK_H +#define PXR_IMAGING_HGIVULKAN_VOLK_H + +// This is an implementation of Volk included from the Vulkan SDK. + +#include + +#endif diff --git a/pxr/imaging/hgiVulkan/vulkan.h b/pxr/imaging/hgiVulkan/vulkan.h index 3ea215679f..76327e7813 100644 --- a/pxr/imaging/hgiVulkan/vulkan.h +++ b/pxr/imaging/hgiVulkan/vulkan.h @@ -20,7 +20,7 @@ #error Unsupported Platform #endif -#include +#include "pxr/imaging/hgiVulkan/volk.h" #include "pxr/imaging/hgiVulkan/vk_mem_alloc.h" From 686269112e7071acfa7bfc1a909714fbe0c66edc Mon Sep 17 00:00:00 2001 From: pixar-oss Date: Tue, 9 Apr 2024 12:58:28 -0700 Subject: [PATCH 120/300] Volk Fix: Provides interface to borrow function pointer of vkGetInstanceProcAddr. --- pxr/imaging/hgiVulkan/instance.cpp | 5 +++++ pxr/imaging/hgiVulkan/instance.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/pxr/imaging/hgiVulkan/instance.cpp b/pxr/imaging/hgiVulkan/instance.cpp index ae971275d0..e50f00b616 100644 --- a/pxr/imaging/hgiVulkan/instance.cpp +++ b/pxr/imaging/hgiVulkan/instance.cpp @@ -161,5 +161,10 @@ HgiVulkanInstance::GetVulkanInstance() const return _vkInstance; } +PFN_vkGetInstanceProcAddr +HgiVulkanInstance::GetPFNInstancProcAddr() +{ + return vkGetInstanceProcAddr; +} PXR_NAMESPACE_CLOSE_SCOPE \ No newline at end of file diff --git a/pxr/imaging/hgiVulkan/instance.h b/pxr/imaging/hgiVulkan/instance.h index 935374ed55..fb1b62caa3 100644 --- a/pxr/imaging/hgiVulkan/instance.h +++ b/pxr/imaging/hgiVulkan/instance.h @@ -37,6 +37,9 @@ class HgiVulkanInstance final PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT = 0; PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT = 0; + HGIVULKAN_API + PFN_vkGetInstanceProcAddr GetPFNInstancProcAddr(); + private: VkInstance _vkInstance; }; From 418a0a2b054c4670e92a47416396e255a4ae0d42 Mon Sep 17 00:00:00 2001 From: pixar-oss Date: Thu, 10 Oct 2024 12:20:29 -0700 Subject: [PATCH 121/300] Autodesk fix: check for vkGetPhysicalDeviceXlibPresentationSupportKHR before using --- pxr/imaging/hgiVulkan/device.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pxr/imaging/hgiVulkan/device.cpp b/pxr/imaging/hgiVulkan/device.cpp index 58d7ebbd9a..15b0bef1c8 100644 --- a/pxr/imaging/hgiVulkan/device.cpp +++ b/pxr/imaging/hgiVulkan/device.cpp @@ -69,7 +69,8 @@ _SupportsPresentation( vkGetInstanceProcAddr( vkInstance, "vkGetPhysicalDeviceXlibPresentationSupportKHR"); - return vkGetPhysicalDeviceXlibPresentationSupportKHR( + return vkGetPhysicalDeviceXlibPresentationSupportKHR && + vkGetPhysicalDeviceXlibPresentationSupportKHR( physicalDevice, familyIndex, dsp, visualID); #elif defined(VK_USE_PLATFORM_METAL_EXT) // Presentation currently always supported on Metal / MoltenVk From 0f6e53bfb05e89f096e99d72a7a902e3f743d996 Mon Sep 17 00:00:00 2001 From: Patrick Hodoul Date: Mon, 18 Nov 2024 13:45:05 -0500 Subject: [PATCH 122/300] Make visible some methods from HdSingleInputFilteringSceneIndexBase Signed-off-by: Patrick Hodoul --- pxr/imaging/hd/filteringSceneIndex.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pxr/imaging/hd/filteringSceneIndex.h b/pxr/imaging/hd/filteringSceneIndex.h index c5093c4880..8fe7f49463 100644 --- a/pxr/imaging/hd/filteringSceneIndex.h +++ b/pxr/imaging/hd/filteringSceneIndex.h @@ -167,18 +167,22 @@ class HdSingleInputFilteringSceneIndexBase : public HdFilteringSceneIndexBase _Observer(HdSingleInputFilteringSceneIndexBase *owner) : _owner(owner) {} + HD_API void PrimsAdded( const HdSceneIndexBase &sender, const AddedPrimEntries &entries) override; + HD_API void PrimsRemoved( const HdSceneIndexBase &sender, const RemovedPrimEntries &entries) override; + HD_API void PrimsDirtied( const HdSceneIndexBase &sender, const DirtiedPrimEntries &entries) override; + HD_API void PrimsRenamed( const HdSceneIndexBase &sender, const RenamedPrimEntries &entries) override; From d09badcc53cf427f7e80b58528c8a2525fd38a29 Mon Sep 17 00:00:00 2001 From: Mark Tucker Date: Mon, 18 Nov 2024 15:10:52 -0500 Subject: [PATCH 123/300] Change use of int to size_t to prevent potential array counter overflows. Addresses one of the points in feedback from @nvmkuruc. --- pxr/imaging/hdx/pickTask.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pxr/imaging/hdx/pickTask.cpp b/pxr/imaging/hdx/pickTask.cpp index 3a16ea7627..fb2be8b08f 100644 --- a/pxr/imaging/hdx/pickTask.cpp +++ b/pxr/imaging/hdx/pickTask.cpp @@ -1217,7 +1217,7 @@ HdxPrimOriginInfo::FromPickHits(HdRenderIndex * const renderIndex, return resultVec; } - for (int i = 0, n = hits.size(); i < n; i++) { + for (size_t i = 0, n = hits.size(); i < n; i++) { resultVec[i] = _FromPickHitWithCache(sceneIndex, hits[i], &infoCache); } From 3b41ea1c5b09511dc23f1b91fc1eda055a3fb627 Mon Sep 17 00:00:00 2001 From: Roggie Zhang Date: Wed, 20 Nov 2024 22:17:59 +0800 Subject: [PATCH 124/300] Improve ArchGetFileName to return full path for Windows platform --- pxr/base/arch/fileSystem.cpp | 32 ++++++++++++++++-------- pxr/base/arch/testenv/testFileSystem.cpp | 7 ++++++ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/pxr/base/arch/fileSystem.cpp b/pxr/base/arch/fileSystem.cpp index 50ce636cb3..c36aa49503 100644 --- a/pxr/base/arch/fileSystem.cpp +++ b/pxr/base/arch/fileSystem.cpp @@ -532,24 +532,34 @@ ArchGetFileName(FILE *file) } return result; #elif defined (ARCH_OS_WINDOWS) - static constexpr DWORD bufSize = - sizeof(FILE_NAME_INFO) + sizeof(WCHAR) * 4096; - HANDLE hfile = _FileToWinHANDLE(file); - auto fileNameInfo = reinterpret_cast(malloc(bufSize)); string result; - if (GetFileInformationByHandleEx( - hfile, FileNameInfo, static_cast(fileNameInfo), bufSize)) { + WCHAR filePath[MAX_PATH]; + HANDLE hfile = _FileToWinHANDLE(file); + if (GetFinalPathNameByHandleW(hfile, filePath, MAX_PATH, VOLUME_NAME_DOS)) { size_t outSize = WideCharToMultiByte( - CP_UTF8, 0, fileNameInfo->FileName, - fileNameInfo->FileNameLength/sizeof(WCHAR), + CP_UTF8, 0, filePath, + wcslen(filePath), NULL, 0, NULL, NULL); result.resize(outSize); WideCharToMultiByte( - CP_UTF8, 0, fileNameInfo->FileName, - fileNameInfo->FileNameLength/sizeof(WCHAR), + CP_UTF8, 0, filePath, + -1, &result.front(), outSize, NULL, NULL); + + if (result.length() > 4) + { + // It needs to strip the path prefix as + // the path returned is DOS device path, and the + // syntax is one of: + // \\.\C:\Test\Foo.txt + // \\?\C:\Test\Foo.txt + if (result.compare(0, 4, "\\\\?\\") == 0 || + result.compare(0, 4, "\\\\.\\") == 0) + { + result.erase(0, 4); + } + } } - free(fileNameInfo); return result; #else #error Unknown system architecture diff --git a/pxr/base/arch/testenv/testFileSystem.cpp b/pxr/base/arch/testenv/testFileSystem.cpp index bbd790699d..b078621a75 100644 --- a/pxr/base/arch/testenv/testFileSystem.cpp +++ b/pxr/base/arch/testenv/testFileSystem.cpp @@ -14,6 +14,7 @@ #include #include #include +#include PXR_NAMESPACE_USING_DIRECTIVE @@ -92,6 +93,12 @@ int main() fclose(firstFile); ARCH_AXIOM(ArchGetFileLength(firstName.c_str()) == strlen(testContent)); + // Open a file, check that the file path from FILE* handle is matched. + ARCH_AXIOM((firstFile = ArchOpenFile(firstName.c_str(), "rb")) != NULL); + std::string filePath = ArchGetFileName(firstFile); + ARCH_AXIOM(std::filesystem::equivalent(filePath, firstName)); + fclose(firstFile); + // Map the file and assert the bytes are what we expect they are. ARCH_AXIOM((firstFile = ArchOpenFile(firstName.c_str(), "rb")) != NULL); ArchConstFileMapping cfm = ArchMapFileReadOnly(firstFile); From ac2e6edbb88703bdbf212b345b4ceafab3c290f7 Mon Sep 17 00:00:00 2001 From: comand Date: Fri, 22 Nov 2024 13:15:20 -0800 Subject: [PATCH 125/300] fix compiler warnings in hdPrman (Internal change: 2347671) --- third_party/renderman-26/plugin/hdPrman/instancer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/renderman-26/plugin/hdPrman/instancer.h b/third_party/renderman-26/plugin/hdPrman/instancer.h index 1bcc073a69..5a42467c96 100644 --- a/third_party/renderman-26/plugin/hdPrman/instancer.h +++ b/third_party/renderman-26/plugin/hdPrman/instancer.h @@ -407,7 +407,7 @@ class HdPrmanInstancer : public HdInstancer void citerate(std::function fn) const { tbb::spin_rw_mutex::scoped_lock lock(_mutex, false); - for (const std::pair& p : _map) { + for (const auto& p : _map) { fn(p.first, p.second); } } From b44de06e42eb754b679065fd4a872f3e1f7160a5 Mon Sep 17 00:00:00 2001 From: clach Date: Fri, 22 Nov 2024 13:16:06 -0800 Subject: [PATCH 126/300] [usdImagingGL] Updated open source tests to match changes made to internal tests after prim id rendering changes. Also slightly increased threshold for primId test case in testUsdImagingGLAovVisualization. (Internal change: 2347932) --- pxr/usdImaging/usdImagingGL/CMakeLists.txt | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/pxr/usdImaging/usdImagingGL/CMakeLists.txt b/pxr/usdImaging/usdImagingGL/CMakeLists.txt index 3f2983d6f0..cfa99fc6d1 100644 --- a/pxr/usdImaging/usdImagingGL/CMakeLists.txt +++ b/pxr/usdImaging/usdImagingGL/CMakeLists.txt @@ -706,7 +706,7 @@ pxr_register_test(testUsdImagingGLBasicDrawing_clipped ) pxr_register_test(testUsdImagingGLBasicDrawing_id - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -idRender -stage basicDrawing/shaders.usd -frameAll -write testUsdImagingGLBasicDrawing_id.png" + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -rendererAov primId -stage basicDrawing/shaders.usd -frameAll -write testUsdImagingGLBasicDrawing_id.png" IMAGE_DIFF_COMPARE testUsdImagingGLBasicDrawing_id.png FAIL 1 @@ -4603,6 +4603,30 @@ pxr_register_test(testUsdImagingGLAovVisualization_Storm_depth TESTENV testUsdImagingGLAovVisualization ) +pxr_register_test(testUsdImagingGLAovVisualization_Storm_primId + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -stage viz_aov.usda -rendererAov primId -clear 0 0 0 1 -lighting -camera /main_cam -write testUsdImagingGLAovVisualization_Storm_primId.png" + IMAGE_DIFF_COMPARE + testUsdImagingGLAovVisualization_Storm_primId.png + FAIL 0.05 + FAIL_PERCENT 0.015 + WARN 0.025 + WARN_PERCENT 0.002 + EXPECTED_RETURN_CODE 0 + TESTENV testUsdImagingGLAovVisualization +) + +pxr_register_test(testUsdImagingGLAovVisualization_Storm_Neye + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -stage viz_aov.usda -rendererAov Neye -clear 0 0 0 1 -lighting -camera /main_cam -write testUsdImagingGLAovVisualization_Storm_Neye.png" + IMAGE_DIFF_COMPARE + testUsdImagingGLAovVisualization_Storm_Neye.png + FAIL 0.05 + FAIL_PERCENT 0.001 + WARN 0.025 + WARN_PERCENT 0.002 + EXPECTED_RETURN_CODE 0 + TESTENV testUsdImagingGLAovVisualization +) + pxr_register_test(testUsdImagingGLInvalidMaterial COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -lighting -shading smooth -frameAll -stage invalidMaterial.usda -write testUsdImagingGLInvalidMaterial.png" IMAGE_DIFF_COMPARE From ec0c39cccb2eea2a4a9031986c3850755b191fb3 Mon Sep 17 00:00:00 2001 From: tallytalwar Date: Fri, 22 Nov 2024 13:16:30 -0800 Subject: [PATCH 127/300] Move validation framework code to its own library and schema validators to its own library as well. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New directory structure being: pxr/usdValidation ├── usdGeomValidators ├── usdShadeValidators ├── usdSkelValidators ├── usdUtilsValidators └── usdValidation - Core UsdValidation library is moved to pxr/usdValidation/usdValidation. - Validators for core usd, usdGeom, usdShade, usdSkel and usdUtils are respectively moved to pxr/usdValidation/usdValidation, pxr/usdValidation/usdGeomValidators, pxr/usdValidation/usdShadeValidators, pxr/usdValidation/usdSkelValidators and pxr/usdValidation/usdUtilsValidators plugin names and validator names are appropriately renamed to use the new plugin names. (Internal change: 2347953) --- cmake/defaults/Options.cmake | 1 + pxr/CMakeLists.txt | 4 + pxr/usd/usd/CMakeLists.txt | 125 ----- pxr/usd/usd/module.cpp | 4 - .../testUsdValidationContextValidators.cpp | 169 ------- .../testenv/testUsdValidationRegistryPy.cpp | 78 --- pxr/usd/usd/validationError.cpp | 100 ---- pxr/usd/usd/validator.cpp | 103 ---- pxr/usd/usd/validator.h | 281 ----------- pxr/usd/usd/validatorTokens.h | 52 -- pxr/usd/usdGeom/CMakeLists.txt | 21 +- pxr/usd/usdGeom/plugInfo.json | 26 - pxr/usd/usdGeom/validators.cpp | 175 ------- pxr/usd/usdShade/CMakeLists.txt | 25 - pxr/usd/usdShade/plugInfo.json | 44 -- pxr/usd/usdShade/validatorTokens.h | 69 --- pxr/usd/usdSkel/CMakeLists.txt | 18 - pxr/usd/usdSkel/plugInfo.json | 14 - pxr/usd/usdSkel/validators.cpp | 116 ----- pxr/usd/usdUtils/CMakeLists.txt | 29 -- pxr/usdValidation/CMakeLists.txt | 11 + .../usdGeomValidators/CMakeLists.txt | 41 ++ pxr/usdValidation/usdGeomValidators/api.h | 34 ++ .../usdGeomValidators/plugInfo.json | 39 ++ .../testenv/testUsdGeomValidators.cpp | 121 ++--- .../usdGeomValidators}/validatorTokens.cpp | 2 +- .../usdGeomValidators}/validatorTokens.h | 41 +- .../usdGeomValidators/validators.cpp | 161 +++++++ .../usdShadeValidators/CMakeLists.txt | 48 ++ pxr/usdValidation/usdShadeValidators/api.h | 34 ++ .../usdShadeValidators/plugInfo.json | 57 +++ .../testenv/testUsdShadeValidators.cpp | 285 ++++++----- .../testUsdShadeValidators/TestShader.glslfx | 0 .../badMaterialCollections.usda | 0 .../testUsdShadeValidators/shaderDefs.usda | 0 .../usdShadeValidators}/validatorTokens.cpp | 6 +- .../usdShadeValidators/validatorTokens.h | 75 +++ .../usdShadeValidators}/validators.cpp | 440 ++++++++--------- .../usdSkelValidators/CMakeLists.txt | 41 ++ pxr/usdValidation/usdSkelValidators/api.h | 34 ++ .../usdSkelValidators/plugInfo.json | 27 ++ .../testenv/testUsdSkelValidators.cpp | 69 +-- .../usdSkelValidators}/validatorTokens.cpp | 2 +- .../usdSkelValidators}/validatorTokens.h | 35 +- .../usdSkelValidators/validators.cpp | 110 +++++ .../usdUtilsValidators/CMakeLists.txt | 49 ++ pxr/usdValidation/usdUtilsValidators/api.h | 34 ++ .../usdUtilsValidators}/plugInfo.json | 2 +- .../testenv/testUsdUtilsValidators.cpp | 89 ++-- .../testUsdUtilsValidators/badRoot.usda | 0 .../excludedDirectory/image.jpg | Bin .../excludedDirectory/layer.usda | 0 .../testenv/testUsdUtilsValidators/fail.usdz | Bin .../testUsdUtilsValidators/goodRoot.usda | 0 .../includedDirectory/image.jpg | Bin .../includedDirectory/layer.usda | 0 .../testenv/testUsdUtilsValidators/pass.usdz | Bin .../usdUtilsValidators}/validatorTokens.cpp | 6 +- .../usdUtilsValidators}/validatorTokens.h | 32 +- .../usdUtilsValidators}/validators.cpp | 75 ++- .../usdValidation/CMakeLists.txt | 175 +++++++ pxr/usdValidation/usdValidation/__init__.py | 9 + pxr/usdValidation/usdValidation/api.h | 34 ++ .../usdValidation/context.cpp} | 240 +++++----- .../usdValidation/context.h} | 159 ++++--- .../usdValidation}/coreValidators.cpp | 32 +- pxr/usdValidation/usdValidation/error.cpp | 106 +++++ .../usdValidation/error.h} | 152 +++--- pxr/usdValidation/usdValidation/module.cpp | 18 + .../usdValidation/moduleDeps.cpp | 33 ++ pxr/usdValidation/usdValidation/plugInfo.json | 24 + .../usdValidation/registry.cpp} | 444 +++++++++--------- .../usdValidation/registry.h} | 421 +++++++++-------- ...dValidationContextValidators_plugInfo.json | 0 .../TestUsdValidationRegistryPy_plugInfo.json | 0 .../testenv/testUsdCoreValidators.cpp | 74 ++- .../testenv/testUsdValidationContext.cpp | 239 +++++----- .../resources/generatedSchema.usda | 0 .../resources/plugInfo.json | 0 .../testenv/testUsdValidationContextPy.py | 19 +- .../testUsdValidationContextValidators.cpp | 145 ++++++ .../testenv/testUsdValidationError.py | 69 +-- .../testenv/testUsdValidationRegistry.cpp | 183 ++++---- .../testUsdValidationRegistry/plugInfo.json | 0 .../testenv/testUsdValidationRegistryPy.cpp | 79 ++++ .../testenv/testUsdValidationRegistryPy.py | 24 +- .../testenv/testUsdValidator.cpp | 79 ++-- .../testenv/testUsdValidatorMetadata.py | 18 +- pxr/usdValidation/usdValidation/validator.cpp | 112 +++++ pxr/usdValidation/usdValidation/validator.h | 295 ++++++++++++ .../usdValidation}/validatorTokens.cpp | 6 +- .../usdValidation/validatorTokens.h | 52 ++ .../usdValidation/wrapContext.cpp} | 14 +- .../usdValidation/wrapError.cpp} | 4 +- .../usdValidation/wrapRegistry.cpp} | 8 +- .../usdValidation}/wrapValidator.cpp | 57 ++- 96 files changed, 3578 insertions(+), 3200 deletions(-) delete mode 100644 pxr/usd/usd/testenv/testUsdValidationContextValidators.cpp delete mode 100644 pxr/usd/usd/testenv/testUsdValidationRegistryPy.cpp delete mode 100644 pxr/usd/usd/validationError.cpp delete mode 100644 pxr/usd/usd/validator.cpp delete mode 100644 pxr/usd/usd/validator.h delete mode 100644 pxr/usd/usd/validatorTokens.h delete mode 100644 pxr/usd/usdGeom/validators.cpp delete mode 100644 pxr/usd/usdShade/validatorTokens.h delete mode 100644 pxr/usd/usdSkel/validators.cpp create mode 100644 pxr/usdValidation/CMakeLists.txt create mode 100644 pxr/usdValidation/usdGeomValidators/CMakeLists.txt create mode 100644 pxr/usdValidation/usdGeomValidators/api.h create mode 100644 pxr/usdValidation/usdGeomValidators/plugInfo.json rename pxr/{usd/usdGeom => usdValidation/usdGeomValidators}/testenv/testUsdGeomValidators.cpp (76%) rename pxr/{usd/usdGeom => usdValidation/usdGeomValidators}/validatorTokens.cpp (89%) rename pxr/{usd/usdGeom => usdValidation/usdGeomValidators}/validatorTokens.h (54%) create mode 100644 pxr/usdValidation/usdGeomValidators/validators.cpp create mode 100644 pxr/usdValidation/usdShadeValidators/CMakeLists.txt create mode 100644 pxr/usdValidation/usdShadeValidators/api.h create mode 100644 pxr/usdValidation/usdShadeValidators/plugInfo.json rename pxr/{usd/usdShade => usdValidation/usdShadeValidators}/testenv/testUsdShadeValidators.cpp (65%) rename pxr/{usd/usdShade => usdValidation/usdShadeValidators}/testenv/testUsdShadeValidators/TestShader.glslfx (100%) rename pxr/{usd/usdShade => usdValidation/usdShadeValidators}/testenv/testUsdShadeValidators/badMaterialCollections.usda (100%) rename pxr/{usd/usdShade => usdValidation/usdShadeValidators}/testenv/testUsdShadeValidators/shaderDefs.usda (100%) rename pxr/{usd/usdShade => usdValidation/usdShadeValidators}/validatorTokens.cpp (71%) create mode 100644 pxr/usdValidation/usdShadeValidators/validatorTokens.h rename pxr/{usd/usdShade => usdValidation/usdShadeValidators}/validators.cpp (56%) create mode 100644 pxr/usdValidation/usdSkelValidators/CMakeLists.txt create mode 100644 pxr/usdValidation/usdSkelValidators/api.h create mode 100644 pxr/usdValidation/usdSkelValidators/plugInfo.json rename pxr/{usd/usdSkel => usdValidation/usdSkelValidators}/testenv/testUsdSkelValidators.cpp (66%) rename pxr/{usd/usdSkel => usdValidation/usdSkelValidators}/validatorTokens.cpp (89%) rename pxr/{usd/usdSkel => usdValidation/usdSkelValidators}/validatorTokens.h (50%) create mode 100644 pxr/usdValidation/usdSkelValidators/validators.cpp create mode 100644 pxr/usdValidation/usdUtilsValidators/CMakeLists.txt create mode 100644 pxr/usdValidation/usdUtilsValidators/api.h rename pxr/{usd/usdUtils => usdValidation/usdUtilsValidators}/plugInfo.json (95%) rename pxr/{usd/usdUtils => usdValidation/usdUtilsValidators}/testenv/testUsdUtilsValidators.cpp (50%) rename pxr/{usd/usdUtils => usdValidation/usdUtilsValidators}/testenv/testUsdUtilsValidators/badRoot.usda (100%) rename pxr/{usd/usdUtils => usdValidation/usdUtilsValidators}/testenv/testUsdUtilsValidators/excludedDirectory/image.jpg (100%) rename pxr/{usd/usdUtils => usdValidation/usdUtilsValidators}/testenv/testUsdUtilsValidators/excludedDirectory/layer.usda (100%) rename pxr/{usd/usdUtils => usdValidation/usdUtilsValidators}/testenv/testUsdUtilsValidators/fail.usdz (100%) rename pxr/{usd/usdUtils => usdValidation/usdUtilsValidators}/testenv/testUsdUtilsValidators/goodRoot.usda (100%) rename pxr/{usd/usdUtils => usdValidation/usdUtilsValidators}/testenv/testUsdUtilsValidators/includedDirectory/image.jpg (100%) rename pxr/{usd/usdUtils => usdValidation/usdUtilsValidators}/testenv/testUsdUtilsValidators/includedDirectory/layer.usda (100%) rename pxr/{usd/usdUtils => usdValidation/usdUtilsValidators}/testenv/testUsdUtilsValidators/pass.usdz (100%) rename pxr/{usd/usdUtils => usdValidation/usdUtilsValidators}/validatorTokens.cpp (71%) rename pxr/{usd/usdUtils => usdValidation/usdUtilsValidators}/validatorTokens.h (53%) rename pxr/{usd/usdUtils => usdValidation/usdUtilsValidators}/validators.cpp (57%) create mode 100644 pxr/usdValidation/usdValidation/CMakeLists.txt create mode 100644 pxr/usdValidation/usdValidation/__init__.py create mode 100644 pxr/usdValidation/usdValidation/api.h rename pxr/{usd/usd/validationContext.cpp => usdValidation/usdValidation/context.cpp} (65%) rename pxr/{usd/usd/validationContext.h => usdValidation/usdValidation/context.h} (78%) rename pxr/{usd/usd => usdValidation/usdValidation}/coreValidators.cpp (62%) create mode 100644 pxr/usdValidation/usdValidation/error.cpp rename pxr/{usd/usd/validationError.h => usdValidation/usdValidation/error.h} (73%) create mode 100644 pxr/usdValidation/usdValidation/module.cpp create mode 100644 pxr/usdValidation/usdValidation/moduleDeps.cpp create mode 100644 pxr/usdValidation/usdValidation/plugInfo.json rename pxr/{usd/usd/validationRegistry.cpp => usdValidation/usdValidation/registry.cpp} (63%) rename pxr/{usd/usd/validationRegistry.h => usdValidation/usdValidation/registry.h} (59%) rename pxr/{usd/usd => usdValidation/usdValidation}/testenv/TestUsdValidationContextValidators_plugInfo.json (100%) rename pxr/{usd/usd => usdValidation/usdValidation}/testenv/TestUsdValidationRegistryPy_plugInfo.json (100%) rename pxr/{usd/usd => usdValidation/usdValidation}/testenv/testUsdCoreValidators.cpp (67%) rename pxr/{usd/usd => usdValidation/usdValidation}/testenv/testUsdValidationContext.cpp (70%) rename pxr/{usd/usd => usdValidation/usdValidation}/testenv/testUsdValidationContext/resources/generatedSchema.usda (100%) rename pxr/{usd/usd => usdValidation/usdValidation}/testenv/testUsdValidationContext/resources/plugInfo.json (100%) rename pxr/{usd/usd => usdValidation/usdValidation}/testenv/testUsdValidationContextPy.py (95%) create mode 100644 pxr/usdValidation/usdValidation/testenv/testUsdValidationContextValidators.cpp rename pxr/{usd/usd => usdValidation/usdValidation}/testenv/testUsdValidationError.py (78%) rename pxr/{usd/usd => usdValidation/usdValidation}/testenv/testUsdValidationRegistry.cpp (51%) rename pxr/{usd/usd => usdValidation/usdValidation}/testenv/testUsdValidationRegistry/plugInfo.json (100%) create mode 100644 pxr/usdValidation/usdValidation/testenv/testUsdValidationRegistryPy.cpp rename pxr/{usd/usd => usdValidation/usdValidation}/testenv/testUsdValidationRegistryPy.py (86%) rename pxr/{usd/usd => usdValidation/usdValidation}/testenv/testUsdValidator.cpp (67%) rename pxr/{usd/usd => usdValidation/usdValidation}/testenv/testUsdValidatorMetadata.py (86%) create mode 100644 pxr/usdValidation/usdValidation/validator.cpp create mode 100644 pxr/usdValidation/usdValidation/validator.h rename pxr/{usd/usd => usdValidation/usdValidation}/validatorTokens.cpp (69%) create mode 100644 pxr/usdValidation/usdValidation/validatorTokens.h rename pxr/{usd/usd/wrapValidationContext.cpp => usdValidation/usdValidation/wrapContext.cpp} (86%) rename pxr/{usd/usd/wrapValidationError.cpp => usdValidation/usdValidation/wrapError.cpp} (96%) rename pxr/{usd/usd/wrapValidationRegistry.cpp => usdValidation/usdValidation/wrapRegistry.cpp} (96%) rename pxr/{usd/usd => usdValidation/usdValidation}/wrapValidator.cpp (64%) diff --git a/cmake/defaults/Options.cmake b/cmake/defaults/Options.cmake index 74cee361fd..a1b1bc9604 100644 --- a/cmake/defaults/Options.cmake +++ b/cmake/defaults/Options.cmake @@ -16,6 +16,7 @@ option(PXR_BUILD_EMBREE_PLUGIN "Build embree imaging plugin" OFF) option(PXR_BUILD_OPENIMAGEIO_PLUGIN "Build OpenImageIO plugin" OFF) option(PXR_BUILD_OPENCOLORIO_PLUGIN "Build OpenColorIO plugin" OFF) option(PXR_BUILD_USD_IMAGING "Build USD imaging components" ON) +option(PXR_BUILD_USD_VALIDATION "Build USD validation library and core USD validators" ON) option(PXR_BUILD_USDVIEW "Build usdview" ON) option(PXR_BUILD_ALEMBIC_PLUGIN "Build the Alembic plugin for USD" OFF) option(PXR_BUILD_DRACO_PLUGIN "Build the Draco plugin for USD" OFF) diff --git a/pxr/CMakeLists.txt b/pxr/CMakeLists.txt index 4c7301b871..d476fae698 100644 --- a/pxr/CMakeLists.txt +++ b/pxr/CMakeLists.txt @@ -8,6 +8,10 @@ if (EXISTS "${PROJECT_SOURCE_DIR}/pxr/exec") add_subdirectory(exec) endif() +if ($(PXR_BUILD_USD_VALIDATION)) + add_subdirectory(usdValidation) +endif() + if (${PXR_BUILD_IMAGING}) add_subdirectory(imaging) if (${PXR_BUILD_USD_IMAGING}) diff --git a/pxr/usd/usd/CMakeLists.txt b/pxr/usd/usd/CMakeLists.txt index 02793db940..dec2fd2ee7 100644 --- a/pxr/usd/usd/CMakeLists.txt +++ b/pxr/usd/usd/CMakeLists.txt @@ -62,11 +62,6 @@ pxr_library(usd stageLoadRules stagePopulationMask timeCode - validator - validatorTokens - validationContext - validationError - validationRegistry usdFileFormat usdaFileFormat usdcFileFormat @@ -103,9 +98,6 @@ pxr_library(usd wrapUtils.h testenv/TestUsdResolverChangedResolver.h - CPPFILES - coreValidators.cpp - PYTHON_CPPFILES moduleDeps.cpp @@ -146,10 +138,6 @@ pxr_library(usd wrapTimeCode.cpp wrapUsdFileFormat.cpp wrapUtils.cpp - wrapValidationContext.cpp - wrapValidationError.cpp - wrapValidationRegistry.cpp - wrapValidator.cpp wrapVariantSets.cpp wrapVersion.cpp wrapZipFile.cpp @@ -269,10 +257,6 @@ pxr_test_scripts( testenv/testUsdTimeSamples.py testenv/testUsdTimeValueAuthoring.py testenv/testUsdUsdzFileFormat.py - testenv/testUsdValidationContextPy.py - testenv/testUsdValidationError.py - testenv/testUsdValidationRegistryPy.py - testenv/testUsdValidatorMetadata.py testenv/testUsdValueClips.py testenv/testUsdVariantEditing.py testenv/testUsdVariantFallbacks.py @@ -302,33 +286,6 @@ pxr_build_test_shared_lib(TestUsdResolverChangedResolver testenv/TestUsdResolverChangedResolver.cpp ) -pxr_build_test_shared_lib(TestUsdValidationContextValidators - INSTALL_PREFIX UsdPlugins - LIBRARIES - tf - usd - - CPPFILES - testenv/testUsdValidationContextValidators.cpp -) - -pxr_build_test_shared_lib(TestUsdValidationRegistryPy - INSTALL_PREFIX UsdPlugins - LIBRARIES - tf - usd - - CPPFILES - testenv/testUsdValidationRegistryPy.cpp -) - -pxr_build_test(testUsdCoreValidators - LIBRARIES - usd - CPPFILES - testenv/testUsdCoreValidators.cpp -) - pxr_build_test(testUsdAttributeBlockingCpp LIBRARIES tf @@ -497,30 +454,6 @@ pxr_build_test(testUsdUsdzResolver testenv/testUsdUsdzResolver.cpp ) -pxr_build_test(testUsdValidator - LIBRARIES - tf - usd - CPPFILES - testenv/testUsdValidator.cpp -) - -pxr_build_test(testUsdValidationContext - LIBRARIES - tf - usd - CPPFILES - testenv/testUsdValidationContext.cpp -) - -pxr_build_test(testUsdValidationRegistry - LIBRARIES - tf - usd - CPPFILES - testenv/testUsdValidationRegistry.cpp -) - pxr_build_test(testUsdZipFile_CPP LIBRARIES ar @@ -803,21 +736,6 @@ pxr_install_test_dir( DEST testUsdUsdzResolver ) -pxr_install_test_dir( - SRC testenv/testUsdValidationContext - DEST testUsdValidationContext -) - -pxr_install_test_dir( - SRC testenv/testUsdValidationContext - DEST testUsdValidationContextPy -) - -pxr_install_test_dir( - SRC testenv/testUsdValidationRegistry - DEST testUsdValidationRegistry -) - pxr_install_test_dir( SRC testenv/testUsdZipFile.testenv DEST testUsdZipFile @@ -833,11 +751,6 @@ pxr_install_test_dir( DEST testUsdUsdzBugGHSA01 ) -pxr_register_test(testUsdCoreValidators - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdCoreValidators" - EXPECTED_RETURN_CODE 0 -) - pxr_register_test(testUsdAppliedAPISchemas PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdAppliedAPISchemas" @@ -1073,16 +986,6 @@ pxr_register_test(testUsdMetadataCpp EXPECTED_RETURN_CODE 0 ) -pxr_register_test(testUsdValidator - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidator" - EXPECTED_RETURN_CODE 0 -) - -pxr_register_test(testUsdValidationRegistry - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationRegistry" - EXPECTED_RETURN_CODE 0 -) - #The following tests rely on plugins built specifically for them. #The build system currently doesn't support test-specific plugins #for static library builds, so we only enable these tests for @@ -1092,10 +995,6 @@ if (BUILD_SHARED_LIBS) COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdResolverChanged" EXPECTED_RETURN_CODE 0 ) - pxr_register_test(testUsdValidationContext - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationContext" - EXPECTED_RETURN_CODE 0 - ) endif() pxr_register_test(testUsdStageNoPython @@ -1423,30 +1322,6 @@ pxr_register_test(testUsdOpaqueAttributes EXPECTED_RETURN_CODE 0 ) -pxr_register_test(testUsdValidatorMetadata - PYTHON - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidatorMetadata" - EXPECTED_RETURN_CODE 0 -) - -pxr_register_test(testUsdValidationError - PYTHON - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationError" - EXPECTED_RETURN_CODE 0 -) - -pxr_register_test(testUsdValidationContextPy - PYTHON - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationContextPy" - EXPECTED_RETURN_CODE 0 -) - -pxr_register_test(testUsdValidationRegistryPy - PYTHON - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationRegistryPy" - EXPECTED_RETURN_CODE 0 -) - pxr_register_test(testUsdUsdzBugGHSA01 COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdUsdzBugGHSA01" EXPECTED_RETURN_CODE 0 diff --git a/pxr/usd/usd/module.cpp b/pxr/usd/usd/module.cpp index c68763c61b..4f9474e713 100644 --- a/pxr/usd/usd/module.cpp +++ b/pxr/usd/usd/module.cpp @@ -37,10 +37,6 @@ TF_WRAP_MODULE TF_WRAP(UsdSpecializes); TF_WRAP(UsdPrimRange); TF_WRAP(UsdVariantSets); - TF_WRAP(UsdValidationContext); - TF_WRAP(UsdValidationError); - TF_WRAP(UsdValidationRegistry); - TF_WRAP(UsdValidator); // SchemaBase. TF_WRAP(UsdSchemaBase); diff --git a/pxr/usd/usd/testenv/testUsdValidationContextValidators.cpp b/pxr/usd/usd/testenv/testUsdValidationContextValidators.cpp deleted file mode 100644 index 66615018d2..0000000000 --- a/pxr/usd/usd/testenv/testUsdValidationContextValidators.cpp +++ /dev/null @@ -1,169 +0,0 @@ -// -// Copyright 2024 Pixar -// -// Licensed under the terms set forth in the LICENSE.txt file available at -// https://openusd.org/license. -// - -#include "pxr/pxr.h" -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usd/validationRegistry.h" -#include "pxr/usd/usd/validator.h" - -PXR_NAMESPACE_USING_DIRECTIVE - -TF_REGISTRY_FUNCTION(UsdValidationRegistry) -{ - UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); - - // Register test plugin validators here - // Test validators simply just return errors, we need to make sure various - // UsdValidationContext APIs work and get the expected errors back, when - // Validate is called in various scenarios on a validation context instance. - { - const TfToken validatorName( - "testUsdValidationContextValidatorsPlugin:Test1"); - const UsdValidateStageTaskFn stageTaskFn = []( - const UsdStagePtr & usdStage) - { - const TfToken validationErrorId("Test1Error"); - return UsdValidationErrorVector{ - UsdValidationError( - validationErrorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(usdStage, - SdfPath::AbsoluteRootPath())}, - "A stage validator error")}; - }; - - TfErrorMark m; - registry.RegisterPluginValidator(validatorName, stageTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const TfToken validatorName( - "testUsdValidationContextValidatorsPlugin:Test2"); - const UsdValidateLayerTaskFn layerTaskFn = []( - const SdfLayerHandle & layer) - { - const TfToken validationErrorId("Test2Error"); - return UsdValidationErrorVector{ - UsdValidationError( - validationErrorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(layer, - SdfPath::AbsoluteRootPath())}, - "A layer validator error")}; - }; - - TfErrorMark m; - registry.RegisterPluginValidator(validatorName, layerTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const TfToken validatorName( - "testUsdValidationContextValidatorsPlugin:Test3"); - const UsdValidatePrimTaskFn primTaskFn = []( - const UsdPrim & prim) - { - const TfToken validationErrorId("Test3Error"); - return UsdValidationErrorVector{ - UsdValidationError( - validationErrorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(prim.GetStage(), - prim.GetPath())}, - "A generic prim validator error")}; - }; - - TfErrorMark m; - registry.RegisterPluginValidator(validatorName, primTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const TfToken validatorName( - "testUsdValidationContextValidatorsPlugin:Test4"); - const UsdValidatePrimTaskFn primTaskFn = []( - const UsdPrim & prim) - { - const TfToken validationErrorId("Test4Error"); - return UsdValidationErrorVector{ - UsdValidationError( - validationErrorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(prim.GetStage(), - prim.GetPath())}, - "A testBaseType prim type validator error")}; - }; - - TfErrorMark m; - registry.RegisterPluginValidator(validatorName, primTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const TfToken validatorName( - "testUsdValidationContextValidatorsPlugin:Test5"); - const UsdValidatePrimTaskFn primTaskFn = []( - const UsdPrim & prim) - { - const TfToken validationErrorId("Test5Error"); - return UsdValidationErrorVector{ - UsdValidationError( - validationErrorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(prim.GetStage(), - prim.GetPath())}, - "A testDerivedType prim type validator error")}; - }; - - TfErrorMark m; - registry.RegisterPluginValidator(validatorName, primTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const TfToken validatorName( - "testUsdValidationContextValidatorsPlugin:Test6"); - const UsdValidatePrimTaskFn primTaskFn = []( - const UsdPrim & prim) - { - const TfToken validationErrorId("Test6Error"); - return UsdValidationErrorVector{ - UsdValidationError( - validationErrorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(prim.GetStage(), - prim.GetPath())}, - "A testNestedDerivedType prim type validator error")}; - }; - - TfErrorMark m; - registry.RegisterPluginValidator(validatorName, primTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const TfToken validatorName( - "testUsdValidationContextValidatorsPlugin:Test7"); - const UsdValidatePrimTaskFn primTaskFn = []( - const UsdPrim & prim) - { - const TfToken validationErrorId("Test7Error"); - return UsdValidationErrorVector{ - UsdValidationError( - validationErrorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(prim.GetStage(), - prim.GetPath())}, - "A testAPISchema prim type validator error")}; - }; - - TfErrorMark m; - registry.RegisterPluginValidator(validatorName, primTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const TfToken suiteName( - "testUsdValidationContextValidatorsPlugin:TestSuite"); - const std::vector containedValidators = - registry.GetOrLoadValidatorsByName( - {TfToken("testUsdValidationContextValidatorsPlugin:Test1"), - TfToken("testUsdValidationContextValidatorsPlugin:Test2"), - TfToken("testUsdValidationContextValidatorsPlugin:Test3")}); - - TfErrorMark m; - registry.RegisterPluginValidatorSuite(suiteName, containedValidators); - TF_AXIOM(m.IsClean()); - } -} diff --git a/pxr/usd/usd/testenv/testUsdValidationRegistryPy.cpp b/pxr/usd/usd/testenv/testUsdValidationRegistryPy.cpp deleted file mode 100644 index e7a7cb05be..0000000000 --- a/pxr/usd/usd/testenv/testUsdValidationRegistryPy.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -// Copyright 2024 Pixar -// -// Licensed under the terms set forth in the LICENSE.txt file available at -// https://openusd.org/license. -// - -#include "pxr/pxr.h" -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usd/validationRegistry.h" -#include "pxr/usd/usd/validator.h" - -#include -#include - -PXR_NAMESPACE_USING_DIRECTIVE - -TF_REGISTRY_FUNCTION(UsdValidationRegistry) -{ - UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); - { - const UsdValidateStageTaskFn stageTaskFn = - [](const UsdStagePtr &usdStage) - { - return UsdValidationErrorVector{UsdValidationError( - TfToken("TestValidator1"), - UsdValidationErrorType::Error, - {UsdValidationErrorSite(usdStage, SdfPath("/"))}, - "This is an error on the stage")}; - }; - - std::cout<<"Registering TestValidator1\n"; - // Register the validator - TfErrorMark m; - UsdValidatorMetadata metadata{ - TfToken("TestValidator1"), - nullptr, - {TfToken("IncludedInAll"), TfToken("SomeKeyword1")}, - "TestValidator1 for keywords metadata parsing", - {}, - false}; - - registry.RegisterValidator(metadata, stageTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const UsdValidatePrimTaskFn primTaskFn = [](const UsdPrim & /*prim*/) - { return UsdValidationErrorVector{}; }; - - // Register the validator - TfErrorMark m; - UsdValidatorMetadata metadata{ - TfToken("TestValidator2"), - nullptr, - {TfToken("IncludedInAll")}, - "TestValidator2 for schemaType metadata parsing", - {TfToken("SomePrimType"), TfToken("SomeAPISchema")}, - false}; - registry.RegisterValidator(metadata, primTaskFn); - TF_AXIOM(m.IsClean()); - } - { - const std::vector containedValidators = - registry.GetOrLoadValidatorsByName( - {TfToken("TestValidator1"), - TfToken("TestValidator2")}); - TfErrorMark m; - UsdValidatorMetadata metadata{ - TfToken("TestValidatorSuite"), - nullptr, - {TfToken("IncludedInAll"), TfToken("SuiteValidator")}, - "Suite of TestValidator1 and TestValidator2", - {}, - true}; - registry.RegisterValidatorSuite(metadata, containedValidators); - TF_AXIOM(m.IsClean()); - } -} diff --git a/pxr/usd/usd/validationError.cpp b/pxr/usd/usd/validationError.cpp deleted file mode 100644 index a448004fc4..0000000000 --- a/pxr/usd/usd/validationError.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// -// Copyright 2024 Pixar -// -// Licensed under the terms set forth in the LICENSE.txt file available at -// https://openusd.org/license. -// - -#include "pxr/base/tf/enum.h" -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usd/validator.h" - -PXR_NAMESPACE_OPEN_SCOPE - -TF_DEFINE_PRIVATE_TOKENS(_tokens, - ((ValidationErrorNameDelimiter, ".")) -); - -TF_REGISTRY_FUNCTION(TfEnum) -{ - TF_ADD_ENUM_NAME(UsdValidationErrorType::None, "None"); - TF_ADD_ENUM_NAME(UsdValidationErrorType::Error, "Error"); - TF_ADD_ENUM_NAME(UsdValidationErrorType::Warn, "Warn"); - TF_ADD_ENUM_NAME(UsdValidationErrorType::Info, "Info"); -} - -UsdValidationErrorSite::UsdValidationErrorSite( - const SdfLayerHandle &layer, const SdfPath &objectPath) : - _layer(layer), _objectPath(objectPath) -{ -} - -UsdValidationErrorSite::UsdValidationErrorSite( - const UsdStagePtr &usdStage, const SdfPath &objectPath, - const SdfLayerHandle &layer) : - _usdStage(usdStage), _layer(layer), _objectPath(objectPath) -{ -} - -UsdValidationError::UsdValidationError() : - _errorType(UsdValidationErrorType::None) -{ - _validator = nullptr; -} - -UsdValidationError::UsdValidationError( - const TfToken &name, const UsdValidationErrorType &type, - const UsdValidationErrorSites &errorSites, const std::string &errorMsg) : - _name(name), _errorType(type), _errorSites(errorSites), - _errorMsg(errorMsg) -{ - _validator = nullptr; -} - -TfToken -UsdValidationError::GetIdentifier() const -{ - // A validation error is created via a call to UsdValidator::Validate(), - // which should have set a validator on the error. But if a ValidationError - // is created directly (not recommended), it will not have a validator set, - // this is improper use of the API, hence we throw a coding error here. - if (!_validator) { - TF_CODING_ERROR("Validator not set on ValidationError. Possibly this " - "validation error was not created via a call to " - "UsdValidator::Validate(), which is responsible to set " - "the validator on the error."); - return TfToken(); - } - // If the name is empty, return the validator's name. - if (_name.IsEmpty()) { - return _validator->GetMetadata().name; - } - return TfToken(_validator->GetMetadata().name.GetString() + - _tokens->ValidationErrorNameDelimiter.GetString() + - _name.GetString()); -} - -std::string -UsdValidationError::GetErrorAsString() const -{ - if (_validator) { - return _errorType == UsdValidationErrorType::None ? _errorMsg : - TfStringPrintf( - "%s: (%s) %s", TfEnum::GetDisplayName(_errorType).c_str(), - GetIdentifier().GetString().c_str(), _errorMsg.c_str()); - } else { - return _errorType == UsdValidationErrorType::None ? _errorMsg : - TfStringPrintf( - "%s: %s", TfEnum::GetDisplayName(_errorType).c_str(), - _errorMsg.c_str()); - } -} - -void -UsdValidationError::_SetValidator(const UsdValidator *validator) -{ - _validator = validator; -} - -PXR_NAMESPACE_CLOSE_SCOPE - diff --git a/pxr/usd/usd/validator.cpp b/pxr/usd/usd/validator.cpp deleted file mode 100644 index e70b48c49d..0000000000 --- a/pxr/usd/usd/validator.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// -// Copyright 2024 Pixar -// -// Licensed under the terms set forth in the LICENSE.txt file available at -// https://openusd.org/license. -// - -#include "pxr/usd/usd/validator.h" -#include "pxr/usd/usd/validationError.h" - -PXR_NAMESPACE_OPEN_SCOPE - -UsdValidator::UsdValidator(const UsdValidatorMetadata& metadata) : - _metadata(metadata) -{ -} - -UsdValidator::UsdValidator(const UsdValidatorMetadata& metadata, - const UsdValidateLayerTaskFn& validateLayerTaskFn) : - _metadata(metadata), _validateTaskFn(validateLayerTaskFn) -{ -} - -UsdValidator::UsdValidator(const UsdValidatorMetadata& metadata, - const UsdValidateStageTaskFn& validateStageTaskFn) : - _metadata(metadata), _validateTaskFn(validateStageTaskFn) -{ -} - -UsdValidator::UsdValidator(const UsdValidatorMetadata& metadata, - const UsdValidatePrimTaskFn& validatePrimTaskFn) : - _metadata(metadata), _validateTaskFn(validatePrimTaskFn) -{ -} - -const UsdValidateLayerTaskFn* -UsdValidator::_GetValidateLayerTask() const -{ - return std::get_if(&_validateTaskFn); -} - -const UsdValidateStageTaskFn* -UsdValidator::_GetValidateStageTask() const -{ - return std::get_if(&_validateTaskFn); -} - -const UsdValidatePrimTaskFn* -UsdValidator::_GetValidatePrimTask() const -{ - return std::get_if(&_validateTaskFn); -} - -UsdValidationErrorVector -UsdValidator::Validate(const SdfLayerHandle &layer) const -{ - const UsdValidateLayerTaskFn *layerTaskFn = _GetValidateLayerTask(); - if (layerTaskFn) { - UsdValidationErrorVector errors = (*layerTaskFn)(layer); - for (UsdValidationError &error : errors) { - error._SetValidator(this); - } - return errors; - } - return {}; -} - -UsdValidationErrorVector -UsdValidator::Validate(const UsdStagePtr &usdStage) const -{ - const UsdValidateStageTaskFn *stageTaskFn = _GetValidateStageTask(); - if (stageTaskFn) { - UsdValidationErrorVector errors = (*stageTaskFn)(usdStage); - for (UsdValidationError &error : errors) { - error._SetValidator(this); - } - return errors; - } - return {}; -} - -UsdValidationErrorVector -UsdValidator::Validate(const UsdPrim &usdPrim) const -{ - const UsdValidatePrimTaskFn *primTaskFn = _GetValidatePrimTask(); - if (primTaskFn) { - UsdValidationErrorVector errors = (*primTaskFn)(usdPrim); - for (UsdValidationError &error : errors) { - error._SetValidator(this); - } - return errors; - } - return {}; -} - -UsdValidatorSuite::UsdValidatorSuite(const UsdValidatorMetadata& metadata, - const std::vector& validators) : - _metadata(metadata), _containedValidators(validators) -{ -} - -PXR_NAMESPACE_CLOSE_SCOPE - diff --git a/pxr/usd/usd/validator.h b/pxr/usd/usd/validator.h deleted file mode 100644 index 1ce538d8d8..0000000000 --- a/pxr/usd/usd/validator.h +++ /dev/null @@ -1,281 +0,0 @@ -// -// Copyright 2024 Pixar -// -// Licensed under the terms set forth in the LICENSE.txt file available at -// https://openusd.org/license. -// -#ifndef PXR_USD_USD_VALIDATOR_H -#define PXR_USD_USD_VALIDATOR_H - -/// \file - -#include "pxr/pxr.h" -#include "pxr/base/tf/token.h" -#include "pxr/usd/usd/api.h" -#include "pxr/usd/usd/stage.h" - -#include -#include -#include - -PXR_NAMESPACE_OPEN_SCOPE - -class UsdValidationError; -using UsdValidationErrorVector = std::vector; -class UsdPrim; - -/// \class UsdValidatorMetadata -/// -/// A structure which describes metadata for a UsdValidator. -/// -/// The metadata values are populated from the plugInfo.json associated with a -/// validator's plugin. PlugInfo can provide the following validator metadata: -/// -/// - name: A required field. This metadatum stores the validator name. For -/// validators defined in a plugin, the name must be a fully qualified name -/// which includes the pluginName as well, separated by ":". This ensures, -/// plugin provided validator names are guaranteed to be unique. -/// - pluginPtr: Pointer to the plugin where a plugin based validator is defined. -/// nullptr for a non-plugin based validator. -/// - keywords: Keywords associated with this validator. -/// - doc: Doc string explaining the purpose of the validator. -/// - schemaTypes: If the validator is associated with specific schemaTypes. -/// - isSuite: If the validator represents a suite of validators. -/// -struct UsdValidatorMetadata -{ - /// Name of the validator. - /// - /// For plugin provided validators, this is prefixed with the pluginName, - /// like "pluginName:testName" in order to uniquely identify these plugin - /// provided validators. - /// - /// This is a mandatory field for a ValidatorMetadata. - TfToken name; - - /// Pointer to the plugin to which a plugin based validator belongs. - /// - /// For non-plugin based validator, pluginPtr is nullptr. - PlugPluginPtr pluginPtr; - - /// list of keywords extracted for this test from the plugInfo.json - TfTokenVector keywords; - - /// doc string extracted from plugInfo.json - /// This is a mandatory field for a ValidatorMetadata. - std::string doc; - - /// list of schemaTypes names this test applies to, extracted from - /// plugInfo.json - TfTokenVector schemaTypes; - - /// whether this test represents a test suite or not - bool isSuite; -}; // UsdValidatorMetadata - -using UsdValidatorMetadataVector = std::vector; - -// TODO: -// - TimeCode (Range), leaving right now for brevity. Will introduce in -// subsequent iterations. -// -// - -/// \defgroup UsdValidateTaskFn_group Validating Task Functions -/// -/// UsdValidateLayerTaskFn, UsdValidateStageTaskFn and UsdValidatePrimTaskFn -/// represent the callbacks associated with each validator's validation logic. -/// -/// Clients must provide implementation for these in their respective plugin -/// registration code. -/// @{ - -/// UsdValidateLayerTaskFn: Validation logic operating on a given SdfLayerHandle -using UsdValidateLayerTaskFn = std::function; -/// UsdValidateStageTaskFn: Validation logic operating on a given UsdStage -using UsdValidateStageTaskFn = std::function; -/// UsdValidatePrimTaskFn: Validation logic operating on a given UsdPrim -using UsdValidatePrimTaskFn = std::function; - -/// @} - -/// \class UsdValidator -/// -/// UsdValidator is a class describing a single test. -/// -/// An instance of UsdValidator is created when plugins are loaded and tests are -/// registered and cached in the UsdValidationRegistry. UsdValidator can -/// consist of any one of the 3 testing tasks: LayerTestingTask, -/// StageTestingTask or PrimTestingTask, which correspond to testing the given -/// SdfLayer, an entire UsdStage or a UsdPrim respectively. -/// -/// UsdValidator instances are immutable and non-copyable. Note that all -/// validators which are registered with the UsdValidationRegistry are immortal. -/// -/// \sa UsdValidationRegistry -class UsdValidator -{ -public: - /// Instantiate a UsdValidator which has no validation logic implementation. - /// This is primarily used by UsdValidatorSuite. - USD_API - explicit UsdValidator(const UsdValidatorMetadata &metadata); - - UsdValidator(const UsdValidator &other) = delete; - UsdValidator &operator=(const UsdValidator&) = delete; - - UsdValidator(UsdValidator &&other) noexcept = default; - UsdValidator& operator=(UsdValidator&&) noexcept = default; - - /// Instantiate a UsdValidator which has its validation logic implemented by - /// a UsdValidateLayerTaskFn. - USD_API - UsdValidator(const UsdValidatorMetadata &metadata, - const UsdValidateLayerTaskFn &validateLayerTaskFn); - - /// Instantiate a UsdValidator which has its validation logic implemented by - /// a UsdValidateStageTaskFn. - USD_API - UsdValidator(const UsdValidatorMetadata &metadata, - const UsdValidateStageTaskFn &validateStageTaskFn); - - /// Instantiate a UsdValidator which has its validation logic implemented by - /// a UsdValidatePrimTaskFn. - USD_API - UsdValidator(const UsdValidatorMetadata &metadata, - const UsdValidatePrimTaskFn &validatePrimTaskFn); - - /// Return metadata associated with this Validator. - const UsdValidatorMetadata& GetMetadata() const & - { - return _metadata; - } - - /// Return metadata associated with this validator by-value. - UsdValidatorMetadata GetMetadata() && - { - return std::move(_metadata); - } - - /// Run validation on the given \p layer by executing the contained - /// validateTaskFn and returns UsdValidationErrorVector. - /// - /// If this Validator doesn't provide a UsdValidateLayerTaskFn, then an - /// empty vector is returned, which signifies no error. - USD_API - UsdValidationErrorVector Validate(const SdfLayerHandle &layer) const; - - /// Run validation on the given \p usdStage by executing the contained - /// validateTaskFn and returns UsdValidationErrorVector. - /// - /// If this Validator doesn't provide a UsdValidateStageTaskFn, then an - /// empty vector is returned, which signifies no error. - USD_API - UsdValidationErrorVector Validate(const UsdStagePtr &usdStage) const; - - /// Run validation on the given \p usdPrim by executing the contained - /// validateTaskFn and returns UsdValidationErrorVector. - /// - /// If this Validator doesn't provide a UsdValidatePrimTaskFn, then an - /// empty vector is returned, which signifies no error. - USD_API - UsdValidationErrorVector Validate(const UsdPrim& usdPrim) const; - -private: - // To make sure registry can query task types on a validator. - // Registry needs access to _GetValidatorPrimTasks, in order to determine if - // the contained validators in a suite, which provides schemaTypes metadata - // are compliant. - friend class UsdValidationRegistry; - // In order to distribute validators into different sets based on the type - // of validation to be performed, ValidationContext needs to access - // _GetValidateLayerTask, _GetValidateStageTask and _GetValidatePrimTask. - friend class UsdValidationContext; - - UsdValidatorMetadata _metadata; - std::variant _validateTaskFn; - - // Return UsdValidateLayerTaskFn if provided by the validator, else a - // nullptr. - const UsdValidateLayerTaskFn* _GetValidateLayerTask() const; - - // Return UsdValidateStageTaskFn if provided by the validator, else a - // nullptr. - const UsdValidateStageTaskFn* _GetValidateStageTask() const; - - // Return UsdValidatePrimTaskFn if provided by the validator, else a - // nullptr. - const UsdValidatePrimTaskFn* _GetValidatePrimTask() const; - -}; // UsdValidator - -/// \class UsdValidatorSuite -/// -/// UsdValidatorSuite acts like a suite for a collection of tests, which -/// clients can use to bundle all tests relevant to test their concepts. -/// -/// If client failed to provide isSuite metadata for a UsdValidatorSuite -/// instance then the validatorSuite will not be registered, and client will -/// appropriately be warned. -/// -/// UsdValidatorSuite instances are immutable and non-copyable. Note that all -/// validator suites which are registered with the UsdValidationRegistry are -/// immortal. -/// -/// \sa UsdValidationRegistry -class UsdValidatorSuite -{ -public: - /// Instantiate UsdValidatorSuite using \p metadata and a vector of \p - /// validators. - USD_API - UsdValidatorSuite(const UsdValidatorMetadata &metadata, - const std::vector& validators); - - UsdValidatorSuite(UsdValidatorSuite &&other) noexcept = default; - - UsdValidatorSuite& operator=(UsdValidatorSuite&&) noexcept = default; - - /// Returns a vector of const UsdValidator pointers, which make this - /// UsdValidatorSuite. Note that the validators are guaranteed to be valid, - /// since their lifetime is managed by the UsdValidationRegistry, which has - /// a higher scope than individual validators. - const std::vector& GetContainedValidators() const & - { - return _containedValidators; - } - - /// Returns a vector of const UsdValidator pointers, which make this - /// UsdValidatorSuite. Note that the validators are guaranteed to be valid, - /// since their lifetime is managed by the UsdValidationRegistry, which has - /// a higher scope than individual validators. - std::vector GetContainedValidators() && - { - return std::move(_containedValidators); - } - - /// Return metadata associated with this validator. - const UsdValidatorMetadata& GetMetadata() const & - { - return _metadata; - } - - /// Return metadata associated with this validator. - UsdValidatorMetadata GetMetadata() && - { - return std::move(_metadata); - } - -private: - UsdValidatorMetadata _metadata; - std::vector _containedValidators; -}; // UsdValidatorSuite - -PXR_NAMESPACE_CLOSE_SCOPE - -#endif // PXR_USD_USD_VALIDATOR_H diff --git a/pxr/usd/usd/validatorTokens.h b/pxr/usd/usd/validatorTokens.h deleted file mode 100644 index a87da39570..0000000000 --- a/pxr/usd/usd/validatorTokens.h +++ /dev/null @@ -1,52 +0,0 @@ -// -// Copyright 2024 Pixar -// -// Licensed under the terms set forth in the LICENSE.txt file available at -// https://openusd.org/license. -// - -#ifndef USD_VALIDATOR_TOKENS_H -#define USD_VALIDATOR_TOKENS_H - -/// \file usd/validatorTokens.h - -#include "pxr/pxr.h" -#include "pxr/usd/usd/api.h" -#include "pxr/base/tf/staticTokens.h" - -PXR_NAMESPACE_OPEN_SCOPE - -#define USD_VALIDATOR_NAME_TOKENS \ - ((compositionErrorTest, "usd:CompositionErrorTest")) \ - ((stageMetadataChecker, "usd:StageMetadataChecker")) - -#define USD_VALIDATOR_KEYWORD_TOKENS \ - (UsdCoreValidators) - -#define USD_VALIDATION_ERROR_NAME_TOKENS \ - ((compositionError, "CompositionError")) \ - ((missingDefaultPrim, "MissingDefaultPrim")) - -/// \def USD_VALIDATOR_NAME_TOKENS -/// Tokens representing validator names. Note that for plugin provided -/// validators, the names must be prefixed by usd:, which is the name of -/// the usd plugin. -TF_DECLARE_PUBLIC_TOKENS(UsdValidatorNameTokens, USD_API, - USD_VALIDATOR_NAME_TOKENS); - -/// \def USD_VALIDATOR_KEYWORD_TOKENS -/// Tokens representing keywords associated with any validator in the usd -/// plugin. Clients can use this to inspect validators contained within a -/// specific keywords, or use these to be added as keywords to any new -/// validator. -TF_DECLARE_PUBLIC_TOKENS(UsdValidatorKeywordTokens, USD_API, - USD_VALIDATOR_KEYWORD_TOKENS); - -/// \def USD_VALIDATION_ERROR_NAME_TOKENS -/// Tokens representing validation error identifier. -TF_DECLARE_PUBLIC_TOKENS(UsdValidationErrorNameTokens, USD_API, - USD_VALIDATION_ERROR_NAME_TOKENS); - -PXR_NAMESPACE_CLOSE_SCOPE - -#endif diff --git a/pxr/usd/usdGeom/CMakeLists.txt b/pxr/usd/usdGeom/CMakeLists.txt index 287473f984..d78efe5905 100644 --- a/pxr/usd/usdGeom/CMakeLists.txt +++ b/pxr/usd/usdGeom/CMakeLists.txt @@ -26,15 +26,11 @@ pxr_library(usdGeom boundableComputeExtent metrics primvar - validatorTokens xformOp - + PUBLIC_HEADERS api.h - - CPPFILES - validators.cpp - + PYTHON_CPPFILES moduleDeps.cpp @@ -122,14 +118,6 @@ pxr_build_test(testUsdGeomHasAPI testenv/testUsdGeomHasAPI.cpp ) -pxr_build_test(testUsdGeomValidators - LIBRARIES - usd - usdGeom - CPPFILES - testenv/testUsdGeomValidators.cpp -) - pxr_install_test_dir( SRC testenv/testUsdGeomBasisCurves DEST testUsdGeomBasisCurves @@ -348,8 +336,3 @@ pxr_register_test(testUsdGeomImageable EXPECTED_RETURN_CODE 0 ) -pxr_register_test(testUsdGeomValidators - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdGeomValidators" - EXPECTED_RETURN_CODE 0 -) - diff --git a/pxr/usd/usdGeom/plugInfo.json b/pxr/usd/usdGeom/plugInfo.json index 6da405f035..4591d0a85d 100644 --- a/pxr/usd/usdGeom/plugInfo.json +++ b/pxr/usd/usdGeom/plugInfo.json @@ -421,32 +421,6 @@ "schemaIdentifier": "Xformable", "schemaKind": "abstractTyped" } - }, - "Validators": { - "StageMetadataChecker": { - "doc": "All stages must declare their 'upAxis' and 'metersPerUnit'." - }, - "SubsetFamilies": { - "doc": "Validates all of the geom subset families authored beneath an Imageable prim.", - "keywords": [ - "UsdGeomSubset" - ], - "schemaTypes": [ - "UsdGeomImageable" - ] - }, - "SubsetParentIsImageable": { - "doc": "Validates that GeomSubset prims are direct descendants of an Imageable prim.", - "keywords": [ - "UsdGeomSubset" - ], - "schemaTypes": [ - "UsdGeomSubset" - ] - }, - "keywords": [ - "UsdGeomValidators" - ] } }, "LibraryPath": "@PLUG_INFO_LIBRARY_PATH@", diff --git a/pxr/usd/usdGeom/validators.cpp b/pxr/usd/usdGeom/validators.cpp deleted file mode 100644 index dff9b71561..0000000000 --- a/pxr/usd/usdGeom/validators.cpp +++ /dev/null @@ -1,175 +0,0 @@ -// -// Copyright 2024 Pixar -// -// Licensed under the terms set forth in the LICENSE.txt file available at -// https://openusd.org/license. -// - -#include "pxr/base/tf/registryManager.h" -#include "pxr/base/tf/stringUtils.h" -#include "pxr/base/tf/token.h" -#include "pxr/usd/usd/prim.h" -#include "pxr/usd/usd/schemaRegistry.h" -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usd/validationRegistry.h" -#include "pxr/usd/usd/validator.h" -#include "pxr/usd/usdGeom/imageable.h" -#include "pxr/usd/usdGeom/subset.h" -#include "pxr/usd/usdGeom/tokens.h" -#include "pxr/usd/usdGeom/validatorTokens.h" - -#include -#include -#include - -PXR_NAMESPACE_OPEN_SCOPE - -static -UsdValidationErrorVector -_GetStageMetadataErrors(const UsdStagePtr &usdStage) -{ - UsdValidationErrorVector errors; - if (!usdStage->HasAuthoredMetadata( - UsdGeomTokens->metersPerUnit)) { - errors.emplace_back( - UsdGeomValidationErrorNameTokens->missingMetersPerUnitMetadata, - UsdValidationErrorType::Error, - UsdValidationErrorSites{UsdValidationErrorSite(usdStage, - SdfPath("/"))}, - TfStringPrintf("Stage with root layer <%s> does not specify its " - "linear scale in metersPerUnit.", - usdStage->GetRootLayer()->GetIdentifier().c_str())); - } - if (!usdStage->HasAuthoredMetadata( - UsdGeomTokens->upAxis)) { - errors.emplace_back( - UsdGeomValidationErrorNameTokens->missingUpAxisMetadata, - UsdValidationErrorType::Error, - UsdValidationErrorSites{UsdValidationErrorSite(usdStage, - SdfPath("/"))}, - TfStringPrintf("Stage with root layer <%s> does not specify an " - "upAxis.", - usdStage->GetRootLayer()->GetIdentifier().c_str())); - } - - return errors; -} - -static -UsdValidationErrorVector -_SubsetFamilies(const UsdPrim& usdPrim) -{ - if (!(usdPrim && usdPrim.IsInFamily( - UsdSchemaRegistry::VersionPolicy::All))) { - return {}; - } - - const UsdGeomImageable imageable(usdPrim); - if (!imageable) { - return {}; - } - - const TfToken::Set subsetFamilyNames = - UsdGeomSubset::GetAllGeomSubsetFamilyNames(imageable); - - // Sort the family names so that they are in dictionary order, making - // the order in which they are validated more predictable. - TfTokenVector subsetFamilyNamesVec( - subsetFamilyNames.begin(), subsetFamilyNames.end()); - std::sort( - subsetFamilyNamesVec.begin(), subsetFamilyNamesVec.end(), - TfDictionaryLessThan()); - - UsdValidationErrorVector errors; - - for (const TfToken& subsetFamilyName : subsetFamilyNamesVec) { - const std::vector familySubsets = - UsdGeomSubset::GetGeomSubsets( - imageable, - /* elementType = */ TfToken(), - /* familyName = */ subsetFamilyName); - - // Determine the element type of the family by looking at the - // first subset. - TfToken elementType; - familySubsets[0u].GetElementTypeAttr().Get(&elementType); - - std::string reason; - if (!UsdGeomSubset::ValidateFamily( - imageable, elementType, subsetFamilyName, &reason)) { - const UsdValidationErrorSites primErrorSites = { - UsdValidationErrorSite(usdPrim.GetStage(), usdPrim.GetPath()) - }; - - errors.emplace_back( - UsdGeomValidationErrorNameTokens->invalidSubsetFamily, - UsdValidationErrorType::Error, - primErrorSites, - TfStringPrintf( - "Imageable prim <%s> has invalid subset family '%s': %s", - usdPrim.GetPath().GetText(), - subsetFamilyName.GetText(), - reason.c_str()) - ); - } - } - - return errors; -} - -static -UsdValidationErrorVector -_SubsetParentIsImageable(const UsdPrim& usdPrim) -{ - if (!(usdPrim && usdPrim.IsInFamily( - UsdSchemaRegistry::VersionPolicy::All))) { - return {}; - } - - const UsdGeomSubset subset(usdPrim); - if (!subset) { - return {}; - } - - const UsdPrim parentPrim = usdPrim.GetParent(); - const UsdGeomImageable parentImageable(parentPrim); - if (parentImageable) { - return {}; - } - - const UsdValidationErrorSites primErrorSites = { - UsdValidationErrorSite(usdPrim.GetStage(), usdPrim.GetPath()) - }; - - return { - UsdValidationError( - UsdGeomValidationErrorNameTokens->notImageableSubsetParent, - UsdValidationErrorType::Error, - primErrorSites, - TfStringPrintf( - "GeomSubset <%s> has direct parent prim <%s> that is not " - "Imageable.", - usdPrim.GetPath().GetText(), - parentPrim.GetPath().GetText()) - ) - }; -} - -TF_REGISTRY_FUNCTION(UsdValidationRegistry) -{ - UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); - - registry.RegisterPluginValidator( - UsdGeomValidatorNameTokens->stageMetadataChecker, - _GetStageMetadataErrors); - - registry.RegisterPluginValidator( - UsdGeomValidatorNameTokens->subsetFamilies, - _SubsetFamilies); - - registry.RegisterPluginValidator( - UsdGeomValidatorNameTokens->subsetParentIsImageable, - _SubsetParentIsImageable); -} - -PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usd/usdShade/CMakeLists.txt b/pxr/usd/usdShade/CMakeLists.txt index 78e557aade..259f811203 100644 --- a/pxr/usd/usdShade/CMakeLists.txt +++ b/pxr/usd/usdShade/CMakeLists.txt @@ -24,7 +24,6 @@ pxr_library(usdShade output shaderDefParser shaderDefUtils - validatorTokens udimUtils utils @@ -32,9 +31,6 @@ pxr_library(usdShade api.h types.h - CPPFILES - validators.cpp - PYTHON_CPPFILES moduleDeps.cpp @@ -63,16 +59,6 @@ pxr_build_test(testUsdShadeHasConnectableAPI testenv/testUsdShadeHasConnectableAPI.cpp ) -pxr_build_test(testUsdShadeValidators - LIBRARIES - sdr - tf - usd - usdShade - CPPFILES - testenv/testUsdShadeValidators.cpp -) - pxr_test_scripts( testenv/testUsdShadeBinding.py testenv/testUsdShadeConnectability.py @@ -149,11 +135,6 @@ pxr_install_test_dir( DEST testUsdShadeUdimUtils ) -pxr_install_test_dir( - SRC testenv/testUsdShadeValidators - DEST testUsdShadeValidators -) - pxr_register_test(testUsdShadeBinding PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdShadeBinding" @@ -263,9 +244,3 @@ pxr_register_test(testUsdShadeUdimUtils COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdShadeUdimUtils" EXPECTED_RETURN_CODE 0 ) - -pxr_register_test(testUsdShadeValidators - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdShadeValidators" - EXPECTED_RETURN_CODE 0 -) - diff --git a/pxr/usd/usdShade/plugInfo.json b/pxr/usd/usdShade/plugInfo.json index c7dcb46998..865bf67eae 100644 --- a/pxr/usd/usdShade/plugInfo.json +++ b/pxr/usd/usdShade/plugInfo.json @@ -133,50 +133,6 @@ ], "displayName": "USD-based shader definition parser plugin" } - }, - "Validators": { - "EncapsulationRulesValidator": { - "doc": "Connectable prims (e.g. Shader, Material, etc) can only be nested inside other Container-like Connectable prims. Container-like prims include Material, NodeGraph, Light, LightFilter. Shader is not a Container-like prim." - }, - "MaterialBindingApiAppliedValidator": { - "doc": "Verify a prim has the MaterialBindingAPI applied if it has a material binding relationship." - }, - "MaterialBindingCollectionValidator": { - "doc": "Verify that a collection defining a material binding is well-formed", - "schemaTypes": [ - "MaterialBindingAPI" - ] - }, - "MaterialBindingRelationships": { - "doc": "All properties named 'material:binding' or in that namespace should be relationships." - }, - "ShaderSdrCompliance": { - "doc": "Shader prim's input types must be conforming to their appropriate sdf types in the respective sdr shader.", - "schemaTypes": [ - "UsdShadeShader" - ] - }, - "SubsetMaterialBindFamilyName": { - "doc": "Geom subsets with authored material bindings should have the 'materialBind' family name.", - "keywords": [ - "UsdGeomSubset" - ], - "schemaTypes": [ - "UsdGeomSubset" - ] - }, - "SubsetsMaterialBindFamily": { - "doc": "Geom subsets of the 'materialBind' family should have a restricted family type.", - "keywords": [ - "UsdGeomSubset" - ], - "schemaTypes": [ - "UsdGeomImageable" - ] - }, - "keywords": [ - "UsdShadeValidators" - ] } }, "LibraryPath": "@PLUG_INFO_LIBRARY_PATH@", diff --git a/pxr/usd/usdShade/validatorTokens.h b/pxr/usd/usdShade/validatorTokens.h deleted file mode 100644 index afc2a909b6..0000000000 --- a/pxr/usd/usdShade/validatorTokens.h +++ /dev/null @@ -1,69 +0,0 @@ -// -// Copyright 2024 Pixar -// -// Licensed under the terms set forth in the LICENSE.txt file available at -// https://openusd.org/license. -// - -#ifndef USDSHADE_VALIDATOR_TOKENS_H -#define USDSHADE_VALIDATOR_TOKENS_H - -/// \file - -#include "pxr/pxr.h" -#include "pxr/usd/usdShade/api.h" -#include "pxr/base/tf/staticTokens.h" - -PXR_NAMESPACE_OPEN_SCOPE - -#define USD_SHADE_VALIDATOR_NAME_TOKENS \ - ((encapsulationValidator, "usdShade:EncapsulationRulesValidator")) \ - ((materialBindingApiAppliedValidator, "usdShade:MaterialBindingApiAppliedValidator")) \ - ((materialBindingRelationships, "usdShade:MaterialBindingRelationships")) \ - ((materialBindingCollectionValidator, "usdShade:MaterialBindingCollectionValidator")) \ - ((shaderSdrCompliance, "usdShade:ShaderSdrCompliance")) \ - ((subsetMaterialBindFamilyName, "usdShade:SubsetMaterialBindFamilyName")) \ - ((subsetsMaterialBindFamily, "usdShade:SubsetsMaterialBindFamily")) - -#define USD_SHADE_VALIDATOR_KEYWORD_TOKENS \ - (UsdShadeValidators) - -#define USD_SHADE_VALIDATION_ERROR_NAME_TOKENS \ - ((connectableInNonContainer, "ConnectableInNonContainer")) \ - ((invalidConnectableHierarchy, "InvalidConnectableHierarchy")) \ - ((missingMaterialBindingAPI, "MissingMaterialBindingAPI")) \ - ((materialBindingPropNotARel, "MaterialBindingPropNotARel")) \ - ((invalidMaterialCollection, "InvalidMaterialCollection")) \ - ((invalidResourcePath, "InvalidResourcePath")) \ - ((invalidImplSource, "InvalidImplementationSrc")) \ - ((missingSourceType, "MissingSourceType")) \ - ((missingShaderIdInRegistry, "MissingShaderIdInRegistry")) \ - ((missingSourceTypeInRegistry, "MissingSourceTypeInRegistry")) \ - ((incompatShaderPropertyWarning, "IncompatShaderPropertyWarning")) \ - ((mismatchPropertyType, "MismatchedPropertyType")) \ - ((missingFamilyNameOnGeomSubset, "MissingFamilyNameOnGeomSubset")) \ - ((invalidFamilyType, "InvalidFamilyType")) \ - -/// \def USD_SHADE_VALIDATOR_NAME_TOKENS -/// Tokens representing validator names. Note that for plugin provided -/// validators, the names must be prefixed by usdShade:, which is the name of -/// the usdShade plugin. -TF_DECLARE_PUBLIC_TOKENS(UsdShadeValidatorNameTokens, USDSHADE_API, - USD_SHADE_VALIDATOR_NAME_TOKENS); - -/// \def USD_SHADE_VALIDATOR_KEYWORD_TOKENS -/// Tokens representing keywords associated with any validator in the usdShade -/// plugin. Cliends can use this to inspect validators contained within a -/// specific keywords, or use these to be added as keywords to any new -/// validator. -TF_DECLARE_PUBLIC_TOKENS(UsdShadeValidatorKeywordTokens, USDSHADE_API, - USD_SHADE_VALIDATOR_KEYWORD_TOKENS); - -/// \def USD_SHADE_VALIDATION_ERROR_NAME_TOKENS -/// Tokens representing validation error identifier. -TF_DECLARE_PUBLIC_TOKENS(UsdShadeValidationErrorNameTokens, USDSHADE_API, - USD_SHADE_VALIDATION_ERROR_NAME_TOKENS); - -PXR_NAMESPACE_CLOSE_SCOPE - -#endif diff --git a/pxr/usd/usdSkel/CMakeLists.txt b/pxr/usd/usdSkel/CMakeLists.txt index 614bbba37e..43589e8966 100644 --- a/pxr/usd/usdSkel/CMakeLists.txt +++ b/pxr/usd/usdSkel/CMakeLists.txt @@ -31,10 +31,6 @@ pxr_library(usdSkel skinningQuery topology utils - validatorTokens - - CPPFILES - validators.cpp PUBLIC_HEADERS api.h @@ -80,15 +76,6 @@ pxr_library(usdSkel images/unboundedInterpolationExample.svg ) -pxr_build_test(testUsdSkelValidators - LIBRARIES - tf - usd - usdSkel - CPPFILES - testenv/testUsdSkelValidators.cpp -) - pxr_test_scripts( testenv/testUsdSkelAnimMapper.py testenv/testUsdSkelAnimQuery.py @@ -185,8 +172,3 @@ pxr_register_test(testUsdSkelUtils EXPECTED_RETURN_CODE 0 ) -pxr_register_test(testUsdSkelValidators - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdSkelValidators" - EXPECTED_RETURN_CODE 0 -) - diff --git a/pxr/usd/usdSkel/plugInfo.json b/pxr/usd/usdSkel/plugInfo.json index ad8381e27f..cccf32a8c9 100644 --- a/pxr/usd/usdSkel/plugInfo.json +++ b/pxr/usd/usdSkel/plugInfo.json @@ -74,20 +74,6 @@ "schemaIdentifier": "Skeleton", "schemaKind": "concreteTyped" } - }, - "Validators": { - "SkelBindingApiAppliedValidator": { - "doc": "Verify a prim has the SkelBindingAPI applied if it has a UsdSkelBinding property." - }, - "SkelBindingApiValidator": { - "doc": "Verify that a prim with SkelBindingAPI applied, is either of SkelRoot type or parented by a SkelRoot prim.", - "schemaTypes": [ - "UsdSkelBindingAPI" - ] - }, - "keywords": [ - "UsdSkelValidators" - ] } }, "LibraryPath": "@PLUG_INFO_LIBRARY_PATH@", diff --git a/pxr/usd/usdSkel/validators.cpp b/pxr/usd/usdSkel/validators.cpp deleted file mode 100644 index b1ecf8f5ec..0000000000 --- a/pxr/usd/usdSkel/validators.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// -// Copyright 2024 Pixar -// -// Licensed under the terms set forth in the LICENSE.txt file available at -// https://openusd.org/license. -// -#include "pxr/usd/usd/prim.h" -#include "pxr/usd/usd/schemaRegistry.h" -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usd/validationRegistry.h" -#include "pxr/usd/usd/validator.h" -#include "pxr/base/tf/token.h" -#include "pxr/base/tf/stringUtils.h" -#include "pxr/usd/usdSkel/validatorTokens.h" -#include "pxr/usd/usdSkel/bindingAPI.h" - -#include -#include - -PXR_NAMESPACE_OPEN_SCOPE - -static -UsdValidationErrorVector -_SkelBindingApiAppliedValidator(const UsdPrim &usdPrim) -{ - UsdValidationErrorVector errors; - - if (!usdPrim.HasAPI()){ - static const std::unordered_set skelPropertyNames = - []() { - UsdSchemaRegistry& usdSchemaRegistry = - UsdSchemaRegistry::GetInstance(); - std::unique_ptr primDef = - usdSchemaRegistry.BuildComposedPrimDefinition( - TfToken(), {UsdSkelTokens->SkelBindingAPI}); - const std::vector skelPropertyNamesVector = - primDef->GetPropertyNames(); - return std::unordered_set( - skelPropertyNamesVector.begin(), - skelPropertyNamesVector.end()); - }(); - - const std::vector primPropertyNames = - usdPrim.GetPropertyNames(); - for (const TfToken &primToken : primPropertyNames){ - if (skelPropertyNames.find(primToken) == skelPropertyNames.end()){ - continue; - } - errors.emplace_back( - UsdSkelValidationErrorNameTokens->missingSkelBindingAPI, - UsdValidationErrorType::Error, - UsdValidationErrorSites{ - UsdValidationErrorSite(usdPrim.GetStage(), - usdPrim.GetPath()) - }, - TfStringPrintf(("Found a UsdSkelBinding property (%s), " - "but no SkelBindingAPI applied on the prim " - "<%s>."), primToken.GetText(), - usdPrim.GetPath().GetText())); - break; - } - } - - return errors; -} - -static -UsdValidationErrorVector -_SkelBindingApiValidator(const UsdPrim &usdPrim) -{ - UsdValidationErrorVector errors; - - if (!usdPrim.HasAPIInFamily(UsdSkelTokens->SkelBindingAPI)) { - return {}; - } - - if (usdPrim.GetTypeName() != UsdSkelTokens->SkelRoot) { - UsdPrim parentPrim = usdPrim.GetParent(); - while (parentPrim && !parentPrim.IsPseudoRoot()) { - if (parentPrim.GetTypeName() != UsdSkelTokens->SkelRoot) { - parentPrim = parentPrim.GetParent(); - } - else { - return errors; - } - } - errors.emplace_back( - UsdSkelValidationErrorNameTokens->invalidSkelBindingAPIApply, - UsdValidationErrorType::Error, - UsdValidationErrorSites{ - UsdValidationErrorSite(usdPrim.GetStage(), - usdPrim.GetPath()) - }, - TfStringPrintf(("UsdSkelBindingAPI applied on prim: <%s>, " - "which is not of type SkelRoot or is not " - "rooted at a prim of type SkelRoot, as " - "required by the UsdSkel schema."), - usdPrim.GetPath().GetText())); - } - return errors; -} - -TF_REGISTRY_FUNCTION(UsdValidationRegistry) -{ - UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); - - registry.RegisterPluginValidator( - UsdSkelValidatorNameTokens->skelBindingApiAppliedValidator, - _SkelBindingApiAppliedValidator); - - registry.RegisterPluginValidator( - UsdSkelValidatorNameTokens->skelBindingApiValidator, - _SkelBindingApiValidator); -} - -PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usd/usdUtils/CMakeLists.txt b/pxr/usd/usdUtils/CMakeLists.txt index 5e27b27b4c..40fc2cdb34 100644 --- a/pxr/usd/usdUtils/CMakeLists.txt +++ b/pxr/usd/usdUtils/CMakeLists.txt @@ -32,7 +32,6 @@ pxr_library(usdUtils stitchClips timeCodeRange usdzPackage - validatorTokens PRIVATE_CLASSES assetLocalization @@ -43,9 +42,6 @@ pxr_library(usdUtils api.h userProcessingFunc.h - CPPFILES - validators.cpp - PYTHON_CPPFILES moduleDeps.cpp @@ -76,9 +72,6 @@ pxr_library(usdUtils updateSchemaWithSdrNode.py usdzUtils.py - RESOURCE_FILES - plugInfo.json - DOXYGEN_FILES overview.dox ) @@ -148,18 +141,6 @@ pxr_build_test(testUsdUtilsTimeCodeRangeCpp testenv/testUsdUtilsTimeCodeRange.cpp ) -pxr_build_test(testUsdUtilsValidators - LIBRARIES - ar - arch - tf - sdf - usd - usdUtils - CPPFILES - testenv/testUsdUtilsValidators.cpp -) - pxr_install_test_dir( SRC testenv/testUsdUtilsAuthoring DEST testUsdUtilsAuthoring @@ -316,11 +297,6 @@ pxr_install_test_dir( DEST testUsdUtilsUserProcessingFunc ) -pxr_install_test_dir( - SRC testenv/testUsdUtilsValidators - DEST testUsdUtilsValidators -) - pxr_register_test(testUsdUtilsAuthoring PYTHON COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdUtilsAuthoring" @@ -734,8 +710,3 @@ pxr_register_test(testUsdUtilsUsdzUtils COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdUtilsUsdzUtils" EXPECTED_RETURN_CODE 0 ) - -pxr_register_test(testUsdUtilsValidators - COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdUtilsValidators" - EXPECTED_RETURN_CODE 0 -) diff --git a/pxr/usdValidation/CMakeLists.txt b/pxr/usdValidation/CMakeLists.txt new file mode 100644 index 0000000000..3d26a7129d --- /dev/null +++ b/pxr/usdValidation/CMakeLists.txt @@ -0,0 +1,11 @@ +set(DIRS + usdValidation + usdGeomValidators + usdShadeValidators + usdSkelValidators + usdUtilsValidators +) + +foreach(d ${DIRS}) + add_subdirectory(${d}) +endforeach() diff --git a/pxr/usdValidation/usdGeomValidators/CMakeLists.txt b/pxr/usdValidation/usdGeomValidators/CMakeLists.txt new file mode 100644 index 0000000000..28471a0893 --- /dev/null +++ b/pxr/usdValidation/usdGeomValidators/CMakeLists.txt @@ -0,0 +1,41 @@ +set(PXR_PREFIX pxr/usdValidation) +set(PXR_PACKAGE usdGeomValidators) + +pxr_library(usdGeomValidators + LIBRARIES + tf + plug + sdf + usd + usdGeom + usdValidation + + PUBLIC_CLASSES + validatorTokens + + PUBLIC_HEADERS + api.h + + CPPFILES + validators.cpp + + RESOURCE_FILES + plugInfo.json +) + +pxr_build_test(testUsdGeomValidators + LIBRARIES + tf + usd + usdValidation + usdGeom + usdGeomValidators + CPPFILES + testenv/testUsdGeomValidators.cpp +) + +pxr_register_test(testUsdGeomValidators + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdGeomValidators" + EXPECTED_RETURN_CODE 0 +) + diff --git a/pxr/usdValidation/usdGeomValidators/api.h b/pxr/usdValidation/usdGeomValidators/api.h new file mode 100644 index 0000000000..8e1b4760bf --- /dev/null +++ b/pxr/usdValidation/usdGeomValidators/api.h @@ -0,0 +1,34 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +#ifndef PXR_USD_VALIDATION_USD_GEOM_VALIDATORS_API_H +#define PXR_USD_VALIDATION_USD_GEOM_VALIDATORS_API_H + +#include "pxr/base/arch/export.h" + +#if defined(PXR_STATIC) +# define USDGEOMVALIDATORS_API +# define USDGEOMVALIDATORS_API_TEMPLATE_CLASS(...) +# define USDGEOMVALIDATORS_API_TEMPLATE_STRUCT(...) +# define USDGEOMVALIDATORS_API_LOCAL +#else +# if defined(USDGEOMVALIDATORS_API_EXPORTS) +# define USDGEOMVALIDATORS_API ARCH_EXPORT +# define USDGEOMVALIDATORS_API_TEMPLATE_CLASS(...) \ + ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__) +# define USDGEOMVALIDATORS_API_TEMPLATE_STRUCT(...) \ + ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__) +# else +# define USDGEOMVALIDATORS_API ARCH_IMPORT +# define USDGEOMVALIDATORS_API_TEMPLATE_CLASS(...) \ + ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__) +# define USDGEOMVALIDATORS_API_TEMPLATE_STRUCT(...) \ + ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__) +# endif +# define USDGEOMVALIDATORS_API_LOCAL ARCH_HIDDEN +#endif + +#endif diff --git a/pxr/usdValidation/usdGeomValidators/plugInfo.json b/pxr/usdValidation/usdGeomValidators/plugInfo.json new file mode 100644 index 0000000000..4ba1af11b9 --- /dev/null +++ b/pxr/usdValidation/usdGeomValidators/plugInfo.json @@ -0,0 +1,39 @@ +{ + "Plugins": [ + { + "Info": { + "Validators": { + "StageMetadataChecker": { + "doc": "All stages must declare their 'upAxis' and 'metersPerUnit'." + }, + "SubsetFamilies": { + "doc": "Validates all of the geom subset families authored beneath an Imageable prim.", + "keywords": [ + "UsdGeomSubset" + ], + "schemaTypes": [ + "UsdGeomImageable" + ] + }, + "SubsetParentIsImageable": { + "doc": "Validates that GeomSubset prims are direct descendants of an Imageable prim.", + "keywords": [ + "UsdGeomSubset" + ], + "schemaTypes": [ + "UsdGeomSubset" + ] + }, + "keywords": [ + "UsdGeomValidators" + ] + } + }, + "LibraryPath": "@PLUG_INFO_LIBRARY_PATH@", + "Name": "usdGeomValidators", + "ResourcePath": "@PLUG_INFO_RESOURCE_PATH@", + "Root": "@PLUG_INFO_ROOT@", + "Type": "library" + } + ] +} diff --git a/pxr/usd/usdGeom/testenv/testUsdGeomValidators.cpp b/pxr/usdValidation/usdGeomValidators/testenv/testUsdGeomValidators.cpp similarity index 76% rename from pxr/usd/usdGeom/testenv/testUsdGeomValidators.cpp rename to pxr/usdValidation/usdGeomValidators/testenv/testUsdGeomValidators.cpp index 376deeebe9..49160f81fc 100644 --- a/pxr/usd/usdGeom/testenv/testUsdGeomValidators.cpp +++ b/pxr/usdValidation/usdGeomValidators/testenv/testUsdGeomValidators.cpp @@ -5,19 +5,19 @@ // https://openusd.org/license. // -#include "pxr/usd/usd/validator.h" -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usdGeom/validatorTokens.h" -#include "pxr/usd/usd/validationRegistry.h" #include "pxr/usd/usdGeom/metrics.h" #include "pxr/usd/usdGeom/tokens.h" +#include "pxr/usdValidation/usdGeomValidators/validatorTokens.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" +#include "pxr/usdValidation/usdValidation/validator.h" #include PXR_NAMESPACE_USING_DIRECTIVE TF_DEFINE_PRIVATE_TOKENS(_tokens, - ((usdGeomPlugin, "usdGeom")) + ((usdGeomValidatorsPlugin, "usdGeomValidators")) ); void @@ -31,18 +31,19 @@ TestUsdGeomValidators() UsdGeomValidatorNameTokens->stageMetadataChecker, }; - const UsdValidationRegistry& registry = - UsdValidationRegistry::GetInstance(); + const UsdValidationRegistry ®istry + = UsdValidationRegistry::GetInstance(); // Since other validators can be registered with the same keywords, // our validators registered in usdGeom are/may be a subset of the // entire set. std::set validatorMetadataNameSet; - UsdValidatorMetadataVector metadata = - registry.GetValidatorMetadataForPlugin(_tokens->usdGeomPlugin); + UsdValidationValidatorMetadataVector metadata + = registry.GetValidatorMetadataForPlugin( + _tokens->usdGeomValidatorsPlugin); TF_AXIOM(metadata.size() == 3); - for (const UsdValidatorMetadata& metadata : metadata) { + for (const UsdValidationValidatorMetadata &metadata : metadata) { validatorMetadataNameSet.insert(metadata.name); } @@ -50,7 +51,7 @@ TestUsdGeomValidators() } static const std::string subsetsLayerContents = -R"usda(#usda 1.0 + R"usda(#usda 1.0 ( defaultPrim = "SubsetsTest" metersPerUnit = 0.01 @@ -168,8 +169,8 @@ def Xform "SubsetsTest" ( void TestUsdGeomSubsetFamilies() { - UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); - const UsdValidator* validator = registry.GetOrLoadValidatorByName( + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); + const UsdValidationValidator *validator = registry.GetOrLoadValidatorByName( UsdGeomValidatorNameTokens->subsetFamilies); TF_AXIOM(validator); @@ -179,10 +180,10 @@ TestUsdGeomSubsetFamilies() TF_AXIOM(usdStage); const TfToken expectedErrorIdentifier( - "usdGeom:SubsetFamilies.InvalidSubsetFamily"); + "usdGeomValidators:SubsetFamilies.InvalidSubsetFamily"); { - const UsdPrim usdPrim = usdStage->GetPrimAtPath( - SdfPath("/SubsetsTest/Geom/Cube")); + const UsdPrim usdPrim + = usdStage->GetPrimAtPath(SdfPath("/SubsetsTest/Geom/Cube")); const std::vector expectedErrorMsgs = { "Imageable prim has invalid subset family " @@ -215,14 +216,13 @@ TestUsdGeomSubsetFamilies() const UsdValidationErrorVector errors = validator->Validate(usdPrim); TF_AXIOM(errors.size() == expectedErrorMsgs.size()); - for (size_t errorIndex = 0u; - errorIndex < expectedErrorMsgs.size(); - ++errorIndex) { - const UsdValidationError& error = errors[errorIndex]; + for (size_t errorIndex = 0u; errorIndex < expectedErrorMsgs.size(); + ++errorIndex) { + const UsdValidationError &error = errors[errorIndex]; TF_AXIOM(error.GetIdentifier() == expectedErrorIdentifier); TF_AXIOM(error.GetType() == UsdValidationErrorType::Error); TF_AXIOM(error.GetSites().size() == 1u); - const UsdValidationErrorSite& errorSite = error.GetSites()[0u]; + const UsdValidationErrorSite &errorSite = error.GetSites()[0u]; TF_AXIOM(errorSite.IsValid()); TF_AXIOM(errorSite.IsPrim()); TF_AXIOM(errorSite.GetPrim().GetPath() == usdPrim.GetPath()); @@ -231,46 +231,46 @@ TestUsdGeomSubsetFamilies() } { - const UsdPrim usdPrim = usdStage->GetPrimAtPath( - SdfPath("/SubsetsTest/Geom/NullMesh")); + const UsdPrim usdPrim + = usdStage->GetPrimAtPath(SdfPath("/SubsetsTest/Geom/NullMesh")); const UsdValidationErrorVector errors = validator->Validate(usdPrim); TF_AXIOM(errors.size() == 1u); - const UsdValidationError& error = errors[0u]; + const UsdValidationError &error = errors[0u]; TF_AXIOM(error.GetIdentifier() == expectedErrorIdentifier); TF_AXIOM(error.GetType() == UsdValidationErrorType::Error); TF_AXIOM(error.GetSites().size() == 1u); - const UsdValidationErrorSite& errorSite = error.GetSites()[0u]; + const UsdValidationErrorSite &errorSite = error.GetSites()[0u]; TF_AXIOM(errorSite.IsValid()); TF_AXIOM(errorSite.IsPrim()); TF_AXIOM(errorSite.GetPrim().GetPath() == usdPrim.GetPath()); - const std::string expectedErrorMsg = - "Imageable prim has invalid subset " - "family 'noElementsInGeometry': Unable to determine element " - "count at earliest time for geom ."; + const std::string expectedErrorMsg + = "Imageable prim has invalid subset " + "family 'noElementsInGeometry': Unable to determine element " + "count at earliest time for geom ."; TF_AXIOM(error.GetMessage() == expectedErrorMsg); } { - const UsdPrim usdPrim = usdStage->GetPrimAtPath( - SdfPath("/SubsetsTest/Geom/VaryingMesh")); + const UsdPrim usdPrim + = usdStage->GetPrimAtPath(SdfPath("/SubsetsTest/Geom/VaryingMesh")); const UsdValidationErrorVector errors = validator->Validate(usdPrim); TF_AXIOM(errors.size() == 1u); - const UsdValidationError& error = errors[0u]; + const UsdValidationError &error = errors[0u]; TF_AXIOM(error.GetIdentifier() == expectedErrorIdentifier); TF_AXIOM(error.GetType() == UsdValidationErrorType::Error); TF_AXIOM(error.GetSites().size() == 1u); - const UsdValidationErrorSite& errorSite = error.GetSites()[0u]; + const UsdValidationErrorSite &errorSite = error.GetSites()[0u]; TF_AXIOM(errorSite.IsValid()); TF_AXIOM(errorSite.IsPrim()); TF_AXIOM(errorSite.GetPrim().GetPath() == usdPrim.GetPath()); - const std::string expectedErrorMsg = - "Imageable prim has invalid " - "subset family 'noDefaultTimeElementsInGeometry': Geometry " - " has no elements at time " - "DEFAULT, but the \"noDefaultTimeElementsInGeometry\" " - "GeomSubset family contains indices."; + const std::string expectedErrorMsg + = "Imageable prim has invalid " + "subset family 'noDefaultTimeElementsInGeometry': Geometry " + " has no elements at time " + "DEFAULT, but the \"noDefaultTimeElementsInGeometry\" " + "GeomSubset family contains indices."; TF_AXIOM(error.GetMessage() == expectedErrorMsg); } } @@ -278,8 +278,8 @@ TestUsdGeomSubsetFamilies() void TestUsdGeomSubsetParentIsImageable() { - UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); - const UsdValidator* validator = registry.GetOrLoadValidatorByName( + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); + const UsdValidationValidator *validator = registry.GetOrLoadValidatorByName( UsdGeomValidatorNameTokens->subsetParentIsImageable); TF_AXIOM(validator); @@ -288,8 +288,8 @@ TestUsdGeomSubsetParentIsImageable() UsdStageRefPtr usdStage = UsdStage::Open(layer); TF_AXIOM(usdStage); - const TfToken expectedErrorIdentifier = - TfToken("usdGeom:SubsetParentIsImageable.NotImageableSubsetParent"); + const TfToken expectedErrorIdentifier = TfToken( + "usdGeomValidators:SubsetParentIsImageable.NotImageableSubsetParent"); { const UsdPrim usdPrim = usdStage->GetPrimAtPath( @@ -297,30 +297,30 @@ TestUsdGeomSubsetParentIsImageable() const UsdValidationErrorVector errors = validator->Validate(usdPrim); TF_AXIOM(errors.size() == 1u); - const UsdValidationError& error = errors[0u]; + const UsdValidationError &error = errors[0u]; TF_AXIOM(error.GetIdentifier() == expectedErrorIdentifier); TF_AXIOM(error.GetType() == UsdValidationErrorType::Error); TF_AXIOM(error.GetSites().size() == 1u); - const UsdValidationErrorSite& errorSite = error.GetSites()[0u]; + const UsdValidationErrorSite &errorSite = error.GetSites()[0u]; TF_AXIOM(errorSite.IsValid()); TF_AXIOM(errorSite.IsPrim()); TF_AXIOM(errorSite.GetPrim().GetPath() == usdPrim.GetPath()); - const std::string expectedErrorMsg = - "GeomSubset " - " has " - "direct parent prim that is " - "not Imageable."; + const std::string expectedErrorMsg + = "GeomSubset " + " has " + "direct parent prim that is " + "not Imageable."; TF_AXIOM(error.GetMessage() == expectedErrorMsg); } } -static -void TestUsdStageMetadata() +static void +TestUsdStageMetadata() { // Get stageMetadataChecker UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); - const UsdValidator *validator = registry.GetOrLoadValidatorByName( - UsdGeomValidatorNameTokens->stageMetadataChecker); + const UsdValidationValidator *validator = registry.GetOrLoadValidatorByName( + UsdGeomValidatorNameTokens->stageMetadataChecker); TF_AXIOM(validator); // Create an empty stage @@ -334,18 +334,19 @@ void TestUsdStageMetadata() auto rootLayerIdentifier = rootLayer->GetIdentifier().c_str(); const std::vector expectedErrorMessages = { TfStringPrintf("Stage with root layer <%s> does not specify its linear " - "scale in metersPerUnit.", rootLayerIdentifier), - TfStringPrintf("Stage with root layer <%s> does not specify an upAxis.", + "scale in metersPerUnit.", + rootLayerIdentifier), + TfStringPrintf("Stage with root layer <%s> does not specify an upAxis.", rootLayerIdentifier) }; const std::vector expectedErrorIdentifiers = { - TfToken("usdGeom:StageMetadataChecker.MissingMetersPerUnitMetadata"), - TfToken("usdGeom:StageMetadataChecker.MissingUpAxisMetadata") + TfToken( + "usdGeomValidators:StageMetadataChecker.MissingMetersPerUnitMetadata"), + TfToken("usdGeomValidators:StageMetadataChecker.MissingUpAxisMetadata") }; - for(size_t i = 0; i < errors.size(); ++i) - { + for (size_t i = 0; i < errors.size(); ++i) { TF_AXIOM(errors[i].GetType() == UsdValidationErrorType::Error); TF_AXIOM(errors[i].GetIdentifier() == expectedErrorIdentifiers[i]); TF_AXIOM(errors[i].GetSites().size() == 1); diff --git a/pxr/usd/usdGeom/validatorTokens.cpp b/pxr/usdValidation/usdGeomValidators/validatorTokens.cpp similarity index 89% rename from pxr/usd/usdGeom/validatorTokens.cpp rename to pxr/usdValidation/usdGeomValidators/validatorTokens.cpp index e50c5fc115..45713c9f33 100644 --- a/pxr/usd/usdGeom/validatorTokens.cpp +++ b/pxr/usdValidation/usdGeomValidators/validatorTokens.cpp @@ -5,7 +5,7 @@ // https://openusd.org/license. // -#include "pxr/usd/usdGeom/validatorTokens.h" +#include "pxr/usdValidation/usdGeomValidators/validatorTokens.h" PXR_NAMESPACE_OPEN_SCOPE diff --git a/pxr/usd/usdGeom/validatorTokens.h b/pxr/usdValidation/usdGeomValidators/validatorTokens.h similarity index 54% rename from pxr/usd/usdGeom/validatorTokens.h rename to pxr/usdValidation/usdGeomValidators/validatorTokens.h index 61b4b0b70c..5340d6a8b1 100644 --- a/pxr/usd/usdGeom/validatorTokens.h +++ b/pxr/usdValidation/usdGeomValidators/validatorTokens.h @@ -5,50 +5,51 @@ // https://openusd.org/license. // -#ifndef USDGEOM_VALIDATOR_TOKENS_H -#define USDGEOM_VALIDATOR_TOKENS_H +#ifndef PXR_USD_VALIDATION_USD_GEOM_VALIDATORS_TOKENS_H +#define PXR_USD_VALIDATION_USD_GEOM_VALIDATORS_TOKENS_H /// \file #include "pxr/pxr.h" -#include "pxr/usd/usdGeom/api.h" #include "pxr/base/tf/staticTokens.h" +#include "pxr/usdValidation/usdGeomValidators/api.h" PXR_NAMESPACE_OPEN_SCOPE -#define USD_GEOM_VALIDATOR_NAME_TOKENS \ - ((stageMetadataChecker, "usdGeom:StageMetadataChecker")) \ - ((subsetFamilies, "usdGeom:SubsetFamilies")) \ - ((subsetParentIsImageable, "usdGeom:SubsetParentIsImageable")) +#define USD_GEOM_VALIDATOR_NAME_TOKENS \ + ((stageMetadataChecker, "usdGeomValidators:StageMetadataChecker")) \ + ((subsetFamilies, "usdGeomValidators:SubsetFamilies")) \ + ((subsetParentIsImageable, "usdGeomValidators:SubsetParentIsImageable")) -#define USD_GEOM_VALIDATOR_KEYWORD_TOKENS \ - (UsdGeomSubset) \ +#define USD_GEOM_VALIDATOR_KEYWORD_TOKENS \ + (UsdGeomSubset) \ (UsdGeomValidators) -#define USD_GEOM_VALIDATION_ERROR_NAME_TOKENS \ - ((missingMetersPerUnitMetadata, "MissingMetersPerUnitMetadata")) \ - ((missingUpAxisMetadata, "MissingUpAxisMetadata")) \ - ((invalidSubsetFamily, "InvalidSubsetFamily")) \ +#define USD_GEOM_VALIDATION_ERROR_NAME_TOKENS \ + ((missingMetersPerUnitMetadata, "MissingMetersPerUnitMetadata")) \ + ((missingUpAxisMetadata, "MissingUpAxisMetadata")) \ + ((invalidSubsetFamily, "InvalidSubsetFamily")) \ ((notImageableSubsetParent, "NotImageableSubsetParent")) /// \def USD_GEOM_VALIDATOR_NAME_TOKENS /// Tokens representing validator names. Note that for plugin provided -/// validators, the names must be prefixed by usdGeom:, which is the name of -/// the usdGeom plugin. - TF_DECLARE_PUBLIC_TOKENS(UsdGeomValidatorNameTokens, USDGEOM_API, - USD_GEOM_VALIDATOR_NAME_TOKENS); +/// validators, the names must be prefixed by usdGeomValidators:, which is the +/// name of the usdGeomValidators plugin. +TF_DECLARE_PUBLIC_TOKENS(UsdGeomValidatorNameTokens, USDGEOMVALIDATORS_API, + USD_GEOM_VALIDATOR_NAME_TOKENS); /// \def USD_GEOM_VALIDATOR_KEYWORD_TOKENS /// Tokens representing keywords associated with any validator in the usdGeom /// plugin. Clients can use this to inspect validators contained within a /// specific keywords, or use these to be added as keywords to any new /// validator. - TF_DECLARE_PUBLIC_TOKENS(UsdGeomValidatorKeywordTokens, USDGEOM_API, - USD_GEOM_VALIDATOR_KEYWORD_TOKENS); +TF_DECLARE_PUBLIC_TOKENS(UsdGeomValidatorKeywordTokens, USDGEOMVALIDATORS_API, + USD_GEOM_VALIDATOR_KEYWORD_TOKENS); /// \def USD_GEOM_VALIDATION_ERROR_NAME_TOKENS /// Tokens representing validation error identifier. -TF_DECLARE_PUBLIC_TOKENS(UsdGeomValidationErrorNameTokens, USDGEOM_API, +TF_DECLARE_PUBLIC_TOKENS(UsdGeomValidationErrorNameTokens, + USDGEOMVALIDATORS_API, USD_GEOM_VALIDATION_ERROR_NAME_TOKENS); PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usdValidation/usdGeomValidators/validators.cpp b/pxr/usdValidation/usdGeomValidators/validators.cpp new file mode 100644 index 0000000000..08f0d2171f --- /dev/null +++ b/pxr/usdValidation/usdGeomValidators/validators.cpp @@ -0,0 +1,161 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// + +#include "pxr/base/tf/registryManager.h" +#include "pxr/base/tf/stringUtils.h" +#include "pxr/base/tf/token.h" +#include "pxr/usd/usd/prim.h" +#include "pxr/usd/usd/schemaRegistry.h" +#include "pxr/usd/usdGeom/imageable.h" +#include "pxr/usd/usdGeom/subset.h" +#include "pxr/usd/usdGeom/tokens.h" +#include "pxr/usdValidation/usdGeomValidators/validatorTokens.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" +#include "pxr/usdValidation/usdValidation/validator.h" + +#include +#include +#include + +PXR_NAMESPACE_OPEN_SCOPE + +static UsdValidationErrorVector +_GetStageMetadataErrors(const UsdStagePtr &usdStage) +{ + UsdValidationErrorVector errors; + if (!usdStage->HasAuthoredMetadata(UsdGeomTokens->metersPerUnit)) { + errors.emplace_back( + UsdGeomValidationErrorNameTokens->missingMetersPerUnitMetadata, + UsdValidationErrorType::Error, + UsdValidationErrorSites { + UsdValidationErrorSite(usdStage, SdfPath("/")) }, + TfStringPrintf("Stage with root layer <%s> does not specify its " + "linear scale in metersPerUnit.", + usdStage->GetRootLayer()->GetIdentifier().c_str())); + } + if (!usdStage->HasAuthoredMetadata(UsdGeomTokens->upAxis)) { + errors.emplace_back( + UsdGeomValidationErrorNameTokens->missingUpAxisMetadata, + UsdValidationErrorType::Error, + UsdValidationErrorSites { + UsdValidationErrorSite(usdStage, SdfPath("/")) }, + TfStringPrintf("Stage with root layer <%s> does not specify an " + "upAxis.", + usdStage->GetRootLayer()->GetIdentifier().c_str())); + } + + return errors; +} + +static UsdValidationErrorVector +_SubsetFamilies(const UsdPrim &usdPrim) +{ + if (!(usdPrim + && usdPrim.IsInFamily( + UsdSchemaRegistry::VersionPolicy::All))) { + return {}; + } + + const UsdGeomImageable imageable(usdPrim); + if (!imageable) { + return {}; + } + + const TfToken::Set subsetFamilyNames + = UsdGeomSubset::GetAllGeomSubsetFamilyNames(imageable); + + // Sort the family names so that they are in dictionary order, making + // the order in which they are validated more predictable. + TfTokenVector subsetFamilyNamesVec(subsetFamilyNames.begin(), + subsetFamilyNames.end()); + std::sort(subsetFamilyNamesVec.begin(), subsetFamilyNamesVec.end(), + TfDictionaryLessThan()); + + UsdValidationErrorVector errors; + + for (const TfToken &subsetFamilyName : subsetFamilyNamesVec) { + const std::vector familySubsets + = UsdGeomSubset::GetGeomSubsets( + imageable, + /* elementType = */ TfToken(), + /* familyName = */ subsetFamilyName); + + // Determine the element type of the family by looking at the + // first subset. + TfToken elementType; + familySubsets[0u].GetElementTypeAttr().Get(&elementType); + + std::string reason; + if (!UsdGeomSubset::ValidateFamily(imageable, elementType, + subsetFamilyName, &reason)) { + const UsdValidationErrorSites primErrorSites + = { UsdValidationErrorSite(usdPrim.GetStage(), + usdPrim.GetPath()) }; + + errors.emplace_back( + UsdGeomValidationErrorNameTokens->invalidSubsetFamily, + UsdValidationErrorType::Error, primErrorSites, + TfStringPrintf( + "Imageable prim <%s> has invalid subset family '%s': %s", + usdPrim.GetPath().GetText(), subsetFamilyName.GetText(), + reason.c_str())); + } + } + + return errors; +} + +static UsdValidationErrorVector +_SubsetParentIsImageable(const UsdPrim &usdPrim) +{ + if (!(usdPrim + && usdPrim.IsInFamily( + UsdSchemaRegistry::VersionPolicy::All))) { + return {}; + } + + const UsdGeomSubset subset(usdPrim); + if (!subset) { + return {}; + } + + const UsdPrim parentPrim = usdPrim.GetParent(); + const UsdGeomImageable parentImageable(parentPrim); + if (parentImageable) { + return {}; + } + + const UsdValidationErrorSites primErrorSites + = { UsdValidationErrorSite(usdPrim.GetStage(), usdPrim.GetPath()) }; + + return { UsdValidationError( + UsdGeomValidationErrorNameTokens->notImageableSubsetParent, + UsdValidationErrorType::Error, primErrorSites, + TfStringPrintf( + "GeomSubset <%s> has direct parent prim <%s> that is not " + "Imageable.", + usdPrim.GetPath().GetText(), parentPrim.GetPath().GetText())) }; +} + +TF_REGISTRY_FUNCTION(UsdValidationRegistry) +{ + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); + + registry.RegisterPluginValidator( + UsdGeomValidatorNameTokens->stageMetadataChecker, + _GetStageMetadataErrors); + + registry.RegisterPluginValidator(UsdGeomValidatorNameTokens->subsetFamilies, + _SubsetFamilies); + + registry.RegisterPluginValidator( + UsdGeomValidatorNameTokens->subsetParentIsImageable, + _SubsetParentIsImageable); +} + +PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usdValidation/usdShadeValidators/CMakeLists.txt b/pxr/usdValidation/usdShadeValidators/CMakeLists.txt new file mode 100644 index 0000000000..1b1c638b93 --- /dev/null +++ b/pxr/usdValidation/usdShadeValidators/CMakeLists.txt @@ -0,0 +1,48 @@ +set(PXR_PREFIX pxr/usdValidation) +set(PXR_PACKAGE usdShadeValidators) + +pxr_library(usdShadeValidators + LIBRARIES + tf + plug + sdf + usd + ndr + sdr + usdShade + usdValidation + + PUBLIC_CLASSES + validatorTokens + + PUBLIC_HEADERS + api.h + + CPPFILES + validators.cpp + + RESOURCE_FILES + plugInfo.json +) + +pxr_build_test(testUsdShadeValidators + LIBRARIES + tf + sdr + usd + usdValidation + usdShade + usdShadeValidators + CPPFILES + testenv/testUsdShadeValidators.cpp +) + +pxr_install_test_dir( + SRC testenv/testUsdShadeValidators + DEST testUsdShadeValidators +) + +pxr_register_test(testUsdShadeValidators + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdShadeValidators" + EXPECTED_RETURN_CODE 0 +) diff --git a/pxr/usdValidation/usdShadeValidators/api.h b/pxr/usdValidation/usdShadeValidators/api.h new file mode 100644 index 0000000000..259b572c21 --- /dev/null +++ b/pxr/usdValidation/usdShadeValidators/api.h @@ -0,0 +1,34 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +#ifndef PXR_USD_VALIDAION_USD_SHADE_VALIDATORS_API_H +#define PXR_USD_VALIDAION_USD_SHADE_VALIDATORS_API_H + +#include "pxr/base/arch/export.h" + +#if defined(PXR_STATIC) +# define USDSHADEVALIDATORS_API +# define USDSHADEVALIDATORS_API_TEMPLATE_CLASS(...) +# define USDSHADEVALIDATORS_API_TEMPLATE_STRUCT(...) +# define USDSHADEVALIDATORS_API_LOCAL +#else +# if defined(USDSHADEVALIDATORS_API_EXPORTS) +# define USDSHADEVALIDATORS_API ARCH_EXPORT +# define USDSHADEVALIDATORS_API_TEMPLATE_CLASS(...) \ + ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__) +# define USDSHADEVALIDATORS_API_TEMPLATE_STRUCT(...) \ + ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__) +# else +# define USDSHADEVALIDATORS_API ARCH_IMPORT +# define USDSHADEVALIDATORS_API_TEMPLATE_CLASS(...) \ + ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__) +# define USDSHADEVALIDATORS_API_TEMPLATE_STRUCT(...) \ + ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__) +# endif +# define USDSHADEVALIDATORS_API_LOCAL ARCH_HIDDEN +#endif + +#endif diff --git a/pxr/usdValidation/usdShadeValidators/plugInfo.json b/pxr/usdValidation/usdShadeValidators/plugInfo.json new file mode 100644 index 0000000000..d16a95a1ed --- /dev/null +++ b/pxr/usdValidation/usdShadeValidators/plugInfo.json @@ -0,0 +1,57 @@ +{ + "Plugins": [ + { + "Info": { + "Validators": { + "EncapsulationRulesValidator": { + "doc": "Connectable prims (e.g. Shader, Material, etc) can only be nested inside other Container-like Connectable prims. Container-like prims include Material, NodeGraph, Light, LightFilter. Shader is not a Container-like prim." + }, + "MaterialBindingApiAppliedValidator": { + "doc": "Verify a prim has the MaterialBindingAPI applied if it has a material binding relationship." + }, + "MaterialBindingCollectionValidator": { + "doc": "Verify that a collection defining a material binding is well-formed", + "schemaTypes": [ + "MaterialBindingAPI" + ] + }, + "MaterialBindingRelationships": { + "doc": "All properties named 'material:binding' or in that namespace should be relationships." + }, + "ShaderSdrCompliance": { + "doc": "Shader prim's input types must be conforming to their appropriate sdf types in the respective sdr shader.", + "schemaTypes": [ + "UsdShadeShader" + ] + }, + "SubsetMaterialBindFamilyName": { + "doc": "Geom subsets with authored material bindings should have the 'materialBind' family name.", + "keywords": [ + "UsdGeomSubset" + ], + "schemaTypes": [ + "UsdGeomSubset" + ] + }, + "SubsetsMaterialBindFamily": { + "doc": "Geom subsets of the 'materialBind' family should have a restricted family type.", + "keywords": [ + "UsdGeomSubset" + ], + "schemaTypes": [ + "UsdGeomImageable" + ] + }, + "keywords": [ + "UsdShadeValidators" + ] + } + }, + "LibraryPath": "@PLUG_INFO_LIBRARY_PATH@", + "Name": "usdShadeValidators", + "ResourcePath": "@PLUG_INFO_RESOURCE_PATH@", + "Root": "@PLUG_INFO_ROOT@", + "Type": "library" + } + ] +} diff --git a/pxr/usd/usdShade/testenv/testUsdShadeValidators.cpp b/pxr/usdValidation/usdShadeValidators/testenv/testUsdShadeValidators.cpp similarity index 65% rename from pxr/usd/usdShade/testenv/testUsdShadeValidators.cpp rename to pxr/usdValidation/usdShadeValidators/testenv/testUsdShadeValidators.cpp index fb54cd9f1a..bc3b4506e1 100644 --- a/pxr/usd/usdShade/testenv/testUsdShadeValidators.cpp +++ b/pxr/usdValidation/usdShadeValidators/testenv/testUsdShadeValidators.cpp @@ -11,19 +11,18 @@ #include "pxr/usd/sdf/path.h" #include "pxr/usd/sdr/registry.h" #include "pxr/usd/usd/prim.h" +#include "pxr/usd/usd/relationship.h" #include "pxr/usd/usd/stage.h" -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usd/validationRegistry.h" -#include "pxr/usd/usd/validator.h" -#include "pxr/usd/usdGeom/validatorTokens.h" #include "pxr/usd/usdGeom/scope.h" +#include "pxr/usd/usdShade/material.h" +#include "pxr/usd/usdShade/materialBindingAPI.h" #include "pxr/usd/usdShade/shader.h" #include "pxr/usd/usdShade/shaderDefUtils.h" #include "pxr/usd/usdShade/tokens.h" -#include "pxr/usd/usdShade/validatorTokens.h" -#include "pxr/usd/usdShade/material.h" -#include "pxr/usd/usdShade/materialBindingAPI.h" -#include "pxr/usd/usd/relationship.h" +#include "pxr/usdValidation/usdShadeValidators/validatorTokens.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" +#include "pxr/usdValidation/usdValidation/validator.h" #include #include @@ -32,7 +31,7 @@ PXR_NAMESPACE_USING_DIRECTIVE TF_DEFINE_PRIVATE_TOKENS(_tokens, - ((usdShadePlugin, "usdShade")) + ((usdShadeValidatorsPlugin, "usdShadeValidators")) ); void @@ -40,28 +39,28 @@ TestUsdShadeValidators() { // This should be updated with every new validator added with the // UsdShadeValidators keyword. - const std::set expectedUsdShadeValidatorNames = { - UsdShadeValidatorNameTokens->encapsulationValidator, - UsdShadeValidatorNameTokens->materialBindingApiAppliedValidator, - UsdShadeValidatorNameTokens->materialBindingRelationships, - UsdShadeValidatorNameTokens->materialBindingCollectionValidator, - UsdShadeValidatorNameTokens->shaderSdrCompliance, - UsdShadeValidatorNameTokens->subsetMaterialBindFamilyName, - UsdShadeValidatorNameTokens->subsetsMaterialBindFamily - }; - - const UsdValidationRegistry& registry = - UsdValidationRegistry::GetInstance(); + const std::set expectedUsdShadeValidatorNames + = { UsdShadeValidatorNameTokens->encapsulationValidator, + UsdShadeValidatorNameTokens->materialBindingApiAppliedValidator, + UsdShadeValidatorNameTokens->materialBindingRelationships, + UsdShadeValidatorNameTokens->materialBindingCollectionValidator, + UsdShadeValidatorNameTokens->shaderSdrCompliance, + UsdShadeValidatorNameTokens->subsetMaterialBindFamilyName, + UsdShadeValidatorNameTokens->subsetsMaterialBindFamily }; + + const UsdValidationRegistry ®istry + = UsdValidationRegistry::GetInstance(); // Since other validators can be registered with the same keywords, // our validators registered in usdShade are/may be a subset of the // entire set. std::set validatorMetadataNameSet; - UsdValidatorMetadataVector metadata = - registry.GetValidatorMetadataForPlugin(_tokens->usdShadePlugin); + UsdValidationValidatorMetadataVector metadata + = registry.GetValidatorMetadataForPlugin( + _tokens->usdShadeValidatorsPlugin); TF_AXIOM(metadata.size() == 7); - for (const UsdValidatorMetadata& metadata : metadata) { + for (const UsdValidationValidatorMetadata &metadata : metadata) { validatorMetadataNameSet.insert(metadata.name); } @@ -71,8 +70,8 @@ TestUsdShadeValidators() void TestUsdShadeMaterialBindingCollections() { - UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); - const UsdValidator* validator = registry.GetOrLoadValidatorByName( + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); + const UsdValidationValidator *validator = registry.GetOrLoadValidatorByName( UsdShadeValidatorNameTokens->materialBindingCollectionValidator); TF_AXIOM(validator); @@ -87,25 +86,25 @@ TestUsdShadeMaterialBindingCollections() TF_AXIOM(errors.size() == 1u); const TfToken expectedErrorIdentifier( - "usdShade:MaterialBindingCollectionValidator." + "usdShadeValidators:MaterialBindingCollectionValidator." "InvalidMaterialCollection"); - const UsdValidationError& error = errors[0]; + const UsdValidationError &error = errors[0]; - const SdfPath expectedAttrPath = - primPath.AppendProperty(UsdShadeTokens->materialBindingCollection); + const SdfPath expectedAttrPath = primPath.AppendProperty( + UsdShadeTokens->materialBindingCollection); TF_AXIOM(error.GetIdentifier() == expectedErrorIdentifier); TF_AXIOM(error.GetType() == UsdValidationErrorType::Error); TF_AXIOM(error.GetSites().size() == 1u); - const UsdValidationErrorSite& errorSite = error.GetSites()[0]; + const UsdValidationErrorSite &errorSite = error.GetSites()[0]; TF_AXIOM(errorSite.IsValid()); TF_AXIOM(errorSite.IsProperty()); TF_AXIOM(errorSite.GetProperty().GetPath() == expectedAttrPath); - const std::string expectedErrorMsg = - "Collection-based material binding on " - " has 1 target , " - "needs 2: a collection path and a UsdShadeMaterial path."; + const std::string expectedErrorMsg + = "Collection-based material binding on " + " has 1 target , " + "needs 2: a collection path and a UsdShadeMaterial path."; TF_AXIOM(error.GetMessage() == expectedErrorMsg); } @@ -118,23 +117,23 @@ TestUsdShadeMaterialBindingCollections() TF_AXIOM(errors.size() == 1u); const TfToken expectedErrorIdentifier( - "usdShade:MaterialBindingCollectionValidator.InvalidResourcePath"); + "usdShadeValidators:MaterialBindingCollectionValidator.InvalidResourcePath"); - const UsdValidationError& error = errors[0]; - const SdfPath expectedAttrPath = - primPath.AppendProperty(UsdShadeTokens->materialBindingCollection); + const UsdValidationError &error = errors[0]; + const SdfPath expectedAttrPath = primPath.AppendProperty( + UsdShadeTokens->materialBindingCollection); TF_AXIOM(error.GetIdentifier() == expectedErrorIdentifier); TF_AXIOM(error.GetType() == UsdValidationErrorType::Error); TF_AXIOM(error.GetSites().size() == 1u); - const UsdValidationErrorSite& errorSite = error.GetSites()[0]; + const UsdValidationErrorSite &errorSite = error.GetSites()[0]; TF_AXIOM(errorSite.IsValid()); TF_AXIOM(errorSite.IsProperty()); TF_AXIOM(errorSite.GetProperty().GetPath() == expectedAttrPath); - const std::string expectedErrorMsg = - "Collection-based material binding targets an invalid collection" - " ."; + const std::string expectedErrorMsg + = "Collection-based material binding targets an invalid collection" + " ."; TF_AXIOM(error.GetMessage() == expectedErrorMsg); } } @@ -142,8 +141,8 @@ TestUsdShadeMaterialBindingCollections() void TestUsdShadeMaterialBindingRelationships() { - UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); - const UsdValidator* validator = registry.GetOrLoadValidatorByName( + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); + const UsdValidationValidator *validator = registry.GetOrLoadValidatorByName( UsdShadeValidatorNameTokens->materialBindingRelationships); TF_AXIOM(validator); @@ -167,62 +166,61 @@ TestUsdShadeMaterialBindingRelationships() TF_AXIOM(errors.size() == 2u); const TfToken expectedErrorIdentifier( - "usdShade:MaterialBindingRelationships.MaterialBindingPropNotARel"); + "usdShadeValidators:MaterialBindingRelationships.MaterialBindingPropNotARel"); { - const UsdValidationError& error = errors[0u]; + const UsdValidationError &error = errors[0u]; - const SdfPath expectedAttrPath = - primPath.AppendProperty(UsdShadeTokens->materialBinding); + const SdfPath expectedAttrPath + = primPath.AppendProperty(UsdShadeTokens->materialBinding); TF_AXIOM(error.GetIdentifier() == expectedErrorIdentifier); TF_AXIOM(error.GetType() == UsdValidationErrorType::Error); TF_AXIOM(error.GetSites().size() == 1u); - const UsdValidationErrorSite& errorSite = error.GetSites()[0u]; + const UsdValidationErrorSite &errorSite = error.GetSites()[0u]; TF_AXIOM(errorSite.IsValid()); TF_AXIOM(errorSite.IsProperty()); TF_AXIOM(errorSite.GetProperty().GetPath() == expectedAttrPath); - const std::string expectedErrorMsg = - "Prim has material binding property " - "'material:binding' that is not a relationship."; + const std::string expectedErrorMsg + = "Prim has material binding property " + "'material:binding' that is not a relationship."; TF_AXIOM(error.GetMessage() == expectedErrorMsg); } { - const UsdValidationError& error = errors[1u]; + const UsdValidationError &error = errors[1u]; - const SdfPath expectedAttrPath = - primPath.AppendProperty(TfToken( - SdfPath::JoinIdentifier( - UsdShadeTokens->materialBinding, "someAttribute"))); + const SdfPath expectedAttrPath + = primPath.AppendProperty(TfToken(SdfPath::JoinIdentifier( + UsdShadeTokens->materialBinding, "someAttribute"))); TF_AXIOM(error.GetIdentifier() == expectedErrorIdentifier); TF_AXIOM(error.GetType() == UsdValidationErrorType::Error); TF_AXIOM(error.GetSites().size() == 1u); - const UsdValidationErrorSite& errorSite = error.GetSites()[0u]; + const UsdValidationErrorSite &errorSite = error.GetSites()[0u]; TF_AXIOM(errorSite.IsValid()); TF_AXIOM(errorSite.IsProperty()); TF_AXIOM(errorSite.GetProperty().GetPath() == expectedAttrPath); - const std::string expectedErrorMsg = - "Prim has material binding property " - "'material:binding:someAttribute' that is not a relationship."; + const std::string expectedErrorMsg + = "Prim has material binding property " + "'material:binding:someAttribute' that is not a relationship."; TF_AXIOM(error.GetMessage() == expectedErrorMsg); } } } -void +void TestUsdShadeShaderPropertyCompliance() { // Need to setup our test shader in sdrRegistry first UsdStageRefPtr shaderDefStage = UsdStage::Open("./shaderDefs.usda"); - UsdShadeShader shaderDef = - UsdShadeShader::Get(shaderDefStage, SdfPath("/TestShaderNode")); + UsdShadeShader shaderDef + = UsdShadeShader::Get(shaderDefStage, SdfPath("/TestShaderNode")); SdrRegistry::GetInstance().AddDiscoveryResult( UsdShadeShaderDefUtils::GetNodeDiscoveryResults( shaderDef, shaderDefStage->GetRootLayer()->GetRealPath())[0]); // Now lets test our ShaderProperty validator UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); - const UsdValidator *validator = registry.GetOrLoadValidatorByName( + const UsdValidationValidator *validator = registry.GetOrLoadValidatorByName( UsdShadeValidatorNameTokens->shaderSdrCompliance); TF_AXIOM(validator); @@ -246,12 +244,11 @@ TestUsdShadeShaderPropertyCompliance() TF_AXIOM(usdStage); { - const UsdPrim usdPrim = usdStage->GetPrimAtPath( - SdfPath("/Test")); + const UsdPrim usdPrim = usdStage->GetPrimAtPath(SdfPath("/Test")); UsdValidationErrorVector errors = validator->Validate(usdPrim); const TfToken expectedErrorIdentifier( - "usdShade:ShaderSdrCompliance.MismatchedPropertyType"); + "usdShadeValidators:ShaderSdrCompliance.MismatchedPropertyType"); TF_AXIOM(errors.size() == 1); TF_AXIOM(errors[0].GetIdentifier() == expectedErrorIdentifier); @@ -259,19 +256,19 @@ TestUsdShadeShaderPropertyCompliance() TF_AXIOM(errors[0].GetSites().size() == 1); TF_AXIOM(errors[0].GetSites()[0].IsValid()); TF_AXIOM(errors[0].GetSites()[0].IsProperty()); - TF_AXIOM(errors[0].GetSites()[0].GetProperty().GetPath() == - SdfPath("/Test.inputs:inputColor")); - const std::string expectedErrorMsg = "Incorrect type for " - "/Test.inputs:inputColor. Expected 'color3f'; " - "got 'float3'."; + TF_AXIOM(errors[0].GetSites()[0].GetProperty().GetPath() + == SdfPath("/Test.inputs:inputColor")); + const std::string expectedErrorMsg + = "Incorrect type for " + "/Test.inputs:inputColor. Expected 'color3f'; " + "got 'float3'."; TF_AXIOM(errors[0].GetMessage() == expectedErrorMsg); } { - const UsdPrim usdPrim = usdStage->GetPrimAtPath( - SdfPath("/Bogus")); + const UsdPrim usdPrim = usdStage->GetPrimAtPath(SdfPath("/Bogus")); const TfToken expectedErrorIdentifier( - "usdShade:ShaderSdrCompliance.MissingShaderIdInRegistry"); + "usdShadeValidators:ShaderSdrCompliance.MissingShaderIdInRegistry"); UsdValidationErrorVector errors = validator->Validate(usdPrim); TF_AXIOM(errors[0].GetIdentifier() == expectedErrorIdentifier); @@ -280,16 +277,17 @@ TestUsdShadeShaderPropertyCompliance() TF_AXIOM(errors[0].GetSites().size() == 1); TF_AXIOM(errors[0].GetSites()[0].IsValid()); TF_AXIOM(errors[0].GetSites()[0].IsProperty()); - TF_AXIOM(errors[0].GetSites()[0].GetProperty().GetPath() == - SdfPath("/Bogus.info:id")); - const std::string expectedErrorMsg = "shaderId 'Bogus' specified on " - "shader prim not found in sdrRegistry."; + TF_AXIOM(errors[0].GetSites()[0].GetProperty().GetPath() + == SdfPath("/Bogus.info:id")); + const std::string expectedErrorMsg + = "shaderId 'Bogus' specified on " + "shader prim not found in sdrRegistry."; TF_AXIOM(errors[0].GetMessage() == expectedErrorMsg); } } static const std::string subsetsLayerContents = -R"usda(#usda 1.0 + R"usda(#usda 1.0 ( defaultPrim = "SubsetsTest" metersPerUnit = 0.01 @@ -361,8 +359,8 @@ def Xform "SubsetsTest" ( void TestUsdShadeSubsetMaterialBindFamilyName() { - UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); - const UsdValidator* validator = registry.GetOrLoadValidatorByName( + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); + const UsdValidationValidator *validator = registry.GetOrLoadValidatorByName( UsdShadeValidatorNameTokens->subsetMaterialBindFamilyName); TF_AXIOM(validator); @@ -375,23 +373,23 @@ TestUsdShadeSubsetMaterialBindFamilyName() const UsdPrim usdPrim = usdStage->GetPrimAtPath( SdfPath("/SubsetsTest/Geom/Cube/materialBindMissingFamilyName")); const TfToken expectedErrorIdentifier( - "usdShade:SubsetMaterialBindFamilyName.MissingFamilyNameOnGeomSubset"); + "usdShadeValidators:SubsetMaterialBindFamilyName.MissingFamilyNameOnGeomSubset"); const UsdValidationErrorVector errors = validator->Validate(usdPrim); TF_AXIOM(errors.size() == 1u); - const UsdValidationError& error = errors[0u]; + const UsdValidationError &error = errors[0u]; TF_AXIOM(error.GetIdentifier() == expectedErrorIdentifier); TF_AXIOM(error.GetType() == UsdValidationErrorType::Error); TF_AXIOM(error.GetSites().size() == 1u); - const UsdValidationErrorSite& errorSite = error.GetSites()[0u]; + const UsdValidationErrorSite &errorSite = error.GetSites()[0u]; TF_AXIOM(errorSite.IsValid()); TF_AXIOM(errorSite.IsPrim()); TF_AXIOM(errorSite.GetPrim().GetPath() == usdPrim.GetPath()); - const std::string expectedErrorMsg = - "GeomSubset prim " - " " - "with material bindings applied but no authored family name " - "should set familyName to 'materialBind'."; + const std::string expectedErrorMsg + = "GeomSubset prim " + " " + "with material bindings applied but no authored family name " + "should set familyName to 'materialBind'."; TF_AXIOM(error.GetMessage() == expectedErrorMsg); } } @@ -399,8 +397,8 @@ TestUsdShadeSubsetMaterialBindFamilyName() void TestUsdShadeSubsetsMaterialBindFamily() { - UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); - const UsdValidator* validator = registry.GetOrLoadValidatorByName( + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); + const UsdValidationValidator *validator = registry.GetOrLoadValidatorByName( UsdShadeValidatorNameTokens->subsetsMaterialBindFamily); TF_AXIOM(validator); @@ -410,27 +408,27 @@ TestUsdShadeSubsetsMaterialBindFamily() TF_AXIOM(usdStage); { - const UsdPrim usdPrim = usdStage->GetPrimAtPath( - SdfPath("/SubsetsTest/Geom/Cube")); + const UsdPrim usdPrim + = usdStage->GetPrimAtPath(SdfPath("/SubsetsTest/Geom/Cube")); const UsdValidationErrorVector errors = validator->Validate(usdPrim); TF_AXIOM(errors.size() == 1u); { const TfToken expectedErrorIdentifier( - "usdShade:SubsetsMaterialBindFamily.InvalidFamilyType"); - const UsdValidationError& error = errors[0u]; + "usdShadeValidators:SubsetsMaterialBindFamily.InvalidFamilyType"); + const UsdValidationError &error = errors[0u]; TF_AXIOM(error.GetIdentifier() == expectedErrorIdentifier); TF_AXIOM(error.GetType() == UsdValidationErrorType::Error); TF_AXIOM(error.GetSites().size() == 1u); - const UsdValidationErrorSite& errorSite = error.GetSites()[0u]; + const UsdValidationErrorSite &errorSite = error.GetSites()[0u]; TF_AXIOM(errorSite.IsValid()); TF_AXIOM(errorSite.IsPrim()); TF_AXIOM(errorSite.GetPrim().GetPath() == usdPrim.GetPath()); - const std::string expectedErrorMsg = - "Imageable prim has 'materialBind' " - "subset family with invalid family type 'unrestricted'. Family " - "type should be 'nonOverlapping' or 'partition' instead."; + const std::string expectedErrorMsg + = "Imageable prim has 'materialBind' " + "subset family with invalid family type 'unrestricted'. Family " + "type should be 'nonOverlapping' or 'partition' instead."; TF_AXIOM(error.GetMessage() == expectedErrorMsg); } } @@ -440,22 +438,22 @@ void TestUsdShadeMaterialBindingAPIAppliedValidator() { UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); - const UsdValidator *validator = registry.GetOrLoadValidatorByName( + const UsdValidationValidator *validator = registry.GetOrLoadValidatorByName( UsdShadeValidatorNameTokens->materialBindingApiAppliedValidator); TF_AXIOM(validator); UsdStageRefPtr usdStage = UsdStage::CreateInMemory(); const UsdPrim usdPrim = usdStage->DefinePrim(SdfPath("/Test")); - UsdShadeMaterial material = - UsdShadeMaterial::Define(usdStage, SdfPath("/Test/Material")); + UsdShadeMaterial material + = UsdShadeMaterial::Define(usdStage, SdfPath("/Test/Material")); // Create the material binding relationship manually - UsdRelationship materialBinding = usdPrim.CreateRelationship( - TfToken("material:binding")); + UsdRelationship materialBinding + = usdPrim.CreateRelationship(TfToken("material:binding")); materialBinding.AddTarget(material.GetPath()); const TfToken expectedErrorIdentifier( - "usdShade:MaterialBindingApiAppliedValidator.MissingMaterialBindingAPI"); + "usdShadeValidators:MaterialBindingApiAppliedValidator.MissingMaterialBindingAPI"); UsdValidationErrorVector errors = validator->Validate(usdPrim); TF_AXIOM(errors.size() == 1); @@ -465,14 +463,14 @@ TestUsdShadeMaterialBindingAPIAppliedValidator() TF_AXIOM(errors[0].GetSites()[0].IsValid()); TF_AXIOM(errors[0].GetSites()[0].IsPrim()); TF_AXIOM(errors[0].GetSites()[0].GetPrim().GetPath() == SdfPath("/Test")); - const std::string expectedErrorMsg = - "Found material bindings but no MaterialBindingAPI applied on the prim " - "."; + const std::string expectedErrorMsg + = "Found material bindings but no MaterialBindingAPI applied on the prim " + "."; TF_AXIOM(errors[0].GetMessage() == expectedErrorMsg); // Apply the material binding API to the prim and bind the material - UsdShadeMaterialBindingAPI bindingAPI = - UsdShadeMaterialBindingAPI::Apply(usdPrim); + UsdShadeMaterialBindingAPI bindingAPI + = UsdShadeMaterialBindingAPI::Apply(usdPrim); bindingAPI.Bind(material); errors = validator->Validate(usdPrim); @@ -485,27 +483,26 @@ void TestUsdShadeEncapsulationRulesValidator() { UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); - const UsdValidator *validator = registry.GetOrLoadValidatorByName( - UsdShadeValidatorNameTokens->encapsulationValidator); + const UsdValidationValidator *validator = registry.GetOrLoadValidatorByName( + UsdShadeValidatorNameTokens->encapsulationValidator); TF_AXIOM(validator); UsdStageRefPtr usdStage = UsdStage::CreateInMemory(); // Create a Material > Shader > Shader hierarchy UsdShadeMaterial::Define(usdStage, SdfPath("/RootMaterial")); - const UsdShadeShader& topShader = - UsdShadeShader::Define(usdStage, SdfPath("/RootMaterial/Shader")); - const UsdShadeShader& insideShader = - UsdShadeShader::Define( - usdStage, SdfPath("/RootMaterial/Shader/InsideShader")); + const UsdShadeShader &topShader + = UsdShadeShader::Define(usdStage, SdfPath("/RootMaterial/Shader")); + const UsdShadeShader &insideShader = UsdShadeShader::Define( + usdStage, SdfPath("/RootMaterial/Shader/InsideShader")); { - // Verify error that does not allow a connectable to be parented by + // Verify error that does not allow a connectable to be parented by // non-container connectable - const UsdValidationErrorVector errors = validator->Validate( - insideShader.GetPrim()); + const UsdValidationErrorVector errors + = validator->Validate(insideShader.GetPrim()); const TfToken expectedErrorIdentifier( - "usdShade:EncapsulationRulesValidator.ConnectableInNonContainer"); + "usdShadeValidators:EncapsulationRulesValidator.ConnectableInNonContainer"); TF_AXIOM(errors.size() == 1); TF_AXIOM(errors[0].GetIdentifier() == expectedErrorIdentifier); @@ -513,18 +510,18 @@ TestUsdShadeEncapsulationRulesValidator() TF_AXIOM(errors[0].GetSites().size() == 1); TF_AXIOM(errors[0].GetSites()[0].IsValid()); TF_AXIOM(errors[0].GetSites()[0].IsPrim()); - TF_AXIOM(errors[0].GetSites()[0].GetPrim().GetPath() == - SdfPath("/RootMaterial/Shader/InsideShader")); - const std::string expectedErrorMsg = - "Connectable Shader cannot " - "reside under a non-Container Connectable Shader"; + TF_AXIOM(errors[0].GetSites()[0].GetPrim().GetPath() + == SdfPath("/RootMaterial/Shader/InsideShader")); + const std::string expectedErrorMsg + = "Connectable Shader cannot " + "reside under a non-Container Connectable Shader"; TF_AXIOM(errors[0].GetMessage() == expectedErrorMsg); } { // Verify the first Shader is valid - const UsdValidationErrorVector errors = - validator->Validate(topShader.GetPrim()); + const UsdValidationErrorVector errors + = validator->Validate(topShader.GetPrim()); TF_AXIOM(errors.empty()); } @@ -533,26 +530,26 @@ TestUsdShadeEncapsulationRulesValidator() usdStage->RemovePrim(SdfPath("/RootMaterial/Shader/InsideShader")); usdStage->RemovePrim(SdfPath("/RootMaterial/Shader")); UsdGeomScope::Define(usdStage, SdfPath("/RootMaterial/Scope")); - const UsdShadeShader& insideScopeShader = UsdShadeShader::Define( + const UsdShadeShader &insideScopeShader = UsdShadeShader::Define( usdStage, SdfPath("/RootMaterial/Scope/InsideShader")); - // Verify error that does not allow a connectable to have any + // Verify error that does not allow a connectable to have any // non-connectable container ancestors - const UsdValidationErrorVector errors = - validator->Validate(insideScopeShader.GetPrim()); + const UsdValidationErrorVector errors + = validator->Validate(insideScopeShader.GetPrim()); const TfToken expectedErrorIdentifier( - "usdShade:EncapsulationRulesValidator.InvalidConnectableHierarchy"); + "usdShadeValidators:EncapsulationRulesValidator.InvalidConnectableHierarchy"); TF_AXIOM(errors.size() == 1); TF_AXIOM(errors[0].GetIdentifier() == expectedErrorIdentifier); TF_AXIOM(errors[0].GetType() == UsdValidationErrorType::Error); TF_AXIOM(errors[0].GetSites().size() == 1); TF_AXIOM(errors[0].GetSites()[0].IsValid()); TF_AXIOM(errors[0].GetSites()[0].IsPrim()); - TF_AXIOM(errors[0].GetSites()[0].GetPrim().GetPath() == - SdfPath("/RootMaterial/Scope/InsideShader")); - const std::string expectedErrorMsg = - "Connectable Shader can only " - "have Connectable Container ancestors up to Material ancestor " - ", but its parent Scope is a Scope."; + TF_AXIOM(errors[0].GetSites()[0].GetPrim().GetPath() + == SdfPath("/RootMaterial/Scope/InsideShader")); + const std::string expectedErrorMsg + = "Connectable Shader can only " + "have Connectable Container ancestors up to Material ancestor " + ", but its parent Scope is a Scope."; TF_AXIOM(errors[0].GetMessage() == expectedErrorMsg); } } diff --git a/pxr/usd/usdShade/testenv/testUsdShadeValidators/TestShader.glslfx b/pxr/usdValidation/usdShadeValidators/testenv/testUsdShadeValidators/TestShader.glslfx similarity index 100% rename from pxr/usd/usdShade/testenv/testUsdShadeValidators/TestShader.glslfx rename to pxr/usdValidation/usdShadeValidators/testenv/testUsdShadeValidators/TestShader.glslfx diff --git a/pxr/usd/usdShade/testenv/testUsdShadeValidators/badMaterialCollections.usda b/pxr/usdValidation/usdShadeValidators/testenv/testUsdShadeValidators/badMaterialCollections.usda similarity index 100% rename from pxr/usd/usdShade/testenv/testUsdShadeValidators/badMaterialCollections.usda rename to pxr/usdValidation/usdShadeValidators/testenv/testUsdShadeValidators/badMaterialCollections.usda diff --git a/pxr/usd/usdShade/testenv/testUsdShadeValidators/shaderDefs.usda b/pxr/usdValidation/usdShadeValidators/testenv/testUsdShadeValidators/shaderDefs.usda similarity index 100% rename from pxr/usd/usdShade/testenv/testUsdShadeValidators/shaderDefs.usda rename to pxr/usdValidation/usdShadeValidators/testenv/testUsdShadeValidators/shaderDefs.usda diff --git a/pxr/usd/usdShade/validatorTokens.cpp b/pxr/usdValidation/usdShadeValidators/validatorTokens.cpp similarity index 71% rename from pxr/usd/usdShade/validatorTokens.cpp rename to pxr/usdValidation/usdShadeValidators/validatorTokens.cpp index 6ebe54ace6..69109cd96c 100644 --- a/pxr/usd/usdShade/validatorTokens.cpp +++ b/pxr/usdValidation/usdShadeValidators/validatorTokens.cpp @@ -5,13 +5,13 @@ // https://openusd.org/license. // -#include "pxr/usd/usdShade/validatorTokens.h" +#include "pxr/usdValidation/usdShadeValidators/validatorTokens.h" PXR_NAMESPACE_OPEN_SCOPE -TF_DEFINE_PUBLIC_TOKENS(UsdShadeValidatorNameTokens, +TF_DEFINE_PUBLIC_TOKENS(UsdShadeValidatorNameTokens, USD_SHADE_VALIDATOR_NAME_TOKENS); -TF_DEFINE_PUBLIC_TOKENS(UsdShadeValidatorKeywordTokens, +TF_DEFINE_PUBLIC_TOKENS(UsdShadeValidatorKeywordTokens, USD_SHADE_VALIDATOR_KEYWORD_TOKENS); TF_DEFINE_PUBLIC_TOKENS(UsdShadeValidationErrorNameTokens, USD_SHADE_VALIDATION_ERROR_NAME_TOKENS); diff --git a/pxr/usdValidation/usdShadeValidators/validatorTokens.h b/pxr/usdValidation/usdShadeValidators/validatorTokens.h new file mode 100644 index 0000000000..cd16c3c82f --- /dev/null +++ b/pxr/usdValidation/usdShadeValidators/validatorTokens.h @@ -0,0 +1,75 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// + +#ifndef PXR_USD_VALIDATION_USD_SHADE_VALIDATOR_TOKENS_H +#define PXR_USD_VALIDATION_USD_SHADE_VALIDATOR_TOKENS_H + +/// \file + +#include "pxr/pxr.h" +#include "pxr/base/tf/staticTokens.h" +#include "pxr/usdValidation/usdShadeValidators/api.h" + +PXR_NAMESPACE_OPEN_SCOPE + +#define USD_SHADE_VALIDATOR_NAME_TOKENS \ + ((encapsulationValidator, \ + "usdShadeValidators:EncapsulationRulesValidator")) \ + ((materialBindingApiAppliedValidator, \ + "usdShadeValidators:MaterialBindingApiAppliedValidator")) \ + ((materialBindingRelationships, \ + "usdShadeValidators:MaterialBindingRelationships")) \ + ((materialBindingCollectionValidator, \ + "usdShadeValidators:MaterialBindingCollectionValidator")) \ + ((shaderSdrCompliance, "usdShadeValidators:ShaderSdrCompliance")) \ + ((subsetMaterialBindFamilyName, \ + "usdShadeValidators:SubsetMaterialBindFamilyName")) \ + ((subsetsMaterialBindFamily, \ + "usdShadeValidators:SubsetsMaterialBindFamily")) + +#define USD_SHADE_VALIDATOR_KEYWORD_TOKENS (UsdShadeValidators) + +#define USD_SHADE_VALIDATION_ERROR_NAME_TOKENS \ + ((connectableInNonContainer, "ConnectableInNonContainer")) \ + ((invalidConnectableHierarchy, "InvalidConnectableHierarchy")) \ + ((missingMaterialBindingAPI, "MissingMaterialBindingAPI")) \ + ((materialBindingPropNotARel, "MaterialBindingPropNotARel")) \ + ((invalidMaterialCollection, "InvalidMaterialCollection")) \ + ((invalidResourcePath, "InvalidResourcePath")) \ + ((invalidImplSource, "InvalidImplementationSrc")) \ + ((missingSourceType, "MissingSourceType")) \ + ((missingShaderIdInRegistry, "MissingShaderIdInRegistry")) \ + ((missingSourceTypeInRegistry, "MissingSourceTypeInRegistry")) \ + ((incompatShaderPropertyWarning, "IncompatShaderPropertyWarning")) \ + ((mismatchPropertyType, "MismatchedPropertyType")) \ + ((missingFamilyNameOnGeomSubset, "MissingFamilyNameOnGeomSubset")) \ + ((invalidFamilyType, "InvalidFamilyType")) + +/// \def USD_SHADE_VALIDATOR_NAME_TOKENS +/// Tokens representing validator names. Note that for plugin provided +/// validators, the names must be prefixed by usdShadeValidators:, which is the +/// name of the usdShadeValidators plugin. +TF_DECLARE_PUBLIC_TOKENS(UsdShadeValidatorNameTokens, USDSHADEVALIDATORS_API, + USD_SHADE_VALIDATOR_NAME_TOKENS); + +/// \def USD_SHADE_VALIDATOR_KEYWORD_TOKENS +/// Tokens representing keywords associated with any validator in the usdShade +/// plugin. Cliends can use this to inspect validators contained within a +/// specific keywords, or use these to be added as keywords to any new +/// validator. +TF_DECLARE_PUBLIC_TOKENS(UsdShadeValidatorKeywordTokens, USDSHADEVALIDATORS_API, + USD_SHADE_VALIDATOR_KEYWORD_TOKENS); + +/// \def USD_SHADE_VALIDATION_ERROR_NAME_TOKENS +/// Tokens representing validation error identifier. +TF_DECLARE_PUBLIC_TOKENS(UsdShadeValidationErrorNameTokens, + USDSHADEVALIDATORS_API, + USD_SHADE_VALIDATION_ERROR_NAME_TOKENS); + +PXR_NAMESPACE_CLOSE_SCOPE + +#endif diff --git a/pxr/usd/usdShade/validators.cpp b/pxr/usdValidation/usdShadeValidators/validators.cpp similarity index 56% rename from pxr/usd/usdShade/validators.cpp rename to pxr/usdValidation/usdShadeValidators/validators.cpp index 49656e6d4e..137090ba76 100644 --- a/pxr/usd/usdShade/validators.cpp +++ b/pxr/usdValidation/usdShadeValidators/validators.cpp @@ -5,23 +5,23 @@ // https://openusd.org/license. // +#include "pxr/base/tf/stringUtils.h" +#include "pxr/base/tf/token.h" +#include "pxr/usd/sdr/registry.h" #include "pxr/usd/sdr/shaderProperty.h" #include "pxr/usd/usd/prim.h" #include "pxr/usd/usd/property.h" #include "pxr/usd/usd/relationship.h" #include "pxr/usd/usd/schemaRegistry.h" -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usd/validationRegistry.h" -#include "pxr/usd/sdr/registry.h" -#include "pxr/base/tf/token.h" -#include "pxr/base/tf/stringUtils.h" #include "pxr/usd/usdGeom/imageable.h" #include "pxr/usd/usdGeom/subset.h" #include "pxr/usd/usdGeom/tokens.h" +#include "pxr/usd/usdShade/materialBindingAPI.h" #include "pxr/usd/usdShade/shader.h" #include "pxr/usd/usdShade/tokens.h" -#include "pxr/usd/usdShade/validatorTokens.h" -#include "pxr/usd/usdShade/materialBindingAPI.h" +#include "pxr/usdValidation/usdShadeValidators/validatorTokens.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" #include #include @@ -29,25 +29,23 @@ PXR_NAMESPACE_OPEN_SCOPE -static -UsdValidationErrorVector -_EncapsulationValidator(const UsdPrim& usdPrim) +static UsdValidationErrorVector +_EncapsulationValidator(const UsdPrim &usdPrim) { - const UsdShadeConnectableAPI& connectable = - UsdShadeConnectableAPI(usdPrim); + const UsdShadeConnectableAPI &connectable = UsdShadeConnectableAPI(usdPrim); - if (!connectable){ + if (!connectable) { return {}; } - const UsdPrim& parentPrim = usdPrim.GetParent(); + const UsdPrim &parentPrim = usdPrim.GetParent(); - if (!parentPrim || parentPrim.IsPseudoRoot()){ + if (!parentPrim || parentPrim.IsPseudoRoot()) { return {}; } - UsdShadeConnectableAPI parentConnectable = - UsdShadeConnectableAPI(parentPrim); + UsdShadeConnectableAPI parentConnectable + = UsdShadeConnectableAPI(parentPrim); UsdValidationErrorVector errors; if (parentConnectable && !parentConnectable.IsContainer()) { // It is a violation of the UsdShade OM which enforces @@ -56,24 +54,21 @@ _EncapsulationValidator(const UsdPrim& usdPrim) errors.emplace_back( UsdShadeValidationErrorNameTokens->connectableInNonContainer, UsdValidationErrorType::Error, - UsdValidationErrorSites{ - UsdValidationErrorSite(usdPrim.GetStage(), - usdPrim.GetPath()) - }, + UsdValidationErrorSites { + UsdValidationErrorSite(usdPrim.GetStage(), usdPrim.GetPath()) }, TfStringPrintf("Connectable %s <%s> cannot reside " "under a non-Container Connectable %s", usdPrim.GetTypeName().GetText(), usdPrim.GetPath().GetText(), parentPrim.GetTypeName().GetText())); - } - else if (!parentConnectable) { - std::function _VerifyValidAncestor = - [&](const UsdPrim& currentAncestor) -> void { + } else if (!parentConnectable) { + std::function _VerifyValidAncestor + = [&](const UsdPrim ¤tAncestor) -> void { if (!currentAncestor || currentAncestor.IsPseudoRoot()) { return; } - const UsdShadeConnectableAPI& ancestorConnectable = - UsdShadeConnectableAPI(currentAncestor); + const UsdShadeConnectableAPI &ancestorConnectable + = UsdShadeConnectableAPI(currentAncestor); if (ancestorConnectable) { // it's only OK to have a non-connectable parent if all // the rest of your ancestors are also non-connectable. @@ -81,12 +76,11 @@ _EncapsulationValidator(const UsdPrim& usdPrim) // infraction, using Scope or other grouping prims inside // a Container like a Material errors.emplace_back( - UsdShadeValidationErrorNameTokens-> - invalidConnectableHierarchy, + UsdShadeValidationErrorNameTokens + ->invalidConnectableHierarchy, UsdValidationErrorType::Error, - UsdValidationErrorSites { - UsdValidationErrorSite(usdPrim.GetStage(), - usdPrim.GetPath()) }, + UsdValidationErrorSites { UsdValidationErrorSite( + usdPrim.GetStage(), usdPrim.GetPath()) }, TfStringPrintf("Connectable %s <%s> can only have " "Connectable Container ancestors up to %s " "ancestor <%s>, but its parent %s is a %s.", @@ -106,122 +100,103 @@ _EncapsulationValidator(const UsdPrim& usdPrim) return errors; } -static -UsdValidationErrorVector +static UsdValidationErrorVector _MaterialBindingApiAppliedValidator(const UsdPrim &usdPrim) { UsdValidationErrorVector errors; - auto hasMaterialBindingRelationship = [](const UsdPrim& usdPrim) { - const std::vector relationships = - usdPrim.GetRelationships(); - static const std::string materialBindingString = - (UsdShadeTokens->materialBinding).GetString(); + auto hasMaterialBindingRelationship = [](const UsdPrim &usdPrim) { + const std::vector relationships + = usdPrim.GetRelationships(); + static const std::string materialBindingString + = (UsdShadeTokens->materialBinding).GetString(); - return std::any_of(relationships.begin(), - relationships.end(), + return std::any_of(relationships.begin(), relationships.end(), [&](const UsdRelationship &rel) { - return TfStringStartsWith(rel.GetName(), + return TfStringStartsWith(rel.GetName(), materialBindingString); -}); + }); }; - if (!usdPrim.HasAPI() && - hasMaterialBindingRelationship(usdPrim)) { + if (!usdPrim.HasAPI() + && hasMaterialBindingRelationship(usdPrim)) { errors.emplace_back( UsdShadeValidationErrorNameTokens->missingMaterialBindingAPI, UsdValidationErrorType::Error, - UsdValidationErrorSites{ - UsdValidationErrorSite(usdPrim.GetStage(), - usdPrim.GetPath()) - }, + UsdValidationErrorSites { + UsdValidationErrorSite(usdPrim.GetStage(), usdPrim.GetPath()) }, TfStringPrintf("Found material bindings but no MaterialBindingAPI " - "applied on the prim <%s>.", + "applied on the prim <%s>.", usdPrim.GetPath().GetText())); } return errors; } -static -UsdValidationErrorVector -_MaterialBindingRelationships(const UsdPrim& usdPrim) +static UsdValidationErrorVector +_MaterialBindingRelationships(const UsdPrim &usdPrim) { if (!usdPrim) { return {}; } - const std::vector matBindingProperties = - usdPrim.GetProperties( - /* predicate = */ [](const TfToken& name) { - return UsdShadeMaterialBindingAPI::CanContainPropertyName( - name); - } - ); + const std::vector matBindingProperties = usdPrim.GetProperties( + /* predicate = */ [](const TfToken &name) { + return UsdShadeMaterialBindingAPI::CanContainPropertyName(name); + }); UsdValidationErrorVector errors; - for (const UsdProperty& matBindingProperty : matBindingProperties) { + for (const UsdProperty &matBindingProperty : matBindingProperties) { if (matBindingProperty.Is()) { continue; } - const UsdValidationErrorSites propertyErrorSites = { - UsdValidationErrorSite( - usdPrim.GetStage(), - matBindingProperty.GetPath()) - }; + const UsdValidationErrorSites propertyErrorSites + = { UsdValidationErrorSite(usdPrim.GetStage(), + matBindingProperty.GetPath()) }; errors.emplace_back( UsdShadeValidationErrorNameTokens->materialBindingPropNotARel, - UsdValidationErrorType::Error, - propertyErrorSites, + UsdValidationErrorType::Error, propertyErrorSites, TfStringPrintf( "Prim <%s> has material binding property '%s' that is not " "a relationship.", usdPrim.GetPath().GetText(), - matBindingProperty.GetName().GetText()) - ); + matBindingProperty.GetName().GetText())); } return errors; } void -_MaterialBindingCheckCollection( - const UsdPrim& prim, - const UsdRelationship& rel, - UsdValidationErrorVector& outErrors) +_MaterialBindingCheckCollection(const UsdPrim &prim, const UsdRelationship &rel, + UsdValidationErrorVector &outErrors) { SdfPathVector targets; rel.GetTargets(&targets); if (targets.size() == 1) { - if (UsdShadeMaterialBindingAPI::CollectionBinding - ::IsCollectionBindingRel(rel)) { + if (UsdShadeMaterialBindingAPI::CollectionBinding :: + IsCollectionBindingRel(rel)) { outErrors.emplace_back( UsdShadeValidationErrorNameTokens->invalidMaterialCollection, UsdValidationErrorType::Error, - UsdValidationErrorSites{ - UsdValidationErrorSite(prim.GetStage(), - rel.GetPath()) - }, + UsdValidationErrorSites { + UsdValidationErrorSite(prim.GetStage(), rel.GetPath()) }, TfStringPrintf("Collection-based material binding on <%s> " "has 1 target <%s>, needs 2: a collection path " "and a UsdShadeMaterial path.", - prim.GetPath().GetText(), - targets[0].GetText())); + prim.GetPath().GetText(), targets[0].GetText())); } else { - UsdShadeMaterialBindingAPI::DirectBinding directBinding = - UsdShadeMaterialBindingAPI::DirectBinding(rel); + UsdShadeMaterialBindingAPI::DirectBinding directBinding + = UsdShadeMaterialBindingAPI::DirectBinding(rel); if (!directBinding.GetMaterial()) { outErrors.emplace_back( UsdShadeValidationErrorNameTokens->invalidResourcePath, UsdValidationErrorType::Error, - UsdValidationErrorSites{ - UsdValidationErrorSite(prim.GetStage(), - rel.GetPath()) - }, + UsdValidationErrorSites { UsdValidationErrorSite( + prim.GetStage(), rel.GetPath()) }, TfStringPrintf("Direct material binding <%s> targets " "an invalid material <%s>.", rel.GetPath().GetText(), @@ -229,16 +204,14 @@ _MaterialBindingCheckCollection( } } } else if (targets.size() == 2) { - UsdShadeMaterialBindingAPI::CollectionBinding collBinding = - UsdShadeMaterialBindingAPI::CollectionBinding(rel); + UsdShadeMaterialBindingAPI::CollectionBinding collBinding + = UsdShadeMaterialBindingAPI::CollectionBinding(rel); if (!collBinding.GetMaterial()) { outErrors.emplace_back( UsdShadeValidationErrorNameTokens->invalidResourcePath, UsdValidationErrorType::Error, - UsdValidationErrorSites{ - UsdValidationErrorSite(prim.GetStage(), - rel.GetPath()) - }, + UsdValidationErrorSites { + UsdValidationErrorSite(prim.GetStage(), rel.GetPath()) }, TfStringPrintf("Collection-based material binding " "<%s> targets an invalid material <%s>.", rel.GetPath().GetText(), @@ -248,10 +221,8 @@ _MaterialBindingCheckCollection( outErrors.emplace_back( UsdShadeValidationErrorNameTokens->invalidResourcePath, UsdValidationErrorType::Error, - UsdValidationErrorSites{ - UsdValidationErrorSite(prim.GetStage(), - rel.GetPath()) - }, + UsdValidationErrorSites { + UsdValidationErrorSite(prim.GetStage(), rel.GetPath()) }, TfStringPrintf("Collection-based material binding " "<%s> targets an invalid collection <%s>.", rel.GetPath().GetText(), @@ -261,51 +232,44 @@ _MaterialBindingCheckCollection( outErrors.emplace_back( UsdShadeValidationErrorNameTokens->invalidMaterialCollection, UsdValidationErrorType::Error, - UsdValidationErrorSites{ - UsdValidationErrorSite(prim.GetStage(), - rel.GetPath()) - }, + UsdValidationErrorSites { + UsdValidationErrorSite(prim.GetStage(), rel.GetPath()) }, TfStringPrintf("Invalid number of targets on " - "material binding <%s>", - rel.GetPath().GetText())); + "material binding <%s>", + rel.GetPath().GetText())); } } -static -UsdValidationErrorVector -_MaterialBindingCollectionValidator(const UsdPrim& usdPrim) +static UsdValidationErrorVector +_MaterialBindingCollectionValidator(const UsdPrim &usdPrim) { if (!usdPrim || !usdPrim.HasAPI()) { return {}; } - const std::vector matBindingProperties = - usdPrim.GetProperties( - /* predicate = */ [](const TfToken& name) { - return UsdShadeMaterialBindingAPI::CanContainPropertyName( - name); - } - ); + const std::vector matBindingProperties = usdPrim.GetProperties( + /* predicate = */ [](const TfToken &name) { + return UsdShadeMaterialBindingAPI::CanContainPropertyName(name); + }); UsdValidationErrorVector outErrors; - for (const UsdProperty& matBindingProperty : matBindingProperties) { - if (const UsdRelationship& matBindingRel = - matBindingProperty.As()) { - _MaterialBindingCheckCollection( - usdPrim, matBindingRel, outErrors); + for (const UsdProperty &matBindingProperty : matBindingProperties) { + if (const UsdRelationship &matBindingRel + = matBindingProperty.As()) { + _MaterialBindingCheckCollection(usdPrim, matBindingRel, outErrors); } } return outErrors; } -static -UsdValidationErrorVector +static UsdValidationErrorVector _ShaderPropertyTypeConformance(const UsdPrim &usdPrim) { - if (!(usdPrim && usdPrim.IsInFamily( - UsdSchemaRegistry::VersionPolicy::All))) { + if (!(usdPrim + && usdPrim.IsInFamily( + UsdSchemaRegistry::VersionPolicy::All))) { return {}; } UsdShadeShader shader(usdPrim); @@ -313,138 +277,137 @@ _ShaderPropertyTypeConformance(const UsdPrim &usdPrim) return {}; } - const TfTokenVector expectedImplSource = - {UsdShadeTokens->id, UsdShadeTokens->sourceAsset, - UsdShadeTokens->sourceCode}; + const TfTokenVector expectedImplSource + = { UsdShadeTokens->id, UsdShadeTokens->sourceAsset, + UsdShadeTokens->sourceCode }; const TfToken implSource = shader.GetImplementationSource(); if (std::find(expectedImplSource.begin(), expectedImplSource.end(), - implSource) == expectedImplSource.end()) { - const UsdValidationErrorSites implSourceErrorSite = { - UsdValidationErrorSite( - usdPrim.GetStage(), + implSource) + == expectedImplSource.end()) { + const UsdValidationErrorSites implSourceErrorSite + = { UsdValidationErrorSite( + usdPrim.GetStage(), shader.GetImplementationSourceAttr().GetPath()) }; - return {UsdValidationError( + return { UsdValidationError( UsdShadeValidationErrorNameTokens->invalidImplSource, UsdValidationErrorType::Error, implSourceErrorSite, TfStringPrintf("Shader <%s> has invalid implementation source " - "'%s'.", usdPrim.GetPath().GetText(), - implSource.GetText()))}; + "'%s'.", + usdPrim.GetPath().GetText(), + implSource.GetText())) }; } const std::vector sourceTypes = shader.GetSourceTypes(); if (sourceTypes.empty() && implSource != UsdShadeTokens->id) { - const UsdValidationErrorSites primErrorSite = { - UsdValidationErrorSite(usdPrim.GetStage(), - usdPrim.GetPath()) }; - return {UsdValidationError( + const UsdValidationErrorSites primErrorSite + = { UsdValidationErrorSite(usdPrim.GetStage(), usdPrim.GetPath()) }; + return { UsdValidationError( UsdShadeValidationErrorNameTokens->missingSourceType, - UsdValidationErrorType::Error, - primErrorSite, - TfStringPrintf("Shader <%s> has no sourceType.", - usdPrim.GetPath().GetText()))}; + UsdValidationErrorType::Error, primErrorSite, + TfStringPrintf("Shader <%s> has no sourceType.", + usdPrim.GetPath().GetText())) }; } UsdValidationErrorVector errors; - std::unordered_map propNameToPropertyMap; + std::unordered_map + propNameToPropertyMap; if (sourceTypes.empty() && implSource == UsdShadeTokens->id) { TfToken shaderId; if (shader.GetShaderId(&shaderId)) { // Single shaderNode, just emplace all properties, no need to find // anything. - if (SdrShaderNodeConstPtr sdrShaderNode = - SdrRegistry::GetInstance().GetShaderNodeByIdentifier( + if (SdrShaderNodeConstPtr sdrShaderNode + = SdrRegistry::GetInstance().GetShaderNodeByIdentifier( shaderId)) { for (const TfToken &propName : sdrShaderNode->GetInputNames()) { - if (const SdrShaderPropertyConstPtr sdrProp = - sdrShaderNode->GetShaderInput(propName)) { + if (const SdrShaderPropertyConstPtr sdrProp + = sdrShaderNode->GetShaderInput(propName)) { propNameToPropertyMap.emplace(propName, sdrProp); } } } else { - const UsdValidationErrorSites shaderIdErrorSite = { - UsdValidationErrorSite(usdPrim.GetStage(), - shader.GetIdAttr().GetPath()) }; - return {UsdValidationError( - UsdShadeValidationErrorNameTokens-> - missingShaderIdInRegistry, - UsdValidationErrorType::Error, - shaderIdErrorSite, + const UsdValidationErrorSites shaderIdErrorSite + = { UsdValidationErrorSite(usdPrim.GetStage(), + shader.GetIdAttr().GetPath()) }; + return { UsdValidationError( + UsdShadeValidationErrorNameTokens + ->missingShaderIdInRegistry, + UsdValidationErrorType::Error, shaderIdErrorSite, TfStringPrintf("shaderId '%s' specified on shader prim " "<%s> not found in sdrRegistry.", - shaderId.GetText(), - usdPrim.GetPath().GetText()))}; + shaderId.GetText(), + usdPrim.GetPath().GetText())) }; } } } else { - // Use the SdrShaderNode::CheckPropertyCompliance to find if these do - // not match, then report a ValidationError as a warning, since asset + // Use the SdrShaderNode::CheckPropertyCompliance to find if these do + // not match, then report a ValidationError as a warning, since asset // authors have no control on fixing the shaders. std::vector shaderNodesFromSourceTypes; // We need to gather all unique inputs from all sdrShaderNodes queried // using multiple sourceTypes. - for (const auto& sourceType : sourceTypes) { - if (SdrShaderNodeConstPtr sdrShaderNode = - shader.GetShaderNodeForSourceType(TfToken(sourceType))) { + for (const auto &sourceType : sourceTypes) { + if (SdrShaderNodeConstPtr sdrShaderNode + = shader.GetShaderNodeForSourceType(TfToken(sourceType))) { shaderNodesFromSourceTypes.push_back(sdrShaderNode); for (const TfToken &propName : sdrShaderNode->GetInputNames()) { // Check if property has already been added to the map. - if (propNameToPropertyMap.find(propName) == - propNameToPropertyMap.end()) { - if (const SdrShaderPropertyConstPtr sdrProp = - sdrShaderNode->GetShaderInput(propName)) { + if (propNameToPropertyMap.find(propName) + == propNameToPropertyMap.end()) { + if (const SdrShaderPropertyConstPtr sdrProp + = sdrShaderNode->GetShaderInput(propName)) { propNameToPropertyMap.emplace(propName, sdrProp); } } } } else { UsdValidationErrorSites sourceTypeSites; - for (const auto& sourceTypeProp : - usdPrim.GetPropertiesInNamespace( - SdfPath::JoinIdentifier("info", sourceType))) { - sourceTypeSites.emplace_back(usdPrim.GetStage(), + for (const auto &sourceTypeProp : + usdPrim.GetPropertiesInNamespace( + SdfPath::JoinIdentifier("info", sourceType))) { + sourceTypeSites.emplace_back(usdPrim.GetStage(), sourceTypeProp.GetPath()); } errors.emplace_back( - UsdShadeValidationErrorNameTokens-> - missingSourceTypeInRegistry, - UsdValidationErrorType::Error, - sourceTypeSites, + UsdShadeValidationErrorNameTokens + ->missingSourceTypeInRegistry, + UsdValidationErrorType::Error, sourceTypeSites, TfStringPrintf("sourceType '%s' specified on shader prim " "<%s> not found in sdrRegistry.", - sourceType.c_str(), + sourceType.c_str(), usdPrim.GetPath().GetText())); } } - SdrShaderNode::ComplianceResults sdrShaderComplianceResults = - SdrShaderNode::CheckPropertyCompliance(shaderNodesFromSourceTypes); - const UsdValidationErrorSites sdrWarnSite = { - UsdValidationErrorSite(usdPrim.GetStage(), usdPrim.GetPath()) - }; - for (const auto& entry : sdrShaderComplianceResults) { + SdrShaderNode::ComplianceResults sdrShaderComplianceResults + = SdrShaderNode::CheckPropertyCompliance( + shaderNodesFromSourceTypes); + const UsdValidationErrorSites sdrWarnSite + = { UsdValidationErrorSite(usdPrim.GetStage(), usdPrim.GetPath()) }; + for (const auto &entry : sdrShaderComplianceResults) { // need this for getting the error message! std::vector shaderNames; shaderNames.reserve(entry.second.size()); - for (const auto& shaderName : entry.second) { + for (const auto &shaderName : entry.second) { shaderNames.push_back(shaderName.GetString()); } errors.emplace_back( - UsdShadeValidationErrorNameTokens-> - incompatShaderPropertyWarning, + UsdShadeValidationErrorNameTokens + ->incompatShaderPropertyWarning, UsdValidationErrorType::Warn, sdrWarnSite, TfStringPrintf("Shader nodes '%s' have incompatible property " - "'%s'.", TfStringJoin(shaderNames).c_str(), - entry.first.GetText())); + "'%s'.", + TfStringJoin(shaderNames).c_str(), + entry.first.GetText())); } } // Get ground truth data about inputName to types from sdrNode const auto sdrPropnameToSdfType = [&propNameToPropertyMap]() { std::unordered_map map; - for (const auto& prop : propNameToPropertyMap) { + for (const auto &prop : propNameToPropertyMap) { map.emplace(prop.first, prop.second->GetTypeAsSdfType().GetSdfType()); } @@ -454,20 +417,17 @@ _ShaderPropertyTypeConformance(const UsdPrim &usdPrim) // Compare ground truth data with the inputs on UsdShadeShader prim for (const UsdShadeInput &input : shader.GetInputs(false)) { const TfToken baseName = input.GetBaseName(); - if (sdrPropnameToSdfType.find(baseName) != - sdrPropnameToSdfType.end()) { - const SdfValueTypeName &expectedSdrInputType = - sdrPropnameToSdfType.at(baseName); + if (sdrPropnameToSdfType.find(baseName) != sdrPropnameToSdfType.end()) { + const SdfValueTypeName &expectedSdrInputType + = sdrPropnameToSdfType.at(baseName); const SdfValueTypeName usdInputType = input.GetTypeName(); if (usdInputType != expectedSdrInputType) { - const UsdValidationErrorSites inputErrorSite = { - UsdValidationErrorSite(usdPrim.GetStage(), - input.GetAttr().GetPath()) - }; + const UsdValidationErrorSites inputErrorSite + = { UsdValidationErrorSite(usdPrim.GetStage(), + input.GetAttr().GetPath()) }; errors.emplace_back( UsdShadeValidationErrorNameTokens->mismatchPropertyType, - UsdValidationErrorType::Error, - inputErrorSite, + UsdValidationErrorType::Error, inputErrorSite, TfStringPrintf("Incorrect type for %s. " "Expected '%s'; got '%s'.", input.GetAttr().GetPath().GetText(), @@ -479,12 +439,12 @@ _ShaderPropertyTypeConformance(const UsdPrim &usdPrim) return errors; } -static -UsdValidationErrorVector -_SubsetMaterialBindFamilyName(const UsdPrim& usdPrim) +static UsdValidationErrorVector +_SubsetMaterialBindFamilyName(const UsdPrim &usdPrim) { - if (!(usdPrim && usdPrim.IsInFamily( - UsdSchemaRegistry::VersionPolicy::All))) { + if (!(usdPrim + && usdPrim.IsInFamily( + UsdSchemaRegistry::VersionPolicy::All))) { return {}; } @@ -495,14 +455,11 @@ _SubsetMaterialBindFamilyName(const UsdPrim& usdPrim) size_t numMatBindingRels = 0u; - const std::vector matBindingProperties = - usdPrim.GetProperties( - /* predicate = */ [](const TfToken& name) { - return UsdShadeMaterialBindingAPI::CanContainPropertyName( - name); - } - ); - for (const UsdProperty& matBindingProperty : matBindingProperties) { + const std::vector matBindingProperties = usdPrim.GetProperties( + /* predicate = */ [](const TfToken &name) { + return UsdShadeMaterialBindingAPI::CanContainPropertyName(name); + }); + for (const UsdProperty &matBindingProperty : matBindingProperties) { if (matBindingProperty.Is()) { ++numMatBindingRels; } @@ -516,30 +473,25 @@ _SubsetMaterialBindFamilyName(const UsdPrim& usdPrim) return {}; } - const UsdValidationErrorSites primErrorSites = { - UsdValidationErrorSite(usdPrim.GetStage(), usdPrim.GetPath()) - }; - - return { - UsdValidationError( - UsdShadeValidationErrorNameTokens->missingFamilyNameOnGeomSubset, - UsdValidationErrorType::Error, - primErrorSites, - TfStringPrintf( - "GeomSubset prim <%s> with material bindings applied but " - "no authored family name should set familyName to '%s'.", - usdPrim.GetPath().GetText(), - UsdShadeTokens->materialBind.GetText()) - ) - }; + const UsdValidationErrorSites primErrorSites + = { UsdValidationErrorSite(usdPrim.GetStage(), usdPrim.GetPath()) }; + + return { UsdValidationError( + UsdShadeValidationErrorNameTokens->missingFamilyNameOnGeomSubset, + UsdValidationErrorType::Error, primErrorSites, + TfStringPrintf( + "GeomSubset prim <%s> with material bindings applied but " + "no authored family name should set familyName to '%s'.", + usdPrim.GetPath().GetText(), + UsdShadeTokens->materialBind.GetText())) }; } -static -UsdValidationErrorVector -_SubsetsMaterialBindFamily(const UsdPrim& usdPrim) +static UsdValidationErrorVector +_SubsetsMaterialBindFamily(const UsdPrim &usdPrim) { - if (!(usdPrim && usdPrim.IsInFamily( - UsdSchemaRegistry::VersionPolicy::All))) { + if (!(usdPrim + && usdPrim.IsInFamily( + UsdSchemaRegistry::VersionPolicy::All))) { return {}; } @@ -548,8 +500,8 @@ _SubsetsMaterialBindFamily(const UsdPrim& usdPrim) return {}; } - const std::vector materialBindSubsets = - UsdGeomSubset::GetGeomSubsets( + const std::vector materialBindSubsets + = UsdGeomSubset::GetGeomSubsets( imageable, /* elementType = */ TfToken(), /* familyName = */ UsdShadeTokens->materialBind); @@ -563,18 +515,15 @@ _SubsetsMaterialBindFamily(const UsdPrim& usdPrim) // Check to make sure that the "materialBind" family is of a restricted // type, since it is invalid for an element of geometry to be bound to // multiple materials. - const TfToken materialBindFamilyType = UsdGeomSubset::GetFamilyType( - imageable, - UsdShadeTokens->materialBind); + const TfToken materialBindFamilyType + = UsdGeomSubset::GetFamilyType(imageable, UsdShadeTokens->materialBind); if (materialBindFamilyType == UsdGeomTokens->unrestricted) { - const UsdValidationErrorSites primErrorSites = { - UsdValidationErrorSite(usdPrim.GetStage(), usdPrim.GetPath()) - }; + const UsdValidationErrorSites primErrorSites + = { UsdValidationErrorSite(usdPrim.GetStage(), usdPrim.GetPath()) }; errors.emplace_back( UsdShadeValidationErrorNameTokens->invalidFamilyType, - UsdValidationErrorType::Error, - primErrorSites, + UsdValidationErrorType::Error, primErrorSites, TfStringPrintf( "Imageable prim <%s> has '%s' subset family with invalid " "family type '%s'. Family type should be '%s' or '%s' " @@ -583,8 +532,7 @@ _SubsetsMaterialBindFamily(const UsdPrim& usdPrim) UsdShadeTokens->materialBind.GetText(), materialBindFamilyType.GetText(), UsdGeomTokens->nonOverlapping.GetText(), - UsdGeomTokens->partition.GetText()) - ); + UsdGeomTokens->partition.GetText())); } return errors; @@ -607,7 +555,7 @@ TF_REGISTRY_FUNCTION(UsdValidationRegistry) _MaterialBindingCollectionValidator); registry.RegisterPluginValidator( - UsdShadeValidatorNameTokens->shaderSdrCompliance, + UsdShadeValidatorNameTokens->shaderSdrCompliance, _ShaderPropertyTypeConformance); registry.RegisterPluginValidator( @@ -619,8 +567,8 @@ TF_REGISTRY_FUNCTION(UsdValidationRegistry) _SubsetsMaterialBindFamily); registry.RegisterPluginValidator( - UsdShadeValidatorNameTokens->encapsulationValidator, - _EncapsulationValidator); + UsdShadeValidatorNameTokens->encapsulationValidator, + _EncapsulationValidator); } PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usdValidation/usdSkelValidators/CMakeLists.txt b/pxr/usdValidation/usdSkelValidators/CMakeLists.txt new file mode 100644 index 0000000000..7f9aea2043 --- /dev/null +++ b/pxr/usdValidation/usdSkelValidators/CMakeLists.txt @@ -0,0 +1,41 @@ +set(PXR_PREFIX pxr/usdValidation) +set(PXR_PACKAGE usdSkelValidators) + +pxr_library(usdSkelValidators + LIBRARIES + tf + plug + sdf + usd + usdSkel + usdValidation + + PUBLIC_CLASSES + validatorTokens + + PUBLIC_HEADERS + api.h + + CPPFILES + validators.cpp + + RESOURCE_FILES + plugInfo.json +) + +pxr_build_test(testUsdSkelValidators + LIBRARIES + tf + usd + usdValidation + usdSkel + usdSkelValidators + CPPFILES + testenv/testUsdSkelValidators.cpp +) + +pxr_register_test(testUsdSkelValidators + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdSkelValidators" + EXPECTED_RETURN_CODE 0 +) + diff --git a/pxr/usdValidation/usdSkelValidators/api.h b/pxr/usdValidation/usdSkelValidators/api.h new file mode 100644 index 0000000000..c067ae9f2b --- /dev/null +++ b/pxr/usdValidation/usdSkelValidators/api.h @@ -0,0 +1,34 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +#ifndef PXR_USD_VALIDATION_USD_SKEL_VALIDATORS_API_H +#define PXR_USD_VALIDATION_USD_SKEL_VALIDATORS_API_H + +#include "pxr/base/arch/export.h" + +#if defined(PXR_STATIC) +# define USDSKELVALIDATORS_API +# define USDSKELVALIDATORS_API_TEMPLATE_CLASS(...) +# define USDSKELVALIDATORS_API_TEMPLATE_STRUCT(...) +# define USDSKELVALIDATORS_API_LOCAL +#else +# if defined(USDSKELVALIDATORS_API_EXPORTS) +# define USDSKELVALIDATORS_API ARCH_EXPORT +# define USDSKELVALIDATORS_API_TEMPLATE_CLASS(...) \ + ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__) +# define USDSKELVALIDATORS_API_TEMPLATE_STRUCT(...) \ + ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__) +# else +# define USDSKELVALIDATORS_API ARCH_IMPORT +# define USDSKELVALIDATORS_API_TEMPLATE_CLASS(...) \ + ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__) +# define USDSKELVALIDATORS_API_TEMPLATE_STRUCT(...) \ + ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__) +# endif +# define USDSKELVALIDATORS_API_LOCAL ARCH_HIDDEN +#endif + +#endif diff --git a/pxr/usdValidation/usdSkelValidators/plugInfo.json b/pxr/usdValidation/usdSkelValidators/plugInfo.json new file mode 100644 index 0000000000..e86350d1a8 --- /dev/null +++ b/pxr/usdValidation/usdSkelValidators/plugInfo.json @@ -0,0 +1,27 @@ +{ + "Plugins": [ + { + "Info": { + "Validators": { + "SkelBindingApiAppliedValidator": { + "doc": "Verify a prim has the SkelBindingAPI applied if it has a UsdSkelBinding property." + }, + "SkelBindingApiValidator": { + "doc": "Verify that a prim with SkelBindingAPI applied, is either of SkelRoot type or parented by a SkelRoot prim.", + "schemaTypes": [ + "UsdSkelBindingAPI" + ] + }, + "keywords": [ + "UsdSkelValidators" + ] + } + }, + "LibraryPath": "@PLUG_INFO_LIBRARY_PATH@", + "Name": "usdSkelValidators", + "ResourcePath": "@PLUG_INFO_RESOURCE_PATH@", + "Root": "@PLUG_INFO_ROOT@", + "Type": "library" + } + ] +} diff --git a/pxr/usd/usdSkel/testenv/testUsdSkelValidators.cpp b/pxr/usdValidation/usdSkelValidators/testenv/testUsdSkelValidators.cpp similarity index 66% rename from pxr/usd/usdSkel/testenv/testUsdSkelValidators.cpp rename to pxr/usdValidation/usdSkelValidators/testenv/testUsdSkelValidators.cpp index 1afddbfba8..babeaee098 100644 --- a/pxr/usd/usdSkel/testenv/testUsdSkelValidators.cpp +++ b/pxr/usdValidation/usdSkelValidators/testenv/testUsdSkelValidators.cpp @@ -4,18 +4,20 @@ // Licensed under the terms set forth in the LICENSE.txt file available at // https://openusd.org/license. // -#include "pxr/usd/usd/validationRegistry.h" -#include "pxr/usd/usd/validationError.h" -#include -#include -#include + +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" + #include #include +#include +#include +#include PXR_NAMESPACE_USING_DIRECTIVE TF_DEFINE_PRIVATE_TOKENS(_tokens, - ((usdSkelPlugin, "usdSkel")) + ((usdSkelValidatorsPlugin, "usdSkelValidators")) ); void @@ -23,21 +25,23 @@ TestUsdSkelValidators() { // This should be updated with every new validator added with // UsdSkelValidators keyword. - UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); - UsdValidatorMetadataVector metadata = - registry.GetValidatorMetadataForPlugin(_tokens->usdSkelPlugin); + const UsdValidationRegistry ®istry + = UsdValidationRegistry::GetInstance(); + UsdValidationValidatorMetadataVector metadata + = registry.GetValidatorMetadataForPlugin( + _tokens->usdSkelValidatorsPlugin); TF_AXIOM(metadata.size() == 2); // Since other validators can be registered with a UsdSkelValidators - // keyword, our validators registered in usdSkel are a subset of the entire - // set. + // keyword, our validators registered in usdSkelValidators are a subset of + // the entire set. std::set validatorMetadataNameSet; - for (const UsdValidatorMetadata &metadata : metadata) { + for (const UsdValidationValidatorMetadata &metadata : metadata) { validatorMetadataNameSet.insert(metadata.name); } - const std::set expectedValidatorNames = - {UsdSkelValidatorNameTokens->skelBindingApiAppliedValidator, - UsdSkelValidatorNameTokens->skelBindingApiValidator}; + const std::set expectedValidatorNames + = { UsdSkelValidatorNameTokens->skelBindingApiAppliedValidator, + UsdSkelValidatorNameTokens->skelBindingApiValidator }; TF_AXIOM(validatorMetadataNameSet == expectedValidatorNames); } @@ -47,8 +51,8 @@ TestUsdSkelBindingApiAppliedValidator() { // Verify that the validator exists. UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); - const UsdValidator *validator = registry.GetOrLoadValidatorByName( - UsdSkelValidatorNameTokens->skelBindingApiAppliedValidator); + const UsdValidationValidator *validator = registry.GetOrLoadValidatorByName( + UsdSkelValidatorNameTokens->skelBindingApiAppliedValidator); TF_AXIOM(validator); // Create Stage and mesh with a skel binding property @@ -56,15 +60,15 @@ TestUsdSkelBindingApiAppliedValidator() UsdGeomMesh mesh = UsdGeomMesh::Define(usdStage, SdfPath("/SkelRoot/Mesh")); UsdGeomPrimvarsAPI primvarsApi(mesh); UsdGeomPrimvar jointIndicesPrimvar = primvarsApi.CreatePrimvar( - TfToken("skel:jointIndices"), SdfValueTypeNames->IntArray, + TfToken("skel:jointIndices"), SdfValueTypeNames->IntArray, UsdGeomTokens->vertex); - jointIndicesPrimvar.Set(VtIntArray{0, 1, 2}); + jointIndicesPrimvar.Set(VtIntArray { 0, 1, 2 }); UsdValidationErrorVector errors = validator->Validate(mesh.GetPrim()); TfToken expectedErrorIdentifier( - "usdSkel:SkelBindingApiAppliedValidator.MissingSkelBindingAPI"); - // Verify the error for not having the SkelBindingAPI schema applied is + "usdSkelValidators:SkelBindingApiAppliedValidator.MissingSkelBindingAPI"); + // Verify the error for not having the SkelBindingAPI schema applied is // present. TF_AXIOM(errors.size() == 1); TF_AXIOM(errors[0].GetIdentifier() == expectedErrorIdentifier); @@ -72,8 +76,8 @@ TestUsdSkelBindingApiAppliedValidator() TF_AXIOM(errors[0].GetSites().size() == 1); TF_AXIOM(errors[0].GetSites()[0].IsValid()); TF_AXIOM(errors[0].GetSites()[0].IsPrim()); - TF_AXIOM(errors[0].GetSites()[0].GetPrim().GetPath() == - SdfPath("/SkelRoot/Mesh")); + TF_AXIOM(errors[0].GetSites()[0].GetPrim().GetPath() + == SdfPath("/SkelRoot/Mesh")); std::string expectedErrorMsg = ("Found a UsdSkelBinding property " "(primvars:skel:jointIndices), but no " "SkelBindingAPI applied on the prim " @@ -86,14 +90,14 @@ TestUsdSkelBindingApiAppliedValidator() // Verify all errors are gone TF_AXIOM(errors.empty()); - const UsdValidator *skelBindingApiValidator = - registry.GetOrLoadValidatorByName( + const UsdValidationValidator *skelBindingApiValidator + = registry.GetOrLoadValidatorByName( UsdSkelValidatorNameTokens->skelBindingApiValidator); errors = skelBindingApiValidator->Validate(mesh.GetPrim()); expectedErrorIdentifier = TfToken( - "usdSkel:SkelBindingApiValidator.InvalidSkelBindingAPIApply"); - // Verify the error for not having a SkelRoot parenting a prim with the + "usdSkelValidators:SkelBindingApiValidator.InvalidSkelBindingAPIApply"); + // Verify the error for not having a SkelRoot parenting a prim with the // SkelBindingAPI applied. TF_AXIOM(errors.size() == 1); TF_AXIOM(errors[0].GetIdentifier() == expectedErrorIdentifier); @@ -101,11 +105,12 @@ TestUsdSkelBindingApiAppliedValidator() TF_AXIOM(errors[0].GetSites().size() == 1); TF_AXIOM(errors[0].GetSites()[0].IsValid()); TF_AXIOM(errors[0].GetSites()[0].IsPrim()); - TF_AXIOM(errors[0].GetSites()[0].GetPrim().GetPath() == - SdfPath("/SkelRoot/Mesh")); - expectedErrorMsg = ("UsdSkelBindingAPI applied on prim: , " - "which is not of type SkelRoot or is not rooted at a prim " - "of type SkelRoot, as required by the UsdSkel schema."); + TF_AXIOM(errors[0].GetSites()[0].GetPrim().GetPath() + == SdfPath("/SkelRoot/Mesh")); + expectedErrorMsg + = ("UsdSkelBindingAPI applied on prim: , " + "which is not of type SkelRoot or is not rooted at a prim " + "of type SkelRoot, as required by the UsdSkel schema."); const std::string message = errors[0].GetMessage(); TF_AXIOM(errors[0].GetMessage() == expectedErrorMsg); diff --git a/pxr/usd/usdSkel/validatorTokens.cpp b/pxr/usdValidation/usdSkelValidators/validatorTokens.cpp similarity index 89% rename from pxr/usd/usdSkel/validatorTokens.cpp rename to pxr/usdValidation/usdSkelValidators/validatorTokens.cpp index a3f32bca21..0baf70c6c6 100644 --- a/pxr/usd/usdSkel/validatorTokens.cpp +++ b/pxr/usdValidation/usdSkelValidators/validatorTokens.cpp @@ -5,7 +5,7 @@ // https://openusd.org/license. // -#include "pxr/usd/usdSkel/validatorTokens.h" +#include "pxr/usdValidation/usdSkelValidators/validatorTokens.h" PXR_NAMESPACE_OPEN_SCOPE diff --git a/pxr/usd/usdSkel/validatorTokens.h b/pxr/usdValidation/usdSkelValidators/validatorTokens.h similarity index 50% rename from pxr/usd/usdSkel/validatorTokens.h rename to pxr/usdValidation/usdSkelValidators/validatorTokens.h index adcaf2e08e..c6e03a7d3f 100644 --- a/pxr/usd/usdSkel/validatorTokens.h +++ b/pxr/usdValidation/usdSkelValidators/validatorTokens.h @@ -4,41 +4,44 @@ // Licensed under the terms set forth in the LICENSE.txt file available at // https://openusd.org/license. // -#ifndef USDSKEL_VALIDATOR_TOKENS_H -#define USDSKEL_VALIDATOR_TOKENS_H +#ifndef PXR_USD_VALIDATION_USD_SKEL_VALIDATORS_TOKENS_H +#define PXR_USD_VALIDATION_USD_SKEL_VALIDATORS_TOKENS_H + /// \file #include "pxr/pxr.h" -#include "pxr/usd/usdSkel/api.h" #include "pxr/base/tf/staticTokens.h" +#include "pxr/usdValidation/usdSkelValidators/api.h" PXR_NAMESPACE_OPEN_SCOPE -#define USD_SKEL_VALIDATOR_NAME_TOKENS \ - ((skelBindingApiAppliedValidator, "usdSkel:SkelBindingApiAppliedValidator")) \ - ((skelBindingApiValidator, "usdSkel:SkelBindingApiValidator")) +#define USD_SKEL_VALIDATOR_NAME_TOKENS \ + ((skelBindingApiAppliedValidator, \ + "usdSkelValidators:SkelBindingApiAppliedValidator")) \ + ((skelBindingApiValidator, "usdSkelValidators:SkelBindingApiValidator")) -#define USD_SKEL_VALIDATOR_KEYWORD_TOKENS \ - (UsdSkelValidators) +#define USD_SKEL_VALIDATOR_KEYWORD_TOKENS \ + (UsdSkelValidators) -#define USD_SKEL_VALIDATION_ERROR_NAME_TOKENS \ - ((missingSkelBindingAPI, "MissingSkelBindingAPI")) \ - ((invalidSkelBindingAPIApply, "InvalidSkelBindingAPIApply")) \ +#define USD_SKEL_VALIDATION_ERROR_NAME_TOKENS \ + ((missingSkelBindingAPI, "MissingSkelBindingAPI")) \ + ((invalidSkelBindingAPIApply, "InvalidSkelBindingAPIApply")) /// \def USD_SKEL_VALIDATOR_NAME_TOKENS /// Tokens representing validator names. Note that for plugin provided -/// validators, the names must be prefixed by usdSkel:, which is the name of -/// the usdSkel plugin. -TF_DECLARE_PUBLIC_TOKENS(UsdSkelValidatorNameTokens, USDSKEL_API, +/// validators, the names must be prefixed by usdSkelValidators:, which is the +/// name of the usdSkelValidators plugin. +TF_DECLARE_PUBLIC_TOKENS(UsdSkelValidatorNameTokens, USDSKELVALIDATORS_API, USD_SKEL_VALIDATOR_NAME_TOKENS); /// \def USD_SKEL_VALIDATOR_KEYWORD_TOKENS /// Tokens representing keywords associated with any validator in the usdSkel /// plugin. Clients can use this to inspect validators contained within a /// specific keywords, or use these to be added as keywords to any new /// validator. -TF_DECLARE_PUBLIC_TOKENS(UsdSkelValidatorKeywordTokens, USDSKEL_API, +TF_DECLARE_PUBLIC_TOKENS(UsdSkelValidatorKeywordTokens, USDSKELVALIDATORS_API, USD_SKEL_VALIDATOR_KEYWORD_TOKENS); /// \def USD_SKEL_VALIDATION_ERROR_NAME_TOKENS /// Tokens representing validation error identifier. -TF_DECLARE_PUBLIC_TOKENS(UsdSkelValidationErrorNameTokens, USDSKEL_API, +TF_DECLARE_PUBLIC_TOKENS(UsdSkelValidationErrorNameTokens, + USDSKELVALIDATORS_API, USD_SKEL_VALIDATION_ERROR_NAME_TOKENS); PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usdValidation/usdSkelValidators/validators.cpp b/pxr/usdValidation/usdSkelValidators/validators.cpp new file mode 100644 index 0000000000..972850d433 --- /dev/null +++ b/pxr/usdValidation/usdSkelValidators/validators.cpp @@ -0,0 +1,110 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +#include "pxr/base/tf/stringUtils.h" +#include "pxr/base/tf/token.h" +#include "pxr/usd/usd/prim.h" +#include "pxr/usd/usd/schemaRegistry.h" +#include "pxr/usd/usdSkel/bindingAPI.h" +#include "pxr/usdValidation/usdSkelValidators/validatorTokens.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" +#include "pxr/usdValidation/usdValidation/validator.h" + +#include +#include + +PXR_NAMESPACE_OPEN_SCOPE + +static UsdValidationErrorVector +_SkelBindingApiAppliedValidator(const UsdPrim &usdPrim) +{ + UsdValidationErrorVector errors; + + if (!usdPrim.HasAPI()) { + static const std::unordered_set skelPropertyNames + = []() { + UsdSchemaRegistry &usdSchemaRegistry + = UsdSchemaRegistry::GetInstance(); + std::unique_ptr primDef + = usdSchemaRegistry.BuildComposedPrimDefinition( + TfToken(), { UsdSkelTokens->SkelBindingAPI }); + const std::vector skelPropertyNamesVector + = primDef->GetPropertyNames(); + return std::unordered_set( + skelPropertyNamesVector.begin(), + skelPropertyNamesVector.end()); + }(); + + const std::vector primPropertyNames + = usdPrim.GetPropertyNames(); + for (const TfToken &primToken : primPropertyNames) { + if (skelPropertyNames.find(primToken) == skelPropertyNames.end()) { + continue; + } + errors.emplace_back( + UsdSkelValidationErrorNameTokens->missingSkelBindingAPI, + UsdValidationErrorType::Error, + UsdValidationErrorSites { UsdValidationErrorSite( + usdPrim.GetStage(), usdPrim.GetPath()) }, + TfStringPrintf(("Found a UsdSkelBinding property (%s), " + "but no SkelBindingAPI applied on the prim " + "<%s>."), + primToken.GetText(), + usdPrim.GetPath().GetText())); + break; + } + } + + return errors; +} + +static UsdValidationErrorVector +_SkelBindingApiValidator(const UsdPrim &usdPrim) +{ + UsdValidationErrorVector errors; + + if (!usdPrim.HasAPIInFamily(UsdSkelTokens->SkelBindingAPI)) { + return {}; + } + + if (usdPrim.GetTypeName() != UsdSkelTokens->SkelRoot) { + UsdPrim parentPrim = usdPrim.GetParent(); + while (parentPrim && !parentPrim.IsPseudoRoot()) { + if (parentPrim.GetTypeName() != UsdSkelTokens->SkelRoot) { + parentPrim = parentPrim.GetParent(); + } else { + return errors; + } + } + errors.emplace_back( + UsdSkelValidationErrorNameTokens->invalidSkelBindingAPIApply, + UsdValidationErrorType::Error, + UsdValidationErrorSites { + UsdValidationErrorSite(usdPrim.GetStage(), usdPrim.GetPath()) }, + TfStringPrintf(("UsdSkelBindingAPI applied on prim: <%s>, " + "which is not of type SkelRoot or is not " + "rooted at a prim of type SkelRoot, as " + "required by the UsdSkel schema."), + usdPrim.GetPath().GetText())); + } + return errors; +} + +TF_REGISTRY_FUNCTION(UsdValidationRegistry) +{ + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); + + registry.RegisterPluginValidator( + UsdSkelValidatorNameTokens->skelBindingApiAppliedValidator, + _SkelBindingApiAppliedValidator); + + registry.RegisterPluginValidator( + UsdSkelValidatorNameTokens->skelBindingApiValidator, + _SkelBindingApiValidator); +} + +PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usdValidation/usdUtilsValidators/CMakeLists.txt b/pxr/usdValidation/usdUtilsValidators/CMakeLists.txt new file mode 100644 index 0000000000..7fb44f7e8c --- /dev/null +++ b/pxr/usdValidation/usdUtilsValidators/CMakeLists.txt @@ -0,0 +1,49 @@ +set(PXR_PREFIX pxr/usdValidation) +set(PXR_PACKAGE usdUtilsValidators) + +pxr_library(usdUtilsValidators + LIBRARIES + tf + plug + sdf + usd + usdUtils + usdValidation + + PUBLIC_CLASSES + validatorTokens + + PUBLIC_HEADERS + api.h + + CPPFILES + validators.cpp + + RESOURCE_FILES + plugInfo.json +) + +pxr_build_test(testUsdUtilsValidators + LIBRARIES + ar + arch + tf + sdf + usd + usdValidation + usdUtils + usdUtilsValidators + CPPFILES + testenv/testUsdUtilsValidators.cpp +) + +pxr_install_test_dir( + SRC testenv/testUsdUtilsValidators + DEST testUsdUtilsValidators +) + +pxr_register_test(testUsdUtilsValidators + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdUtilsValidators" + EXPECTED_RETURN_CODE 0 +) + diff --git a/pxr/usdValidation/usdUtilsValidators/api.h b/pxr/usdValidation/usdUtilsValidators/api.h new file mode 100644 index 0000000000..16f218380a --- /dev/null +++ b/pxr/usdValidation/usdUtilsValidators/api.h @@ -0,0 +1,34 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +#ifndef PXR_USD_VALIDATION_USD_UTILS_VALIDATORS_API_H +#define PXR_USD_VALIDATION_USD_UTILS_VALIDATORS_API_H + +#include "pxr/base/arch/export.h" + +#if defined(PXR_STATIC) +# define USDUTILSVALIDATORS_API +# define USDUTILSVALIDATORS_API_TEMPLATE_CLASS(...) +# define USDUTILSVALIDATORS_API_TEMPLATE_STRUCT(...) +# define USDUTILSVALIDATORS_API_LOCAL +#else +# if defined(USDUTILSVALIDATORS_API_EXPORTS) +# define USDUTILSVALIDATORS_API ARCH_EXPORT +# define USDUTILSVALIDATORS_API_TEMPLATE_CLASS(...) \ + ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__) +# define USDUTILSVALIDATORS_API_TEMPLATE_STRUCT(...) \ + ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__) +# else +# define USDUTILSVALIDATORS_API ARCH_IMPORT +# define USDUTILSVALIDATORS_API_TEMPLATE_CLASS(...) \ + ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__) +# define USDUTILSVALIDATORS_API_TEMPLATE_STRUCT(...) \ + ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__) +# endif +# define USDUTILSVALIDATORS_API_LOCAL ARCH_HIDDEN +#endif + +#endif diff --git a/pxr/usd/usdUtils/plugInfo.json b/pxr/usdValidation/usdUtilsValidators/plugInfo.json similarity index 95% rename from pxr/usd/usdUtils/plugInfo.json rename to pxr/usdValidation/usdUtilsValidators/plugInfo.json index 1962a094a6..9a6dc55333 100644 --- a/pxr/usd/usdUtils/plugInfo.json +++ b/pxr/usdValidation/usdUtilsValidators/plugInfo.json @@ -15,7 +15,7 @@ } }, "LibraryPath": "@PLUG_INFO_LIBRARY_PATH@", - "Name": "usdUtils", + "Name": "usdUtilsValidators", "ResourcePath": "@PLUG_INFO_RESOURCE_PATH@", "Root": "@PLUG_INFO_ROOT@", "Type": "library" diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsValidators.cpp b/pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators.cpp similarity index 50% rename from pxr/usd/usdUtils/testenv/testUsdUtilsValidators.cpp rename to pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators.cpp index 165b8e917f..26c425722a 100644 --- a/pxr/usd/usdUtils/testenv/testUsdUtilsValidators.cpp +++ b/pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators.cpp @@ -5,61 +5,60 @@ // https://openusd.org/license. // -#include "pxr/usd/usd/validator.h" -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usdUtils/validatorTokens.h" -#include "pxr/usd/usd/validationRegistry.h" #include "pxr/base/arch/systemInfo.h" #include "pxr/base/tf/pathUtils.h" +#include "pxr/usdValidation/usdUtilsValidators/validatorTokens.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" +#include "pxr/usdValidation/usdValidation/validator.h" -#include #include +#include PXR_NAMESPACE_USING_DIRECTIVE TF_DEFINE_PRIVATE_TOKENS(_tokens, - ((usdUtilsPlugin, "usdUtils")) + ((usdUtilsValidatorsPlugin, "usdUtilsValidators")) ); -static -void +static void TestUsdUsdzValidators() { // This should be updated with every new validator added with // UsdUtilsValidators keyword. - UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); - UsdValidatorMetadataVector metadata = - registry.GetValidatorMetadataForPlugin(_tokens->usdUtilsPlugin); + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); + UsdValidationValidatorMetadataVector metadata + = registry.GetValidatorMetadataForPlugin( + _tokens->usdUtilsValidatorsPlugin); TF_AXIOM(metadata.size() == 1); // Since other validators can be registered with a UsdUtilsValidators // keyword, our validators registered in usd are a subset of the entire // set. std::set validatorMetadataNameSet; - for (const UsdValidatorMetadata &metadata : metadata) { + for (const UsdValidationValidatorMetadata &metadata : metadata) { validatorMetadataNameSet.insert(metadata.name); } - const std::set expectedValidatorNames = - {UsdUtilsValidatorNameTokens->packageEncapsulationValidator}; + const std::set expectedValidatorNames + = { UsdUtilsValidatorNameTokens->packageEncapsulationValidator }; TF_AXIOM(validatorMetadataNameSet == expectedValidatorNames); } -static -void +static void TestPackageEncapsulationValidator() { - UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); // Verify the validator exists - const UsdValidator *validator = registry.GetOrLoadValidatorByName( - UsdUtilsValidatorNameTokens->packageEncapsulationValidator); + const UsdValidationValidator *validator = registry.GetOrLoadValidatorByName( + UsdUtilsValidatorNameTokens->packageEncapsulationValidator); TF_AXIOM(validator); // Load the pre-created usdz stage with paths to a layer and asset // that are not included in the package, but exist - const UsdStageRefPtr& stage = UsdStage::Open("fail.usdz"); + const UsdStageRefPtr &stage = UsdStage::Open("fail.usdz"); UsdValidationErrorVector errors = validator->Validate(stage); @@ -69,34 +68,34 @@ TestPackageEncapsulationValidator() // Note that we keep the referenced layer in normalized path to represent // the layer identifier, whereas the asset path is platform specific path, // as returned by UsdUtilsComputeAllDependencies - const SdfLayerRefPtr& rootLayer = stage->GetRootLayer(); - const std::string& rootLayerIdentifier = rootLayer->GetIdentifier(); + const SdfLayerRefPtr &rootLayer = stage->GetRootLayer(); + const std::string &rootLayerIdentifier = rootLayer->GetIdentifier(); const std::string realUsdzPath = rootLayer->GetRealPath(); - const std::string errorLayer = TfStringCatPaths( - TfGetPathName(TfAbsPath(rootLayerIdentifier)), - "excludedDirectory/layer.usda"); - - std::filesystem::path parentDir = - std::filesystem::path(realUsdzPath).parent_path(); - const std::string errorAsset = - (parentDir / "excludedDirectory" / "image.jpg").string(); - - std::array expectedErrorMessages = { - TfStringPrintf(("Found referenced layer '%s' that does not " - "belong to the package '%s'."), - errorLayer.c_str(), realUsdzPath.c_str()), - TfStringPrintf(("Found asset reference '%s' that does not belong" - " to the package '%s'."), - errorAsset.c_str(), realUsdzPath.c_str()) - }; + const std::string errorLayer + = TfStringCatPaths(TfGetPathName(TfAbsPath(rootLayerIdentifier)), + "excludedDirectory/layer.usda"); + + std::filesystem::path parentDir + = std::filesystem::path(realUsdzPath).parent_path(); + const std::string errorAsset + = (parentDir / "excludedDirectory" / "image.jpg").string(); + + std::array expectedErrorMessages + = { TfStringPrintf(("Found referenced layer '%s' that does not " + "belong to the package '%s'."), + errorLayer.c_str(), realUsdzPath.c_str()), + TfStringPrintf(("Found asset reference '%s' that does not belong" + " to the package '%s'."), + errorAsset.c_str(), realUsdzPath.c_str()) }; std::array expectedErrorIdentifiers = { - TfToken("usdUtils:PackageEncapsulationValidator.LayerNotInPackage"), - TfToken("usdUtils:PackageEncapsulationValidator.AssetNotInPackage") + TfToken( + "usdUtilsValidators:PackageEncapsulationValidator.LayerNotInPackage"), + TfToken( + "usdUtilsValidators:PackageEncapsulationValidator.AssetNotInPackage") }; - for (size_t i = 0; i < errors.size(); ++i) - { + for (size_t i = 0; i < errors.size(); ++i) { TF_AXIOM(errors[i].GetIdentifier() == expectedErrorIdentifiers[i]); TF_AXIOM(errors[i].GetType() == UsdValidationErrorType::Warn); TF_AXIOM(errors[i].GetSites().size() == 1); @@ -106,8 +105,8 @@ TestPackageEncapsulationValidator() // Load the pre-created usdz stage with relative paths to both a reference // and an asset that are included in the package. - const UsdStageRefPtr& passStage = UsdStage::Open("pass.usdz"); - + const UsdStageRefPtr &passStage = UsdStage::Open("pass.usdz"); + errors = validator->Validate(passStage); // Verify the errors are gone diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsValidators/badRoot.usda b/pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/badRoot.usda similarity index 100% rename from pxr/usd/usdUtils/testenv/testUsdUtilsValidators/badRoot.usda rename to pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/badRoot.usda diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsValidators/excludedDirectory/image.jpg b/pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/excludedDirectory/image.jpg similarity index 100% rename from pxr/usd/usdUtils/testenv/testUsdUtilsValidators/excludedDirectory/image.jpg rename to pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/excludedDirectory/image.jpg diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsValidators/excludedDirectory/layer.usda b/pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/excludedDirectory/layer.usda similarity index 100% rename from pxr/usd/usdUtils/testenv/testUsdUtilsValidators/excludedDirectory/layer.usda rename to pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/excludedDirectory/layer.usda diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsValidators/fail.usdz b/pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/fail.usdz similarity index 100% rename from pxr/usd/usdUtils/testenv/testUsdUtilsValidators/fail.usdz rename to pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/fail.usdz diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsValidators/goodRoot.usda b/pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/goodRoot.usda similarity index 100% rename from pxr/usd/usdUtils/testenv/testUsdUtilsValidators/goodRoot.usda rename to pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/goodRoot.usda diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsValidators/includedDirectory/image.jpg b/pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/includedDirectory/image.jpg similarity index 100% rename from pxr/usd/usdUtils/testenv/testUsdUtilsValidators/includedDirectory/image.jpg rename to pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/includedDirectory/image.jpg diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsValidators/includedDirectory/layer.usda b/pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/includedDirectory/layer.usda similarity index 100% rename from pxr/usd/usdUtils/testenv/testUsdUtilsValidators/includedDirectory/layer.usda rename to pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/includedDirectory/layer.usda diff --git a/pxr/usd/usdUtils/testenv/testUsdUtilsValidators/pass.usdz b/pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/pass.usdz similarity index 100% rename from pxr/usd/usdUtils/testenv/testUsdUtilsValidators/pass.usdz rename to pxr/usdValidation/usdUtilsValidators/testenv/testUsdUtilsValidators/pass.usdz diff --git a/pxr/usd/usdUtils/validatorTokens.cpp b/pxr/usdValidation/usdUtilsValidators/validatorTokens.cpp similarity index 71% rename from pxr/usd/usdUtils/validatorTokens.cpp rename to pxr/usdValidation/usdUtilsValidators/validatorTokens.cpp index 655127be3a..dc82a6256a 100644 --- a/pxr/usd/usdUtils/validatorTokens.cpp +++ b/pxr/usdValidation/usdUtilsValidators/validatorTokens.cpp @@ -5,13 +5,13 @@ // https://openusd.org/license. // -#include "pxr/usd/usdUtils/validatorTokens.h" +#include "pxr/usdValidation/usdUtilsValidators/validatorTokens.h" PXR_NAMESPACE_OPEN_SCOPE -TF_DEFINE_PUBLIC_TOKENS(UsdUtilsValidatorNameTokens, +TF_DEFINE_PUBLIC_TOKENS(UsdUtilsValidatorNameTokens, USD_UTILS_VALIDATOR_NAMES_TOKENS); -TF_DEFINE_PUBLIC_TOKENS(UsdUtilsValidatorKeywordTokens, +TF_DEFINE_PUBLIC_TOKENS(UsdUtilsValidatorKeywordTokens, USD_UTILS_VALIDATOR_KEYWORD_TOKENS); TF_DEFINE_PUBLIC_TOKENS(UsdUtilsValidationErrorNameTokens, USD_UTILS_VALIDATION_ERROR_NAME_TOKENS); diff --git a/pxr/usd/usdUtils/validatorTokens.h b/pxr/usdValidation/usdUtilsValidators/validatorTokens.h similarity index 53% rename from pxr/usd/usdUtils/validatorTokens.h rename to pxr/usdValidation/usdUtilsValidators/validatorTokens.h index cc0b7ac1df..694326274d 100644 --- a/pxr/usd/usdUtils/validatorTokens.h +++ b/pxr/usdValidation/usdUtilsValidators/validatorTokens.h @@ -5,47 +5,49 @@ // https://openusd.org/license. // -#ifndef USDGEOM_VALIDATOR_TOKENS_H -#define USDGEOM_VALIDATOR_TOKENS_H +#ifndef PXR_USD_VALIDATION_USD_UTILS_VALIDATORS_TOKENS_H +#define PXR_USD_VALIDATION_USD_UTILS_VALIDATORS_TOKENS_H /// \file #include "pxr/pxr.h" -#include "pxr/usd/usdUtils/api.h" #include "pxr/base/tf/staticTokens.h" +#include "pxr/usdValidation/usdUtilsValidators/api.h" PXR_NAMESPACE_OPEN_SCOPE -#define USD_UTILS_VALIDATOR_NAME_TOKENS \ - ((packageEncapsulationValidator, "usdUtils:PackageEncapsulationValidator")) +#define USD_UTILS_VALIDATOR_NAME_TOKENS \ + ((packageEncapsulationValidator, \ + "usdUtilsValidators:PackageEncapsulationValidator")) -#define USD_UTILS_VALIDATOR_KEYWORD_TOKENS \ - (UsdUtilsValidators) \ +#define USD_UTILS_VALIDATOR_KEYWORD_TOKENS \ + (UsdUtilsValidators) \ (UsdzValidators) -#define USD_UTILS_VALIDATION_ERROR_NAME_TOKENS \ - ((layerNotInPackage, "LayerNotInPackage")) \ - ((assetNotInPackage, "AssetNotInPackage")) \ +#define USD_UTILS_VALIDATION_ERROR_NAME_TOKENS \ + ((layerNotInPackage, "LayerNotInPackage")) \ + ((assetNotInPackage, "AssetNotInPackage")) \ ((invalidLayerInPackage, "InvalidLayerInPackage")) ///\def /// Tokens representing validator names. Note that for plugin provided /// validators, the names must be prefixed by usdGeom:, which is the name of /// the usdGeom plugin. - TF_DECLARE_PUBLIC_TOKENS(UsdUtilsValidatorNameTokens, USDUTILS_API, - USD_UTILS_VALIDATOR_NAME_TOKENS); +TF_DECLARE_PUBLIC_TOKENS(UsdUtilsValidatorNameTokens, USDUTILSVALIDATORS_API, + USD_UTILS_VALIDATOR_NAME_TOKENS); ///\def /// Tokens representing keywords associated with any validator in the usdGeom /// plugin. Clients can use this to inspect validators contained within a /// specific keywords, or use these to be added as keywords to any new /// validator. - TF_DECLARE_PUBLIC_TOKENS(UsdUtilsValidatorKeywordTokens, USDUTILS_API, - USD_UTILS_VALIDATOR_KEYWORD_TOKENS); +TF_DECLARE_PUBLIC_TOKENS(UsdUtilsValidatorKeywordTokens, USDUTILSVALIDATORS_API, + USD_UTILS_VALIDATOR_KEYWORD_TOKENS); /// \def USD_UTILS_VALIDATION_ERROR_NAME_TOKENS /// Tokens representing validation error identifier. -TF_DECLARE_PUBLIC_TOKENS(UsdUtilsValidationErrorNameTokens, USDUTILS_API, +TF_DECLARE_PUBLIC_TOKENS(UsdUtilsValidationErrorNameTokens, + USDUTILSVALIDATORS_API, USD_UTILS_VALIDATION_ERROR_NAME_TOKENS); PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usd/usdUtils/validators.cpp b/pxr/usdValidation/usdUtilsValidators/validators.cpp similarity index 57% rename from pxr/usd/usdUtils/validators.cpp rename to pxr/usdValidation/usdUtilsValidators/validators.cpp index 64e4cd33c3..bd617f3533 100644 --- a/pxr/usd/usdUtils/validators.cpp +++ b/pxr/usdValidation/usdUtilsValidators/validators.cpp @@ -5,26 +5,26 @@ // https://openusd.org/license. // -#include -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usd/validationRegistry.h" -#include "pxr/usd/usdUtils/validatorTokens.h" #include "pxr/usd/ar/packageUtils.h" #include "pxr/usd/usdUtils/dependencies.h" #include "pxr/usd/usdUtils/userProcessingFunc.h" +#include "pxr/usdValidation/usdUtilsValidators/validatorTokens.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" + +#include PXR_NAMESPACE_OPEN_SCOPE -static -UsdValidationErrorVector -_PackageEncapsulationValidator(const UsdStagePtr& usdStage) { +static UsdValidationErrorVector +_PackageEncapsulationValidator(const UsdStagePtr &usdStage) +{ UsdValidationErrorVector errors; - const SdfLayerRefPtr& rootLayer = usdStage->GetRootLayer(); - const bool isPackage = [](const SdfLayerHandle& layer) - { - return layer->GetFileFormat()->IsPackage() || - ArIsPackageRelativePath(layer->GetIdentifier()); + const SdfLayerRefPtr &rootLayer = usdStage->GetRootLayer(); + const bool isPackage = [](const SdfLayerHandle &layer) { + return layer->GetFileFormat()->IsPackage() + || ArIsPackageRelativePath(layer->GetIdentifier()); }(rootLayer); if (!isPackage) { @@ -33,32 +33,31 @@ _PackageEncapsulationValidator(const UsdStagePtr& usdStage) { SdfLayerRefPtrVector layers; std::vector> assets, unresolvedPaths; - const SdfAssetPath& path = SdfAssetPath(rootLayer->GetIdentifier()); + const SdfAssetPath &path = SdfAssetPath(rootLayer->GetIdentifier()); - UsdUtilsComputeAllDependencies(path, &layers, &assets, &unresolvedPaths, + UsdUtilsComputeAllDependencies(path, &layers, &assets, &unresolvedPaths, nullptr); - const std::string& realPath = rootLayer->GetRealPath(); - const std::string& packagePath = ArIsPackageRelativePath( - rootLayer->GetIdentifier()) ? - ArSplitPackageRelativePathOuter(realPath).first : realPath; + const std::string &realPath = rootLayer->GetRealPath(); + const std::string &packagePath + = ArIsPackageRelativePath(rootLayer->GetIdentifier()) + ? ArSplitPackageRelativePathOuter(realPath).first + : realPath; if (!packagePath.empty()) { - for (const SdfLayerRefPtr& referencedLayer : layers) { + for (const SdfLayerRefPtr &referencedLayer : layers) { if (!referencedLayer) { errors.emplace_back( UsdUtilsValidationErrorNameTokens->invalidLayerInPackage, UsdValidationErrorType::Error, UsdValidationErrorSites { - UsdValidationErrorSite( - rootLayer, SdfPath()) - }, + UsdValidationErrorSite(rootLayer, SdfPath()) }, "Found invalid layer reference in package. This could be " "due to a layer that failed to load or a layer that is not " "a valid layer to be bundled in a package."); continue; } - const std::string& realPath = referencedLayer->GetRealPath(); + const std::string &realPath = referencedLayer->GetRealPath(); // We don't want to validate in-memory or session layers // since these layers will not have a real path, we skip here @@ -70,33 +69,27 @@ _PackageEncapsulationValidator(const UsdStagePtr& usdStage) { errors.emplace_back( UsdUtilsValidationErrorNameTokens->layerNotInPackage, UsdValidationErrorType::Warn, - UsdValidationErrorSites { - UsdValidationErrorSite( - rootLayer, referencedLayer->GetDefaultPrimAsPath()) - }, + UsdValidationErrorSites { UsdValidationErrorSite( + rootLayer, referencedLayer->GetDefaultPrimAsPath()) }, TfStringPrintf( ("Found referenced layer '%s' that does not belong to " - "the package '%s'."), - referencedLayer->GetIdentifier().c_str(), - packagePath.c_str()) - ); + "the package '%s'."), + referencedLayer->GetIdentifier().c_str(), + packagePath.c_str())); } } - for (const std::string& asset : assets) { + for (const std::string &asset : assets) { if (!TfStringStartsWith(asset, packagePath)) { errors.emplace_back( UsdUtilsValidationErrorNameTokens->assetNotInPackage, UsdValidationErrorType::Warn, UsdValidationErrorSites { - UsdValidationErrorSite( - rootLayer, SdfPath(asset)) - }, + UsdValidationErrorSite(rootLayer, SdfPath(asset)) }, TfStringPrintf( ("Found asset reference '%s' that does not belong to " - "the package '%s'."), asset.c_str(), - packagePath.c_str()) - ); + "the package '%s'."), + asset.c_str(), packagePath.c_str())); } } } @@ -106,10 +99,10 @@ _PackageEncapsulationValidator(const UsdStagePtr& usdStage) { TF_REGISTRY_FUNCTION(UsdValidationRegistry) { - UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); registry.RegisterPluginValidator( - UsdUtilsValidatorNameTokens->packageEncapsulationValidator, _PackageEncapsulationValidator); + UsdUtilsValidatorNameTokens->packageEncapsulationValidator, + _PackageEncapsulationValidator); } PXR_NAMESPACE_CLOSE_SCOPE - diff --git a/pxr/usdValidation/usdValidation/CMakeLists.txt b/pxr/usdValidation/usdValidation/CMakeLists.txt new file mode 100644 index 0000000000..b247ef7ef4 --- /dev/null +++ b/pxr/usdValidation/usdValidation/CMakeLists.txt @@ -0,0 +1,175 @@ +set(PXR_PREFIX pxr/usd) +set(PXR_PACKAGE usdValidation) + +pxr_library(usdValidation + LIBRARIES + sdf + plug + tf + work + ${TBB_tbb_LIBRARY} + + INCLUDE_DIRS + ${TBB_INCLUDE_DIRS} + + PUBLIC_CLASSES + context + error + registry + validator + validatorTokens + + PUBLIC_HEADERS + api.h + + CPPFILES + coreValidators.cpp + + PYTHON_CPPFILES + moduleDeps.cpp + + PYMODULE_CPPFILES + wrapContext.cpp + wrapError.cpp + wrapRegistry.cpp + wrapValidator.cpp + + PYMODULE_FILES + __init__.py + + RESOURCE_FILES + plugInfo.json +) + +pxr_test_scripts( + testenv/testUsdValidationContextPy.py + testenv/testUsdValidationError.py + testenv/testUsdValidationRegistryPy.py + testenv/testUsdValidatorMetadata.py +) + +pxr_build_test_shared_lib(TestUsdValidationContextValidators + INSTALL_PREFIX UsdValidationPlugins + LIBRARIES + tf + usd + usdValidation + + CPPFILES + testenv/testUsdValidationContextValidators.cpp +) + +pxr_build_test_shared_lib(TestUsdValidationRegistryPy + INSTALL_PREFIX UsdValidationPlugins + LIBRARIES + tf + usd + usdValidation + + CPPFILES + testenv/testUsdValidationRegistryPy.cpp +) + +pxr_build_test(testUsdCoreValidators + LIBRARIES + usd + usdValidation + + CPPFILES + testenv/testUsdCoreValidators.cpp +) + +pxr_build_test(testUsdValidator + LIBRARIES + tf + usd + usdValidation + + CPPFILES + testenv/testUsdValidator.cpp +) + +pxr_build_test(testUsdValidationContext + LIBRARIES + tf + usd + usdValidation + + CPPFILES + testenv/testUsdValidationContext.cpp +) + +pxr_build_test(testUsdValidationRegistry + LIBRARIES + tf + usd + usdValidation + + CPPFILES + testenv/testUsdValidationRegistry.cpp +) + +pxr_install_test_dir( + SRC testenv/testUsdValidationContext + DEST testUsdValidationContext +) + +pxr_install_test_dir( + SRC testenv/testUsdValidationContext + DEST testUsdValidationContextPy +) + +pxr_install_test_dir( + SRC testenv/testUsdValidationRegistry + DEST testUsdValidationRegistry +) + +pxr_register_test(testUsdCoreValidators + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdCoreValidators" + EXPECTED_RETURN_CODE 0 +) + +pxr_register_test(testUsdValidator + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidator" + EXPECTED_RETURN_CODE 0 +) + +pxr_register_test(testUsdValidationRegistry + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationRegistry" + EXPECTED_RETURN_CODE 0 +) + +#The following tests rely on plugins built specifically for them. +#The build system currently doesn't support test-specific plugins +#for static library builds, so we only enable these tests for +#shared library builds. +if (BUILD_SHARED_LIBS) + pxr_register_test(testUsdValidationContext + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationContext" + EXPECTED_RETURN_CODE 0 + ) +endif() + +pxr_register_test(testUsdValidatorMetadata + PYTHON + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidatorMetadata" + EXPECTED_RETURN_CODE 0 +) + +pxr_register_test(testUsdValidationError + PYTHON + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationError" + EXPECTED_RETURN_CODE 0 +) + +pxr_register_test(testUsdValidationContextPy + PYTHON + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationContextPy" + EXPECTED_RETURN_CODE 0 +) + +pxr_register_test(testUsdValidationRegistryPy + PYTHON + COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdValidationRegistryPy" + EXPECTED_RETURN_CODE 0 +) diff --git a/pxr/usdValidation/usdValidation/__init__.py b/pxr/usdValidation/usdValidation/__init__.py new file mode 100644 index 0000000000..648a4d6da2 --- /dev/null +++ b/pxr/usdValidation/usdValidation/__init__.py @@ -0,0 +1,9 @@ +# +# Copyright 2024 Pixar +# +# Licensed under the terms set forth in the LICENSE.txt file available at +# https://openusd.org/license. +# +from pxr import Tf +Tf.PreparePythonModule() +del Tf diff --git a/pxr/usdValidation/usdValidation/api.h b/pxr/usdValidation/usdValidation/api.h new file mode 100644 index 0000000000..09c3020b71 --- /dev/null +++ b/pxr/usdValidation/usdValidation/api.h @@ -0,0 +1,34 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +#ifndef PXR_USD_VALIDATION_USD_VALIDATION_API_H +#define PXR_USD_VALIDATION_USD_VALIDATION_API_H + +#include "pxr/base/arch/export.h" + +#if defined(PXR_STATIC) +# define USDVALIDATION_API +# define USDVALIDATION_API_TEMPLATE_CLASS(...) +# define USDVALIDATION_API_TEMPLATE_STRUCT(...) +# define USDVALIDATION_LOCAL +#else +# if defined(USDVALIDATION_EXPORTS) +# define USDVALIDATION_API ARCH_EXPORT +# define USDVALIDATION_API_TEMPLATE_CLASS(...) \ + ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__) +# define USDVALIDATION_API_TEMPLATE_STRUCT(...) \ + ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__) +# else +# define USDVALIDATION_API ARCH_IMPORT +# define USDVALIDATION_API_TEMPLATE_CLASS(...) \ + ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__) +# define USDVALIDATION_API_TEMPLATE_STRUCT(...) \ + ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__) +# endif +# define USDVALIDATION_LOCAL ARCH_HIDDEN +#endif + +#endif diff --git a/pxr/usd/usd/validationContext.cpp b/pxr/usdValidation/usdValidation/context.cpp similarity index 65% rename from pxr/usd/usd/validationContext.cpp rename to pxr/usdValidation/usdValidation/context.cpp index 0f7aba863a..6db0e3b50d 100644 --- a/pxr/usd/usd/validationContext.cpp +++ b/pxr/usdValidation/usdValidation/context.cpp @@ -5,18 +5,19 @@ // https://openusd.org/license. // +#include "pxr/usdValidation/usdValidation/context.h" + #include "pxr/base/tf/type.h" #include "pxr/base/work/dispatcher.h" #include "pxr/base/work/withScopedParallelism.h" #include "pxr/usd/usd/primFlags.h" #include "pxr/usd/usd/schemaRegistry.h" #include "pxr/usd/usd/stage.h" -#include "pxr/usd/usd/validationContext.h" -#include "pxr/usd/usd/validator.h" -#include "pxr/usd/usd/validationRegistry.h" +#include "pxr/usdValidation/usdValidation/registry.h" +#include "pxr/usdValidation/usdValidation/validator.h" -#include #include +#include PXR_NAMESPACE_OPEN_SCOPE @@ -24,42 +25,40 @@ PXR_NAMESPACE_OPEN_SCOPE // This can result in new plugins being loaded. If the validator metadata // being processed is a suite, then all validators contained in the suite // are collected. -static -void +static void _AppendValidatorsFromMetadata( - const UsdValidatorMetadataVector &metadata, - std::unordered_set *outUniqueValidators) + const UsdValidationValidatorMetadataVector &metadata, + std::unordered_set *outUniqueValidators) { - UsdValidationRegistry& validationRegistry = - UsdValidationRegistry::GetInstance(); + UsdValidationRegistry &validationRegistry + = UsdValidationRegistry::GetInstance(); - for (const UsdValidatorMetadata &m : metadata) { + for (const UsdValidationValidatorMetadata &m : metadata) { if (!m.isSuite) { - if (const UsdValidator *const validator = - validationRegistry.GetOrLoadValidatorByName(m.name)) { - outUniqueValidators->insert(validator); + if (const UsdValidationValidator *const validator + = validationRegistry.GetOrLoadValidatorByName(m.name)) { + outUniqueValidators->insert(validator); } } else { - if (const UsdValidatorSuite *const suite = - validationRegistry.GetOrLoadValidatorSuiteByName(m.name)) { - const std::vector suiteValidators = - suite->GetContainedValidators(); - outUniqueValidators->insert(suiteValidators.begin(), - suiteValidators.end()); + if (const UsdValidationValidatorSuite *const suite + = validationRegistry.GetOrLoadValidatorSuiteByName(m.name)) { + const std::vector + suiteValidators = suite->GetContainedValidators(); + outUniqueValidators->insert(suiteValidators.begin(), + suiteValidators.end()); } } } } // Helper function to collect all validators for the given schema types, -// including all ancestor types. This then calls _AppendValidatorsFromMetadata +// including all ancestor types. This then calls _AppendValidatorsFromMetadata // to collect validators for the ancestor schema types. -static -void +static void _CollectAncestorTypeValidators( - const TfTokenVector &schemaTypeNames, - std::unordered_set *outUniqueValidators) -{ + const TfTokenVector &schemaTypeNames, + std::unordered_set *outUniqueValidators) +{ std::unordered_set allTypes( schemaTypeNames.begin(), schemaTypeNames.end()); @@ -74,18 +73,17 @@ _CollectAncestorTypeValidators( allTypes.insert(TfToken(ancestorType.GetTypeName())); } } - + // Convert the set to a vector. TfTokenVector allSchemaTypes(allTypes.begin(), allTypes.end()); - UsdValidationRegistry& validationRegistry = - UsdValidationRegistry::GetInstance(); - const UsdValidatorMetadataVector ancestorsMetadata = - validationRegistry.GetValidatorMetadataForSchemaTypes(allSchemaTypes); + UsdValidationRegistry &validationRegistry + = UsdValidationRegistry::GetInstance(); + const UsdValidationValidatorMetadataVector ancestorsMetadata + = validationRegistry.GetValidatorMetadataForSchemaTypes(allSchemaTypes); _AppendValidatorsFromMetadata(ancestorsMetadata, outUniqueValidators); } -static -bool +static bool _ShouldRunSchemaTypeValidator(const UsdPrim &prim, const TfToken &schema) { // Check if the prim is of the given schema type. @@ -94,8 +92,8 @@ _ShouldRunSchemaTypeValidator(const UsdPrim &prim, const TfToken &schema) return false; } - const TfToken schemaTypeName = - UsdSchemaRegistry::GetInstance().GetSchemaTypeName(type); + const TfToken schemaTypeName + = UsdSchemaRegistry::GetInstance().GetSchemaTypeName(type); if (prim.IsA(schemaTypeName)) { return true; } @@ -107,77 +105,77 @@ _ShouldRunSchemaTypeValidator(const UsdPrim &prim, const TfToken &schema) const TfTokenVector apiSchemas = prim.GetAppliedSchemas(); // Check if the prim has the given API schema applied. - return std::find(apiSchemas.begin(), - apiSchemas.end(), - schemaTypeName) != apiSchemas.end(); + return std::find(apiSchemas.begin(), apiSchemas.end(), schemaTypeName) + != apiSchemas.end(); } -UsdValidationContext::UsdValidationContext( - const TfTokenVector &keywords, bool includeAllAncestors) +UsdValidationContext::UsdValidationContext(const TfTokenVector &keywords, + bool includeAllAncestors) { - UsdValidationRegistry& validationRegistry = - UsdValidationRegistry::GetInstance(); + UsdValidationRegistry &validationRegistry + = UsdValidationRegistry::GetInstance(); - const UsdValidatorMetadataVector validatorsMetadata = - validationRegistry.GetValidatorMetadataForKeywords(keywords); + const UsdValidationValidatorMetadataVector validatorsMetadata + = validationRegistry.GetValidatorMetadataForKeywords(keywords); _InitializeFromValidatorMetadata(validatorsMetadata, includeAllAncestors); } -UsdValidationContext::UsdValidationContext( - const PlugPluginPtrVector &plugins, bool includeAllAncestors) +UsdValidationContext::UsdValidationContext(const PlugPluginPtrVector &plugins, + bool includeAllAncestors) { - UsdValidationRegistry& validationRegistry = - UsdValidationRegistry::GetInstance(); + UsdValidationRegistry &validationRegistry + = UsdValidationRegistry::GetInstance(); const TfTokenVector pluginNames = [&plugins]() { - TfTokenVector names; - names.reserve(plugins.size()); - for (const PlugPluginPtr &plugin : plugins) { - if (plugin) { - names.emplace_back(plugin->GetName()); - } + TfTokenVector names; + names.reserve(plugins.size()); + for (const PlugPluginPtr &plugin : plugins) { + if (plugin) { + names.emplace_back(plugin->GetName()); } - return names; - }(); + } + return names; + }(); - const UsdValidatorMetadataVector validatorsMetadata = - validationRegistry.GetValidatorMetadataForPlugins(pluginNames); + const UsdValidationValidatorMetadataVector validatorsMetadata + = validationRegistry.GetValidatorMetadataForPlugins(pluginNames); _InitializeFromValidatorMetadata(validatorsMetadata, includeAllAncestors); } UsdValidationContext::UsdValidationContext( - const UsdValidatorMetadataVector &metadata, bool includeAllAncestors) + const UsdValidationValidatorMetadataVector &metadata, + bool includeAllAncestors) { _InitializeFromValidatorMetadata(metadata, includeAllAncestors); } void UsdValidationContext::_InitializeFromValidatorMetadata( - const UsdValidatorMetadataVector &metadata, bool includeAllAncestors) + const UsdValidationValidatorMetadataVector &metadata, + bool includeAllAncestors) { - std::unordered_set uniqueValidators; + std::unordered_set uniqueValidators; // collect validators from the metadata _AppendValidatorsFromMetadata(metadata, &uniqueValidators); if (includeAllAncestors) { - const TfTokenVector schemaTypesFromMetadata = - [&metadata]() -> TfTokenVector { - std::unordered_set uniqueTypes; - for (const UsdValidatorMetadata &m : metadata) { - uniqueTypes.insert(m.schemaTypes.begin(), - m.schemaTypes.end()); - } - return {uniqueTypes.begin(), uniqueTypes.end()}; - }(); + const TfTokenVector schemaTypesFromMetadata + = [&metadata]() -> TfTokenVector { + std::unordered_set uniqueTypes; + for (const UsdValidationValidatorMetadata &m : metadata) { + uniqueTypes.insert(m.schemaTypes.begin(), m.schemaTypes.end()); + } + return { uniqueTypes.begin(), uniqueTypes.end() }; + }(); - // if the collected validators have schematypes metadata, collect all + // if the collected validators have schematypes metadata, collect all // ancestor type validators for those schema types. - _CollectAncestorTypeValidators(schemaTypesFromMetadata, + _CollectAncestorTypeValidators(schemaTypesFromMetadata, &uniqueValidators); } // distribute the collected validators into different sets based on the type // of validation to be performed. - _DistributeValidators({uniqueValidators.begin(), uniqueValidators.end()}); + _DistributeValidators({ uniqueValidators.begin(), uniqueValidators.end() }); } UsdValidationContext::UsdValidationContext( @@ -192,17 +190,17 @@ UsdValidationContext::UsdValidationContext( return names; }(); - std::unordered_set uniqueValidators; + std::unordered_set uniqueValidators; // collect validators for the given schema types, including all ancestor // type validators. _CollectAncestorTypeValidators(schemaTypeNames, &uniqueValidators); // distribute the collected validators into different sets based on the type // of validation to be performed. - _DistributeValidators({uniqueValidators.begin(), uniqueValidators.end()}); + _DistributeValidators({ uniqueValidators.begin(), uniqueValidators.end() }); } UsdValidationContext::UsdValidationContext( - const std::vector &validators) + const std::vector &validators) { // distribute the given validators into different sets based on the type of // validation to be performed. @@ -210,32 +208,30 @@ UsdValidationContext::UsdValidationContext( } UsdValidationContext::UsdValidationContext( - const std::vector &suites) + const std::vector &suites) { - std::unordered_set uniqueValidators; - for (const UsdValidatorSuite *suite : suites) { + std::unordered_set uniqueValidators; + for (const UsdValidationValidatorSuite *suite : suites) { if (!suite) { continue; } - const std::vector suiteValidators = - suite->GetContainedValidators(); - uniqueValidators.insert(suiteValidators.begin(), - suiteValidators.end()); + const std::vector suiteValidators + = suite->GetContainedValidators(); + uniqueValidators.insert(suiteValidators.begin(), suiteValidators.end()); } - _DistributeValidators( - { uniqueValidators.begin(), uniqueValidators.end() }); + _DistributeValidators({ uniqueValidators.begin(), uniqueValidators.end() }); } void UsdValidationContext::_DistributeValidators( - const std::vector &validators) + const std::vector &validators) { size_t layerValidatorCount = 0; size_t stageValidatorCount = 0; size_t primValidatorCount = 0; // Count the number of validators for each type of validation. - for (const UsdValidator *validator : validators) { + for (const UsdValidationValidator *validator : validators) { if (validator->_GetValidateLayerTask()) { ++layerValidatorCount; } else if (validator->_GetValidateStageTask()) { @@ -249,7 +245,7 @@ UsdValidationContext::_DistributeValidators( _stageValidators.reserve(stageValidatorCount); _primValidators.reserve(primValidatorCount); - for (const UsdValidator *const validator : validators) { + for (const UsdValidationValidator *const validator : validators) { if (validator->_GetValidateLayerTask()) { _layerValidators.push_back(validator); } else if (validator->_GetValidateStageTask()) { @@ -258,22 +254,24 @@ UsdValidationContext::_DistributeValidators( if (validator->GetMetadata().schemaTypes.empty()) { _primValidators.push_back(validator); } else { - // Distribute schema type validators into a vector of pairs, + // Distribute schema type validators into a vector of pairs, // where the first element is the schema type and the second // element is a vector of validators for that schema type. - for (const TfToken &schemaType : + for (const TfToken &schemaType : validator->GetMetadata().schemaTypes) { - const auto it = std::find_if(_schemaTypeValidators.begin(), - _schemaTypeValidators.end(), - [&](const _SchemaTypeValidatorPair& pair) { + const auto it = std::find_if( + _schemaTypeValidators.begin(), + _schemaTypeValidators.end(), + [&](const _SchemaTypeValidatorPair &pair) { return pair.first == schemaType; }); if (it != _schemaTypeValidators.end()) { it->second.push_back(validator); } else { _schemaTypeValidators.emplace_back( - schemaType, - std::vector{validator}); + schemaType, + std::vector { + validator }); } } } @@ -309,12 +307,10 @@ UsdValidationContext::Validate(const UsdStagePtr &stage, UsdValidationErrorVector errors; std::mutex errorsMutex; - WorkWithScopedDispatcher( - [this, &stage, &errors, &errorsMutex, &predicate]( - WorkDispatcher &dispatcher) { - _ValidateStage(dispatcher, stage, &errors, &errorsMutex, - predicate); - }); + WorkWithScopedDispatcher([this, &stage, &errors, &errorsMutex, + &predicate](WorkDispatcher &dispatcher) { + _ValidateStage(dispatcher, stage, &errors, &errorsMutex, predicate); + }); return errors; } @@ -332,7 +328,7 @@ UsdValidationContext::Validate(const std::vector &prims) const WorkWithScopedDispatcher( [this, &prims, &errors, &errorsMutex](WorkDispatcher &dispatcher) { _ValidatePrims(dispatcher, prims, &errors, &errorsMutex); - }); + }); return errors; } @@ -344,15 +340,14 @@ UsdValidationContext::Validate(const UsdPrimRange &prims) const WorkWithScopedDispatcher( [this, &prims, &errors, &errorsMutex](WorkDispatcher &dispatcher) { _ValidatePrims(dispatcher, prims, &errors, &errorsMutex); - }); + }); return errors; } // Helper function to add errors to the output vector guarded by a mutex. void -_AddErrors(const UsdValidationErrorVector &errors, - UsdValidationErrorVector *outErrors, - std::mutex *errorsMutex) +_AddErrors(const UsdValidationErrorVector &errors, + UsdValidationErrorVector *outErrors, std::mutex *errorsMutex) { if (errors.empty()) { return; @@ -369,13 +364,13 @@ UsdValidationContext::_ValidateLayer(WorkDispatcher &dispatcher, { // If we reached here via Validate(const SdfLayerHandle&), then the layer // must be valid. Else if we reach here via _ValidateStage, then the layer - // should be valid as well as these are gathered using + // should be valid as well as these are gathered using // UsdStage::GetUsedLayers. if (!TF_VERIFY(layer)) { return; } - for (const UsdValidator *validator : _layerValidators) { + for (const UsdValidationValidator *validator : _layerValidators) { dispatcher.Run([validator, layer, errors, errorsMutex]() { _AddErrors(validator->Validate(layer), errors, errorsMutex); }); @@ -384,8 +379,8 @@ UsdValidationContext::_ValidateLayer(WorkDispatcher &dispatcher, void UsdValidationContext::_ValidateStage( - WorkDispatcher &dispatcher, const UsdStagePtr &stage, - UsdValidationErrorVector *errors, std::mutex *errorsMutex, + WorkDispatcher &dispatcher, const UsdStagePtr &stage, + UsdValidationErrorVector *errors, std::mutex *errorsMutex, const Usd_PrimFlagsPredicate &predicate) const { // If we reached here via Validate(const UsdStagePtr&), then the stage @@ -397,8 +392,8 @@ UsdValidationContext::_ValidateStage( for (const SdfLayerHandle &layer : stage->GetUsedLayers()) { _ValidateLayer(dispatcher, layer, errors, errorsMutex); } - - for (const UsdValidator *validator : _stageValidators) { + + for (const UsdValidationValidator *validator : _stageValidators) { dispatcher.Run([validator, stage, errors, errorsMutex]() { _AddErrors(validator->Validate(stage), errors, errorsMutex); }); @@ -407,13 +402,12 @@ UsdValidationContext::_ValidateStage( } template -void -UsdValidationContext::_ValidatePrims(WorkDispatcher &dispatcher, - const T &prims, +void +UsdValidationContext::_ValidatePrims(WorkDispatcher &dispatcher, const T &prims, UsdValidationErrorVector *errors, std::mutex *errorsMutex) const { - for (const UsdValidator *validator : _primValidators) { + for (const UsdValidationValidator *validator : _primValidators) { for (const UsdPrim &prim : prims) { if (!prim) { TF_CODING_ERROR("Invalid prim found in the vector of prims to " @@ -434,9 +428,9 @@ UsdValidationContext::_ValidatePrims(WorkDispatcher &dispatcher, return; } if (_ShouldRunSchemaTypeValidator(prim, pair.first)) { - for (const UsdValidator *validator : pair.second) { + for (const UsdValidationValidator *validator : pair.second) { dispatcher.Run([validator, prim, errors, errorsMutex]() { - _AddErrors(validator->Validate(prim), errors, + _AddErrors(validator->Validate(prim), errors, errorsMutex); }); } @@ -447,15 +441,11 @@ UsdValidationContext::_ValidatePrims(WorkDispatcher &dispatcher, // Explicit instantiations for the required types: UsdPrimRange and vector of // Prims -template -void -UsdValidationContext::_ValidatePrims( - WorkDispatcher &dispatcher, const UsdPrimRange &prims, +template void UsdValidationContext::_ValidatePrims( + WorkDispatcher &dispatcher, const UsdPrimRange &prims, UsdValidationErrorVector *errors, std::mutex *errorsMutex) const; -template -void -UsdValidationContext::_ValidatePrims>( +template void UsdValidationContext::_ValidatePrims>( WorkDispatcher &dispatcher, const std::vector &prims, UsdValidationErrorVector *errors, std::mutex *errorsMutex) const; diff --git a/pxr/usd/usd/validationContext.h b/pxr/usdValidation/usdValidation/context.h similarity index 78% rename from pxr/usd/usd/validationContext.h rename to pxr/usdValidation/usdValidation/context.h index 46ca8bce06..baaa3ef37e 100644 --- a/pxr/usd/usd/validationContext.h +++ b/pxr/usdValidation/usdValidation/context.h @@ -4,20 +4,19 @@ // Licensed under the terms set forth in the LICENSE.txt file available at // https://openusd.org/license. // -#ifndef PXR_USD_USD_VALIDATION_CONTEXT_H -#define PXR_USD_USD_VALIDATION_CONTEXT_H +#ifndef PXR_USD_VALIDATION_USD_VALIDATION_CONTEXT_H +#define PXR_USD_VALIDATION_USD_VALIDATION_CONTEXT_H /// \file #include "pxr/pxr.h" -#include "pxr/usd/usd/api.h" - #include "pxr/base/plug/plugin.h" #include "pxr/base/tf/stringUtils.h" #include "pxr/base/tf/token.h" #include "pxr/usd/usd/primRange.h" -#include "pxr/usd/usd/validator.h" -#include "pxr/usd/usd/validationError.h" +#include "pxr/usdValidation/usdValidation/api.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/validator.h" #include @@ -33,14 +32,14 @@ class Usd_PrimFlagsPredicate; /// validators on USD layers, stages, or prims. /// /// The UsdValidationContext can be constructed using various methods to select -/// validators by keywords, schema types, plugins, or pre-selected sets of +/// validators by keywords, schema types, plugins, or pre-selected sets of /// validatorMetadata or validators. /// -/// Pre-selected set of UsdValidatorMetadata or UsdValidators can be gathered -/// using various UsdValidationRegistry APIs. For example, a client can -/// construct a validation context by providing validator metadata for all -/// usdGeom plugin validators but excluding all validators metadata belonging -/// to a specific schemaType like UsdGeomPoints. +/// Pre-selected set of UsdValidationValidatorMetadata or +/// UsdValidationValidators can be gathered using various UsdValidationRegistry +/// APIs. For example, a client can construct a validation context by providing +/// validator metadata for all usdGeom plugin validators but excluding all +/// validators metadata belonging to a specific schemaType like UsdGeomPoints. /// /// When schema type validators are provided, an appropriate hierarchy of schema /// validators are included in the selected list of validators. For example, @@ -49,19 +48,19 @@ class Usd_PrimFlagsPredicate; /// /// Clients can also provide \p includeAllAncestors flag (defaults to true) to /// also select validators from all ancestor TfType for any selected schemaType -/// validator when initializing a UsdValidationContext using \p keywords and +/// validator when initializing a UsdValidationContext using \p keywords and /// of the provided schemaType(s) validators.\p metadata constructors. /// /// Once a context is created and the list of validators to be run is populated, -/// clients can simply run the validators on a layer, stage or a set of prims. -/// All validators with UsdValidateLayerTaskFn, UsdValidateStageTaskFn or -/// UsdValidatePrimTaskFn will be run in a parallel and UsdValidationError will +/// clients can simply run the validators on a layer, stage or a set of prims. +/// All validators with UsdValidateLayerTaskFn, UsdValidateStageTaskFn or +/// UsdValidatePrimTaskFn will be run in a parallel and UsdValidationError will /// be collected for each validator. /// -/// Note that initializing a UsdValidationContext can result in loading new +/// Note that initializing a UsdValidationContext can result in loading new /// plugins, if the validators are not already loaded. /// -/// UsdValidationContext::Validate() call could initiate a stage traversal, and +/// UsdValidationContext::Validate() call could initiate a stage traversal, and /// appropriately call various validation tasks on the validators. /// /// UsdValidationContext does not hold any state about the validation errors @@ -69,27 +68,27 @@ class Usd_PrimFlagsPredicate; /// UsdValidationError when Validate() is called. /// /// \sa UsdValidationRegistry -/// \sa UsdValidator +/// \sa UsdValidationValidator /// \sa UsdValidationError /// class UsdValidationContext { public: - /// Create a UsdValidationContext by collecting validators using the - /// specified keywords. + /// Create a UsdValidationContext by collecting validators using the + /// specified keywords. /// /// \param keywords /// A vector of keywords to select validators from. All validators having /// these keywords will get loaded and included in the selected group of - /// validators to be run for validation. It will also collect validators - /// from a UsdValidatorSuite if the suite also contains the specified - /// keywords. + /// validators to be run for validation. It will also collect validators + /// from a UsdValidationValidatorSuite if the suite also contains the + /// specified keywords. /// /// \param includeAllAncestors - /// An optional parameter to include all validators from ancestor TfTypes + /// An optional parameter to include all validators from ancestor TfTypes /// for any schema type validators found, default is `true`. - USD_API - explicit UsdValidationContext(const TfTokenVector &keywords, + USDVALIDATION_API + explicit UsdValidationContext(const TfTokenVector &keywords, bool includeAllAncestors = true); /// Create a UsdValidationContext by collecting validators using the @@ -99,14 +98,14 @@ class UsdValidationContext /// A vector of plugins to select validators from. All validators belonging /// to the specified plugins will get loaded and included in the selected /// group of validators to be run for validation. It will also collect - /// validators from a UsdValidatorSuite if the suite belongs to the - /// specified plugins + /// validators from a UsdValidationValidatorSuite if the suite belongs to + /// the specified plugins /// /// \param includeAllAncestors /// An optional parameter to include all validators from ancestor TfTypes /// for any schema type validators found, default is `true`. - USD_API - explicit UsdValidationContext(const PlugPluginPtrVector &plugins, + USDVALIDATION_API + explicit UsdValidationContext(const PlugPluginPtrVector &plugins, bool includeAllAncestors = true); /// Create a UsdValidationContext by collecting validators using the @@ -116,14 +115,16 @@ class UsdValidationContext /// A vector of validator metadata. All validators corresponding to the /// metadata will get loaded and included in the selected group of /// validators to be run for validation. It will also collect validators - /// from a UsdValidatorSuite if a metadata has isSuite set to true. + /// from a UsdValidationValidatorSuite if a metadata has isSuite set to + /// true. /// /// \param includeAllAncestors /// An optional parameter to include all validators from ancestor TfTypes /// for any schema type validators found, default is `true`. - USD_API - explicit UsdValidationContext(const UsdValidatorMetadataVector &metadata, - bool includeAllAncestors = true); + USDVALIDATION_API + explicit UsdValidationContext( + const UsdValidationValidatorMetadataVector &metadata, + bool includeAllAncestors = true); /// Create a UsdValidationContext by collecting validators using the /// specified schema types. @@ -135,35 +136,35 @@ class UsdValidationContext /// /// Note that all validators corresponding to the ancestor TfTypes for the /// provided schemaTypes are included in the selected group of validators. - USD_API + USDVALIDATION_API explicit UsdValidationContext(const std::vector &schemaTypes); - /// Create a UsdValidationContext by collecting validators using the - /// specified vector of validators. + /// Create a UsdValidationContext by collecting validators using the + /// specified vector of validators. /// /// \param validators /// A vector of explicit validators. - USD_API + USDVALIDATION_API explicit UsdValidationContext( - const std::vector &validators); + const std::vector &validators); - /// Create a UsdValidationContext by collecting validators from the - /// specified vector of validator suites. + /// Create a UsdValidationContext by collecting validators from the + /// specified vector of validator suites. /// /// \param suites /// A vector of validator suites. - USD_API + USDVALIDATION_API explicit UsdValidationContext( - const std::vector &suites); + const std::vector &suites); - /// Run validation on the given valid \p layer by executing the selected + /// Run validation on the given valid \p layer by executing the selected /// validators for this UsdValidationContext; Returns a vector of errors /// collected during validation. /// /// Only layer validators in the selected group of validators will be run on - /// the given layer. + /// the given layer. /// - /// All the validators run in parallel. Any resulting errors are collected + /// All the validators run in parallel. Any resulting errors are collected /// in the returned vector. /// /// Note that it's the responsibility of the caller to maintain the lifetime @@ -172,10 +173,10 @@ class UsdValidationContext /// and hence are valid only as long as the layer is valid. /// /// A coding error is issued if the layer being validated is not valid. - USD_API + USDVALIDATION_API UsdValidationErrorVector Validate(const SdfLayerHandle &layer) const; - /// Run validation on the given valid \p stage by executing the selected + /// Run validation on the given valid \p stage by executing the selected /// validators for this UsdValidationContext; Returns a vector of errors /// /// Any Layer validators in the selected group of validators will be run on @@ -193,23 +194,23 @@ class UsdValidationContext /// and hence are valid only as long as the stage is valid. /// /// A coding error is issued if the stage being validated is not valid. - USD_API - UsdValidationErrorVector Validate( - const UsdStageWeakPtr &stage, - const Usd_PrimFlagsPredicate &predicate) const; + USDVALIDATION_API + UsdValidationErrorVector + Validate(const UsdStageWeakPtr &stage, + const Usd_PrimFlagsPredicate &predicate) const; /// Run validation on the given valid \p stage by executing the selected /// validators for this UsdValidationContext; Returns a vector of errors /// - /// \ref UsdTraverseInstanceProxies "Instance Proxy predicate" is used to + /// \ref UsdTraverseInstanceProxies "Instance Proxy predicate" is used to /// traverse the prims to be validated in this overload. /// - /// \sa UsdValidationContext::Validate(const UsdStageWeakPtr &stage, + /// \sa UsdValidationContext::Validate(const UsdStageWeakPtr &stage, /// const Usd_PrimFlagsPredicate &predicate) const - USD_API + USDVALIDATION_API UsdValidationErrorVector Validate(const UsdStagePtr &stage) const; - /// Run validation on the given valid \p prims by executing the selected + /// Run validation on the given valid \p prims by executing the selected /// validators for this UsdValidationContext; Returns a vector of errors /// collected during validation. /// @@ -222,12 +223,12 @@ class UsdValidationContext /// of the stage that the prims belong to, during the lifetime of the /// this validation context. /// - /// A coding error is issued if any of the prims being validated are + /// A coding error is issued if any of the prims being validated are /// invalid. - USD_API + USDVALIDATION_API UsdValidationErrorVector Validate(const std::vector &prims) const; - /// Run validation on the given valid \p prims by executing the selected + /// Run validation on the given valid \p prims by executing the selected /// validators for this UsdValidationContext; Returns a vector of errors /// collected during validation. /// @@ -240,32 +241,31 @@ class UsdValidationContext /// All the validators run in parallel. Any resulting errors are collected /// in the returned vector. /// - /// A coding error is issued if any of the prims being validated are + /// A coding error is issued if any of the prims being validated are /// invalid. - USD_API + USDVALIDATION_API UsdValidationErrorVector Validate(const UsdPrimRange &prims) const; private: - // helper to initialize UsdValidationContext, given a vector of metadata + // helper to initialize UsdValidationContext, given a vector of metadata // and a flag to include all ancestors. void _InitializeFromValidatorMetadata( - const UsdValidatorMetadataVector &metadata, bool includeAllAncestors); + const UsdValidationValidatorMetadataVector &metadata, + bool includeAllAncestors); // Distribute the validators into different groups based on the type of // validation to be performed. This method distributes the selected // validators into _layerValidators, _stageValidators, _primValidators and // _schemaTypeValidators. void _DistributeValidators( - const std::vector &validators); + const std::vector &validators); // Private helper functions to validate layers, stages and prims. - void _ValidateLayer(WorkDispatcher &dispatcher, - const SdfLayerHandle &layer, + void _ValidateLayer(WorkDispatcher &dispatcher, const SdfLayerHandle &layer, UsdValidationErrorVector *errors, std::mutex *errorsMutex) const; - void _ValidateStage(WorkDispatcher &dispatcher, - const UsdStagePtr &stage, + void _ValidateStage(WorkDispatcher &dispatcher, const UsdStagePtr &stage, UsdValidationErrorVector *errors, std::mutex *errorsMutex, const Usd_PrimFlagsPredicate &predicate) const; @@ -273,24 +273,23 @@ class UsdValidationContext // Helper function to validate prims. Generalized for UsdPrimRange and // vector of UsdPrims. template - void _ValidatePrims(WorkDispatcher &dispatcher, - const T &prims, + void _ValidatePrims(WorkDispatcher &dispatcher, const T &prims, UsdValidationErrorVector *errors, std::mutex *errorsMutex) const; - // Validators catering to a specific schemaType - using _SchemaTypeValidatorPair = - std::pair>; - using _SchemaTypeValidatorPairVector = - std::vector<_SchemaTypeValidatorPair>; + // Validators catering to a specific schemaType + using _SchemaTypeValidatorPair + = std::pair>; + using _SchemaTypeValidatorPairVector + = std::vector<_SchemaTypeValidatorPair>; // Vectors of selected sets of validators, which will be run for this // UsdValidationContext. Validation tasks will be enqueued for each of these // validators on a given layer / stage or prims (traversed or explicitly // specified). - std::vector _layerValidators; - std::vector _stageValidators; - std::vector _primValidators; + std::vector _layerValidators; + std::vector _stageValidators; + std::vector _primValidators; // validators here will be used to validate prims based on their schema // types, such that: @@ -305,4 +304,4 @@ class UsdValidationContext PXR_NAMESPACE_CLOSE_SCOPE -#endif // PXR_USD_USD_VALIDATION_CONTEXT_H +#endif // PXR_USD_VALIDATION_USD_VALIDATION_CONTEXT_H diff --git a/pxr/usd/usd/coreValidators.cpp b/pxr/usdValidation/usdValidation/coreValidators.cpp similarity index 62% rename from pxr/usd/usd/coreValidators.cpp rename to pxr/usdValidation/usdValidation/coreValidators.cpp index cd44220913..685d822352 100644 --- a/pxr/usd/usd/coreValidators.cpp +++ b/pxr/usdValidation/usdValidation/coreValidators.cpp @@ -5,34 +5,30 @@ // https://openusd.org/license. // -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usd/validationRegistry.h" -#include "pxr/usd/usd/validatorTokens.h" -#include "pxr/usd/usd/validator.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" +#include "pxr/usdValidation/usdValidation/validator.h" +#include "pxr/usdValidation/usdValidation/validatorTokens.h" PXR_NAMESPACE_OPEN_SCOPE -static -UsdValidationErrorVector +static UsdValidationErrorVector _GetCompositionErrors(const UsdStagePtr &usdStage) { UsdValidationErrorVector errors; const PcpErrorVector pcpErrors = usdStage->GetCompositionErrors(); errors.reserve(pcpErrors.size()); for (const PcpErrorBasePtr &pcpError : pcpErrors) { - UsdValidationErrorSites errorSites = { - UsdValidationErrorSite(usdStage, pcpError->rootSite.path)}; - errors.emplace_back( - UsdValidationErrorNameTokens->compositionError, - UsdValidationErrorType::Error, - std::move(errorSites), - pcpError->ToString()); + UsdValidationErrorSites errorSites + = { UsdValidationErrorSite(usdStage, pcpError->rootSite.path) }; + errors.emplace_back(UsdValidationErrorNameTokens->compositionError, + UsdValidationErrorType::Error, + std::move(errorSites), pcpError->ToString()); } return errors; } -static -UsdValidationErrorVector +static UsdValidationErrorVector _GetStageMetadataErrors(const UsdStagePtr &usdStage) { UsdValidationErrorVector errors; @@ -40,10 +36,10 @@ _GetStageMetadataErrors(const UsdStagePtr &usdStage) errors.emplace_back( UsdValidationErrorNameTokens->missingDefaultPrim, UsdValidationErrorType::Error, - UsdValidationErrorSites{UsdValidationErrorSite( - usdStage, SdfPath::AbsoluteRootPath())}, + UsdValidationErrorSites { + UsdValidationErrorSite(usdStage, SdfPath::AbsoluteRootPath()) }, TfStringPrintf("Stage with root layer <%s> has an invalid or " - "missing defaultPrim.", + "missing defaultPrim.", usdStage->GetRootLayer()->GetIdentifier().c_str())); } diff --git a/pxr/usdValidation/usdValidation/error.cpp b/pxr/usdValidation/usdValidation/error.cpp new file mode 100644 index 0000000000..ad3e025abd --- /dev/null +++ b/pxr/usdValidation/usdValidation/error.cpp @@ -0,0 +1,106 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// + +#include "pxr/usdValidation/usdValidation/error.h" + +#include "pxr/base/tf/enum.h" +#include "pxr/usdValidation/usdValidation/validator.h" + +PXR_NAMESPACE_OPEN_SCOPE + +TF_DEFINE_PRIVATE_TOKENS(_tokens, ((ValidationErrorNameDelimiter, "."))); + +TF_REGISTRY_FUNCTION(TfEnum) +{ + TF_ADD_ENUM_NAME(UsdValidationErrorType::None, "None"); + TF_ADD_ENUM_NAME(UsdValidationErrorType::Error, "Error"); + TF_ADD_ENUM_NAME(UsdValidationErrorType::Warn, "Warn"); + TF_ADD_ENUM_NAME(UsdValidationErrorType::Info, "Info"); +} + +UsdValidationErrorSite::UsdValidationErrorSite(const SdfLayerHandle &layer, + const SdfPath &objectPath) + : _layer(layer) + , _objectPath(objectPath) +{ +} + +UsdValidationErrorSite::UsdValidationErrorSite(const UsdStagePtr &usdStage, + const SdfPath &objectPath, + const SdfLayerHandle &layer) + : _usdStage(usdStage) + , _layer(layer) + , _objectPath(objectPath) +{ +} + +UsdValidationError::UsdValidationError() + : _errorType(UsdValidationErrorType::None) +{ + _validator = nullptr; +} + +UsdValidationError::UsdValidationError( + const TfToken &name, const UsdValidationErrorType &type, + const UsdValidationErrorSites &errorSites, const std::string &errorMsg) + : _name(name) + , _errorType(type) + , _errorSites(errorSites) + , _errorMsg(errorMsg) +{ + _validator = nullptr; +} + +TfToken +UsdValidationError::GetIdentifier() const +{ + // A validation error is created via a call to + // UsdValidationValidator::Validate(), which should have set a validator on + // the error. But if a ValidationError is created directly (not + // recommended), it will not have a validator set, this is improper use of + // the API, hence we throw a coding error here. + if (!_validator) { + TF_CODING_ERROR("Validator not set on ValidationError. Possibly this " + "validation error was not created via a call to " + "UsdValidationValidator::Validate(), which is " + "responsible to set the validator on the error."); + return TfToken(); + } + // If the name is empty, return the validator's name. + if (_name.IsEmpty()) { + return _validator->GetMetadata().name; + } + return TfToken(_validator->GetMetadata().name.GetString() + + _tokens->ValidationErrorNameDelimiter.GetString() + + _name.GetString()); +} + +std::string +UsdValidationError::GetErrorAsString() const +{ + if (_validator) { + return _errorType == UsdValidationErrorType::None + ? _errorMsg + : TfStringPrintf( + "%s: (%s) %s", TfEnum::GetDisplayName(_errorType).c_str(), + GetIdentifier().GetString().c_str(), _errorMsg.c_str()); + } else { + return _errorType == UsdValidationErrorType::None + ? _errorMsg + : TfStringPrintf("%s: %s", + TfEnum::GetDisplayName(_errorType).c_str(), + _errorMsg.c_str()); + } +} + +void +UsdValidationError::_SetValidator(const UsdValidationValidator *validator) +{ + _validator = validator; +} + +PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usd/usd/validationError.h b/pxr/usdValidation/usdValidation/error.h similarity index 73% rename from pxr/usd/usd/validationError.h rename to pxr/usdValidation/usdValidation/error.h index ec41e9e351..de16115981 100644 --- a/pxr/usd/usd/validationError.h +++ b/pxr/usdValidation/usdValidation/error.h @@ -5,20 +5,21 @@ // https://openusd.org/license. // -#ifndef PXR_USD_USD_VALIDATION_ERROR_H -#define PXR_USD_USD_VALIDATION_ERROR_H +#ifndef PXR_USD_VALIDATION_USD_VALIDATION_ERROR_H +#define PXR_USD_VALIDATION_USD_VALIDATION_ERROR_H #include "pxr/pxr.h" #include "pxr/usd/sdf/path.h" -#include "pxr/usd/usd/stage.h" #include "pxr/usd/usd/property.h" +#include "pxr/usd/usd/stage.h" +#include "pxr/usdValidation/usdValidation/api.h" #include PXR_NAMESPACE_OPEN_SCOPE class UsdPrim; -class UsdValidator; +class UsdValidationValidator; /// \class UsdValidationErrorType /// @@ -32,7 +33,8 @@ class UsdValidator; /// hence reported as warning by the validation task. /// Info: Associates the UsdValidationErrorType with information which needs to /// be reported to the users by the validation task. -enum class UsdValidationErrorType { +enum class UsdValidationErrorType +{ None = 0, Error, Warn, @@ -43,10 +45,10 @@ enum class UsdValidationErrorType { /// /// UsdValidationErrorSite is important information available from a /// ValidationError, which annotates the site where the Error was reported by a -/// validation task. +/// validation task. /// -/// An Error could be reported in a SdfLayer (in layer metadata, for example), -/// or a UsdStage (in stage metadata, for example) or a Prim within a stage, or +/// An Error could be reported in a SdfLayer (in layer metadata, for example), +/// or a UsdStage (in stage metadata, for example) or a Prim within a stage, or /// a property of a prim. struct UsdValidationErrorSite { @@ -57,12 +59,12 @@ struct UsdValidationErrorSite /// \p objectPath. /// /// Object Path here could be a prim or a property spec path. - /// + /// /// Note that to identify a layer metadata, objectPath can be set as the /// pseudoRoot. - USD_API + USDVALIDATION_API UsdValidationErrorSite(const SdfLayerHandle &layer, - const SdfPath &objectPath); + const SdfPath &objectPath); /// Initialize an UsdValidationErrorSite using a \p usdStage and an \p /// objectPath. @@ -74,21 +76,21 @@ struct UsdValidationErrorSite /// Object Path here could be a prim path or a property path. /// Note that to identify stage's root layer metadata, objectPath can be set /// as the pseudoRoot. - USD_API - UsdValidationErrorSite(const UsdStagePtr &usdStage, + USDVALIDATION_API + UsdValidationErrorSite(const UsdStagePtr &usdStage, const SdfPath &objectPath, - const SdfLayerHandle &layer=SdfLayerHandle()); + const SdfLayerHandle &layer = SdfLayerHandle()); /// Returns true if UsdValidationErrorSite instance can either point to a /// prim or property spec in a layer or a prim or property on a stage. - bool IsValid() const + bool IsValid() const { return IsValidSpecInLayer() || IsPrim() || IsProperty(); } /// Returns true if the objectPath and layer represent a spec in the layer; /// false otherwise. - bool IsValidSpecInLayer() const + bool IsValidSpecInLayer() const { if (!_layer || _objectPath.IsEmpty()) { return false; @@ -127,7 +129,7 @@ struct UsdValidationErrorSite /// Returns the SdfPrimSpecHandle associated with this ValidationErrorSite's /// layer and objectPath. /// - /// Returns an invalid SdfPrimSpecHandle if no valid prim spec is found, or + /// Returns an invalid SdfPrimSpecHandle if no valid prim spec is found, or /// when UsdValidationErrorSite instance doesn't have a layer. const SdfPrimSpecHandle GetPrimSpec() const { @@ -137,15 +139,16 @@ struct UsdValidationErrorSite return _layer->GetPrimAtPath(_objectPath); } - /// Returns the SdfLayerHandle associated with this UsdValidatorErrorSite - const SdfLayerHandle& GetLayer() const + /// Returns the SdfLayerHandle associated with this + /// UsdValidationValidatorErrorSite + const SdfLayerHandle &GetLayer() const { return _layer; } /// Returns the UsdStage associated with this UsdValidationErrorSite; /// nullptr othewrise. - const UsdStagePtr& GetStage() const + const UsdStagePtr &GetStage() const { return _usdStage; } @@ -174,15 +177,16 @@ struct UsdValidationErrorSite /// Returns true if \p other UsdValidationErrorSite has same valued members /// as this UsdValidationErrorSite, false otherwise. - bool operator==(const UsdValidationErrorSite& other) const { - return (_layer == other._layer) && - (_usdStage == other._usdStage) && - (_objectPath == other._objectPath); + bool operator==(const UsdValidationErrorSite &other) const + { + return (_layer == other._layer) && (_usdStage == other._usdStage) + && (_objectPath == other._objectPath); } /// Returns false if \p other UsdValidationErrorSite has same valued members /// as this UsdValidationErrorSite, true otherwise. - bool operator!=(const UsdValidationErrorSite& other) const { + bool operator!=(const UsdValidationErrorSite &other) const + { return !(*this == other); } @@ -198,53 +202,55 @@ using UsdValidationErrorSites = std::vector; /// \class UsdValidationError /// /// UsdValidationError is an entity returned by a validation task, which is -/// associated with a UsdValidator. +/// associated with a UsdValidationValidator. /// /// A UsdValidationError instance contains important information, like: /// /// - Name - A name the validator writer provided for the error. This is then -/// used to construct an identifier for the error. +/// used to construct an identifier for the error. /// -/// - UsdValidationErrorType - severity of an error, +/// - UsdValidationErrorType - severity of an error, /// -/// - UsdValidationErrorSites - on what sites validationError was reported by a -/// validation task, +/// - UsdValidationErrorSites - on what sites validationError was reported by a +/// validation task, /// /// - Message - Message providing more information associated with the error. /// Such a message is provided by the validator writer, when providing /// implementation for the validation task function. -/// +/// /// UsdValidationError instances will be stored in the UsdValidationContext -/// responsible for executing a set of UsdValidators. +/// responsible for executing a set of UsdValidationValidators. /// -class UsdValidationError { +class UsdValidationError +{ public: /// A default constructed UsdValidationError signifies no error. - USD_API + USDVALIDATION_API UsdValidationError(); - /// Instantiate a ValidationError by providing its \p name, \p errorType, + /// Instantiate a ValidationError by providing its \p name, \p errorType, /// \p errorSites and an \p errorMsg. - USD_API + USDVALIDATION_API UsdValidationError(const TfToken &name, - const UsdValidationErrorType &errorType, - const UsdValidationErrorSites &errorSites, + const UsdValidationErrorType &errorType, + const UsdValidationErrorSites &errorSites, const std::string &errorMsg); - bool operator==(const UsdValidationError& other) const { - return (_name == other._name) && - (_errorType == other._errorType) && - (_errorSites == other._errorSites) && - (_errorMsg == other._errorMsg) && - (_validator == other._validator); + bool operator==(const UsdValidationError &other) const + { + return (_name == other._name) && (_errorType == other._errorType) + && (_errorSites == other._errorSites) + && (_errorMsg == other._errorMsg) + && (_validator == other._validator); } - bool operator!=(const UsdValidationError& other) const { + bool operator!=(const UsdValidationError &other) const + { return !(*this == other); } /// Returns the name token of the UsdValidationError - const TfToken& GetName() const & + const TfToken &GetName() const & { return _name; } @@ -254,7 +260,7 @@ class UsdValidationError { { return std::move(_name); } - + /// Returns the UsdValidationErrorType associated with this /// UsdValidationError UsdValidationErrorType GetType() const @@ -264,7 +270,7 @@ class UsdValidationError { /// Returns the UsdValidationErrorSite associated with this /// UsdValidationError - const UsdValidationErrorSites& GetSites() const & + const UsdValidationErrorSites &GetSites() const & { return _errorSites; } @@ -276,18 +282,18 @@ class UsdValidationError { return std::move(_errorSites); } - /// Returns the UsdValidator that reported this error. + /// Returns the UsdValidationValidator that reported this error. /// - /// This will return nullptr if there is no UsdValidator associated with - /// this error. This will never be nullptr for validation errors returned - /// from calls to UsdValidator::Validate. - const UsdValidator* GetValidator() const + /// This will return nullptr if there is no UsdValidationValidator + /// associated with this error. This will never be nullptr for validation + /// errors returned from calls to UsdValidationValidator::Validate. + const UsdValidationValidator *GetValidator() const { return _validator; } /// Returns the message associated with this UsdValidationError - const std::string& GetMessage() const + const std::string &GetMessage() const { return _errorMsg; } @@ -304,34 +310,36 @@ class UsdValidationError { /// For an error that was generated without a name, the identifier will be /// same as the validator name which generated the error. /// - /// For an error which is created directly and not via - /// UsdValidator::Validate() call, we throw a coding error, as its an - /// improper use of the API. - USD_API + /// For an error which is created directly and not via + /// UsdValidationValidator::Validate() call, we throw a coding error, as its + /// an improper use of the API. + USDVALIDATION_API TfToken GetIdentifier() const; /// Returns UsdValidationErrorType and ErrorMessage concatenated as a string - USD_API + USDVALIDATION_API std::string GetErrorAsString() const; /// Returns true if UsdValidationErrorType is UsdValidationErrorType::None, /// false otherwise - bool HasNoError() const { - return _errorType == UsdValidationErrorType::None; + bool HasNoError() const + { + return _errorType == UsdValidationErrorType::None; } private: - // UsdValidatorError holds a pointer to the UsdValidator that generated it, so - // we need to provide friend access to allow the necessary mutation. - friend class UsdValidator; + // UsdValidationValidatorError holds a pointer to the UsdValidationValidator + // that generated it, so we need to provide friend access to allow the + // necessary mutation. + friend class UsdValidationValidator; - // Used by UsdValidator::Validate methods to embed itself to the reported - // errors. - void _SetValidator(const UsdValidator *validator); + // Used by UsdValidationValidator::Validate methods to embed itself to the + // reported errors. + void _SetValidator(const UsdValidationValidator *validator); - // _validator is set when ValidationError is generated via a - // UsdValidator::Validate() call. - const UsdValidator *_validator; + // _validator is set when ValidationError is generated via a + // UsdValidationValidator::Validate() call. + const UsdValidationValidator *_validator; // These data members should not be modified other than during // initialization by the validate task functions. @@ -343,9 +351,9 @@ class UsdValidationError { // TODO:(Subsequent iterations) // - VtValue of a random value the error wants to propagate down to the // fixer - + }; // UsdValidationError PXR_NAMESPACE_CLOSE_SCOPE -#endif // PXR_USD_USD_VALIDATION_ERROR_H +#endif // PXR_USD_VALIDATION_USD_VALIDATION_ERROR_H diff --git a/pxr/usdValidation/usdValidation/module.cpp b/pxr/usdValidation/usdValidation/module.cpp new file mode 100644 index 0000000000..1eafd2795b --- /dev/null +++ b/pxr/usdValidation/usdValidation/module.cpp @@ -0,0 +1,18 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +#include "pxr/pxr.h" +#include "pxr/base/tf/pyModule.h" + +PXR_NAMESPACE_USING_DIRECTIVE + +TF_WRAP_MODULE +{ + TF_WRAP(UsdValidationContext); + TF_WRAP(UsdValidationError); + TF_WRAP(UsdValidationRegistry); + TF_WRAP(UsdValidationValidator); +} diff --git a/pxr/usdValidation/usdValidation/moduleDeps.cpp b/pxr/usdValidation/usdValidation/moduleDeps.cpp new file mode 100644 index 0000000000..0e5146de32 --- /dev/null +++ b/pxr/usdValidation/usdValidation/moduleDeps.cpp @@ -0,0 +1,33 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +//////////////////////////////////////////////////////////////////////// + +#include "pxr/pxr.h" +#include "pxr/base/tf/registryManager.h" +#include "pxr/base/tf/scriptModuleLoader.h" +#include "pxr/base/tf/token.h" + +#include + +PXR_NAMESPACE_OPEN_SCOPE + +TF_REGISTRY_FUNCTION(TfScriptModuleLoader) { + // List of direct dependencies for this library. + const std::vector reqs = { + TfToken("plug"), + TfToken("sdf"), + TfToken("tf"), + TfToken("usd"), + TfToken("work") + }; + TfScriptModuleLoader::GetInstance(). + RegisterLibrary(TfToken("usdValidation"), TfToken("pxr.UsdValidation"), reqs); +} + +PXR_NAMESPACE_CLOSE_SCOPE + + diff --git a/pxr/usdValidation/usdValidation/plugInfo.json b/pxr/usdValidation/usdValidation/plugInfo.json new file mode 100644 index 0000000000..fd1b1c1dbc --- /dev/null +++ b/pxr/usdValidation/usdValidation/plugInfo.json @@ -0,0 +1,24 @@ +{ + "Plugins": [ + { + "Info": { + "Validators": { + "CompositionErrorTest": { + "doc": "Validator aims at providing all composition errors, which were generated while composing the stage." + }, + "StageMetadataChecker": { + "doc": "Stages that can be consumed as referenceable assets must have a valid 'defaultPrim' specified." + }, + "keywords": [ + "UsdCoreValidators" + ] + } + }, + "LibraryPath": "@PLUG_INFO_LIBRARY_PATH@", + "Name": "usdValidation", + "ResourcePath": "@PLUG_INFO_RESOURCE_PATH@", + "Root": "@PLUG_INFO_ROOT@", + "Type": "library" + } + ] +} diff --git a/pxr/usd/usd/validationRegistry.cpp b/pxr/usdValidation/usdValidation/registry.cpp similarity index 63% rename from pxr/usd/usd/validationRegistry.cpp rename to pxr/usdValidation/usdValidation/registry.cpp index 4aa36668aa..8f47b75562 100644 --- a/pxr/usd/usd/validationRegistry.cpp +++ b/pxr/usdValidation/usdValidation/registry.cpp @@ -5,12 +5,12 @@ // https://openusd.org/license. // -#include "pxr/usd/usd/validationRegistry.h" +#include "pxr/usdValidation/usdValidation/registry.h" -#include "pxr/base/tf/instantiateSingleton.h" -#include "pxr/base/tf/registryManager.h" #include "pxr/base/plug/plugin.h" #include "pxr/base/plug/registry.h" +#include "pxr/base/tf/instantiateSingleton.h" +#include "pxr/base/tf/registryManager.h" #include "pxr/base/tf/token.h" #include @@ -22,16 +22,11 @@ PXR_NAMESPACE_OPEN_SCOPE TF_INSTANTIATE_SINGLETON(UsdValidationRegistry); -TF_DEFINE_PRIVATE_TOKENS(_tokens, - ((PluginValidatorsKey, "Validators")) - ((Keywords, "keywords")) - ((Doc, "doc")) - ((SchemaTypes, "schemaTypes")) - ((IsSuite, "isSuite")) - ((PluginValidatorNameDelimiter, ":")) -); - - +TF_DEFINE_PRIVATE_TOKENS( + _tokens, + ((PluginValidatorsKey, "Validators"))((Keywords, "keywords"))((Doc, "doc"))( + (SchemaTypes, "schemaTypes"))((IsSuite, "isSuite"))( + (PluginValidatorNameDelimiter, ":"))); UsdValidationRegistry::UsdValidationRegistry() { @@ -59,38 +54,38 @@ static TfTokenVector _ParseStringArrayValue(const JsObject &object, const TfToken &token, const TfToken &validatorName = TfToken()) { - const std::string &errorStrTemplate = - "Expected array of strings for " + token.GetString() + " metadata"; - const std::string &errorStr = validatorName.IsEmpty() ? - errorStrTemplate : - errorStrTemplate + " for validator " + validatorName.GetString(); - if (const JsValue * const value = TfMapLookupPtr(object, token)) { + const std::string &errorStrTemplate + = "Expected array of strings for " + token.GetString() + " metadata"; + const std::string &errorStr = validatorName.IsEmpty() + ? errorStrTemplate + : errorStrTemplate + " for validator " + validatorName.GetString(); + if (const JsValue *const value = TfMapLookupPtr(object, token)) { if (!value->IsArrayOf()) { TF_RUNTIME_ERROR("%s", errorStr.c_str()); - return TfTokenVector{}; + return TfTokenVector {}; } return _FillTokenVector(*value); } - return TfTokenVector{}; + return TfTokenVector {}; } -void +void UsdValidationRegistry::_PopulateMetadataFromPlugInfo() { - const PlugPluginPtrVector &plugins = - PlugRegistry::GetInstance().GetAllPlugins(); + const PlugPluginPtrVector &plugins + = PlugRegistry::GetInstance().GetAllPlugins(); - auto _GetKey = [](const JsObject &dict, const std::string &key, - JsObject *value) { - const JsObject::const_iterator i = dict.find(key); - if (i != dict.end() && i->second.IsObject()) { - *value = i->second.GetJsObject(); - return true; - } - return false; - }; + auto _GetKey + = [](const JsObject &dict, const std::string &key, JsObject *value) { + const JsObject::const_iterator i = dict.find(key); + if (i != dict.end() && i->second.IsObject()) { + *value = i->second.GetJsObject(); + return true; + } + return false; + }; - for(const PlugPluginPtr &plugin : plugins) { + for (const PlugPluginPtr &plugin : plugins) { JsObject validators; const JsObject &plugMetadata = plugin->GetMetadata(); @@ -99,10 +94,9 @@ UsdValidationRegistry::_PopulateMetadataFromPlugInfo() continue; } - const TfTokenVector keywords = - _ParseStringArrayValue(validators, - _tokens->Keywords); - + const TfTokenVector keywords + = _ParseStringArrayValue(validators, _tokens->Keywords); + const TfToken pluginName = TfToken(plugin->GetName()); TfTokenVector validatorNames; // Parse all validator names and respective plugMetadata @@ -119,8 +113,8 @@ UsdValidationRegistry::_PopulateMetadataFromPlugInfo() continue; } - const JsValue * const doc = - TfMapLookupPtr(validatorDict, _tokens->Doc); + const JsValue *const doc + = TfMapLookupPtr(validatorDict, _tokens->Doc); if (!doc || !doc->IsString() || doc->GetString().empty()) { TF_RUNTIME_ERROR("Missing or invalid or empty doc string " "metadata for '%s' validator", @@ -128,38 +122,37 @@ UsdValidationRegistry::_PopulateMetadataFromPlugInfo() continue; } - UsdValidatorMetadata metadata; + UsdValidationValidatorMetadata metadata; metadata.pluginPtr = plugin; // prefix pluginName to validatorName to make these plugin // validator's metadata.name unique - metadata.name = TfToken( - pluginName.GetString() + - _tokens->PluginValidatorNameDelimiter.GetString() + - validatorName.GetString()); + metadata.name + = TfToken(pluginName.GetString() + + _tokens->PluginValidatorNameDelimiter.GetString() + + validatorName.GetString()); validatorNames.push_back(metadata.name); metadata.doc = doc->GetString(); - metadata.schemaTypes = - _ParseStringArrayValue(validatorDict, _tokens->SchemaTypes, - metadata.name); - + metadata.schemaTypes = _ParseStringArrayValue( + validatorDict, _tokens->SchemaTypes, metadata.name); + metadata.keywords = keywords; - const TfTokenVector &localKeywords = - _ParseStringArrayValue(validatorDict, _tokens->Keywords, - metadata.name); - metadata.keywords.reserve( - metadata.keywords.size() + localKeywords.size()); - metadata.keywords.insert(metadata.keywords.end(), - localKeywords.begin(), + const TfTokenVector &localKeywords = _ParseStringArrayValue( + validatorDict, _tokens->Keywords, metadata.name); + metadata.keywords.reserve(metadata.keywords.size() + + localKeywords.size()); + metadata.keywords.insert(metadata.keywords.end(), + localKeywords.begin(), localKeywords.end()); - - if (const JsValue * const isSuite = - TfMapLookupPtr(validatorDict, _tokens->IsSuite)) { + + if (const JsValue *const isSuite + = TfMapLookupPtr(validatorDict, _tokens->IsSuite)) { if (!isSuite->IsBool()) { TF_RUNTIME_ERROR("Expected bool for isSuite for validator " - "'%s'", metadata.name.GetText()); + "'%s'", + metadata.name.GetText()); } else { metadata.isSuite = isSuite->GetBool(); } @@ -173,48 +166,47 @@ UsdValidationRegistry::_PopulateMetadataFromPlugInfo() _AddValidatorMetadata(metadata); } if (!validatorNames.empty()) { - _pluginNameToValidatorNames.emplace(plugin->GetName(), + _pluginNameToValidatorNames.emplace(plugin->GetName(), validatorNames); } } } -void +void UsdValidationRegistry::RegisterPluginValidator( const TfToken &validatorName, const UsdValidateLayerTaskFn &layerTaskFn) { - _RegisterPluginValidator( - validatorName, layerTaskFn); + _RegisterPluginValidator(validatorName, + layerTaskFn); } void UsdValidationRegistry::RegisterPluginValidator( const TfToken &validatorName, const UsdValidateStageTaskFn &stageTaskFn) { - _RegisterPluginValidator( - validatorName, stageTaskFn); + _RegisterPluginValidator(validatorName, + stageTaskFn); } void UsdValidationRegistry::RegisterPluginValidator( const TfToken &validatorName, const UsdValidatePrimTaskFn &primTaskFn) { - _RegisterPluginValidator( - validatorName, primTaskFn); + _RegisterPluginValidator(validatorName, primTaskFn); } -template +template void -UsdValidationRegistry::_RegisterPluginValidator(const TfToken &validatorName, +UsdValidationRegistry::_RegisterPluginValidator(const TfToken &validatorName, const ValidateTaskFn &taskFn) { - static_assert(std::is_same_v || - std::is_same_v || - std::is_same_v, - "template parameter must be UsdValidateLayerTaskFn," + static_assert(std::is_same_v + || std::is_same_v + || std::is_same_v, + "template parameter must be UsdValidateLayerTaskFn," "UsdValidateStageTaskFn, or UsdValidatePrimTaskFn"); - UsdValidatorMetadata metadata; + UsdValidationValidatorMetadata metadata; if (!GetValidatorMetadata(validatorName, &metadata)) { // if this validatorName is from a plugin, which it should be since // this API is only for registering validators which are defined @@ -233,7 +225,7 @@ UsdValidationRegistry::_RegisterPluginValidator(const TfToken &validatorName, void UsdValidationRegistry::RegisterValidator( - const UsdValidatorMetadata &metadata, + const UsdValidationValidatorMetadata &metadata, const UsdValidateLayerTaskFn &layerTaskFn) { _RegisterValidator(metadata, layerTaskFn); @@ -241,7 +233,7 @@ UsdValidationRegistry::RegisterValidator( void UsdValidationRegistry::RegisterValidator( - const UsdValidatorMetadata &metadata, + const UsdValidationValidatorMetadata &metadata, const UsdValidateStageTaskFn &stageTaskFn) { _RegisterValidator(metadata, stageTaskFn); @@ -249,25 +241,26 @@ UsdValidationRegistry::RegisterValidator( void UsdValidationRegistry::RegisterValidator( - const UsdValidatorMetadata &metadata, + const UsdValidationValidatorMetadata &metadata, const UsdValidatePrimTaskFn &primTaskFn) { _RegisterValidator(metadata, primTaskFn); } -template +template void -UsdValidationRegistry::_RegisterValidator(const UsdValidatorMetadata &metadata, +UsdValidationRegistry::_RegisterValidator( + const UsdValidationValidatorMetadata &metadata, const ValidateTaskFn &taskFn, bool addMetadata) { - static_assert(std::is_same_v || - std::is_same_v || - std::is_same_v, - "template parameter must be UsdValidateLayerTaskFn," + static_assert(std::is_same_v + || std::is_same_v + || std::is_same_v, + "template parameter must be UsdValidateLayerTaskFn," "UsdValidateStageTaskFn, or UsdValidatePrimTaskFn"); - static constexpr bool isPrimTaskFn = - std::is_same::value; + static constexpr bool isPrimTaskFn + = std::is_same::value; if (!_CheckMetadata(metadata, isPrimTaskFn)) { return; } @@ -276,9 +269,9 @@ UsdValidationRegistry::_RegisterValidator(const UsdValidatorMetadata &metadata, // Lock for writing validators. std::unique_lock lock(_mutex); if (_validators.find(metadata.name) != _validators.end()) { - TF_CODING_ERROR( - "Validator '%s' already registered with the " - "UsdValidationRegistry", metadata.name.GetText()); + TF_CODING_ERROR("Validator '%s' already registered with the " + "UsdValidationRegistry", + metadata.name.GetText()); return; } @@ -290,18 +283,20 @@ UsdValidationRegistry::_RegisterValidator(const UsdValidatorMetadata &metadata, // above. if (!_AddValidatorMetadata(metadata)) { TF_CODING_ERROR( - "Metadata already added for a UsdValidatorSuite with the " - "same name '%s'.", metadata.name.GetText()); + "Metadata already added for a UsdValidationValidatorSuite " + "with the same name '%s'.", + metadata.name.GetText()); return; } } - std::unique_ptr validator = - std::make_unique(metadata, taskFn); + std::unique_ptr validator + = std::make_unique(metadata, taskFn); if (!_validators.emplace(metadata.name, std::move(validator)).second) { TF_CODING_ERROR( "Validator with name '%s' already exists, failed to register " - "it again.", metadata.name.GetText()); + "it again.", + metadata.name.GetText()); } } } @@ -313,37 +308,38 @@ UsdValidationRegistry::HasValidator(const TfToken &validatorName) const return _validators.find(validatorName) != _validators.end(); } -std::vector +std::vector UsdValidationRegistry::GetOrLoadAllValidators() { const TfTokenVector &validatorNames = [&]() { - TfTokenVector result; - std::shared_lock lock(_mutex); - result.reserve(_validatorNameToMetadata.size()); - - // Ensure _validatorNameToMetadata is accessed as a const; This will - // ensure multiple threads can safely read from - // _validatorNameToMetadata without risking data races, as const - // begin / end overloads will be invoked below. - for (const auto &entry : std::as_const(_validatorNameToMetadata)) { - if (!entry.second.isSuite) { - result.push_back(entry.first); - } + TfTokenVector result; + std::shared_lock lock(_mutex); + result.reserve(_validatorNameToMetadata.size()); + + // Ensure _validatorNameToMetadata is accessed as a const; This will + // ensure multiple threads can safely read from + // _validatorNameToMetadata without risking data races, as const + // begin / end overloads will be invoked below. + for (const auto &entry : std::as_const(_validatorNameToMetadata)) { + if (!entry.second.isSuite) { + result.push_back(entry.first); } - return result; - }(); + } + return result; + }(); return GetOrLoadValidatorsByName(validatorNames); } -const UsdValidator* +const UsdValidationValidator * UsdValidationRegistry::GetOrLoadValidatorByName(const TfToken &validatorName) { - auto _GetValidator = [&](const TfToken &name) -> const UsdValidator* { + auto _GetValidator + = [&](const TfToken &name) -> const UsdValidationValidator * { std::shared_lock lock(_mutex); - // Ensure _validators is accessed as a const; This will ensure multiple - // threads can safely read from _validators without risking data races, - // as const find overload will be invoked below. + // Ensure _validators is accessed as a const; This will ensure + // multiple threads can safely read from _validators without risking + // data races, as const find overload will be invoked below. const auto &validatorItr = std::as_const(_validators).find(name); if (validatorItr != _validators.cend()) { return validatorItr->second.get(); @@ -351,11 +347,12 @@ UsdValidationRegistry::GetOrLoadValidatorByName(const TfToken &validatorName) return nullptr; }; - if (const UsdValidator *const validator = _GetValidator(validatorName)) { + if (const UsdValidationValidator *const validator + = _GetValidator(validatorName)) { return validator; } - - UsdValidatorMetadata metadata; + + UsdValidationValidatorMetadata metadata; if (!GetValidatorMetadata(validatorName, &metadata)) { // No validatorMetadata found corresponding to this validatorName return nullptr; @@ -373,15 +370,16 @@ UsdValidationRegistry::GetOrLoadValidatorByName(const TfToken &validatorName) return nullptr; } -std::vector +std::vector UsdValidationRegistry::GetOrLoadValidatorsByName( const TfTokenVector &validatorNames) { - std::vector validators; + std::vector validators; validators.reserve(validatorNames.size()); for (const TfToken &validatorName : validatorNames) { - const UsdValidator *validator = GetOrLoadValidatorByName(validatorName); + const UsdValidationValidator *validator + = GetOrLoadValidatorByName(validatorName); // If validator is nullptr, that means the validatorName was not found // in the registry and it failed to register, in which case appropriate // coding error would have been reported. @@ -394,10 +392,10 @@ UsdValidationRegistry::GetOrLoadValidatorsByName( void UsdValidationRegistry::RegisterPluginValidatorSuite( - const TfToken &suiteName, - const std::vector &containedValidators) + const TfToken &suiteName, + const std::vector &containedValidators) { - UsdValidatorMetadata metadata; + UsdValidationValidatorMetadata metadata; if (!GetValidatorMetadata(suiteName, &metadata)) { // if this suiteName is from a plugin, which it should be since // this API is only for registering validators which are defined @@ -410,25 +408,25 @@ UsdValidationRegistry::RegisterPluginValidatorSuite( suiteName.GetText()); return; } - _RegisterValidatorSuite(metadata, containedValidators, - /* addMetadata */ false); + _RegisterValidatorSuite(metadata, containedValidators, + /* addMetadata */ false); } void UsdValidationRegistry::RegisterValidatorSuite( - const UsdValidatorMetadata &metadata, - const std::vector &containedValidators) + const UsdValidationValidatorMetadata &metadata, + const std::vector &containedValidators) { _RegisterValidatorSuite(metadata, containedValidators); } void UsdValidationRegistry::_RegisterValidatorSuite( - const UsdValidatorMetadata &metadata, - const std::vector &containedValidators, + const UsdValidationValidatorMetadata &metadata, + const std::vector &containedValidators, bool addMetadata) { - if (!_CheckMetadata(metadata, /* checkForPrimTask */ false, + if (!_CheckMetadata(metadata, /* checkForPrimTask */ false, /* expectSuite */ true)) { return; } @@ -438,7 +436,8 @@ UsdValidationRegistry::_RegisterValidatorSuite( // validator. And contained validators's schemaType is a subset of Suite's // schemaTypes metadata. if (!metadata.schemaTypes.empty()) { - for(const UsdValidator *const validator : containedValidators) { + for (const UsdValidationValidator *const validator : + containedValidators) { if (!validator) { // Possible clients try to register a validator which is // invalid/nullptr @@ -452,23 +451,23 @@ UsdValidationRegistry::_RegisterValidatorSuite( TF_CODING_ERROR( "ValidatorSuite '%s' cannot be registered, as it provides " "schemaTypes, but at least one of its contained validator " - "'%s' does not provide a UsdValidatePrimTaskFn", - metadata.name.GetText(), + "'%s' does not provide a UsdValidatePrimTaskFn", + metadata.name.GetText(), validator->GetMetadata().name.GetText()); return; } - // We also need to make sure the contained validator's schemaTypes + // We also need to make sure the contained validator's schemaTypes // is a subset of validatorSuite's schemaTypes // NB: The size of the vectors here should be small. - for (const TfToken& schemaType : - validator->GetMetadata().schemaTypes) { + for (const TfToken &schemaType : + validator->GetMetadata().schemaTypes) { if (std::find(metadata.schemaTypes.begin(), - metadata.schemaTypes.end(), schemaType) == - metadata.schemaTypes.end()) { + metadata.schemaTypes.end(), schemaType) + == metadata.schemaTypes.end()) { TF_CODING_ERROR( "schemaType '%s' provided by a contained validator " "'%s' is not in schemaTypes for '%s' validator suite", - schemaType.GetText(), + schemaType.GetText(), validator->GetMetadata().name.GetText(), metadata.name.GetText()); return; @@ -478,13 +477,12 @@ UsdValidationRegistry::_RegisterValidatorSuite( } { - // Lock for writing validatorSuites + // Lock for writing validatorSuites std::unique_lock lock(_mutex); - if (_validatorSuites.find(metadata.name) != - _validatorSuites.end()) { - TF_CODING_ERROR( - "ValidatorSuite '%s' already registered with the " - "UsdValidationRegistry", metadata.name.GetText()); + if (_validatorSuites.find(metadata.name) != _validatorSuites.end()) { + TF_CODING_ERROR("ValidatorSuite '%s' already registered with the " + "UsdValidationRegistry", + metadata.name.GetText()); return; } @@ -496,19 +494,22 @@ UsdValidationRegistry::_RegisterValidatorSuite( // above. if (!_AddValidatorMetadata(metadata)) { TF_CODING_ERROR( - "Metadata already added for a UsdValidator with the same " - "name '%s'.", metadata.name.GetText()); + "Metadata already added for a UsdValidationValidator with " + "the same name '%s'.", + metadata.name.GetText()); return; } } - std::unique_ptr validatorSuite = - std::make_unique(metadata, containedValidators); - if (!_validatorSuites.emplace(metadata.name, - std::move(validatorSuite)).second) { + std::unique_ptr validatorSuite + = std::make_unique( + metadata, containedValidators); + if (!_validatorSuites.emplace(metadata.name, std::move(validatorSuite)) + .second) { TF_CODING_ERROR( "Suite with name '%s' already exists, failed to register it " - "again.", metadata.name.GetText()); + "again.", + metadata.name.GetText()); } } } @@ -520,31 +521,31 @@ UsdValidationRegistry::HasValidatorSuite(const TfToken &suiteName) const return _validatorSuites.find(suiteName) != _validatorSuites.end(); } -std::vector +std::vector UsdValidationRegistry::GetOrLoadAllValidatorSuites() { const TfTokenVector suiteNames = [&]() { - TfTokenVector result; - std::shared_lock lock(_mutex); - result.reserve(_validatorNameToMetadata.size()); - // Ensure _validatorNameToMetadata is accessed as a const; This will - // ensure multiple threads can safely read from - // _validatorNameToMetadata without risking data races, as const - // begin / end overloads will be invoked below. - for (const auto &entry : std::as_const(_validatorNameToMetadata)) { - if (entry.second.isSuite) { - result.push_back(entry.first); - } + TfTokenVector result; + std::shared_lock lock(_mutex); + result.reserve(_validatorNameToMetadata.size()); + // Ensure _validatorNameToMetadata is accessed as a const; This will + // ensure multiple threads can safely read from + // _validatorNameToMetadata without risking data races, as const + // begin / end overloads will be invoked below. + for (const auto &entry : std::as_const(_validatorNameToMetadata)) { + if (entry.second.isSuite) { + result.push_back(entry.first); } - return result; - }(); - - std::vector suites; + } + return result; + }(); + + std::vector suites; suites.reserve(suiteNames.size()); - for (const auto& suiteName : suiteNames) { - const UsdValidatorSuite* suite = - GetOrLoadValidatorSuiteByName(suiteName); + for (const auto &suiteName : suiteNames) { + const UsdValidationValidatorSuite *suite + = GetOrLoadValidatorSuiteByName(suiteName); if (suite) { suites.push_back(suite); } @@ -552,28 +553,29 @@ UsdValidationRegistry::GetOrLoadAllValidatorSuites() return suites; } -const UsdValidatorSuite* -UsdValidationRegistry::GetOrLoadValidatorSuiteByName( - const TfToken &suiteName) +const UsdValidationValidatorSuite * +UsdValidationRegistry::GetOrLoadValidatorSuiteByName(const TfToken &suiteName) { - auto _GetValidatorSuite = [&](const TfToken &name) - -> const UsdValidatorSuite* { + auto _GetValidatorSuite + = [&](const TfToken &name) -> const UsdValidationValidatorSuite * { std::shared_lock lock(_mutex); - // Ensure _validatorSuites is accessed as a const; This will ensure - // multiple threads can safely read from _validatorSuites without + // Ensure _validatorSuites is accessed as a const; This will ensure + // multiple threads can safely read from _validatorSuites without // risking data races, as const find overload will be invoked below. - const auto& validatorSuiteItr = std::as_const(_validatorSuites).find(name); + const auto &validatorSuiteItr + = std::as_const(_validatorSuites).find(name); if (validatorSuiteItr != _validatorSuites.cend()) { return validatorSuiteItr->second.get(); } return nullptr; }; - if (const UsdValidatorSuite *const suite = _GetValidatorSuite(suiteName)) { + if (const UsdValidationValidatorSuite *const suite + = _GetValidatorSuite(suiteName)) { return suite; } - UsdValidatorMetadata metadata; + UsdValidationValidatorMetadata metadata; if (!GetValidatorMetadata(suiteName, &metadata)) { // No validatorMetadata found corresponding to this suiteName return nullptr; @@ -591,15 +593,16 @@ UsdValidationRegistry::GetOrLoadValidatorSuiteByName( return nullptr; } -std::vector +std::vector UsdValidationRegistry::GetOrLoadValidatorSuitesByName( const TfTokenVector &suiteNames) { - std::vector suites; + std::vector suites; suites.reserve(suiteNames.size()); for (const TfToken &suiteName : suiteNames) { - const UsdValidatorSuite *suite = GetOrLoadValidatorSuiteByName(suiteName); + const UsdValidationValidatorSuite *suite + = GetOrLoadValidatorSuiteByName(suiteName); // if suite is nullptr, that means suiteName was not found in the // registry and it failed to register, in which case appropriate coding // error would have been reported. @@ -612,12 +615,11 @@ UsdValidationRegistry::GetOrLoadValidatorSuitesByName( bool UsdValidationRegistry::GetValidatorMetadata( - const TfToken &name, - UsdValidatorMetadata *metadata) const + const TfToken &name, UsdValidationValidatorMetadata *metadata) const { std::shared_lock lock(_mutex); - const auto& validatorNameToMetadataItr = - _validatorNameToMetadata.find(name); + const auto &validatorNameToMetadataItr + = _validatorNameToMetadata.find(name); if (validatorNameToMetadataItr == _validatorNameToMetadata.end()) { return false; } @@ -625,10 +627,10 @@ UsdValidationRegistry::GetValidatorMetadata( return true; } -UsdValidatorMetadataVector +UsdValidationValidatorMetadataVector UsdValidationRegistry::GetAllValidatorMetadata() const { - UsdValidatorMetadataVector result; + UsdValidationValidatorMetadataVector result; std::shared_lock lock(_mutex); result.reserve(_validatorNameToMetadata.size()); for (const auto &entry : _validatorNameToMetadata) { @@ -637,39 +639,39 @@ UsdValidationRegistry::GetAllValidatorMetadata() const return result; } -UsdValidatorMetadataVector +UsdValidationValidatorMetadataVector UsdValidationRegistry::GetValidatorMetadataForPlugin( const TfToken &pluginName) const { - return GetValidatorMetadataForPlugins({pluginName}); + return GetValidatorMetadataForPlugins({ pluginName }); } -UsdValidatorMetadataVector +UsdValidationValidatorMetadataVector UsdValidationRegistry::GetValidatorMetadataForKeyword( const TfToken &keyword) const { - return GetValidatorMetadataForKeywords({keyword}); + return GetValidatorMetadataForKeywords({ keyword }); } -UsdValidatorMetadataVector +UsdValidationValidatorMetadataVector UsdValidationRegistry::GetValidatorMetadataForSchemaType( const TfToken &schemaType) const { - return GetValidatorMetadataForSchemaTypes({schemaType}); + return GetValidatorMetadataForSchemaTypes({ schemaType }); } -UsdValidatorMetadataVector +UsdValidationValidatorMetadataVector UsdValidationRegistry::GetValidatorMetadataForPlugins( const TfTokenVector &pluginNames) const { // Since the _pluginNameToValidatorNames is created during registry // initialization this method is inherently thread safe, as // _pluginNameToValidatorNames is already populated and never updated. - return _GetValidatorMetadataForToken(_pluginNameToValidatorNames, + return _GetValidatorMetadataForToken(_pluginNameToValidatorNames, pluginNames); } -UsdValidatorMetadataVector +UsdValidationValidatorMetadataVector UsdValidationRegistry::GetValidatorMetadataForKeywords( const TfTokenVector &keywords) const { @@ -677,21 +679,21 @@ UsdValidationRegistry::GetValidatorMetadataForKeywords( return _GetValidatorMetadataForToken(_keywordToValidatorNames, keywords); } -UsdValidatorMetadataVector +UsdValidationValidatorMetadataVector UsdValidationRegistry::GetValidatorMetadataForSchemaTypes( const TfTokenVector &schemaTypes) const { std::shared_lock lock(_mutex); - return _GetValidatorMetadataForToken(_schemaTypeToValidatorNames, + return _GetValidatorMetadataForToken(_schemaTypeToValidatorNames, schemaTypes); } -UsdValidatorMetadataVector +UsdValidationValidatorMetadataVector UsdValidationRegistry::_GetValidatorMetadataForToken( const _TokenToValidatorNamesMap &tokenToValidatorNames, const TfTokenVector &tokens) const { - UsdValidatorMetadataVector result; + UsdValidationValidatorMetadataVector result; for (const TfToken &token : tokens) { const auto &itr = tokenToValidatorNames.find(token); if (itr == tokenToValidatorNames.end()) { @@ -702,8 +704,8 @@ UsdValidationRegistry::_GetValidatorMetadataForToken( // If we have a validatorName in tokenToValidatorNames, we // must have a validatorMetadata for this validatorName, because // that's how these are added in _AddValidatorMetadata - const auto &nameToMetadataItr = - _validatorNameToMetadata.find(validatorName); + const auto &nameToMetadataItr + = _validatorNameToMetadata.find(validatorName); TF_VERIFY(nameToMetadataItr != _validatorNameToMetadata.end()); result.push_back(nameToMetadataItr->second); } @@ -713,22 +715,20 @@ UsdValidationRegistry::_GetValidatorMetadataForToken( bool UsdValidationRegistry::_AddValidatorMetadata( - const UsdValidatorMetadata &metadata) + const UsdValidationValidatorMetadata &metadata) { - const bool didAddValidatorMetadata = [&]() - { - return _validatorNameToMetadata.emplace( - metadata.name, metadata).second; - }(); + const bool didAddValidatorMetadata = [&]() { + return _validatorNameToMetadata.emplace(metadata.name, metadata).second; + }(); if (didAddValidatorMetadata) { - // Callers are required to hold a lock on `_mutex`, so - // _schemaTypeToValidatorNames and _keywordToValidatorNames are + // Callers are required to hold a lock on `_mutex`, so + // _schemaTypeToValidatorNames and _keywordToValidatorNames are // protected here. _UpdateValidatorNamesMappings(_schemaTypeToValidatorNames, metadata.name, metadata.schemaTypes); - _UpdateValidatorNamesMappings(_keywordToValidatorNames, - metadata.name, metadata.keywords); + _UpdateValidatorNamesMappings(_keywordToValidatorNames, metadata.name, + metadata.keywords); } return didAddValidatorMetadata; } @@ -736,8 +736,7 @@ UsdValidationRegistry::_AddValidatorMetadata( /* static */ bool UsdValidationRegistry::_CheckMetadata( - const UsdValidatorMetadata &metadata, - bool checkForPrimTask, + const UsdValidationValidatorMetadata &metadata, bool checkForPrimTask, bool expectSuite) { // return false if we are trying to register a validator which is @@ -747,14 +746,14 @@ UsdValidationRegistry::_CheckMetadata( TF_CODING_ERROR( "Invalid metadata for ('%s') validator. Can not provide " "schemaTypes metadata when registering a " - "UsdValidateLayerTaskFn or UsdValidateStageTaskFn validator.", + "UsdValidateLayerTaskFn or UsdValidateStageTaskFn validator.", metadata.name.GetText()); return false; } // Return false if isSuite metadata is set, but we are dealing with a - // UsdValidator, similarly returns false if isSuite metadata is not set, but - // we are dealing with a UsdValidatorSuite. + // UsdValidationValidator, similarly returns false if isSuite metadata is + // not set, but we are dealing with a UsdValidationValidatorSuite. if (metadata.isSuite != expectSuite) { TF_CODING_ERROR( "Invalid metadata for '%s' validator. Incompatible isSuite " @@ -768,13 +767,12 @@ UsdValidationRegistry::_CheckMetadata( /* static */ void UsdValidationRegistry::_UpdateValidatorNamesMappings( - _TokenToValidatorNamesMap &tokenMap, - const TfToken &validatorName, + _TokenToValidatorNamesMap &tokenMap, const TfToken &validatorName, const TfTokenVector &tokens) { for (const TfToken &token : tokens) { if (tokenMap.find(token) == tokenMap.end()) { - tokenMap.emplace(token, TfTokenVector{validatorName}); + tokenMap.emplace(token, TfTokenVector { validatorName }); } else { // Since this method is only called from the // _PopulateMetadataFromPlugInfo, its guaranteed that diff --git a/pxr/usd/usd/validationRegistry.h b/pxr/usdValidation/usdValidation/registry.h similarity index 59% rename from pxr/usd/usd/validationRegistry.h rename to pxr/usdValidation/usdValidation/registry.h index 9b1041281f..6bbca370fe 100644 --- a/pxr/usd/usd/validationRegistry.h +++ b/pxr/usdValidation/usdValidation/registry.h @@ -4,16 +4,16 @@ // Licensed under the terms set forth in the LICENSE.txt file available at // https://openusd.org/license. // -#ifndef PXR_USD_USD_VALIDATION_REGISTRY_H -#define PXR_USD_USD_VALIDATION_REGISTRY_H +#ifndef PXR_USD_VALIDATION_USD_VALIDATION_REGISTRY_H +#define PXR_USD_VALIDATION_USD_VALIDATION_REGISTRY_H #include "pxr/pxr.h" -#include "pxr/usd/usd/api.h" -#include "pxr/usd/usd/validator.h" #include "pxr/base/tf/singleton.h" +#include "pxr/usdValidation/usdValidation/api.h" +#include "pxr/usdValidation/usdValidation/validator.h" -#include #include +#include #include /// \file @@ -22,8 +22,8 @@ PXR_NAMESPACE_OPEN_SCOPE /// \class UsdValidationRegistry /// -/// UsdValidationRegistry manages and provides access to UsdValidator / -/// UsdValidatorSuite for USD Validation. +/// UsdValidationRegistry manages and provides access to UsdValidationValidator +/// / UsdValidationValidatorSuite for USD Validation. /// /// UsdValidationRegistry is a singleton class, which serves as a central /// registry to hold / own all validators and validatorSuites by their names. @@ -39,14 +39,15 @@ PXR_NAMESPACE_OPEN_SCOPE /// which results in lazy loading of the validators, or explicitly register /// validators in their code via appropriate APIs. /// -/// As discussed in UsdValidator, validators are associated with +/// As discussed in UsdValidationValidator, validators are associated with /// UsdValidateLayerTaskFn, UsdValidateStageTaskFn or UsdValidatePrimTaskFn, /// which govern how a layer, stage or a prim needs to be validated. -/// UsdValidator / UsdValidatorSuite also have metadata, which can either be -/// provided in the plugInfo.json when registering the validators via plugin -/// mechanism, or by providing metadata field when registering validators. +/// UsdValidationValidator / UsdValidationValidatorSuite also have metadata, +/// which can either be provided in the plugInfo.json when registering the +/// validators via plugin mechanism, or by providing metadata field when +/// registering validators. /// -/// Example of registering a validator named "StageMetadataValidator" with +/// Example of registering a validator named "StageMetadataValidator" with /// doc metadata using plufInfo.json: /// /// \code @@ -80,13 +81,13 @@ PXR_NAMESPACE_OPEN_SCOPE /// TF_REGISTRY_FUNCTION(UsdValidationRegistry) /// { /// UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); -/// const TfToken validatorName("usd:StageMetadataValidator"); -/// const UsdValidateStageTaskFn stageTaskFn = +/// const TfToken validatorName("usdValidation:StageMetadataValidator"); +/// const UsdValidateStageTaskFn stageTaskFn = /// [](const UsdStagePtr &usdStage) { /// UsdValidationErrorVector errors; /// if (!usdStage->GetDefaultPrim()) { /// errors.emplace_back(UsdValidationErrorType::Error, -/// {UsdValidationErrorSite(usdStage, SdfPath("/"))}, +/// {UsdValidationErrorSite(usdStage, SdfPath("/"))}, /// "Stage has missing or invalid defaultPrim."); /// } /// if (!usdStage->HasAuthoredMetadata( @@ -109,9 +110,9 @@ PXR_NAMESPACE_OPEN_SCOPE /// ``` /// /// Clients can also register validators by explicitly providing -/// UsdValidatorMetadata, instead of relying on plugInfo.json for the same. -/// Though its recommended to use appropriate APIs when validator metadata is -/// being provided in the plugInfo.json. +/// UsdValidationValidatorMetadata, instead of relying on plugInfo.json for the +/// same. Though its recommended to use appropriate APIs when validator metadata +/// is being provided in the plugInfo.json. /// /// Example of validator registration by explicitly providing metadata, when its /// not available in the plugInfo.json: @@ -119,18 +120,20 @@ PXR_NAMESPACE_OPEN_SCOPE /// ```cpp /// { /// UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); -/// const UsdValidatorMetadata &metadata = GetMetadataToBeRegistered(); -/// const UsdValidateLayerTaskFn &layerTask = GetLayerTaskForValidator(); -/// registry.RegisterValidator(metadata, layerTask); +/// const UsdValidationValidatorMetadata &metadata = +/// GetMetadataToBeRegistered(); const UsdValidateLayerTaskFn &layerTask = +/// GetLayerTaskForValidator(); registry.RegisterValidator(metadata, +/// layerTask); /// } /// ``` /// /// Usage: /// -/// As shown above, UsdValidator or UsdValidatorSuite can be registered using -/// specific metadata or names, and retrieved by their name. The registry also -/// provides functionality to check the existence of a validator / suite, load -/// validators / suites dynamically if they are not in the registry. +/// As shown above, UsdValidationValidator or UsdValidationValidatorSuite can be +/// registered using specific metadata or names, and retrieved by their name. +/// The registry also provides functionality to check the existence of a +/// validator / suite, load validators / suites dynamically if they are not in +/// the registry. /// /// Clients can also retrieve metadata for validators associated with a /// specific plugin, keywords or schemaTypes, this can help clients filter out @@ -141,20 +144,22 @@ PXR_NAMESPACE_OPEN_SCOPE /// the registry) or retrieving previously registered validator are designed to /// be thread-safe. /// -/// \sa UsdValidator -/// \sa UsdValidatorSuite +/// \sa UsdValidationValidator +/// \sa UsdValidationValidatorSuite class UsdValidationRegistry { - UsdValidationRegistry(const UsdValidationRegistry&) = delete; - UsdValidationRegistry& operator=(const UsdValidationRegistry&) = delete; + UsdValidationRegistry(const UsdValidationRegistry &) = delete; + UsdValidationRegistry &operator=(const UsdValidationRegistry &) = delete; + public: - USD_API - static UsdValidationRegistry& GetInstance() { + USDVALIDATION_API + static UsdValidationRegistry &GetInstance() + { return TfSingleton::GetInstance(); } - /// Register UsdValidator defined in a plugin using \p validatorName and - /// \p layerTaskFn with the UsdValidationRegistry. + /// Register UsdValidationValidator defined in a plugin using \p + /// validatorName and \p layerTaskFn with the UsdValidationRegistry. /// /// Here \p validatorName should include the name of the plugin the /// validator belongs to, delimited by ":". @@ -164,16 +169,16 @@ class UsdValidationRegistry /// used to determine if a validator is already registered and associated /// with validatorName. /// - /// Also note any other failure to register a validator results in a coding + /// Also note any other failure to register a validator results in a coding /// error. /// /// \sa HasValidator - USD_API + USDVALIDATION_API void RegisterPluginValidator(const TfToken &validatorName, - const UsdValidateLayerTaskFn &layerTaskFn); + const UsdValidateLayerTaskFn &layerTaskFn); - /// Register UsdValidator defined in a plugin using \p validatorName and - /// \p stageTaskFn with the UsdValidationRegistry. + /// Register UsdValidationValidator defined in a plugin using \p + /// validatorName and \p stageTaskFn with the UsdValidationRegistry. /// /// Here \p validatorName should include the name of the plugin the /// validator belongs to, delimited by ":". @@ -183,16 +188,16 @@ class UsdValidationRegistry /// used to determine if a validator is already registered and associated /// with validatorName. /// - /// Also note any other failure to register a validator results in a coding + /// Also note any other failure to register a validator results in a coding /// error. /// /// \sa HasValidator - USD_API + USDVALIDATION_API void RegisterPluginValidator(const TfToken &validatorName, - const UsdValidateStageTaskFn &stageTaskFn); + const UsdValidateStageTaskFn &stageTaskFn); - /// Register UsdValidator defined in a plugin using \p validatorName and - /// \p primTaskFn with the UsdValidationRegistry. + /// Register UsdValidationValidator defined in a plugin using \p + /// validatorName and \p primTaskFn with the UsdValidationRegistry. /// /// Here \p validatorName should include the name of the plugin the /// validator belongs to, delimited by ":". @@ -202,18 +207,18 @@ class UsdValidationRegistry /// used to determine if a validator is already registered and associated /// with validatorName. /// - /// Also note any other failure to register a validator results in a coding + /// Also note any other failure to register a validator results in a coding /// error. /// /// \sa HasValidator - USD_API + USDVALIDATION_API void RegisterPluginValidator(const TfToken &validatorName, - const UsdValidatePrimTaskFn &primTaskFn); + const UsdValidatePrimTaskFn &primTaskFn); - /// Register UsdValidator using \p metadata and \p layerTaskFn + /// Register UsdValidationValidator using \p metadata and \p layerTaskFn /// with the UsdValidationRegistry. /// - /// Clients can explicitly provide validator metadata, which is then used to + /// Clients can explicitly provide validator metadata, which is then used to /// register a validator and associate it with name metadata. The metadata /// here is not specified in a plugInfo. /// @@ -222,18 +227,18 @@ class UsdValidationRegistry /// determine if a validator is already registered and associated with /// validatorName. /// - /// Also note any other failure to register a validator results in a coding + /// Also note any other failure to register a validator results in a coding /// error. /// /// \sa HasValidator - USD_API - void RegisterValidator(const UsdValidatorMetadata &metadata, + USDVALIDATION_API + void RegisterValidator(const UsdValidationValidatorMetadata &metadata, const UsdValidateLayerTaskFn &layerTaskFn); - /// Register UsdValidator using \p metadata and \p stageTaskFn + /// Register UsdValidationValidator using \p metadata and \p stageTaskFn /// with the UsdValidationRegistry. /// - /// Clients can explicitly provide validator metadata, which is then used to + /// Clients can explicitly provide validator metadata, which is then used to /// register a validator and associate it with name metadata. The metadata /// here is not specified in a plugInfo. /// @@ -242,18 +247,18 @@ class UsdValidationRegistry /// determine if a validator is already registered and associated with /// validatorName. /// - /// Also note any other failure to register a validator results in a coding + /// Also note any other failure to register a validator results in a coding /// error. /// /// \sa HasValidator - USD_API - void RegisterValidator(const UsdValidatorMetadata &metadata, + USDVALIDATION_API + void RegisterValidator(const UsdValidationValidatorMetadata &metadata, const UsdValidateStageTaskFn &stageTaskFn); - /// Register UsdValidator using \p metadata and \p primTaskFn + /// Register UsdValidationValidator using \p metadata and \p primTaskFn /// with the UsdValidationRegistry. /// - /// Clients can explicitly provide validator metadata, which is then used to + /// Clients can explicitly provide validator metadata, which is then used to /// register a validator and associate it with name metadata. The metadata /// here is not specified in a plugInfo. /// @@ -262,229 +267,233 @@ class UsdValidationRegistry /// determine if a validator is already registered and associated with /// validatorName. /// - /// Also note any other failure to register a validator results in a coding + /// Also note any other failure to register a validator results in a coding /// error. /// /// \sa HasValidator - USD_API - void RegisterValidator(const UsdValidatorMetadata &metadata, + USDVALIDATION_API + void RegisterValidator(const UsdValidationValidatorMetadata &metadata, const UsdValidatePrimTaskFn &primTaskFn); - /// Register UsdValidatorSuite defined in a plugin using + /// Register UsdValidationValidatorSuite defined in a plugin using /// \p validatorSuiteName and \p containedValidators with the /// UsdValidationRegistry. /// /// Here \p validatorSuiteName should include the name of the plugin the /// validator belongs to, delimited by ":". /// - /// Note UsdValidatorMetadata::isSuite must be set to true in the plugInfo, - /// else the validatorSuite will not be registered. + /// Note UsdValidationValidatorMetadata::isSuite must be set to true in the + /// plugInfo, else the validatorSuite will not be registered. /// /// Note calling RegisterPluginValidatorSuite with a validatorSuiteName /// which is already registered will result in a coding error. /// HasValidatorSuite can be used to determine if a validator is already /// registered and associated with validatorName. /// - /// Also note any other failure to register a validator results in a coding + /// Also note any other failure to register a validator results in a coding /// error. /// /// \sa HasValidatorSuite - USD_API - void RegisterPluginValidatorSuite(const TfToken &validatorSuiteName, - const std::vector& - containedValidators); + USDVALIDATION_API + void RegisterPluginValidatorSuite( + const TfToken &validatorSuiteName, + const std::vector &containedValidators); - /// Register UsdValidatorSuite using \p metadata and + /// Register UsdValidationValidatorSuite using \p metadata and /// \p containedValidators with the UsdValidationRegistry. /// - /// Clients can explicitly provide validator metadata, which is then used to + /// Clients can explicitly provide validator metadata, which is then used to /// register a suite and associate it with name metadata. The metadata /// here is not specified in a plugInfo. - /// - /// Note UsdValidatorMetadata::isSuite must be set to true in the plugInfo, - /// else the validatorSuite will not be registered. + /// + /// Note UsdValidationValidatorMetadata::isSuite must be set to true in the + /// plugInfo, else the validatorSuite will not be registered. /// /// Note calling RegisterPluginValidatorSuite with a validatorSuiteName /// which is already registered will result in a coding error. /// HasValidatorSuite can be used to determine if a validator is already /// registered and associated with validatorName. /// - /// Also note any other failure to register a validator results in a coding + /// Also note any other failure to register a validator results in a coding /// error. /// /// \sa HasValidatorSuite - USD_API - void RegisterValidatorSuite(const UsdValidatorMetadata &metadata, - const std::vector& - containedValidators); + USDVALIDATION_API + void RegisterValidatorSuite( + const UsdValidationValidatorMetadata &metadata, + const std::vector &containedValidators); - /// Return true if a UsdValidator is registered with the name \p + /// Return true if a UsdValidationValidator is registered with the name \p /// validatorName; false otherwise. - USD_API + USDVALIDATION_API bool HasValidator(const TfToken &validatorName) const; - /// Return true if a UsdValidatorSuite is registered with the name \p - /// validatorSuiteName; false otherwise. - USD_API + /// Return true if a UsdValidationValidatorSuite is registered with the name + /// \p validatorSuiteName; false otherwise. + USDVALIDATION_API bool HasValidatorSuite(const TfToken &suiteName) const; - /// Returns a vector of const pointer to UsdValidator corresponding to all - /// validators registered in the UsdValidationRegistry. + /// Returns a vector of const pointer to UsdValidationValidator + /// corresponding to all validators registered in the UsdValidationRegistry. /// /// If a validator is not found in the registry, this method will load /// appropriate plugins, if the validator is made available via a plugin. /// /// Note that this call will load in many plugins which provide a - /// UsdValidator, if not already loaded. Also note that returned validators - /// will only include validators defined in plugins or any explicitly - /// registered validators before this call. - USD_API - std::vector GetOrLoadAllValidators(); + /// UsdValidationValidator, if not already loaded. Also note that returned + /// validators will only include validators defined in plugins or any + /// explicitly registered validators before this call. + USDVALIDATION_API + std::vector GetOrLoadAllValidators(); - /// Returns a const pointer to UsdValidator if \p validatorName is found in - /// the registry. + /// Returns a const pointer to UsdValidationValidator if \p validatorName is + /// found in the registry. /// /// If a validator is not found in the registry, this method will load /// appropriate plugins, if the validator is made available via a plugin. /// /// Returns a nullptr if no validator is found. - USD_API - const UsdValidator* GetOrLoadValidatorByName(const TfToken &validatorName); + USDVALIDATION_API + const UsdValidationValidator * + GetOrLoadValidatorByName(const TfToken &validatorName); - /// Returns a vector of const pointer to UsdValidator corresponding to - /// \p validatorNames found in the registry. + /// Returns a vector of const pointer to UsdValidationValidator + /// corresponding to \p validatorNames found in the registry. /// /// If a validator is not found in the registry, this method will load /// appropriate plugins, if the validator is made available via a plugin. /// /// Size of returned vector might be less than the size of the input /// validatorNames, in case of missing validators. - USD_API - std::vector + USDVALIDATION_API + std::vector GetOrLoadValidatorsByName(const TfTokenVector &validatorNames); - /// Returns a vector of const pointer to UsdValidatorSuite corresponding to - /// all validator suites registered in the UsdValidationRegistry. + /// Returns a vector of const pointer to UsdValidationValidatorSuite + /// corresponding to all validator suites registered in the + /// UsdValidationRegistry. /// /// If a suite is not found in the registry, this method will load /// appropriate plugins, if the suite is made available via a plugin. /// /// Note that this call might load in many plugins which provide a - /// UsdValidatorSuite, if not already loaded. Also note that returned suites - /// will only include suites defined in plugins or any explicitly registered - /// suites before this call. - USD_API - std::vector GetOrLoadAllValidatorSuites(); - - /// Returns a const pointer to UsdValidatorSuite if \p suiteName + /// UsdValidationValidatorSuite, if not already loaded. Also note that + /// returned suites will only include suites defined in plugins or any + /// explicitly registered suites before this call. + USDVALIDATION_API + std::vector + GetOrLoadAllValidatorSuites(); + + /// Returns a const pointer to UsdValidationValidatorSuite if \p suiteName /// is found in the registry. /// /// If a suite is not found in the registry, this method will load /// appropriate plugins, if the suite is made available via a plugin. /// /// Returns a nullptr if no validator is found. - USD_API - const UsdValidatorSuite* GetOrLoadValidatorSuiteByName( - const TfToken &suiteName); + USDVALIDATION_API + const UsdValidationValidatorSuite * + GetOrLoadValidatorSuiteByName(const TfToken &suiteName); - /// Returns a vector of const pointer to UsdValidatorSuite corresponding to - /// \p suiteNames found in the registry. + /// Returns a vector of const pointer to UsdValidationValidatorSuite + /// corresponding to \p suiteNames found in the registry. /// /// If a suite is not found in the registry, this method will load /// appropriate plugins, if the suite is made available via a plugin. /// /// Size of returned vector might be less than the size of the input /// suiteNames, in case of missing validators. - USD_API - std::vector + USDVALIDATION_API + std::vector GetOrLoadValidatorSuitesByName(const TfTokenVector &suiteNames); /// Returns true if metadata is found in the _validatorNameToMetadata for /// a validator/suite name, false otherwise. /// /// \p metadata parameter is used as an out parameter here. - USD_API - bool GetValidatorMetadata(const TfToken &name, - UsdValidatorMetadata *metadata) const; + USDVALIDATION_API + bool GetValidatorMetadata(const TfToken &name, + UsdValidationValidatorMetadata *metadata) const; - /// Return vector of all UsdValidatorMetadata known to the registry - USD_API - UsdValidatorMetadataVector GetAllValidatorMetadata() const; + /// Return vector of all UsdValidationValidatorMetadata known to the + /// registry + USDVALIDATION_API + UsdValidationValidatorMetadataVector GetAllValidatorMetadata() const; - /// Returns vector of UsdValidatorMetadata associated with the Validators - /// which belong to the \p pluginName. + /// Returns vector of UsdValidationValidatorMetadata associated with the + /// Validators which belong to the \p pluginName. /// - /// This API can be used to curate a vector of validator metadata, that + /// This API can be used to curate a vector of validator metadata, that /// clients may want to load and use in their validation context. /// /// Note that this method does not result in any plugins to be loaded. - USD_API - UsdValidatorMetadataVector GetValidatorMetadataForPlugin( - const TfToken &pluginName) const; + USDVALIDATION_API + UsdValidationValidatorMetadataVector + GetValidatorMetadataForPlugin(const TfToken &pluginName) const; - /// Returns vector of UsdValidatorMetadata associated with the Validators - /// which has the \p keyword. + /// Returns vector of UsdValidationValidatorMetadata associated with the + /// Validators which has the \p keyword. /// - /// This API can be used to curate a vector of validator metadata, that + /// This API can be used to curate a vector of validator metadata, that /// clients may want to load and use in their validation context. /// /// Note that this method does not result in any plugins to be loaded. - USD_API - UsdValidatorMetadataVector GetValidatorMetadataForKeyword( - const TfToken &keyword) const; + USDVALIDATION_API + UsdValidationValidatorMetadataVector + GetValidatorMetadataForKeyword(const TfToken &keyword) const; - /// Returns vector of UsdValidatorMetadata associated with the Validators - /// which has the \p schemaType. + /// Returns vector of UsdValidationValidatorMetadata associated with the + /// Validators which has the \p schemaType. /// - /// This API can be used to curate a vector of validator metadata, that + /// This API can be used to curate a vector of validator metadata, that /// clients may want to load and use in their validation context. /// /// Note that this method does not result in any plugins to be loaded. - USD_API - UsdValidatorMetadataVector GetValidatorMetadataForSchemaType( - const TfToken &schemaType) const; + USDVALIDATION_API + UsdValidationValidatorMetadataVector + GetValidatorMetadataForSchemaType(const TfToken &schemaType) const; - /// Returns vector of UsdValidatorMetadata associated with the Validators - /// which belong to the \p pluginNames. + /// Returns vector of UsdValidationValidatorMetadata associated with the + /// Validators which belong to the \p pluginNames. /// - /// The returned vector is a union of all UsdValidatorMetadata associated - /// with the plugins. + /// The returned vector is a union of all UsdValidationValidatorMetadata + /// associated with the plugins. /// - /// This API can be used to curate a vector of validator metadata, that + /// This API can be used to curate a vector of validator metadata, that /// clients may want to load and use in their validation context. /// /// Note that this method does not result in any plugins to be loaded. - USD_API - UsdValidatorMetadataVector GetValidatorMetadataForPlugins( - const TfTokenVector &pluginNames) const; + USDVALIDATION_API + UsdValidationValidatorMetadataVector + GetValidatorMetadataForPlugins(const TfTokenVector &pluginNames) const; - /// Returns vector of UsdValidatorMetadata associated with the Validators - /// which has at least one of the \p keywords. + /// Returns vector of UsdValidationValidatorMetadata associated with the + /// Validators which has at least one of the \p keywords. /// - /// The returned vector is a union of all UsdValidatorMetadata associated - /// with the keywords. + /// The returned vector is a union of all UsdValidationValidatorMetadata + /// associated with the keywords. /// - /// This API can be used to curate a vector of validator metadata, that + /// This API can be used to curate a vector of validator metadata, that /// clients may want to load and use in their validation context. /// /// Note that this method does not result in any plugins to be loaded. - USD_API - UsdValidatorMetadataVector GetValidatorMetadataForKeywords( - const TfTokenVector &keywords) const; + USDVALIDATION_API + UsdValidationValidatorMetadataVector + GetValidatorMetadataForKeywords(const TfTokenVector &keywords) const; - /// Returns vector of UsdValidatorMetadata associated with the Validators - /// which has at least one of the \p schameTypes. + /// Returns vector of UsdValidationValidatorMetadata associated with the + /// Validators which has at least one of the \p schameTypes. /// - /// The returned vector is a union of all UsdValidatorMetadata associated - /// with the schemaTypes. + /// The returned vector is a union of all UsdValidationValidatorMetadata + /// associated with the schemaTypes. /// - /// This API can be used to curate a vector of validator metadata, that + /// This API can be used to curate a vector of validator metadata, that /// clients may want to load and use in their validation context. /// /// Note that this method does not result in any plugins to be loaded. - USD_API - UsdValidatorMetadataVector GetValidatorMetadataForSchemaTypes( - const TfTokenVector &schemaTypes) const; + USDVALIDATION_API + UsdValidationValidatorMetadataVector + GetValidatorMetadataForSchemaTypes(const TfTokenVector &schemaTypes) const; private: friend class TfSingleton; @@ -492,25 +501,27 @@ class UsdValidationRegistry UsdValidationRegistry(); // Initialize _validatorNameToMetadata, _keywordToValidatorNames and - // _schemaTypeToValidatorNames by parsing all plugInfo.json, find all + // _schemaTypeToValidatorNames by parsing all plugInfo.json, find all // Validators. void _PopulateMetadataFromPlugInfo(); // Templated method to register validator, called by appropriate // RegisterValidator methods, providing UsdValidateLayerTaskFn, // UsdValidateStageTaskFn or UsdValidatePrimTaskFn. - template - void _RegisterPluginValidator(const TfToken &validatorName, - const ValidateTaskFn &taskFn); + template + void _RegisterPluginValidator(const TfToken &validatorName, + const ValidateTaskFn &taskFn); // Overloaded templated _RegisterValidator, where metadata is explicitly - // provided. - template - void _RegisterValidator(const UsdValidatorMetadata &metadata, - const ValidateTaskFn &taskFn, bool addMetadata = true); - - void _RegisterValidatorSuite(const UsdValidatorMetadata &metadata, - const std::vector& containedValidators, + // provided. + template + void _RegisterValidator(const UsdValidationValidatorMetadata &metadata, + const ValidateTaskFn &taskFn, + bool addMetadata = true); + + void _RegisterValidatorSuite( + const UsdValidationValidatorMetadata &metadata, + const std::vector &containedValidators, bool addMetadata = true); // makes sure metadata provided is legal @@ -518,45 +529,48 @@ class UsdValidationRegistry // is provided and if the task being registered for the validator is // UsdValidatePrimTaskFn. // expectSuite parameter is used to determine if the isSuite metadata is - // appropriately set (for UsdValidatorSuite) or not (for UsdValidator). - static - bool _CheckMetadata(const UsdValidatorMetadata &metadata, - bool checkForPrimTask, bool expectSuite = false); + // appropriately set (for UsdValidationValidatorSuite) or not (for + // UsdValidationValidator). + static bool _CheckMetadata(const UsdValidationValidatorMetadata &metadata, + bool checkForPrimTask, bool expectSuite = false); // Add validator metadata to _validatorNameToMetadata, also updates // _schemaTypeToValidatorNames and _keywordToValidatorNames, for easy access // to what validators are linked to specific schemaTypes or keywords. // _mutex must be acquired before calling this method. - bool _AddValidatorMetadata(const UsdValidatorMetadata &metadata); - - using _ValidatorNameToValidatorMap = - std::unordered_map, - TfToken::HashFunctor>; - using _ValidatorSuiteNameToValidatorSuiteMap = - std::unordered_map, - TfToken::HashFunctor>; - using _ValidatorNameToMetadataMap = - std::unordered_map; - using _TokenToValidatorNamesMap = - std::unordered_map; - - // Helper to query - UsdValidatorMetadataVector _GetValidatorMetadataForToken( + bool _AddValidatorMetadata(const UsdValidationValidatorMetadata &metadata); + + using _ValidatorNameToValidatorMap + = std::unordered_map, + TfToken::HashFunctor>; + using _ValidatorSuiteNameToValidatorSuiteMap + = std::unordered_map, + TfToken::HashFunctor>; + using _ValidatorNameToMetadataMap + = std::unordered_map; + using _TokenToValidatorNamesMap + = std::unordered_map; + + // Helper to query + UsdValidationValidatorMetadataVector _GetValidatorMetadataForToken( const _TokenToValidatorNamesMap &tokenToValidatorNames, const TfTokenVector &tokens) const; // Helper to populate _keywordToValidatorNames and // _schemaTypeToValidatorNames // _mutex must be acquired before calling this method. - static - void _UpdateValidatorNamesMappings(_TokenToValidatorNamesMap &tokenMap, - const TfToken &validatorName, const TfTokenVector &tokens); + static void + _UpdateValidatorNamesMappings(_TokenToValidatorNamesMap &tokenMap, + const TfToken &validatorName, + const TfTokenVector &tokens); - // Main datastructure which holds validatorName to - // std::unique_ptr + // Main datastructure which holds validatorName to + // std::unique_ptr _ValidatorNameToValidatorMap _validators; - // Main datastructure which holds suiteName to - // std::unique_ptr + // Main datastructure which holds suiteName to + // std::unique_ptr _ValidatorSuiteNameToValidatorSuiteMap _validatorSuites; // ValidatorName to ValidatorMetadata map @@ -587,11 +601,10 @@ class UsdValidationRegistry // Specialize and delete the DeleteInstance function to prevent destruction. // This will prevent the singleton instance for UsdValidationRegistry from // being destroyed and hence making it immortal. -template <> -void TfSingleton::DeleteInstance() = delete; +template <> void TfSingleton::DeleteInstance() = delete; -USD_API_TEMPLATE_CLASS(TfSingleton); +USDVALIDATION_API_TEMPLATE_CLASS(TfSingleton); PXR_NAMESPACE_CLOSE_SCOPE -#endif // PXR_USD_USD_VALIDATION_REGISTRY_H +#endif // PXR_USD_VALIDATION_USD_VALIDATION_REGISTRY_H diff --git a/pxr/usd/usd/testenv/TestUsdValidationContextValidators_plugInfo.json b/pxr/usdValidation/usdValidation/testenv/TestUsdValidationContextValidators_plugInfo.json similarity index 100% rename from pxr/usd/usd/testenv/TestUsdValidationContextValidators_plugInfo.json rename to pxr/usdValidation/usdValidation/testenv/TestUsdValidationContextValidators_plugInfo.json diff --git a/pxr/usd/usd/testenv/TestUsdValidationRegistryPy_plugInfo.json b/pxr/usdValidation/usdValidation/testenv/TestUsdValidationRegistryPy_plugInfo.json similarity index 100% rename from pxr/usd/usd/testenv/TestUsdValidationRegistryPy_plugInfo.json rename to pxr/usdValidation/usdValidation/testenv/TestUsdValidationRegistryPy_plugInfo.json diff --git a/pxr/usd/usd/testenv/testUsdCoreValidators.cpp b/pxr/usdValidation/usdValidation/testenv/testUsdCoreValidators.cpp similarity index 67% rename from pxr/usd/usd/testenv/testUsdCoreValidators.cpp rename to pxr/usdValidation/usdValidation/testenv/testUsdCoreValidators.cpp index 56da500725..919deb43d5 100644 --- a/pxr/usd/usd/testenv/testUsdCoreValidators.cpp +++ b/pxr/usdValidation/usdValidation/testenv/testUsdCoreValidators.cpp @@ -5,53 +5,52 @@ // https://openusd.org/license. // -#include "pxr/usd/usd/validator.h" -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usd/validatorTokens.h" -#include "pxr/usd/usd/validationRegistry.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" +#include "pxr/usdValidation/usdValidation/validator.h" +#include "pxr/usdValidation/usdValidation/validatorTokens.h" #include PXR_NAMESPACE_USING_DIRECTIVE TF_DEFINE_PRIVATE_TOKENS(_tokens, - ((usdPlugin, "usd")) + ((usdValidationPlugin, "usdValidation")) ); -static -void +static void TestUsdValidators() { - UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); // The following test keeps track of all the available validators within // UsdCoreValidators keyword, hence as new validators are added under // this keyword this unit test will have to be updated. - const UsdValidatorMetadataVector coreValidatorMetadata = - registry.GetValidatorMetadataForPlugin(_tokens->usdPlugin); + const UsdValidationValidatorMetadataVector coreValidatorMetadata + = registry.GetValidatorMetadataForPlugin(_tokens->usdValidationPlugin); TF_AXIOM(coreValidatorMetadata.size() == 2); std::set validatorMetadataNameSet; - for (const UsdValidatorMetadata &metadata : coreValidatorMetadata) { + for (const UsdValidationValidatorMetadata &metadata : + coreValidatorMetadata) { validatorMetadataNameSet.insert(metadata.name); } - const std::set expectedValidatorNames = - {UsdValidatorNameTokens->compositionErrorTest, - UsdValidatorNameTokens->stageMetadataChecker}; + const std::set expectedValidatorNames + = { UsdValidatorNameTokens->compositionErrorTest, + UsdValidatorNameTokens->stageMetadataChecker }; TF_AXIOM(validatorMetadataNameSet == expectedValidatorNames); } -static -void +static void TestCoreUsdStageMetadata() { // Get stageMetadataChecker UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); - const UsdValidator *validator = registry.GetOrLoadValidatorByName( - UsdValidatorNameTokens->stageMetadataChecker); + const UsdValidationValidator *validator = registry.GetOrLoadValidatorByName( + UsdValidatorNameTokens->stageMetadataChecker); TF_AXIOM(validator); // Create an empty stage @@ -65,15 +64,16 @@ TestCoreUsdStageMetadata() // Verify the correct error is returned TF_AXIOM(errors.size() == 1); const TfToken expectedErrorIdentifier( - "usd:StageMetadataChecker.MissingDefaultPrim"); + "usdValidation:StageMetadataChecker.MissingDefaultPrim"); TF_AXIOM(errors[0].GetValidator() == validator); TF_AXIOM(errors[0].GetIdentifier() == expectedErrorIdentifier); TF_AXIOM(errors[0].GetType() == UsdValidationErrorType::Error); TF_AXIOM(errors[0].GetSites().size() == 1); TF_AXIOM(errors[0].GetSites()[0].IsValid()); - const std::string expectedErrorMsg = - TfStringPrintf("Stage with root layer <%s> has an invalid or missing " - "defaultPrim.", rootLayer->GetIdentifier().c_str()); + const std::string expectedErrorMsg + = TfStringPrintf("Stage with root layer <%s> has an invalid or missing " + "defaultPrim.", + rootLayer->GetIdentifier().c_str()); const std::string error = errors[0].GetMessage(); TF_AXIOM(errors[0].GetMessage() == expectedErrorMsg); @@ -86,21 +86,20 @@ TestCoreUsdStageMetadata() TF_AXIOM(errors.empty()); } -static -void +static void TestUsdCompositionErrorTest() { - UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); // test to make sure CompositionErrorTest validator provided in the core // usd plugin works correctly by reporting all the composition errors, // error sites and appropriate messages pertaining to these errors. - const UsdValidator* const compositionErrorValidator = - registry.GetOrLoadValidatorByName( + const UsdValidationValidator *const compositionErrorValidator + = registry.GetOrLoadValidatorByName( UsdValidatorNameTokens->compositionErrorTest); TF_AXIOM(compositionErrorValidator); - static const std::string layerContents = + static const std::string layerContents = R"usda(#usda 1.0 ( subLayers = [ @@ -141,29 +140,28 @@ TestUsdCompositionErrorTest() UsdStageRefPtr usdStage = UsdStage::Open(layer); // Get expected list of composition errors from the stage. - const PcpErrorVector expectedPcpErrors = - usdStage->GetCompositionErrors(); + const PcpErrorVector expectedPcpErrors = usdStage->GetCompositionErrors(); TF_AXIOM(expectedPcpErrors.size() == 5); // Get wrapped validation errors from our compositionErrorValidator - UsdValidationErrorVector errors = - compositionErrorValidator->Validate(usdStage); + UsdValidationErrorVector errors + = compositionErrorValidator->Validate(usdStage); TF_AXIOM(errors.size() == 5); // Lets make sure pcpErrors and validationErrors match - const TfToken expectedErrorIdentifier = - TfToken("usd:CompositionErrorTest.CompositionError"); + const TfToken expectedErrorIdentifier + = TfToken("usdValidation:CompositionErrorTest.CompositionError"); for (size_t index = 0; index < errors.size(); ++index) { TF_AXIOM(errors[index].GetValidator() == compositionErrorValidator); TF_AXIOM(errors[index].GetIdentifier() == expectedErrorIdentifier); - TF_AXIOM(errors[index].GetMessage() == - expectedPcpErrors[index]->ToString()); + TF_AXIOM(errors[index].GetMessage() + == expectedPcpErrors[index]->ToString()); TF_AXIOM(errors[index].GetSites().size() == 1); TF_AXIOM(errors[index].GetSites().size() == 1); TF_AXIOM(errors[index].GetSites()[0].IsValid()); TF_AXIOM(errors[index].GetSites()[0].IsPrim()); - TF_AXIOM(errors[index].GetSites()[0].GetPrim().GetPath() == - expectedPcpErrors[index]->rootSite.path); + TF_AXIOM(errors[index].GetSites()[0].GetPrim().GetPath() + == expectedPcpErrors[index]->rootSite.path); } } diff --git a/pxr/usd/usd/testenv/testUsdValidationContext.cpp b/pxr/usdValidation/usdValidation/testenv/testUsdValidationContext.cpp similarity index 70% rename from pxr/usd/usd/testenv/testUsdValidationContext.cpp rename to pxr/usdValidation/usdValidation/testenv/testUsdValidationContext.cpp index db83eacbef..da57e472a2 100644 --- a/pxr/usd/usd/testenv/testUsdValidationContext.cpp +++ b/pxr/usdValidation/usdValidation/testenv/testUsdValidationContext.cpp @@ -8,17 +8,17 @@ #include "pxr/pxr.h" #include "pxr/base/arch/systemInfo.h" #include "pxr/base/plug/registry.h" -#include "pxr/usd/usd/validationContext.h" -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usd/validationRegistry.h" -#include "pxr/usd/usd/validator.h" +#include "pxr/usdValidation/usdValidation/context.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" +#include "pxr/usdValidation/usdValidation/validator.h" PXR_NAMESPACE_USING_DIRECTIVE -static -std::string _LayerContents() +static std::string +_LayerContents() { - static const std::string layerContents = + static const std::string layerContents = R"usda(#usda 1.0 def "World" { @@ -41,128 +41,114 @@ std::string _LayerContents() return layerContents; } -static -SdfLayerRefPtr -_CreateTestLayer() { +static SdfLayerRefPtr +_CreateTestLayer() +{ SdfLayerRefPtr testLayer = SdfLayer::CreateAnonymous(".usda"); testLayer->ImportFromString(_LayerContents()); return testLayer; } -static -void -_TestError1(const UsdValidationError &error) { - TF_AXIOM( - error.GetValidator()->GetMetadata().name == - TfToken("testUsdValidationContextValidatorsPlugin:Test1")); +static void +_TestError1(const UsdValidationError &error) +{ + TF_AXIOM(error.GetValidator()->GetMetadata().name + == TfToken("testUsdValidationContextValidatorsPlugin:Test1")); TF_AXIOM(error.GetSites().size() == 1); TF_AXIOM(error.GetSites()[0].IsPrim()); - TF_AXIOM(error.GetSites()[0].GetPrim().GetPath() == - SdfPath::AbsoluteRootPath()); + TF_AXIOM(error.GetSites()[0].GetPrim().GetPath() + == SdfPath::AbsoluteRootPath()); } -static -void -_TestError2(const UsdValidationError &error) { - TF_AXIOM( - error.GetValidator()->GetMetadata().name == - TfToken("testUsdValidationContextValidatorsPlugin:Test2")); +static void +_TestError2(const UsdValidationError &error) +{ + TF_AXIOM(error.GetValidator()->GetMetadata().name + == TfToken("testUsdValidationContextValidatorsPlugin:Test2")); TF_AXIOM(error.GetSites().size() == 1); TF_AXIOM(error.GetSites()[0].IsValidSpecInLayer()); } -static -void -_TestError3(const UsdValidationError &error) { - TF_AXIOM( - error.GetValidator()->GetMetadata().name == - TfToken("testUsdValidationContextValidatorsPlugin:Test3")); - const std::set expectedPrimPaths = { - SdfPath("/World"), - SdfPath("/World/baseType"), - SdfPath("/World/derivedType"), - SdfPath("/World/nestedDerivedType"), - SdfPath("/World/somePrim")}; - TF_AXIOM(expectedPrimPaths.find( - error.GetSites()[0].GetPrim().GetPath()) != - expectedPrimPaths.end()); +static void +_TestError3(const UsdValidationError &error) +{ + TF_AXIOM(error.GetValidator()->GetMetadata().name + == TfToken("testUsdValidationContextValidatorsPlugin:Test3")); + const std::set expectedPrimPaths + = { SdfPath("/World"), SdfPath("/World/baseType"), + SdfPath("/World/derivedType"), SdfPath("/World/nestedDerivedType"), + SdfPath("/World/somePrim") }; + TF_AXIOM(expectedPrimPaths.find(error.GetSites()[0].GetPrim().GetPath()) + != expectedPrimPaths.end()); } -static -void -_TestError4(const UsdValidationError &error) { - TF_AXIOM( - error.GetValidator()->GetMetadata().name == - TfToken("testUsdValidationContextValidatorsPlugin:Test4")); - const std::set expectedPrimPaths = { - SdfPath("/World/baseType"), - SdfPath("/World/derivedType"), - SdfPath("/World/nestedDerivedType")}; - TF_AXIOM(expectedPrimPaths.find( - error.GetSites()[0].GetPrim().GetPath()) != - expectedPrimPaths.end()); +static void +_TestError4(const UsdValidationError &error) +{ + TF_AXIOM(error.GetValidator()->GetMetadata().name + == TfToken("testUsdValidationContextValidatorsPlugin:Test4")); + const std::set expectedPrimPaths + = { SdfPath("/World/baseType"), SdfPath("/World/derivedType"), + SdfPath("/World/nestedDerivedType") }; + TF_AXIOM(expectedPrimPaths.find(error.GetSites()[0].GetPrim().GetPath()) + != expectedPrimPaths.end()); } -static -void -_TestError5(const UsdValidationError &error) { - TF_AXIOM( - error.GetValidator()->GetMetadata().name == - TfToken("testUsdValidationContextValidatorsPlugin:Test5")); - const std::set expectedPrimPaths = { - SdfPath("/World/derivedType"), - SdfPath("/World/nestedDerivedType")}; - TF_AXIOM(expectedPrimPaths.find( - error.GetSites()[0].GetPrim().GetPath()) != - expectedPrimPaths.end()); +static void +_TestError5(const UsdValidationError &error) +{ + TF_AXIOM(error.GetValidator()->GetMetadata().name + == TfToken("testUsdValidationContextValidatorsPlugin:Test5")); + const std::set expectedPrimPaths + = { SdfPath("/World/derivedType"), + SdfPath("/World/nestedDerivedType") }; + TF_AXIOM(expectedPrimPaths.find(error.GetSites()[0].GetPrim().GetPath()) + != expectedPrimPaths.end()); } -static -void -_TestError6(const UsdValidationError &error) { - TF_AXIOM( - error.GetValidator()->GetMetadata().name == - TfToken("testUsdValidationContextValidatorsPlugin:Test6")); +static void +_TestError6(const UsdValidationError &error) +{ + TF_AXIOM(error.GetValidator()->GetMetadata().name + == TfToken("testUsdValidationContextValidatorsPlugin:Test6")); TF_AXIOM(error.GetSites().size() == 1); TF_AXIOM(error.GetSites()[0].IsPrim()); - TF_AXIOM(error.GetSites()[0].GetPrim().GetName() == - TfToken("nestedDerivedType")); + TF_AXIOM(error.GetSites()[0].GetPrim().GetName() + == TfToken("nestedDerivedType")); } -static -void -_TestError7(const UsdValidationError &error) { +static void +_TestError7(const UsdValidationError &error) +{ TF_AXIOM(error.GetName() == TfToken("Test7Error")); - TF_AXIOM( - error.GetValidator()->GetMetadata().name == - TfToken("testUsdValidationContextValidatorsPlugin:Test7")); + TF_AXIOM(error.GetValidator()->GetMetadata().name + == TfToken("testUsdValidationContextValidatorsPlugin:Test7")); TF_AXIOM(error.GetSites().size() == 1); TF_AXIOM(error.GetSites()[0].IsPrim()); - TF_AXIOM(error.GetSites()[0].GetPrim().GetName() == - TfToken("somePrim")); + TF_AXIOM(error.GetSites()[0].GetPrim().GetName() == TfToken("somePrim")); } -static -void -_TestNonPluginError(const UsdValidationError &error) { - TF_AXIOM(error.GetValidator()->GetMetadata().name == - TfToken("nonPluginValidator")); +static void +_TestNonPluginError(const UsdValidationError &error) +{ + TF_AXIOM(error.GetValidator()->GetMetadata().name + == TfToken("nonPluginValidator")); const SdfPath expectedPrimPaths = SdfPath("/"); TF_AXIOM(error.GetSites()[0].GetPrim().GetPath() == expectedPrimPaths); } -static -void +static void _TestUsdValidationContext() { // Test the UsdValidationContext here. { // Create a ValidationContext with a suite - const UsdValidatorSuite* suite = - UsdValidationRegistry::GetInstance().GetOrLoadValidatorSuiteByName( - TfToken("testUsdValidationContextValidatorsPlugin:TestSuite")); - UsdValidationContext context({suite}); + const UsdValidationValidatorSuite *suite + = UsdValidationRegistry::GetInstance() + .GetOrLoadValidatorSuiteByName(TfToken( + "testUsdValidationContextValidatorsPlugin:TestSuite")); + UsdValidationContext context({ suite }); SdfLayerRefPtr testLayer = _CreateTestLayer(); // Run Validate(layer) UsdValidationErrorVector errors = context.Validate(testLayer); @@ -175,7 +161,7 @@ _TestUsdValidationContext() UsdStageRefPtr stage = UsdStage::Open(testLayer); errors = context.Validate(stage); // 1 error for Test1 validator (stage) - // 2 error for Test2 validator - root layer and session layer + // 2 error for Test2 validator - root layer and session layer // 5 errors for Test3 generic prim validator which runs on all 5 prims TF_AXIOM(errors.size() == 8); for (const auto &error : errors) { @@ -192,8 +178,7 @@ _TestUsdValidationContext() } { // Create a ValidationContext with explicit schemaTypes - UsdValidationContext context( - {TfType::FindByName("testBaseType")}); + UsdValidationContext context({ TfType::FindByName("testBaseType") }); SdfLayerRefPtr testLayer = _CreateTestLayer(); // Run Validate(layer) UsdValidationErrorVector errors = context.Validate(testLayer); @@ -215,7 +200,7 @@ _TestUsdValidationContext() { // Create a ValidationContext with explicit schemaType - apiSchema UsdValidationContext context( - {TfType::FindByName("testAPISchemaAPI")}); + { TfType::FindByName("testAPISchemaAPI") }); SdfLayerRefPtr testLayer = _CreateTestLayer(); // Run Validate(layer) UsdValidationErrorVector errors = context.Validate(testLayer); @@ -234,7 +219,7 @@ _TestUsdValidationContext() { // Create a ValidationContext with keywords API and have // includeAllAncestors set to default (true) - UsdValidationContext context({TfToken("Keyword1")}); + UsdValidationContext context({ TfToken("Keyword1") }); SdfLayerRefPtr testLayer = _CreateTestLayer(); // Run Validate(layer) UsdValidationErrorVector errors = context.Validate(testLayer); @@ -249,7 +234,7 @@ _TestUsdValidationContext() // 5 errors for Test3 generic prim validator which runs on all 5 prims // 2 errors for Test5 testDerivedType prim type validator which runs on // the derivedType and nestedDerivedType prims - // 3 errors for Test4 testBaseType prim type validator which runs on + // 3 errors for Test4 testBaseType prim type validator which runs on // the baseType, derivedType and nestedDerivedType prims (This gets // includes as an ancestor type of derivedType) // 1 error for Test7 testAPISchema prim type validator which runs on @@ -275,7 +260,7 @@ _TestUsdValidationContext() { // Create a ValidationContext with keywords API and have // includeAllAncestors set to false. - UsdValidationContext context({TfToken("Keyword2")}, false); + UsdValidationContext context({ TfToken("Keyword2") }, false); SdfLayerRefPtr testLayer = _CreateTestLayer(); // Run Validate(layer) UsdValidationErrorVector errors = context.Validate(testLayer); @@ -289,7 +274,7 @@ _TestUsdValidationContext() errors = context.Validate(stage->Traverse()); // 3 errors for Test4 testBaseType prim type validator which runs on // the baseType, derivedType and nestedDerivedType prims - // 1 error for Test6 testNestedDerivedType prim type validator which + // 1 error for Test6 testNestedDerivedType prim type validator which // runs on the nestedDerivedType prim // 5 errors for testNonPluginValidator which runs on all prims // Because of TestSuite: @@ -316,7 +301,7 @@ _TestUsdValidationContext() // 2 error for Test2 validator - root layer and session layer // 3 errors for Test4 testBaseType prim type validator which runs on // the baseType, derivedType and nestedDerivedType prims - // 1 error for Test6 testNestedDerivedType prim type validator which + // 1 error for Test6 testNestedDerivedType prim type validator which // runs on the nestedDerivedType prim // 5 errors for testNonPluginValidator which runs on all prims // Because of TestSuite: @@ -344,9 +329,9 @@ _TestUsdValidationContext() } { // Create a ValidationContext with plugins - UsdValidationContext context({ - PlugRegistry::GetInstance().GetPluginWithName( - "testUsdValidationContextValidatorsPlugin")}); + UsdValidationContext context( + { PlugRegistry::GetInstance().GetPluginWithName( + "testUsdValidationContextValidatorsPlugin") }); SdfLayerRefPtr testLayer = _CreateTestLayer(); UsdStageRefPtr stage = UsdStage::Open(testLayer); UsdValidationErrorVector errors = context.Validate(stage); @@ -357,7 +342,7 @@ _TestUsdValidationContext() // the baseType, derivedType and nestedDerivedType prims // 2 error for Test5 testDerivedType prim type validator which runs on // the derivedType and nestedDerivedType prims - // 1 error for Test6 testNestedDerivedType prim type validator which + // 1 error for Test6 testNestedDerivedType prim type validator which // runs on the nestedDerivedType prim // 1 error for Test7 testAPISchema prim type validator which runs on // the somePrim prim @@ -385,48 +370,48 @@ _TestUsdValidationContext() } } -int +int main() { // Register the test plugins // Plugin which provides test usd schema types const std::string testTypePluginPath = ArchGetCwd() + "/resources"; - TF_AXIOM(!PlugRegistry::GetInstance().RegisterPlugins( - testTypePluginPath).empty()); + TF_AXIOM(!PlugRegistry::GetInstance() + .RegisterPlugins(testTypePluginPath) + .empty()); // Plugin which provides test validators - const std::string testValidatorPluginPath = - TfStringCatPaths( - TfGetPathName(ArchGetExecutablePath()), - "UsdPlugins/lib/TestUsdValidationContextValidators*/Resources/") + - "/"; - TF_AXIOM(!PlugRegistry::GetInstance().RegisterPlugins( - testValidatorPluginPath).empty()); + const std::string testValidatorPluginPath + = TfStringCatPaths( + TfGetPathName(ArchGetExecutablePath()), + "UsdValidationPlugins/lib/TestUsdValidationContextValidators*/" + "Resources/") + + "/"; + TF_AXIOM(!PlugRegistry::GetInstance() + .RegisterPlugins(testValidatorPluginPath) + .empty()); // Add a non-plugin based validator here. { - UsdValidatorMetadata metadata; + UsdValidationValidatorMetadata metadata; metadata.name = TfToken("nonPluginValidator"); - metadata.keywords = {TfToken("Keyword2")}; + metadata.keywords = { TfToken("Keyword2") }; metadata.pluginPtr = nullptr; metadata.doc = "This is a non-plugin based validator."; metadata.isSuite = false; - const UsdValidatePrimTaskFn primTaskFn = []( - const UsdPrim &prim) - { + const UsdValidatePrimTaskFn primTaskFn = [](const UsdPrim &prim) { const TfToken errorId("nonPluginError"); - return UsdValidationErrorVector{ - UsdValidationError( - errorId, UsdValidationErrorType::Error, - {UsdValidationErrorSite(prim.GetStage(), - SdfPath::AbsoluteRootPath())}, - "A non-plugin based validator error")}; + return UsdValidationErrorVector { UsdValidationError( + errorId, UsdValidationErrorType::Error, + { UsdValidationErrorSite(prim.GetStage(), + SdfPath::AbsoluteRootPath()) }, + "A non-plugin based validator error") }; }; // Register the validator TfErrorMark m; - UsdValidationRegistry::GetInstance(). - RegisterValidator(metadata, primTaskFn); + UsdValidationRegistry::GetInstance().RegisterValidator(metadata, + primTaskFn); TF_AXIOM(m.IsClean()); } diff --git a/pxr/usd/usd/testenv/testUsdValidationContext/resources/generatedSchema.usda b/pxr/usdValidation/usdValidation/testenv/testUsdValidationContext/resources/generatedSchema.usda similarity index 100% rename from pxr/usd/usd/testenv/testUsdValidationContext/resources/generatedSchema.usda rename to pxr/usdValidation/usdValidation/testenv/testUsdValidationContext/resources/generatedSchema.usda diff --git a/pxr/usd/usd/testenv/testUsdValidationContext/resources/plugInfo.json b/pxr/usdValidation/usdValidation/testenv/testUsdValidationContext/resources/plugInfo.json similarity index 100% rename from pxr/usd/usd/testenv/testUsdValidationContext/resources/plugInfo.json rename to pxr/usdValidation/usdValidation/testenv/testUsdValidationContext/resources/plugInfo.json diff --git a/pxr/usd/usd/testenv/testUsdValidationContextPy.py b/pxr/usdValidation/usdValidation/testenv/testUsdValidationContextPy.py similarity index 95% rename from pxr/usd/usd/testenv/testUsdValidationContextPy.py rename to pxr/usdValidation/usdValidation/testenv/testUsdValidationContextPy.py index 4d04077d9b..f1d4812d04 100644 --- a/pxr/usd/usd/testenv/testUsdValidationContextPy.py +++ b/pxr/usdValidation/usdValidation/testenv/testUsdValidationContextPy.py @@ -7,7 +7,7 @@ import os, unittest -from pxr import Plug, Sdf, Tf, Usd +from pxr import Plug, Sdf, Tf, Usd, UsdValidation class TestUsdValidationContextPy(unittest.TestCase): @@ -18,7 +18,8 @@ def setUpClass(cls) -> None: assert os.path.exists(testTypePluginPath) testValidatorPluginPath = os.path.join( os.path.dirname(__file__), - "UsdPlugins/lib/TestUsdValidationContextValidators*/Resources/") + "UsdValidationPlugins/lib/TestUsdValidationContextValidators*/" \ + "Resources/") try: typePlugins = Plug.Registry().RegisterPlugins(testTypePluginPath) assert typePlugins @@ -135,9 +136,9 @@ def _TestError7(self, error): def test_UsdValidationContext(self): # Create a ValidationContext with a suite - suite = Usd.ValidationRegistry().GetOrLoadValidatorSuiteByName( + suite = UsdValidation.ValidationRegistry().GetOrLoadValidatorSuiteByName( "testUsdValidationContextValidatorsPlugin:TestSuite") - context = Usd.ValidationContext([suite]) + context = UsdValidation.ValidationContext([suite]) testLayer = self._CreateTestLayer() # Run Validate(layer) errors = context.Validate(testLayer) @@ -162,7 +163,7 @@ def test_UsdValidationContext(self): self.assertFalse(True) # Create a ValidationContext with explicit schemaTypes - context = Usd.ValidationContext( + context = UsdValidation.ValidationContext( [Tf.Type.FindByName("testBaseType")]) testLayer = self._CreateTestLayer() # Run Validate(layer) @@ -180,7 +181,7 @@ def test_UsdValidationContext(self): self._TestError4(error) # Create a ValidationContext with explicit schemaType - apiSchema - context = Usd.ValidationContext( + context = UsdValidation.ValidationContext( [Tf.Type.FindByName("testAPISchemaAPI")]) testLayer = self._CreateTestLayer() # Run Validate(layer) @@ -198,7 +199,7 @@ def test_UsdValidationContext(self): # Create a ValidationContext with keywords API and have # includeAllAncestors set to true - context = Usd.ValidationContext(["Keyword1"], True) + context = UsdValidation.ValidationContext(["Keyword1"], True) testLayer = self._CreateTestLayer() # Run Validate(layer) errors = context.Validate(testLayer) @@ -234,7 +235,7 @@ def test_UsdValidationContext(self): # Create a ValidationContext with keywords API and have # includeAllAncestors set to false - context = Usd.ValidationContext(["Keyword2"], False) + context = UsdValidation.ValidationContext(["Keyword2"], False) testLayer = self._CreateTestLayer() # Run Validate(layer) errors = context.Validate(testLayer) @@ -286,7 +287,7 @@ def test_UsdValidationContext(self): self.assertFalse(True) # Create a ValidationContext with plugins - context = Usd.ValidationContext( + context = UsdValidation.ValidationContext( [Plug.Registry().GetPluginWithName( "testUsdValidationContextValidatorsPlugin")], True) testLayer = self._CreateTestLayer() diff --git a/pxr/usdValidation/usdValidation/testenv/testUsdValidationContextValidators.cpp b/pxr/usdValidation/usdValidation/testenv/testUsdValidationContextValidators.cpp new file mode 100644 index 0000000000..ea49d810ad --- /dev/null +++ b/pxr/usdValidation/usdValidation/testenv/testUsdValidationContextValidators.cpp @@ -0,0 +1,145 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// + +#include "pxr/pxr.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" +#include "pxr/usdValidation/usdValidation/validator.h" + +PXR_NAMESPACE_USING_DIRECTIVE + +TF_REGISTRY_FUNCTION(UsdValidationRegistry) +{ + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); + + // Register test plugin validators here + // Test validators simply just return errors, we need to make sure various + // UsdValidationContext APIs work and get the expected errors back, when + // Validate is called in various scenarios on a validation context instance. + { + const TfToken validatorName( + "testUsdValidationContextValidatorsPlugin:Test1"); + const UsdValidateStageTaskFn stageTaskFn + = [](const UsdStagePtr &usdStage) { + const TfToken validationErrorId("Test1Error"); + return UsdValidationErrorVector { UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + { UsdValidationErrorSite(usdStage, + SdfPath::AbsoluteRootPath()) }, + "A stage validator error") }; + }; + + TfErrorMark m; + registry.RegisterPluginValidator(validatorName, stageTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const TfToken validatorName( + "testUsdValidationContextValidatorsPlugin:Test2"); + const UsdValidateLayerTaskFn layerTaskFn + = [](const SdfLayerHandle &layer) { + const TfToken validationErrorId("Test2Error"); + return UsdValidationErrorVector { UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + { UsdValidationErrorSite(layer, + SdfPath::AbsoluteRootPath()) }, + "A layer validator error") }; + }; + + TfErrorMark m; + registry.RegisterPluginValidator(validatorName, layerTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const TfToken validatorName( + "testUsdValidationContextValidatorsPlugin:Test3"); + const UsdValidatePrimTaskFn primTaskFn = [](const UsdPrim &prim) { + const TfToken validationErrorId("Test3Error"); + return UsdValidationErrorVector { UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + { UsdValidationErrorSite(prim.GetStage(), prim.GetPath()) }, + "A generic prim validator error") }; + }; + + TfErrorMark m; + registry.RegisterPluginValidator(validatorName, primTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const TfToken validatorName( + "testUsdValidationContextValidatorsPlugin:Test4"); + const UsdValidatePrimTaskFn primTaskFn = [](const UsdPrim &prim) { + const TfToken validationErrorId("Test4Error"); + return UsdValidationErrorVector { UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + { UsdValidationErrorSite(prim.GetStage(), prim.GetPath()) }, + "A testBaseType prim type validator error") }; + }; + + TfErrorMark m; + registry.RegisterPluginValidator(validatorName, primTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const TfToken validatorName( + "testUsdValidationContextValidatorsPlugin:Test5"); + const UsdValidatePrimTaskFn primTaskFn = [](const UsdPrim &prim) { + const TfToken validationErrorId("Test5Error"); + return UsdValidationErrorVector { UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + { UsdValidationErrorSite(prim.GetStage(), prim.GetPath()) }, + "A testDerivedType prim type validator error") }; + }; + + TfErrorMark m; + registry.RegisterPluginValidator(validatorName, primTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const TfToken validatorName( + "testUsdValidationContextValidatorsPlugin:Test6"); + const UsdValidatePrimTaskFn primTaskFn = [](const UsdPrim &prim) { + const TfToken validationErrorId("Test6Error"); + return UsdValidationErrorVector { UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + { UsdValidationErrorSite(prim.GetStage(), prim.GetPath()) }, + "A testNestedDerivedType prim type validator error") }; + }; + + TfErrorMark m; + registry.RegisterPluginValidator(validatorName, primTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const TfToken validatorName( + "testUsdValidationContextValidatorsPlugin:Test7"); + const UsdValidatePrimTaskFn primTaskFn = [](const UsdPrim &prim) { + const TfToken validationErrorId("Test7Error"); + return UsdValidationErrorVector { UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + { UsdValidationErrorSite(prim.GetStage(), prim.GetPath()) }, + "A testAPISchema prim type validator error") }; + }; + + TfErrorMark m; + registry.RegisterPluginValidator(validatorName, primTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const TfToken suiteName( + "testUsdValidationContextValidatorsPlugin:TestSuite"); + const std::vector containedValidators + = registry.GetOrLoadValidatorsByName( + { TfToken("testUsdValidationContextValidatorsPlugin:Test1"), + TfToken("testUsdValidationContextValidatorsPlugin:Test2"), + TfToken("testUsdValidationContextValidatorsPlugin:Test3") }); + + TfErrorMark m; + registry.RegisterPluginValidatorSuite(suiteName, containedValidators); + TF_AXIOM(m.IsClean()); + } +} diff --git a/pxr/usd/usd/testenv/testUsdValidationError.py b/pxr/usdValidation/usdValidation/testenv/testUsdValidationError.py similarity index 78% rename from pxr/usd/usd/testenv/testUsdValidationError.py rename to pxr/usdValidation/usdValidation/testenv/testUsdValidationError.py index d2c038c6ac..64da90a3eb 100644 --- a/pxr/usd/usd/testenv/testUsdValidationError.py +++ b/pxr/usdValidation/usdValidation/testenv/testUsdValidationError.py @@ -7,12 +7,12 @@ import unittest -from pxr import Plug, Sdf, Usd, Tf +from pxr import Plug, Sdf, Usd, Tf, UsdValidation class TestUsdValidationError(unittest.TestCase): def test_CreateDefaultErrorSite(self): - errorSite = Usd.ValidationErrorSite() + errorSite = UsdValidation.ValidationErrorSite() self.assertFalse(errorSite.IsValid()) self.assertFalse(errorSite.IsValidSpecInLayer()) self.assertFalse(errorSite.IsPrim()) @@ -24,8 +24,9 @@ def test_CreateDefaultErrorSite(self): self.assertFalse(errorSite.GetLayer()) self.assertFalse(errorSite.GetStage()) - def _VerifyErrorSiteWithLayer(self, errorSite: Usd.ValidationErrorSite, - layer: Sdf.Layer, objectPath: Sdf.Path): + def _VerifyErrorSiteWithLayer(self, + errorSite: UsdValidation.ValidationErrorSite, + layer: Sdf.Layer, objectPath: Sdf.Path): self.assertTrue(errorSite.IsValid()) self.assertTrue(errorSite.IsValidSpecInLayer()) self.assertFalse(errorSite.IsPrim()) @@ -45,7 +46,7 @@ def test_CreateErrorSiteWithLayerAndPrimSpec(self): stage = Usd.Stage.CreateInMemory() testPrimPath = Sdf.Path("/test") stage.DefinePrim(testPrimPath, "Xform") - errorSite = Usd.ValidationErrorSite(stage.GetRootLayer(), + errorSite = UsdValidation.ValidationErrorSite(stage.GetRootLayer(), testPrimPath) self._VerifyErrorSiteWithLayer(errorSite, stage.GetRootLayer(), testPrimPath) @@ -56,13 +57,14 @@ def test_CreateErrorSiteWithLayerAndPropertySpec(self): testPrim = stage.DefinePrim(testPrimPath, "Xform") testAttr = testPrim.CreateAttribute("attr", Sdf.ValueTypeNames.Int) testAttrPath = testAttr.GetPath() - errorSite = Usd.ValidationErrorSite(stage.GetRootLayer(), + errorSite = UsdValidation.ValidationErrorSite(stage.GetRootLayer(), testAttrPath) self._VerifyErrorSiteWithLayer(errorSite, stage.GetRootLayer(), testAttrPath) - def _VerifyErrorSiteWithStage(self, errorSite: Usd.ValidationErrorSite, - stage: Usd.Stage, objectPath: Sdf.Path): + def _VerifyErrorSiteWithStage(self, + errorSite: UsdValidation.ValidationErrorSite, + stage: Usd.Stage, objectPath: Sdf.Path): self.assertTrue(errorSite.IsValid()) self.assertFalse(errorSite.IsValidSpecInLayer()) self.assertEqual(errorSite.IsPrim(), objectPath.IsPrimPath()) @@ -79,8 +81,8 @@ def _VerifyErrorSiteWithStage(self, errorSite: Usd.ValidationErrorSite, self.assertEqual(errorSite.GetStage(), stage) def _VerifyErrorSiteWithStageAndLayer( - self, errorSite: Usd.ValidationErrorSite, stage: Usd.Stage, - layer: Sdf.Layer, objectPath: Sdf.Path): + self, errorSite: UsdValidation.ValidationErrorSite, + stage: Usd.Stage, layer: Sdf.Layer, objectPath: Sdf.Path): self.assertTrue(errorSite.IsValid()) self.assertTrue(errorSite.IsValidSpecInLayer()) self.assertEqual(errorSite.IsPrim(), objectPath.IsPrimPath()) @@ -106,11 +108,11 @@ def test_CreateErrorSiteWithStageAndPrim(self): stage = Usd.Stage.CreateInMemory() testPrimPath = Sdf.Path("/test") stage.DefinePrim(testPrimPath, "Xform") - errorSite = Usd.ValidationErrorSite(stage, testPrimPath) + errorSite = UsdValidation.ValidationErrorSite(stage, testPrimPath) self._VerifyErrorSiteWithStage(errorSite, stage, testPrimPath) # With layer also - errorSite = Usd.ValidationErrorSite(stage, testPrimPath, + errorSite = UsdValidation.ValidationErrorSite(stage, testPrimPath, stage.GetRootLayer()) self._VerifyErrorSiteWithStageAndLayer(errorSite, stage, stage.GetRootLayer(), @@ -122,11 +124,11 @@ def test_CreateErrorSiteWithStageAndProperty(self): testPrim = stage.DefinePrim(testPrimPath, "Xform") testAttr = testPrim.CreateAttribute("attr", Sdf.ValueTypeNames.Int) testAttrPath = testAttr.GetPath() - errorSite = Usd.ValidationErrorSite(stage, testAttrPath) + errorSite = UsdValidation.ValidationErrorSite(stage, testAttrPath) self._VerifyErrorSiteWithStage(errorSite, stage, testAttrPath) # With layer also - errorSite = Usd.ValidationErrorSite(stage, testAttrPath, + errorSite = UsdValidation.ValidationErrorSite(stage, testAttrPath, stage.GetRootLayer()) self._VerifyErrorSiteWithStageAndLayer(errorSite, stage, stage.GetRootLayer(), @@ -157,18 +159,18 @@ def test_CreateErrorSiteWithInvalidArgs(self): for errorCategory, args in errors.items(): with self.subTest(errorType=errorCategory): with self.assertRaises(Exception): - Usd.ValidationErrorSite(**args) + UsdValidation.ValidationErrorSite(**args) def _VerifyValidationError(self, error, name="", - errorType=Usd.ValidationErrorType.None_, - errorSites=None, errorMessage=""): + errorType=UsdValidation.ValidationErrorType.None_, + errorSites=None, errorMessage=""): if not errorSites: errorSites = [] self.assertEqual(error.GetName(), name) self.assertEqual(error.GetType(), errorType) self.assertEqual(error.GetSites(), errorSites) self.assertEqual(error.GetMessage(), errorMessage) - if errorType != Usd.ValidationErrorType.None_: + if errorType != UsdValidation.ValidationErrorType.None_: self.assertTrue(error.GetErrorAsString()) self.assertFalse(error.HasNoError()) else: @@ -181,46 +183,47 @@ def _VerifyValidationError(self, error, name="", except Tf.ErrorException as e: expectedErrorStr = \ "Validator not set on ValidationError. Possibly this validation " \ - "error was not created via a call to UsdValidator::Validate(), " \ - "which is responsible to set the validator on the error." + "error was not created via a call to " \ + "UsdValidationValidator::Validate(), which is responsible to set " \ + "the validator on the error." self.assertTrue(expectedErrorStr in str(e)) def test_CreateDefaultValidationError(self): - validationError = Usd.ValidationError() + validationError = UsdValidation.ValidationError() self._VerifyValidationError(validationError) def test_CreateValidationErrorWithKeywordArgs(self): errors = [ { "name": "error1", - "errorType": Usd.ValidationErrorType.None_, + "errorType": UsdValidation.ValidationErrorType.None_, "errorSites": [], "errorMessage": "" }, { "name": "error2", - "errorType": Usd.ValidationErrorType.Error, - "errorSites": [Usd.ValidationErrorSite()], + "errorType": UsdValidation.ValidationErrorType.Error, + "errorSites": [UsdValidation.ValidationErrorSite()], "errorMessage": "This is an error." }, { "name": "error3", - "errorType": Usd.ValidationErrorType.Warn, - "errorSites": [Usd.ValidationErrorSite()], + "errorType": UsdValidation.ValidationErrorType.Warn, + "errorSites": [UsdValidation.ValidationErrorSite()], "errorMessage": "This is a warning." }, { "name": "error4", - "errorType": Usd.ValidationErrorType.Info, - "errorSites": [Usd.ValidationErrorSite(), - Usd.ValidationErrorSite()], + "errorType": UsdValidation.ValidationErrorType.Info, + "errorSites": [UsdValidation.ValidationErrorSite(), + UsdValidation.ValidationErrorSite()], "errorMessage": "This is an info." }, ] for error in errors: with self.subTest(errorType=error["errorType"]): - validationError = Usd.ValidationError(**error) + validationError = UsdValidation.ValidationError(**error) self._VerifyValidationError(validationError, **error) def test_CreateValidationErrorWithInvalidArgs(self): @@ -233,13 +236,13 @@ def test_CreateValidationErrorWithInvalidArgs(self): }, "Wrong Sites Type": { "name": "error2", - "errorType": Usd.ValidationErrorType.None_, + "errorType": UsdValidation.ValidationErrorType.None_, "errorSites": "wrongType", "errorMessage": "" }, "Wrong Message Type": { "name": "error3", - "errorType": Usd.ValidationErrorType.None_, + "errorType": UsdValidation.ValidationErrorType.None_, "errorSites": [], "errorMessage": 123 }, @@ -248,7 +251,7 @@ def test_CreateValidationErrorWithInvalidArgs(self): for errorCategory, error in errors.items(): with self.subTest(errorType=errorCategory): with self.assertRaises(Exception): - Usd.ValidationError(**error) + UsdValidation.ValidationError(**error) if __name__ == "__main__": diff --git a/pxr/usd/usd/testenv/testUsdValidationRegistry.cpp b/pxr/usdValidation/usdValidation/testenv/testUsdValidationRegistry.cpp similarity index 51% rename from pxr/usd/usd/testenv/testUsdValidationRegistry.cpp rename to pxr/usdValidation/usdValidation/testenv/testUsdValidationRegistry.cpp index 99142a3aa6..64c340e359 100644 --- a/pxr/usd/usd/testenv/testUsdValidationRegistry.cpp +++ b/pxr/usdValidation/usdValidation/testenv/testUsdValidationRegistry.cpp @@ -6,35 +6,33 @@ // #include "pxr/pxr.h" -#include "pxr/usd/usd/validationRegistry.h" -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usd/validatorTokens.h" -#include "pxr/usd/usd/validator.h" #include "pxr/base/arch/systemInfo.h" #include "pxr/base/plug/registry.h" #include "pxr/base/tf/errorMark.h" #include "pxr/base/tf/registryManager.h" #include "pxr/base/tf/token.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" +#include "pxr/usdValidation/usdValidation/validator.h" +#include "pxr/usdValidation/usdValidation/validatorTokens.h" PXR_NAMESPACE_USING_DIRECTIVE TF_REGISTRY_FUNCTION(UsdValidationRegistry) { - UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance(); + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); { const TfToken validatorName("testValidationPlugin:TestValidator1"); - const UsdValidateStageTaskFn stageTaskFn = []( - const UsdStagePtr & usdStage) - { - const TfToken validationErrorId("ErrorId"); - return UsdValidationErrorVector{ - UsdValidationError(validationErrorId, - UsdValidationErrorType::Error, - {UsdValidationErrorSite( - usdStage, SdfPath::AbsoluteRootPath())}, - "This is an error on the stage")}; - }; + const UsdValidateStageTaskFn stageTaskFn + = [](const UsdStagePtr &usdStage) { + const TfToken validationErrorId("ErrorId"); + return UsdValidationErrorVector { UsdValidationError( + validationErrorId, UsdValidationErrorType::Error, + { UsdValidationErrorSite(usdStage, + SdfPath::AbsoluteRootPath()) }, + "This is an error on the stage") }; + }; // Register the validator TfErrorMark m; @@ -43,9 +41,8 @@ TF_REGISTRY_FUNCTION(UsdValidationRegistry) } { const TfToken validatorName("testValidationPlugin:TestValidator2"); - const UsdValidatePrimTaskFn primTaskFn = [](const UsdPrim & /*prim*/) - { - return UsdValidationErrorVector{}; + const UsdValidatePrimTaskFn primTaskFn = [](const UsdPrim & /*prim*/) { + return UsdValidationErrorVector {}; }; // Register the validator @@ -55,10 +52,9 @@ TF_REGISTRY_FUNCTION(UsdValidationRegistry) } { const TfToken validatorName("testValidationPlugin:TestValidator3"); - const UsdValidatePrimTaskFn primTaskFn = [](const UsdPrim & /*prim*/) - { - return UsdValidationErrorVector{}; - }; + const UsdValidatePrimTaskFn primTaskFn = [](const UsdPrim & /*prim*/) { + return UsdValidationErrorVector {}; + }; // Register the validator TfErrorMark m; @@ -67,21 +63,20 @@ TF_REGISTRY_FUNCTION(UsdValidationRegistry) } { const TfToken suiteName("testValidationPlugin:TestValidatorSuite"); - const std::vector containedValidators = - registry.GetOrLoadValidatorsByName( - {TfToken("testValidationPlugin:TestValidator1"), - TfToken("testValidationPlugin:TestValidator2")}); + const std::vector containedValidators + = registry.GetOrLoadValidatorsByName( + { TfToken("testValidationPlugin:TestValidator1"), + TfToken("testValidationPlugin:TestValidator2") }); TfErrorMark m; registry.RegisterPluginValidatorSuite(suiteName, containedValidators); TF_AXIOM(m.IsClean()); } { const TfToken validatorName("testValidationPlugin:FailedValidator"); - const UsdValidateStageTaskFn stageTaskFn = []( - const UsdStagePtr & /*stage*/) - { - return UsdValidationErrorVector{}; - }; + const UsdValidateStageTaskFn stageTaskFn + = [](const UsdStagePtr & /*stage*/) { + return UsdValidationErrorVector {}; + }; // Register the validator TfErrorMark m; @@ -90,53 +85,53 @@ TF_REGISTRY_FUNCTION(UsdValidationRegistry) } { const TfToken suiteName("testValidationPlugin:FailedValidatorSuite"); - const std::vector containedValidators = - registry.GetOrLoadValidatorsByName( - {TfToken("testValidationPlugin:TestValidator2"), - TfToken("testValidationPlugin:TestValidator1")}); + const std::vector containedValidators + = registry.GetOrLoadValidatorsByName( + { TfToken("testValidationPlugin:TestValidator2"), + TfToken("testValidationPlugin:TestValidator1") }); TfErrorMark m; registry.RegisterPluginValidatorSuite(suiteName, containedValidators); TF_AXIOM(!m.IsClean()); } { const TfToken suiteName("testValidationPlugin:FailedValidatorSuite2"); - const std::vector containedValidators = - registry.GetOrLoadValidatorsByName( - {TfToken("testValidationPlugin:TestValidator2")}); + const std::vector containedValidators + = registry.GetOrLoadValidatorsByName( + { TfToken("testValidationPlugin:TestValidator2") }); TfErrorMark m; registry.RegisterPluginValidatorSuite(suiteName, containedValidators); TF_AXIOM(!m.IsClean()); } } -void TestUsdValidationRegistry() +void +TestUsdValidationRegistry() { UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); { - UsdValidatorMetadata metadata; + UsdValidationValidatorMetadata metadata; TF_AXIOM(registry.GetValidatorMetadata( TfToken("testValidationPlugin:TestValidator1"), &metadata)); - const TfTokenVector expectedKeywords = { - TfToken("IncludedInAll"), - TfToken("SomeKeyword1") }; + const TfTokenVector expectedKeywords + = { TfToken("IncludedInAll"), TfToken("SomeKeyword1") }; TF_AXIOM(metadata.keywords == expectedKeywords); const std::string expectedDoc = "TestValidator1 for keywords metadata " - "parsing"; + "parsing"; TF_AXIOM(metadata.doc == expectedDoc); TF_AXIOM(!metadata.isSuite); // Actually go and call validate on this and inspect the Error. - const UsdValidator* const validator = - registry.GetOrLoadValidatorByName(metadata.name); + const UsdValidationValidator *const validator + = registry.GetOrLoadValidatorByName(metadata.name); TF_AXIOM(validator); UsdStageRefPtr usdStage = UsdStage::CreateInMemory(); const UsdValidationErrorVector errors = validator->Validate(usdStage); TF_AXIOM(errors.size() == 1); TF_AXIOM(!errors[0].HasNoError()); - TF_AXIOM(errors[0].GetIdentifier() == - TfToken("testValidationPlugin:TestValidator1.ErrorId")); + TF_AXIOM(errors[0].GetIdentifier() + == TfToken("testValidationPlugin:TestValidator1.ErrorId")); TF_AXIOM(errors[0].GetType() == UsdValidationErrorType::Error); TF_AXIOM(errors[0].GetValidator() == validator); const UsdValidationErrorSites &errorSites = errors[0].GetSites(); @@ -151,90 +146,94 @@ void TestUsdValidationRegistry() TF_AXIOM(validator->Validate(usdStage->GetRootLayer()).empty()); } { - UsdValidatorMetadataVector metadata = - registry.GetValidatorMetadataForSchemaType( + UsdValidationValidatorMetadataVector metadata + = registry.GetValidatorMetadataForSchemaType( TfToken("SomePrimType")); TF_AXIOM(metadata.size() == 4); - TfTokenVector expectedValue({ - TfToken("testValidationPlugin:FailedValidator"), - TfToken("testValidationPlugin:FailedValidatorSuite"), - TfToken("testValidationPlugin:TestValidator2"), - TfToken("testValidationPlugin:TestValidator3") - }); - TF_AXIOM(TfTokenVector({metadata[0].name, metadata[1].name, - metadata[2].name, metadata[3].name}) == expectedValue); + TfTokenVector expectedValue( + { TfToken("testValidationPlugin:FailedValidator"), + TfToken("testValidationPlugin:FailedValidatorSuite"), + TfToken("testValidationPlugin:TestValidator2"), + TfToken("testValidationPlugin:TestValidator3") }); + TF_AXIOM(TfTokenVector({ metadata[0].name, metadata[1].name, + metadata[2].name, metadata[3].name }) + == expectedValue); } { - UsdValidatorMetadataVector metadata = - registry.GetValidatorMetadataForKeyword( - TfToken("SomeKeyword1")); + UsdValidationValidatorMetadataVector metadata + = registry.GetValidatorMetadataForKeyword(TfToken("SomeKeyword1")); TF_AXIOM(metadata.size() == 2); - TfTokenVector expectedValue({ - TfToken("testValidationPlugin:TestValidator1"), - TfToken("testValidationPlugin:TestValidator3") - }); - TF_AXIOM(TfTokenVector({metadata[0].name, metadata[1].name}) == - expectedValue); + TfTokenVector expectedValue( + { TfToken("testValidationPlugin:TestValidator1"), + TfToken("testValidationPlugin:TestValidator3") }); + TF_AXIOM(TfTokenVector({ metadata[0].name, metadata[1].name }) + == expectedValue); TF_AXIOM(!metadata[0].isSuite); TF_AXIOM(!metadata[1].isSuite); } { - const UsdValidatorSuite* suiteValidator = - registry.GetOrLoadValidatorSuiteByName( + const UsdValidationValidatorSuite *suiteValidator + = registry.GetOrLoadValidatorSuiteByName( TfToken("testValidationPlugin:TestValidatorSuite")); - const UsdValidatorMetadata &metadata = suiteValidator->GetMetadata(); - TF_AXIOM(metadata.name == TfToken( - "testValidationPlugin:TestValidatorSuite")); + const UsdValidationValidatorMetadata &metadata + = suiteValidator->GetMetadata(); + TF_AXIOM(metadata.name + == TfToken("testValidationPlugin:TestValidatorSuite")); TF_AXIOM(metadata.isSuite); TF_AXIOM(metadata.doc == "Suite of TestValidator1 and TestValidator2"); TF_AXIOM(metadata.keywords.size() == 2); - TF_AXIOM(metadata.keywords == TfTokenVector({ - TfToken("IncludedInAll"), TfToken("SuiteValidator")})); - const std::vector containedValidators = - suiteValidator->GetContainedValidators(); + TF_AXIOM(metadata.keywords + == TfTokenVector( + { TfToken("IncludedInAll"), TfToken("SuiteValidator") })); + const std::vector containedValidators + = suiteValidator->GetContainedValidators(); { - const UsdValidatorMetadata &vm = - containedValidators[0]->GetMetadata(); + const UsdValidationValidatorMetadata &vm + = containedValidators[0]->GetMetadata(); TF_AXIOM(vm.name == TfToken("testValidationPlugin:TestValidator1")); TF_AXIOM(vm.keywords.size() == 2); - TF_AXIOM(vm.keywords == TfTokenVector({ - TfToken("IncludedInAll"), TfToken("SomeKeyword1")})); + TF_AXIOM(vm.keywords + == TfTokenVector({ TfToken("IncludedInAll"), + TfToken("SomeKeyword1") })); TF_AXIOM(vm.schemaTypes.empty()); } { - const UsdValidatorMetadata &vm = - containedValidators[1]->GetMetadata(); + const UsdValidationValidatorMetadata &vm + = containedValidators[1]->GetMetadata(); TF_AXIOM(vm.name == TfToken("testValidationPlugin:TestValidator2")); TF_AXIOM(vm.keywords.size() == 1); TF_AXIOM(vm.keywords[0] == TfToken("IncludedInAll")); TF_AXIOM(vm.schemaTypes.size() == 2); - TF_AXIOM(vm.schemaTypes == TfTokenVector({ - TfToken("SomePrimType"), TfToken("SomeAPISchema")})); + TF_AXIOM(vm.schemaTypes + == TfTokenVector({ TfToken("SomePrimType"), + TfToken("SomeAPISchema") })); } } { // Try to retrieve a failed validator (stageTask for validator which // provides schemaTypes - const UsdValidator* validator = registry.GetOrLoadValidatorByName( - TfToken("testValidationPlugin:FailedValidator")); + const UsdValidationValidator *validator + = registry.GetOrLoadValidatorByName( + TfToken("testValidationPlugin:FailedValidator")); TF_AXIOM(!validator); } { - // Try to retrieve a failed validator suite (stageTask for a contained + // Try to retrieve a failed validator suite (stageTask for a contained // validator but suite provides schemaTypes - const UsdValidatorSuite* suite = registry.GetOrLoadValidatorSuiteByName( - TfToken("testValidationPlugin:FailedValidatorSuite")); + const UsdValidationValidatorSuite *suite + = registry.GetOrLoadValidatorSuiteByName( + TfToken("testValidationPlugin:FailedValidatorSuite")); TF_AXIOM(!suite); } } -int +int main() { // Register the test plugin const std::string testDir = ArchGetCwd(); TF_AXIOM(!PlugRegistry::GetInstance().RegisterPlugins(testDir).empty()); - + TestUsdValidationRegistry(); printf("OK\n"); diff --git a/pxr/usd/usd/testenv/testUsdValidationRegistry/plugInfo.json b/pxr/usdValidation/usdValidation/testenv/testUsdValidationRegistry/plugInfo.json similarity index 100% rename from pxr/usd/usd/testenv/testUsdValidationRegistry/plugInfo.json rename to pxr/usdValidation/usdValidation/testenv/testUsdValidationRegistry/plugInfo.json diff --git a/pxr/usdValidation/usdValidation/testenv/testUsdValidationRegistryPy.cpp b/pxr/usdValidation/usdValidation/testenv/testUsdValidationRegistryPy.cpp new file mode 100644 index 0000000000..f43496e1fa --- /dev/null +++ b/pxr/usdValidation/usdValidation/testenv/testUsdValidationRegistryPy.cpp @@ -0,0 +1,79 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// + +#include "pxr/pxr.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" +#include "pxr/usdValidation/usdValidation/validator.h" + +#include +#include + +PXR_NAMESPACE_USING_DIRECTIVE + +TF_REGISTRY_FUNCTION(UsdValidationRegistry) +{ + UsdValidationRegistry ®istry = UsdValidationRegistry::GetInstance(); + { + const UsdValidateStageTaskFn stageTaskFn + = [](const UsdStagePtr &usdStage) { + return UsdValidationErrorVector { UsdValidationError( + TfToken("TestValidator1"), UsdValidationErrorType::Error, + { UsdValidationErrorSite(usdStage, SdfPath("/")) }, + "This is an error on the stage") }; + }; + + std::cout << "Registering TestValidator1\n"; + // Register the validator + TfErrorMark m; + UsdValidationValidatorMetadata metadata { + TfToken("TestValidator1"), + nullptr, + { TfToken("IncludedInAll"), TfToken("SomeKeyword1") }, + "TestValidator1 for keywords metadata parsing", + {}, + false + }; + + registry.RegisterValidator(metadata, stageTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const UsdValidatePrimTaskFn primTaskFn = [](const UsdPrim & /*prim*/) { + return UsdValidationErrorVector {}; + }; + + // Register the validator + TfErrorMark m; + UsdValidationValidatorMetadata metadata { + TfToken("TestValidator2"), + nullptr, + { TfToken("IncludedInAll") }, + "TestValidator2 for schemaType metadata parsing", + { TfToken("SomePrimType"), TfToken("SomeAPISchema") }, + false + }; + registry.RegisterValidator(metadata, primTaskFn); + TF_AXIOM(m.IsClean()); + } + { + const std::vector containedValidators + = registry.GetOrLoadValidatorsByName( + { TfToken("TestValidator1"), TfToken("TestValidator2") }); + TfErrorMark m; + UsdValidationValidatorMetadata metadata { + TfToken("TestValidatorSuite"), + nullptr, + { TfToken("IncludedInAll"), TfToken("SuiteValidator") }, + "Suite of TestValidator1 and TestValidator2", + {}, + true + }; + registry.RegisterValidatorSuite(metadata, containedValidators); + TF_AXIOM(m.IsClean()); + } +} diff --git a/pxr/usd/usd/testenv/testUsdValidationRegistryPy.py b/pxr/usdValidation/usdValidation/testenv/testUsdValidationRegistryPy.py similarity index 86% rename from pxr/usd/usd/testenv/testUsdValidationRegistryPy.py rename to pxr/usdValidation/usdValidation/testenv/testUsdValidationRegistryPy.py index a9dfa85629..acb70590fb 100644 --- a/pxr/usd/usd/testenv/testUsdValidationRegistryPy.py +++ b/pxr/usdValidation/usdValidation/testenv/testUsdValidationRegistryPy.py @@ -8,7 +8,7 @@ import os import unittest -from pxr import Plug, Usd +from pxr import Plug, Usd, UsdValidation class TestUsdValidationRegistryPy(unittest.TestCase): @@ -20,11 +20,11 @@ class TestUsdValidationRegistryPy(unittest.TestCase): @classmethod def setUpClass(cls) -> None: # Register TestUsdValidationRegistryPy plugin. We assume the build - # system will install it to the UsdPlugins subdirectory in the same - # location as this test. + # system will install it to the UsdValidationPlugins subdirectory in the + # same location as this test. testPluginsDsoSearchPath = os.path.join( - os.path.dirname(__file__), - "UsdPlugins/lib/TestUsdValidationRegistryPy*/Resources/") + os.path.dirname(__file__), + "UsdValidationPlugins/lib/TestUsdValidationRegistryPy*/Resources/") try: plugins = Plug.Registry().RegisterPlugins(testPluginsDsoSearchPath) assert len(plugins) == 1 @@ -32,11 +32,11 @@ def setUpClass(cls) -> None: except RuntimeError: pass - validationRegistry = Usd.ValidationRegistry() + validationRegistry = UsdValidation.ValidationRegistry() validationRegistry.GetOrLoadAllValidators() def test_QueryValidatorsAndSuites(self): - validationRegistry = Usd.ValidationRegistry() + validationRegistry = UsdValidation.ValidationRegistry() self.assertFalse(validationRegistry.HasValidator("invalid_validator")) allValidators = validationRegistry.GetOrLoadAllValidators() @@ -70,13 +70,13 @@ def test_QueryValidatorsAndSuites(self): self.assertIn(suite, allSuites) def test_QueryMetadata(self): - validationRegistry = Usd.ValidationRegistry() + validationRegistry = UsdValidation.ValidationRegistry() invalidMetadata = validationRegistry.GetValidatorMetadata( "invalid_validator" ) self.assertFalse(invalidMetadata) - metadata: Usd.ValidatorMetadata = ( + metadata: UsdValidation.ValidatorMetadata = ( validationRegistry.GetValidatorMetadata(self.VALIDATOR1_NAME) ) expectedKeywords = ["IncludedInAll", "SomeKeyword1"] @@ -116,10 +116,10 @@ def test_QueryMetadata(self): ) self.assertTrue(metadatas) - # We put tests for Usd.Validator and Usd.ValidatorSuite here as we cannot construct - # validator directly but only through registry. + # We put tests for UsdValidation.Validator and UsdValidation.ValidatorSuite + # here as we cannot construct validator directly but only through registry. def test_ValidatorAndSuite(self): - validationRegistry = Usd.ValidationRegistry() + validationRegistry = UsdValidation.ValidationRegistry() validator = validationRegistry.GetOrLoadValidatorByName( self.VALIDATOR1_NAME ) diff --git a/pxr/usd/usd/testenv/testUsdValidator.cpp b/pxr/usdValidation/usdValidation/testenv/testUsdValidator.cpp similarity index 67% rename from pxr/usd/usd/testenv/testUsdValidator.cpp rename to pxr/usdValidation/usdValidation/testenv/testUsdValidator.cpp index 5b5950f815..2507767da3 100644 --- a/pxr/usd/usd/testenv/testUsdValidator.cpp +++ b/pxr/usdValidation/usdValidation/testenv/testUsdValidator.cpp @@ -7,30 +7,31 @@ #include "pxr/pxr.h" #include "pxr/usd/sdf/layer.h" -#include "pxr/usd/usd/validator.h" -#include "pxr/usd/usd/validationError.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/validator.h" #include PXR_NAMESPACE_USING_DIRECTIVE -static -void TestSimpleValidator() +static void +TestSimpleValidator() { - // Note that these are just to test the validator -> taskFn -> Error - // pipeline, validators should ideally be registered with the + // Note that these are just to test the validator -> taskFn -> Error + // pipeline, validators should ideally be registered with the // UsdValidationRegistry. // // Simple LayerValidator - UsdValidateLayerTaskFn validateLayerTaskFn = - [](const SdfLayerHandle& layer) { - return UsdValidationErrorVector{UsdValidationError()}; - }; - UsdValidatorMetadata metadata; + UsdValidateLayerTaskFn validateLayerTaskFn + = [](const SdfLayerHandle &layer) { + return UsdValidationErrorVector { UsdValidationError() }; + }; + UsdValidationValidatorMetadata metadata; metadata.name = TfToken("TestSimpleLayerValidator"); metadata.doc = "This is a test."; metadata.isSuite = false; - UsdValidator layerValidator = UsdValidator(metadata, validateLayerTaskFn); + UsdValidationValidator layerValidator + = UsdValidationValidator(metadata, validateLayerTaskFn); SdfLayerRefPtr testLayer = SdfLayer::CreateAnonymous(); { UsdValidationErrorVector errors = layerValidator.Validate(testLayer); @@ -54,17 +55,17 @@ void TestSimpleValidator() const TfToken expectedErrorIdentifier( "TestSimpleStageValidator.ErrorOnStage"); // Simple StageValidator - UsdValidateStageTaskFn validateStageTaskFn = - [errorName](const UsdStageRefPtr &usdStage) { - return UsdValidationErrorVector{ - UsdValidationError(errorName, - UsdValidationErrorType::Error, - {UsdValidationErrorSite( - usdStage, SdfPath::AbsoluteRootPath())}, - "This is an error on the stage")}; - }; + UsdValidateStageTaskFn validateStageTaskFn + = [errorName](const UsdStageRefPtr &usdStage) { + return UsdValidationErrorVector { UsdValidationError( + errorName, UsdValidationErrorType::Error, + { UsdValidationErrorSite(usdStage, + SdfPath::AbsoluteRootPath()) }, + "This is an error on the stage") }; + }; metadata.name = TfToken("TestSimpleStageValidator"); - UsdValidator stageValidator = UsdValidator(metadata, validateStageTaskFn); + UsdValidationValidator stageValidator + = UsdValidationValidator(metadata, validateStageTaskFn); UsdStageRefPtr usdStage = UsdStage::CreateInMemory(); { UsdValidationErrorVector errors = stageValidator.Validate(usdStage); @@ -87,8 +88,8 @@ void TestSimpleValidator() // Create a stage using the layer and validate the stage now! UsdStageRefPtr usdStageFromLayer = UsdStage::Open(testLayer); { - UsdValidationErrorVector errors = - stageValidator.Validate(usdStageFromLayer); + UsdValidationErrorVector errors + = stageValidator.Validate(usdStageFromLayer); TF_AXIOM(errors.size() == 1); TF_AXIOM(errors[0].GetIdentifier() == expectedErrorIdentifier); TF_AXIOM(!errors[0].HasNoError()); @@ -103,21 +104,19 @@ void TestSimpleValidator() // Simple SchemaTypeValidator const TfToken errorName2("ErrorOnSchemaType"); - UsdValidatePrimTaskFn validatePrimTaskFn = - [errorName2](const UsdPrim &usdPrim) { - return UsdValidationErrorVector{ - UsdValidationError(errorName2, - UsdValidationErrorType::Error, - {UsdValidationErrorSite(usdPrim.GetStage(), - usdPrim.GetPath())}, - "This is an error on the stage")}; + UsdValidatePrimTaskFn validatePrimTaskFn = [errorName2]( + const UsdPrim &usdPrim) { + return UsdValidationErrorVector { UsdValidationError( + errorName2, UsdValidationErrorType::Error, + { UsdValidationErrorSite(usdPrim.GetStage(), usdPrim.GetPath()) }, + "This is an error on the stage") }; }; metadata.name = TfToken("TestSimplePrimValidator"); - metadata.schemaTypes = {TfToken("MadeUpPrimType")}; + metadata.schemaTypes = { TfToken("MadeUpPrimType") }; const TfToken expectedErrorIdentifier2( "TestSimplePrimValidator.ErrorOnSchemaType"); - UsdValidator schemaTypeValidator = UsdValidator(metadata, - validatePrimTaskFn); + UsdValidationValidator schemaTypeValidator + = UsdValidationValidator(metadata, validatePrimTaskFn); { UsdValidationErrorVector errors = schemaTypeValidator.Validate(prim); TF_AXIOM(errors.size() == 1); @@ -137,16 +136,12 @@ void TestSimpleValidator() metadata.doc = "This is a test."; metadata.schemaTypes = {}; metadata.isSuite = true; - UsdValidatorSuite validatorSuite = UsdValidatorSuite(metadata, - { - &layerValidator, - &stageValidator, - &schemaTypeValidator - }); + UsdValidationValidatorSuite validatorSuite = UsdValidationValidatorSuite( + metadata, { &layerValidator, &stageValidator, &schemaTypeValidator }); TF_AXIOM(validatorSuite.GetContainedValidators().size() == 3); } -int +int main() { TestSimpleValidator(); diff --git a/pxr/usd/usd/testenv/testUsdValidatorMetadata.py b/pxr/usdValidation/usdValidation/testenv/testUsdValidatorMetadata.py similarity index 86% rename from pxr/usd/usd/testenv/testUsdValidatorMetadata.py rename to pxr/usdValidation/usdValidation/testenv/testUsdValidatorMetadata.py index 2b1ff499ea..9a564b70d5 100644 --- a/pxr/usd/usd/testenv/testUsdValidatorMetadata.py +++ b/pxr/usdValidation/usdValidation/testenv/testUsdValidatorMetadata.py @@ -7,12 +7,12 @@ import unittest -from pxr import Plug, Sdf, Usd +from pxr import Plug, Sdf, Usd, UsdValidation class TestUsdValidatorMetadata(unittest.TestCase): def _VerifyMetadata( self, - metadata: Usd.ValidatorMetadata, + metadata: UsdValidation.ValidatorMetadata, name="", doc="", keywords=[], @@ -28,7 +28,7 @@ def _VerifyMetadata( self.assertEqual(metadata.isSuite, isSuite) def test_CreateDefaultMetadata(self): - metadata = Usd.ValidatorMetadata() + metadata = UsdValidation.ValidatorMetadata() self._VerifyMetadata(metadata) def test_CreateMetadataWithValidKeywordArgs(self): @@ -58,7 +58,7 @@ def test_CreateMetadataWithValidKeywordArgs(self): for args in valid_metadatas: with self.subTest(name=args["name"]): - metadata = Usd.ValidatorMetadata(**args) + metadata = UsdValidation.ValidatorMetadata(**args) self._VerifyMetadata(metadata, **args) def test_CreateMetadataWithInvalidKeywordArgs(self): @@ -86,27 +86,27 @@ def test_CreateMetadataWithInvalidKeywordArgs(self): for error_category, args in invalid_metadatas.items(): with self.subTest(error_type=error_category): with self.assertRaises(Exception): - Usd.ValidatorMetadata(**args) + UsdValidation.ValidatorMetadata(**args) def test_MetadataNameImmutable(self): - metadata = Usd.ValidatorMetadata() + metadata = UsdValidation.ValidatorMetadata() with self.assertRaises(Exception): metadata.name = "test" def test_MetadataDocImmutable(self): - metadata = Usd.ValidatorMetadata() + metadata = UsdValidation.ValidatorMetadata() with self.assertRaises(Exception): metadata.doc = "doc" def test_MetadataPluginImmutable(self): all_plugins = Plug.Registry().GetAllPlugins() expected_plugin = all_plugins[0] if all_plugins else None - metadata = Usd.ValidatorMetadata() + metadata = UsdValidation.ValidatorMetadata() with self.assertRaises(Exception): metadata.plugin = expected_plugin def test_MetadataIsSuiteImmutable(self): - metadata = Usd.ValidatorMetadata() + metadata = UsdValidation.ValidatorMetadata() with self.assertRaises(Exception): metadata.isSuite = True diff --git a/pxr/usdValidation/usdValidation/validator.cpp b/pxr/usdValidation/usdValidation/validator.cpp new file mode 100644 index 0000000000..11ff11d840 --- /dev/null +++ b/pxr/usdValidation/usdValidation/validator.cpp @@ -0,0 +1,112 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// + +#include "pxr/usdValidation/usdValidation/validator.h" + +#include "pxr/usdValidation/usdValidation/error.h" + +PXR_NAMESPACE_OPEN_SCOPE + +UsdValidationValidator::UsdValidationValidator( + const UsdValidationValidatorMetadata &metadata) + : _metadata(metadata) +{ +} + +UsdValidationValidator::UsdValidationValidator( + const UsdValidationValidatorMetadata &metadata, + const UsdValidateLayerTaskFn &validateLayerTaskFn) + : _metadata(metadata) + , _validateTaskFn(validateLayerTaskFn) +{ +} + +UsdValidationValidator::UsdValidationValidator( + const UsdValidationValidatorMetadata &metadata, + const UsdValidateStageTaskFn &validateStageTaskFn) + : _metadata(metadata) + , _validateTaskFn(validateStageTaskFn) +{ +} + +UsdValidationValidator::UsdValidationValidator( + const UsdValidationValidatorMetadata &metadata, + const UsdValidatePrimTaskFn &validatePrimTaskFn) + : _metadata(metadata) + , _validateTaskFn(validatePrimTaskFn) +{ +} + +const UsdValidateLayerTaskFn * +UsdValidationValidator::_GetValidateLayerTask() const +{ + return std::get_if(&_validateTaskFn); +} + +const UsdValidateStageTaskFn * +UsdValidationValidator::_GetValidateStageTask() const +{ + return std::get_if(&_validateTaskFn); +} + +const UsdValidatePrimTaskFn * +UsdValidationValidator::_GetValidatePrimTask() const +{ + return std::get_if(&_validateTaskFn); +} + +UsdValidationErrorVector +UsdValidationValidator::Validate(const SdfLayerHandle &layer) const +{ + const UsdValidateLayerTaskFn *layerTaskFn = _GetValidateLayerTask(); + if (layerTaskFn) { + UsdValidationErrorVector errors = (*layerTaskFn)(layer); + for (UsdValidationError &error : errors) { + error._SetValidator(this); + } + return errors; + } + return {}; +} + +UsdValidationErrorVector +UsdValidationValidator::Validate(const UsdStagePtr &usdStage) const +{ + const UsdValidateStageTaskFn *stageTaskFn = _GetValidateStageTask(); + if (stageTaskFn) { + UsdValidationErrorVector errors = (*stageTaskFn)(usdStage); + for (UsdValidationError &error : errors) { + error._SetValidator(this); + } + return errors; + } + return {}; +} + +UsdValidationErrorVector +UsdValidationValidator::Validate(const UsdPrim &usdPrim) const +{ + const UsdValidatePrimTaskFn *primTaskFn = _GetValidatePrimTask(); + if (primTaskFn) { + UsdValidationErrorVector errors = (*primTaskFn)(usdPrim); + for (UsdValidationError &error : errors) { + error._SetValidator(this); + } + return errors; + } + return {}; +} + +UsdValidationValidatorSuite::UsdValidationValidatorSuite( + const UsdValidationValidatorMetadata &metadata, + const std::vector &validators) + : _metadata(metadata) + , _containedValidators(validators) +{ +} + +PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usdValidation/usdValidation/validator.h b/pxr/usdValidation/usdValidation/validator.h new file mode 100644 index 0000000000..7d6c4d259d --- /dev/null +++ b/pxr/usdValidation/usdValidation/validator.h @@ -0,0 +1,295 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// +#ifndef PXR_USD_VALIDATION_USD_VALIDATION_VALIDATOR_H +#define PXR_USD_VALIDATION_USD_VALIDATION_VALIDATOR_H + +/// \file + +#include "pxr/pxr.h" +#include "pxr/base/tf/token.h" +#include "pxr/usd/usd/stage.h" +#include "pxr/usdValidation/usdValidation/api.h" + +#include +#include +#include +#include + +PXR_NAMESPACE_OPEN_SCOPE + +class UsdValidationError; +using UsdValidationErrorVector = std::vector; +class UsdPrim; + +/// \class UsdValidationValidatorMetadata +/// +/// A structure which describes metadata for a UsdValidationValidator. +/// +/// The metadata values are populated from the plugInfo.json associated with a +/// validator's plugin. PlugInfo can provide the following validator metadata: +/// +/// - name: A required field. This metadatum stores the validator name. For +/// validators defined in a plugin, the name must be a fully qualified name +/// which includes the pluginName as well, separated by ":". This ensures, +/// plugin provided validator names are guaranteed to be unique. +/// - pluginPtr: Pointer to the plugin where a plugin based validator is +/// defined. nullptr for a non-plugin based validator. +/// - keywords: Keywords associated with this validator. +/// - doc: Doc string explaining the purpose of the validator. +/// - schemaTypes: If the validator is associated with specific schemaTypes. +/// - isSuite: If the validator represents a suite of validators. +/// +struct UsdValidationValidatorMetadata +{ + /// Name of the validator. + /// + /// For plugin provided validators, this is prefixed with the pluginName, + /// like "pluginName:testName" in order to uniquely identify these plugin + /// provided validators. + /// + /// This is a mandatory field for a ValidatorMetadata. + TfToken name; + + /// Pointer to the plugin to which a plugin based validator belongs. + /// + /// For non-plugin based validator, pluginPtr is nullptr. + PlugPluginPtr pluginPtr; + + /// list of keywords extracted for this test from the plugInfo.json + TfTokenVector keywords; + + /// doc string extracted from plugInfo.json + /// This is a mandatory field for a ValidatorMetadata. + std::string doc; + + /// list of schemaTypes names this test applies to, extracted from + /// plugInfo.json + TfTokenVector schemaTypes; + + /// whether this test represents a test suite or not + bool isSuite; +}; // UsdValidationValidatorMetadata + +using UsdValidationValidatorMetadataVector + = std::vector; + +// TODO: +// - TimeCode (Range), leaving right now for brevity. Will introduce in +// subsequent iterations. +// +// + +/// \defgroup UsdValidateTaskFn_group Validating Task Functions +/// +/// UsdValidateLayerTaskFn, UsdValidateStageTaskFn and UsdValidatePrimTaskFn +/// represent the callbacks associated with each validator's validation logic. +/// +/// Clients must provide implementation for these in their respective plugin +/// registration code. +/// @{ + +/// UsdValidateLayerTaskFn: Validation logic operating on a given SdfLayerHandle +using UsdValidateLayerTaskFn + = std::function; +/// UsdValidateStageTaskFn: Validation logic operating on a given UsdStage +using UsdValidateStageTaskFn + = std::function; +/// UsdValidatePrimTaskFn: Validation logic operating on a given UsdPrim +using UsdValidatePrimTaskFn + = std::function; + +/// @} + +/// \class UsdValidationValidator +/// +/// UsdValidationValidator is a class describing a single test. +/// +/// An instance of UsdValidationValidator is created when plugins are loaded and +/// tests are registered and cached in the UsdValidationRegistry. +/// UsdValidationValidator can consist of any one of the 3 testing tasks: +/// LayerTestingTask, StageTestingTask or PrimTestingTask, which correspond to +/// testing the given SdfLayer, an entire UsdStage or a UsdPrim respectively. +/// +/// UsdValidationValidator instances are immutable and non-copyable. Note that +/// all validators which are registered with the UsdValidationRegistry are +/// immortal. +/// +/// \sa UsdValidationRegistry +class UsdValidationValidator +{ +public: + /// Instantiate a UsdValidationValidator which has no validation logic + /// implementation. + /// + /// This is primarily used by UsdValidationValidatorSuite. + USDVALIDATION_API + explicit UsdValidationValidator( + const UsdValidationValidatorMetadata &metadata); + + UsdValidationValidator(const UsdValidationValidator &other) = delete; + UsdValidationValidator &operator=(const UsdValidationValidator &) = delete; + + UsdValidationValidator(UsdValidationValidator &&other) noexcept = default; + UsdValidationValidator &operator=(UsdValidationValidator &&) noexcept + = default; + + /// Instantiate a UsdValidationValidator which has its validation logic + /// implemented by a UsdValidateLayerTaskFn. + USDVALIDATION_API + UsdValidationValidator(const UsdValidationValidatorMetadata &metadata, + const UsdValidateLayerTaskFn &validateLayerTaskFn); + + /// Instantiate a UsdValidationValidator which has its validation logic + /// implemented by a UsdValidateStageTaskFn. + USDVALIDATION_API + UsdValidationValidator(const UsdValidationValidatorMetadata &metadata, + const UsdValidateStageTaskFn &validateStageTaskFn); + + /// Instantiate a UsdValidationValidator which has its validation logic + /// implemented by a UsdValidatePrimTaskFn. + USDVALIDATION_API + UsdValidationValidator(const UsdValidationValidatorMetadata &metadata, + const UsdValidatePrimTaskFn &validatePrimTaskFn); + + /// Return metadata associated with this Validator. + const UsdValidationValidatorMetadata &GetMetadata() const & + { + return _metadata; + } + + /// Return metadata associated with this validator by-value. + UsdValidationValidatorMetadata GetMetadata() && + { + return std::move(_metadata); + } + + /// Run validation on the given \p layer by executing the contained + /// validateTaskFn and returns UsdValidationErrorVector. + /// + /// If this Validator doesn't provide a UsdValidateLayerTaskFn, then an + /// empty vector is returned, which signifies no error. + USDVALIDATION_API + UsdValidationErrorVector Validate(const SdfLayerHandle &layer) const; + + /// Run validation on the given \p usdStage by executing the contained + /// validateTaskFn and returns UsdValidationErrorVector. + /// + /// If this Validator doesn't provide a UsdValidateStageTaskFn, then an + /// empty vector is returned, which signifies no error. + USDVALIDATION_API + UsdValidationErrorVector Validate(const UsdStagePtr &usdStage) const; + + /// Run validation on the given \p usdPrim by executing the contained + /// validateTaskFn and returns UsdValidationErrorVector. + /// + /// If this Validator doesn't provide a UsdValidatePrimTaskFn, then an + /// empty vector is returned, which signifies no error. + USDVALIDATION_API + UsdValidationErrorVector Validate(const UsdPrim &usdPrim) const; + +private: + // To make sure registry can query task types on a validator. + // Registry needs access to _GetValidatorPrimTasks, in order to determine if + // the contained validators in a suite, which provides schemaTypes metadata + // are compliant. + friend class UsdValidationRegistry; + // In order to distribute validators into different sets based on the type + // of validation to be performed, ValidationContext needs to access + // _GetValidateLayerTask, _GetValidateStageTask and _GetValidatePrimTask. + friend class UsdValidationContext; + + UsdValidationValidatorMetadata _metadata; + std::variant + _validateTaskFn; + + // Return UsdValidateLayerTaskFn if provided by the validator, else a + // nullptr. + const UsdValidateLayerTaskFn *_GetValidateLayerTask() const; + + // Return UsdValidateStageTaskFn if provided by the validator, else a + // nullptr. + const UsdValidateStageTaskFn *_GetValidateStageTask() const; + + // Return UsdValidatePrimTaskFn if provided by the validator, else a + // nullptr. + const UsdValidatePrimTaskFn *_GetValidatePrimTask() const; + +}; // UsdValidationValidator + +/// \class UsdValidationValidatorSuite +/// +/// UsdValidationValidatorSuite acts like a suite for a collection of tests, +/// which clients can use to bundle all tests relevant to test their concepts. +/// +/// If client failed to provide isSuite metadata for a +/// UsdValidationValidatorSuite instance then the validatorSuite will not be +/// registered, and client will appropriately be warned. +/// +/// UsdValidationValidatorSuite instances are immutable and non-copyable. Note +/// that all validator suites which are registered with the +/// UsdValidationRegistry are immortal. +/// +/// \sa UsdValidationRegistry +class UsdValidationValidatorSuite +{ +public: + /// Instantiate UsdValidationValidatorSuite using \p metadata and a vector + /// of \p validators. + USDVALIDATION_API + UsdValidationValidatorSuite( + const UsdValidationValidatorMetadata &metadata, + const std::vector &validators); + + UsdValidationValidatorSuite(UsdValidationValidatorSuite &&other) noexcept + = default; + + UsdValidationValidatorSuite & + operator=(UsdValidationValidatorSuite &&) noexcept + = default; + + /// Returns a vector of const UsdValidationValidator pointers, which make + /// this UsdValidationValidatorSuite. Note that the validators are + /// guaranteed to be valid, since their lifetime is managed by the + /// UsdValidationRegistry, which has a higher scope than individual + /// validators. + const std::vector & + GetContainedValidators() const & + { + return _containedValidators; + } + + /// Returns a vector of const UsdValidationValidator pointers, which make + /// this UsdValidationValidatorSuite. Note that the validators are + /// guaranteed to be valid, since their lifetime is managed by the + /// UsdValidationRegistry, which has a higher scope than individual + /// validators. + std::vector GetContainedValidators() && + { + return std::move(_containedValidators); + } + + /// Return metadata associated with this validator. + const UsdValidationValidatorMetadata &GetMetadata() const & + { + return _metadata; + } + + /// Return metadata associated with this validator. + UsdValidationValidatorMetadata GetMetadata() && + { + return std::move(_metadata); + } + +private: + UsdValidationValidatorMetadata _metadata; + std::vector _containedValidators; +}; // UsdValidationValidatorSuite + +PXR_NAMESPACE_CLOSE_SCOPE + +#endif // PXR_USD_VALIDATION_USD_VALIDATION_VALIDATOR_H diff --git a/pxr/usd/usd/validatorTokens.cpp b/pxr/usdValidation/usdValidation/validatorTokens.cpp similarity index 69% rename from pxr/usd/usd/validatorTokens.cpp rename to pxr/usdValidation/usdValidation/validatorTokens.cpp index 08b5dfceaf..f94f748080 100644 --- a/pxr/usd/usd/validatorTokens.cpp +++ b/pxr/usdValidation/usdValidation/validatorTokens.cpp @@ -5,14 +5,14 @@ // https://openusd.org/license. // -#include "pxr/usd/usd/validatorTokens.h" +#include "pxr/usdValidation/usdValidation/validatorTokens.h" PXR_NAMESPACE_OPEN_SCOPE TF_DEFINE_PUBLIC_TOKENS(UsdValidatorNameTokens, USD_VALIDATOR_NAMES_TOKENS); -TF_DEFINE_PUBLIC_TOKENS(UsdValidatorKeywordTokens, +TF_DEFINE_PUBLIC_TOKENS(UsdValidatorKeywordTokens, USD_VALIDATOR_KEYWORD_TOKENS); -TF_DEFINE_PUBLIC_TOKENS(UsdValidationErrorNameTokens, +TF_DEFINE_PUBLIC_TOKENS(UsdValidationErrorNameTokens, USD_VALIDATION_ERROR_NAME_TOKENS); PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/usdValidation/usdValidation/validatorTokens.h b/pxr/usdValidation/usdValidation/validatorTokens.h new file mode 100644 index 0000000000..bf7f5879d6 --- /dev/null +++ b/pxr/usdValidation/usdValidation/validatorTokens.h @@ -0,0 +1,52 @@ +// +// Copyright 2024 Pixar +// +// Licensed under the terms set forth in the LICENSE.txt file available at +// https://openusd.org/license. +// + +#ifndef PXR_USD_VALIDATION_USD_VALIDATION_VALIDATOR_TOKENS_H +#define PXR_USD_VALIDATION_USD_VALIDATION_VALIDATOR_TOKENS_H + +/// \file usdValidation/validatorTokens.h + +#include "pxr/pxr.h" +#include "pxr/base/tf/staticTokens.h" +#include "pxr/usdValidation/usdValidation/api.h" + +PXR_NAMESPACE_OPEN_SCOPE + +#define USD_VALIDATOR_NAME_TOKENS \ + ((compositionErrorTest, "usdValidation:CompositionErrorTest")) \ + ((stageMetadataChecker, "usdValidation:StageMetadataChecker")) + +#define USD_VALIDATOR_KEYWORD_TOKENS \ + (UsdCoreValidators) + +#define USD_VALIDATION_ERROR_NAME_TOKENS \ + ((compositionError, "CompositionError")) \ + ((missingDefaultPrim, "MissingDefaultPrim")) + +/// \def USD_VALIDATOR_NAME_TOKENS +/// Tokens representing validator names. Note that for plugin provided +/// validators, the names must be prefixed by usdValidation:, which is the name +/// of the usdValidation plugin. +TF_DECLARE_PUBLIC_TOKENS(UsdValidatorNameTokens, USDVALIDATION_API, + USD_VALIDATOR_NAME_TOKENS); + +/// \def USD_VALIDATOR_KEYWORD_TOKENS +/// Tokens representing keywords associated with any validator in the usd +/// plugin. Clients can use this to inspect validators contained within a +/// specific keywords, or use these to be added as keywords to any new +/// validator. +TF_DECLARE_PUBLIC_TOKENS(UsdValidatorKeywordTokens, USDVALIDATION_API, + USD_VALIDATOR_KEYWORD_TOKENS); + +/// \def USD_VALIDATION_ERROR_NAME_TOKENS +/// Tokens representing validation error identifier. +TF_DECLARE_PUBLIC_TOKENS(UsdValidationErrorNameTokens, USDVALIDATION_API, + USD_VALIDATION_ERROR_NAME_TOKENS); + +PXR_NAMESPACE_CLOSE_SCOPE + +#endif diff --git a/pxr/usd/usd/wrapValidationContext.cpp b/pxr/usdValidation/usdValidation/wrapContext.cpp similarity index 86% rename from pxr/usd/usd/wrapValidationContext.cpp rename to pxr/usdValidation/usdValidation/wrapContext.cpp index d6f63d3883..29e9c86983 100644 --- a/pxr/usd/usd/wrapValidationContext.cpp +++ b/pxr/usdValidation/usdValidation/wrapContext.cpp @@ -11,9 +11,9 @@ #include "pxr/usd/usd/prim.h" #include "pxr/usd/usd/primRange.h" #include "pxr/usd/usd/stage.h" -#include "pxr/usd/usd/validator.h" -#include "pxr/usd/usd/validationContext.h" -#include "pxr/usd/usd/validationError.h" +#include "pxr/usdValidation/usdValidation/validator.h" +#include "pxr/usdValidation/usdValidation/context.h" +#include "pxr/usdValidation/usdValidation/error.h" #include "pxr/base/tf/pyContainerConversions.h" #include "pxr/base/tf/pyPtrHelpers.h" @@ -36,11 +36,13 @@ void wrapUsdValidationContext() (arg("keywords"), arg("includeAllAncestors") = true))) .def(init( (arg("plugins"), arg("includeAllAncestors") = true))) - .def(init( + .def(init( (arg("metadata"), arg("includeAllAncestors") = true))) .def(init &>(arg("schemaTypes"))) - .def(init &>(arg("validators"))) - .def(init &>(arg("suites"))) + .def(init &>( + arg("validators"))) + .def(init &>( + arg("suites"))) .def("Validate", +[](const UsdValidationContext &ctx, const SdfLayerHandle &layer) -> UsdValidationErrorVector { diff --git a/pxr/usd/usd/wrapValidationError.cpp b/pxr/usdValidation/usdValidation/wrapError.cpp similarity index 96% rename from pxr/usd/usd/wrapValidationError.cpp rename to pxr/usdValidation/usdValidation/wrapError.cpp index 2cbfe1f084..dca4f1f6bd 100644 --- a/pxr/usd/usd/wrapValidationError.cpp +++ b/pxr/usdValidation/usdValidation/wrapError.cpp @@ -5,8 +5,8 @@ // https://openusd.org/license. // #include "pxr/pxr.h" -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usd/validator.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/validator.h" #include "pxr/base/tf/pyContainerConversions.h" #include "pxr/base/tf/pyEnum.h" diff --git a/pxr/usd/usd/wrapValidationRegistry.cpp b/pxr/usdValidation/usdValidation/wrapRegistry.cpp similarity index 96% rename from pxr/usd/usd/wrapValidationRegistry.cpp rename to pxr/usdValidation/usdValidation/wrapRegistry.cpp index 6399f91a40..cf54ff0469 100644 --- a/pxr/usd/usd/wrapValidationRegistry.cpp +++ b/pxr/usdValidation/usdValidation/wrapRegistry.cpp @@ -6,9 +6,9 @@ // #include "pxr/pxr.h" #include "pxr/usd/usd/prim.h" -#include "pxr/usd/usd/validationError.h" -#include "pxr/usd/usd/validationRegistry.h" -#include "pxr/usd/usd/validator.h" +#include "pxr/usdValidation/usdValidation/error.h" +#include "pxr/usdValidation/usdValidation/registry.h" +#include "pxr/usdValidation/usdValidation/validator.h" #include "pxr/base/tf/pyContainerConversions.h" #include "pxr/base/tf/pyFunction.h" @@ -75,7 +75,7 @@ list _GetOrLoadValidatorSuitesByName(UsdValidationRegistry &validationRegistry, object _GetValidatorMetadata(const UsdValidationRegistry &validationRegistry, const TfToken &name) { - UsdValidatorMetadata metadata; + UsdValidationValidatorMetadata metadata; bool success = validationRegistry.GetValidatorMetadata(name, &metadata); if (success) { diff --git a/pxr/usd/usd/wrapValidator.cpp b/pxr/usdValidation/usdValidation/wrapValidator.cpp similarity index 64% rename from pxr/usd/usd/wrapValidator.cpp rename to pxr/usdValidation/usdValidation/wrapValidator.cpp index 19aa0f6e35..9ca7545844 100644 --- a/pxr/usd/usd/wrapValidator.cpp +++ b/pxr/usdValidation/usdValidation/wrapValidator.cpp @@ -6,8 +6,8 @@ // #include "pxr/pxr.h" #include "pxr/usd/usd/prim.h" -#include "pxr/usd/usd/validator.h" -#include "pxr/usd/usd/validationError.h" +#include "pxr/usdValidation/usdValidation/validator.h" +#include "pxr/usdValidation/usdValidation/error.h" #include "pxr/base/tf/pyContainerConversions.h" #include "pxr/base/tf/pyPtrHelpers.h" @@ -25,7 +25,7 @@ using namespace pxr_boost::python; namespace { - std::string _Repr(const UsdValidator &self) + std::string _Repr(const UsdValidationValidator &self) { return std::string( TF_PY_REPR_PREFIX + @@ -33,7 +33,7 @@ namespace TfPyRepr(self.GetMetadata().name.GetString()) + ")"); } - UsdValidatorMetadata * + UsdValidationValidatorMetadata * _NewMetadata( const TfToken &name, const PlugPluginPtr &plugin, @@ -42,12 +42,12 @@ namespace const TfTokenVector &schemaTypes, bool isSuite) { - return new UsdValidatorMetadata{ + return new UsdValidationValidatorMetadata{ name, plugin, keywords, doc, schemaTypes, isSuite }; } list - _GetContainedValidators(const UsdValidatorSuite &validatorSuite) + _GetContainedValidators(const UsdValidationValidatorSuite &validatorSuite) { list result; for (const auto *validator : validatorSuite.GetContainedValidators()) @@ -59,9 +59,9 @@ namespace } // anonymous namespace -void wrapUsdValidator() +void wrapUsdValidationValidator() { - class_("ValidatorMetadata", no_init) + class_("ValidatorMetadata", no_init) .def("__init__", make_constructor(&_NewMetadata, default_call_policies(), (arg("name") = TfToken(), arg("plugin") = PlugPluginPtr(), @@ -70,67 +70,72 @@ void wrapUsdValidator() arg("schemaTypes") = TfTokenVector(), arg("isSuite") = false))) .add_property("name", make_getter( - &UsdValidatorMetadata::name, return_value_policy())) + &UsdValidationValidatorMetadata::name, + return_value_policy())) .add_property("plugin", make_getter( - &UsdValidatorMetadata::pluginPtr, + &UsdValidationValidatorMetadata::pluginPtr, return_value_policy())) - .def_readonly("doc", &UsdValidatorMetadata::doc) - .def_readonly("isSuite", &UsdValidatorMetadata::isSuite) + .def_readonly("doc", &UsdValidationValidatorMetadata::doc) + .def_readonly("isSuite", &UsdValidationValidatorMetadata::isSuite) .def("GetKeywords", - +[](const UsdValidatorMetadata &self) { + +[](const UsdValidationValidatorMetadata &self) { return self.keywords; }) .def("GetSchemaTypes", - +[](const UsdValidatorMetadata &self) { + +[](const UsdValidationValidatorMetadata &self) { return self.schemaTypes; }); - TfPyRegisterStlSequencesFromPython(); + TfPyRegisterStlSequencesFromPython(); TfPyRegisterStlSequencesFromPython(); - class_("Validator", no_init) + class_("Validator", no_init) .def("GetMetadata", - +[](const UsdValidator &validator) { + +[](const UsdValidationValidator &validator) { return validator.GetMetadata(); }, return_value_policy()) .def("Validate", - +[](const UsdValidator& validator, const SdfLayerHandle& layer) + +[](const UsdValidationValidator& validator, + const SdfLayerHandle& layer) -> UsdValidationErrorVector { return validator.Validate(layer); }, return_value_policy(), (arg("layer"))) .def("Validate", - +[](const UsdValidator& validator, const UsdStagePtr& stage) + +[](const UsdValidationValidator& validator, + const UsdStagePtr& stage) -> UsdValidationErrorVector { return validator.Validate(stage); }, return_value_policy(), (arg("stage"))) .def("Validate", - +[](const UsdValidator& validator, const UsdPrim& prim) + +[](const UsdValidationValidator& validator, const UsdPrim& prim) -> UsdValidationErrorVector { return validator.Validate(prim); }, return_value_policy(), (arg("prim"))) .def("__eq__", - +[](const UsdValidator *left, const UsdValidator *right) { + +[](const UsdValidationValidator *left, + const UsdValidationValidator *right) { return left == right; }) .def("__repr__", &_Repr); - TfPyRegisterStlSequencesFromPython(); + TfPyRegisterStlSequencesFromPython(); - class_("ValidatorSuite", no_init) + class_("ValidatorSuite", no_init) .def("GetMetadata", - +[](const UsdValidatorSuite &validatorSuite) { + +[](const UsdValidationValidatorSuite &validatorSuite) { return validatorSuite.GetMetadata(); }, return_value_policy()) .def("GetContainedValidators", &_GetContainedValidators) .def("__eq__", - +[](const UsdValidatorSuite *left, const UsdValidatorSuite *right) { + +[](const UsdValidationValidatorSuite *left, + const UsdValidationValidatorSuite *right) { return left == right; }); - TfPyRegisterStlSequencesFromPython(); + TfPyRegisterStlSequencesFromPython(); } From 2acd3a1ab52ff3283721d23d6c278103adf85d48 Mon Sep 17 00:00:00 2001 From: sunyab Date: Fri, 22 Nov 2024 13:16:43 -0800 Subject: [PATCH 128/300] usdUtils: Remove stale use of boost namespace Also some small header/namespace cleanups. (Internal change: 2347992) --- pxr/usd/usdUtils/wrapStageCache.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pxr/usd/usdUtils/wrapStageCache.cpp b/pxr/usd/usdUtils/wrapStageCache.cpp index a8ddc7ca4e..25254d14c9 100644 --- a/pxr/usd/usdUtils/wrapStageCache.cpp +++ b/pxr/usd/usdUtils/wrapStageCache.cpp @@ -5,16 +5,12 @@ // https://openusd.org/license. // #include "pxr/pxr.h" -#include "pxr/external/boost/python/def.hpp" -#include "pxr/external/boost/python.hpp" +#include "pxr/external/boost/python/class.hpp" #include "pxr/usd/usdUtils/stageCache.h" #include "pxr/base/tf/pyResultConversions.h" -using namespace std; -using namespace boost; - PXR_NAMESPACE_USING_DIRECTIVE using namespace pxr_boost::python; From 27936dcb03d2d347431eb12a9572d899e83cc988 Mon Sep 17 00:00:00 2001 From: sunyab Date: Fri, 22 Nov 2024 13:16:51 -0800 Subject: [PATCH 129/300] tf, sdf: Clean up unnecessary boost::get_pointer support Remove injection of get_pointer overloads into the boost namespace. These are no longer needed since OpenUSD does not use boost. (Internal change: 2348002) --- pxr/base/tf/refPtr.h | 16 ---------------- pxr/base/tf/weakPtrFacade.h | 13 ------------- pxr/usd/sdf/declareHandles.h | 10 ---------- 3 files changed, 39 deletions(-) diff --git a/pxr/base/tf/refPtr.h b/pxr/base/tf/refPtr.h index dc0d8f677c..37e29d2c2f 100644 --- a/pxr/base/tf/refPtr.h +++ b/pxr/base/tf/refPtr.h @@ -1299,22 +1299,6 @@ swap(TfRefPtr& lhs, TfRefPtr& rhs) lhs.swap(rhs); } -PXR_NAMESPACE_CLOSE_SCOPE - -namespace boost { - -template -T * -get_pointer(PXR_NS::TfRefPtr const& p) -{ - return get_pointer(p); -} - -} // end namespace boost - -PXR_NAMESPACE_OPEN_SCOPE - -// Extend boost::hash to support TfRefPtr. template inline size_t hash_value(const TfRefPtr& ptr) diff --git a/pxr/base/tf/weakPtrFacade.h b/pxr/base/tf/weakPtrFacade.h index 7b22e457f9..1706d42809 100644 --- a/pxr/base/tf/weakPtrFacade.h +++ b/pxr/base/tf/weakPtrFacade.h @@ -59,24 +59,11 @@ class TfWeakPtrFacadeAccess { TfWeakPtrFacadeAccess(); }; -// Provide an overload of get_pointer for WeakPtrFacade. Boost libraries do -// unqualified calls to get_pointer to get the underlying pointer from a smart -// pointer, expecting the right overload will be found by ADL. template