From 9350c1293bcad943a483cf15d64b010cc8a966c7 Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Wed, 25 Feb 2026 10:06:51 -0800 Subject: [PATCH 1/2] SceneCacheFileFormat : Support USD 25.11 --- Changes | 5 +++++ contrib/IECoreUSD/src/IECoreUSD/SceneCacheFileFormat.cpp | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/Changes b/Changes index fb17e701ec..a9d1eca421 100644 --- a/Changes +++ b/Changes @@ -8,6 +8,11 @@ Breaking Changes - SweepAndPrune.h : Removed. - RadixSort.h : Removed. +Build +----- + +- Added compatibility with USD 25.11 and 26.03. + 10.7.0.0a6 (relative to 10.7.0.0a5) ========== diff --git a/contrib/IECoreUSD/src/IECoreUSD/SceneCacheFileFormat.cpp b/contrib/IECoreUSD/src/IECoreUSD/SceneCacheFileFormat.cpp index 0a3676f941..57afcaec68 100644 --- a/contrib/IECoreUSD/src/IECoreUSD/SceneCacheFileFormat.cpp +++ b/contrib/IECoreUSD/src/IECoreUSD/SceneCacheFileFormat.cpp @@ -57,7 +57,11 @@ ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS #include "pxr/usd/sdf/layer.h" #include "pxr/usd/usd/clipsAPI.h" #include "pxr/usd/usd/prim.h" +#if PXR_VERSION >= 2511 +#include "pxr/usd/sdf/usdaFileFormat.h" +#else #include "pxr/usd/usd/usdaFileFormat.h" +#endif #include "pxr/usd/usdGeom/tokens.h" ARCH_PRAGMA_POP @@ -92,7 +96,11 @@ TF_REGISTRY_FUNCTION(TfType) UsdSceneCacheFileFormat::UsdSceneCacheFileFormat() : SdfFileFormat( UsdSceneCacheFileFormatTokens->Id, UsdSceneCacheFileFormatTokens->Version, UsdSceneCacheFileFormatTokens->Target, UsdSceneCacheFileFormatTokens->Id), +#if PXR_VERSION >= 2511 + m_usda(SdfFileFormat::FindById(SdfUsdaFileFormatTokens->Id)) +#else m_usda(SdfFileFormat::FindById(UsdUsdaFileFormatTokens->Id)) +#endif { } From 1d7bd440e5999f8ed8b80942674cd87a8897073d Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Wed, 25 Feb 2026 10:07:02 -0800 Subject: [PATCH 2/2] IECoreUSD : Remove code specific to USD 21.08 and earlier --- .../IECoreUSD/include/IECoreUSD/ShaderAlgo.h | 5 ---- .../IECoreUSD/src/IECoreUSD/PrimitiveAlgo.cpp | 4 --- .../IECoreUSD/src/IECoreUSD/ShaderAlgo.cpp | 19 +----------- contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp | 30 ------------------- 4 files changed, 1 insertion(+), 57 deletions(-) diff --git a/contrib/IECoreUSD/include/IECoreUSD/ShaderAlgo.h b/contrib/IECoreUSD/include/IECoreUSD/ShaderAlgo.h index 079bc843f9..892b8e1038 100644 --- a/contrib/IECoreUSD/include/IECoreUSD/ShaderAlgo.h +++ b/contrib/IECoreUSD/include/IECoreUSD/ShaderAlgo.h @@ -42,9 +42,7 @@ IECORE_PUSH_DEFAULT_VISIBILITY #include "pxr/usd/usdShade/material.h" #include "pxr/usd/usdShade/output.h" -#if PXR_VERSION >= 2111 #include "pxr/usd/usdLux/lightAPI.h" -#endif IECORE_POP_DEFAULT_VISIBILITY namespace IECoreUSD @@ -64,15 +62,12 @@ IECOREUSD_API IECoreScene::ShaderNetworkPtr readShaderNetwork( const pxr::UsdSha bool canReadShaderNetwork( const pxr::UsdShadeOutput &output ); IECOREUSD_API bool shaderNetworkMightBeTimeVarying( const pxr::UsdShadeOutput &output ); -#if PXR_VERSION >= 2111 /// Writes a UsdLuxLight from a shader network. IECOREUSD_API void writeLight( const IECoreScene::ShaderNetwork *shaderNetwork, pxr::UsdPrim prim ); /// Reads a ShaderNetwork from a light. IECOREUSD_API IECoreScene::ShaderNetworkPtr readLight( const pxr::UsdLuxLightAPI &light, pxr::UsdTimeCode timeCode = pxr::UsdTimeCode::Default() ); IECOREUSD_API bool lightMightBeTimeVarying( const pxr::UsdLuxLightAPI &light ); -#endif - } // namespace ShaderAlgo } // namespace IECoreUSD diff --git a/contrib/IECoreUSD/src/IECoreUSD/PrimitiveAlgo.cpp b/contrib/IECoreUSD/src/IECoreUSD/PrimitiveAlgo.cpp index edc00ff166..95a6cd15c7 100644 --- a/contrib/IECoreUSD/src/IECoreUSD/PrimitiveAlgo.cpp +++ b/contrib/IECoreUSD/src/IECoreUSD/PrimitiveAlgo.cpp @@ -385,11 +385,7 @@ bool readPrimitiveVariables( const pxr::UsdSkelRoot &skelRoot, const pxr::UsdGeo } Canceller::check( canceller ); -#if PXR_VERSION < 2011 - ::skelCache()->Populate( skelRoot ); -#else ::skelCache()->Populate( skelRoot, pxr::UsdTraverseInstanceProxies() ); -#endif Canceller::check( canceller ); pxr::UsdSkelSkinningQuery skinningQuery = ::skelCache()->GetSkinningQuery( pointBased.GetPrim() ); diff --git a/contrib/IECoreUSD/src/IECoreUSD/ShaderAlgo.cpp b/contrib/IECoreUSD/src/IECoreUSD/ShaderAlgo.cpp index 49e048f6b4..77ed4e5c4a 100644 --- a/contrib/IECoreUSD/src/IECoreUSD/ShaderAlgo.cpp +++ b/contrib/IECoreUSD/src/IECoreUSD/ShaderAlgo.cpp @@ -41,13 +41,11 @@ #include "IECore/MessageHandler.h" #include "IECore/SimpleTypedData.h" -#if PXR_VERSION >= 2111 #include "pxr/usd/usdLux/cylinderLight.h" #include "pxr/usd/usdLux/nonboundableLightBase.h" #include "pxr/usd/usdLux/sphereLight.h" #include "pxr/usd/usd/schemaRegistry.h" -#endif #include "pxr/usd/usdGeom/primvarsAPI.h" #include "pxr/usd/usdShade/utils.h" @@ -58,10 +56,6 @@ #include -#if PXR_VERSION < 2102 -#define IsContainer IsNodeGraph -#endif - namespace { @@ -82,20 +76,17 @@ std::pair shaderIdAndType( const pxr::UsdShadeConnect shader.GetShaderId( &id ); type = "surface"; } -#if PXR_VERSION >= 2111 else if( auto light = pxr::UsdLuxLightAPI( connectable ) ) { light.GetShaderIdAttr().Get( &id ); type = "light"; } -#endif return std::make_pair( id, type ); } bool writeNonStandardLightParameter( const std::string &name, const IECore::Data *value, pxr::UsdShadeConnectableAPI usdShader ) { -#if PXR_VERSION >= 2111 if( auto sphereLight = pxr::UsdLuxSphereLight( usdShader.GetPrim() ) ) { @@ -125,7 +116,6 @@ bool writeNonStandardLightParameter( const std::string &name, const IECore::Data } } -#endif return false; } @@ -133,7 +123,6 @@ void readNonStandardLightParameters( const pxr::UsdPrim &prim, IECore::CompoundD { // Just to keep us on our toes, not all light parameters are stored as UsdShade inputs, // so we have special-case code for loading those here. -#if PXR_VERSION >= 2111 if( auto sphereLight = pxr::UsdLuxSphereLight( prim ) ) { bool treatAsPoint = false; @@ -165,12 +154,10 @@ void readNonStandardLightParameters( const pxr::UsdPrim &prim, IECore::CompoundD } } } -#endif } bool nonStandardLightParametersMightBeTimeVarying( const pxr::UsdPrim &prim ) { -#if PXR_VERSION >= 2111 if( auto sphereLight = pxr::UsdLuxSphereLight( prim ) ) { if( sphereLight.GetTreatAsPointAttr().ValueMightBeTimeVarying() ) @@ -203,7 +190,7 @@ bool nonStandardLightParametersMightBeTimeVarying( const pxr::UsdPrim &prim ) } } } -#endif + return false; } @@ -636,8 +623,6 @@ bool IECoreUSD::ShaderAlgo::shaderNetworkMightBeTimeVarying( const pxr::UsdShade return shaderNetworkMightBeTimeVaryingWalk( usdSource, visited ); } -#if PXR_VERSION >= 2111 - // This is very similar to `writeShaderNetwork` but with these key differences : // // - The output shader is written as a UsdLight-derived prim rather than a UsdShadeShader. @@ -708,5 +693,3 @@ bool IECoreUSD::ShaderAlgo::lightMightBeTimeVarying( const pxr::UsdLuxLightAPI & std::unordered_set visited; return shaderNetworkMightBeTimeVaryingWalk( pxr::UsdShadeConnectableAPI( light ), visited ); } - -#endif diff --git a/contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp b/contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp index 9a6177fdfc..24dbfcab1e 100644 --- a/contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp +++ b/contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp @@ -65,9 +65,7 @@ IECORE_PUSH_DEFAULT_VISIBILITY #include "pxr/usd/usdGeom/scope.h" #include "pxr/usd/usdGeom/tokens.h" #include "pxr/usd/usdGeom/xform.h" -#if PXR_VERSION >= 2111 #include "pxr/usd/usdLux/lightAPI.h" -#endif #include "pxr/usd/usdShade/material.h" #include "pxr/usd/usdShade/materialBindingAPI.h" #include "pxr/usd/usdShade/connectableAPI.h" @@ -96,10 +94,6 @@ using namespace IECore; using namespace IECoreScene; using namespace IECoreUSD; -#if PXR_VERSION < 2011 -#define GetPrimInPrototype GetPrimInMaster -#endif - namespace { @@ -262,26 +256,15 @@ void writeSetInternal( const pxr::UsdPrim &prim, const pxr::TfToken &name, const targets.push_back( USDScene::toUSD( *it, /* relative = */ true ) ); } -#if PXR_VERSION < 2009 - - pxr::UsdCollectionAPI collection = pxr::UsdCollectionAPI::ApplyCollection( prim, validNamespacedName( name ), pxr::UsdTokens->explicitOnly ); - -#else - pxr::UsdCollectionAPI collection = pxr::UsdCollectionAPI::Apply( prim, validNamespacedName( name ) ); collection.CreateExpansionRuleAttr( pxr::VtValue( pxr::UsdTokens->explicitOnly ) ); - -#endif - collection.CreateIncludesRel().SetTargets( targets ); } using PrimPredicate = bool (pxr::UsdPrim::*)() const; boost::container::flat_map g_schemaTypeSetPredicates = { { pxr::TfToken( "__cameras" ), &pxr::UsdPrim::IsA }, -#if PXR_VERSION >= 2111 { pxr::TfToken( "__lights" ), &pxr::UsdPrim::HasAPI }, -#endif { pxr::TfToken( "usd:pointInstancers" ), &pxr::UsdPrim::IsA } }; @@ -1117,12 +1100,10 @@ bool USDScene::hasAttribute( const SceneInterface::Name &name ) const pxr::TfToken kind; return model.GetKind( &kind ); } -#if PXR_VERSION >= 2111 else if( name == g_lightAttributeName ) { return m_location->prim.HasAPI(); } -#endif else if( name == g_doubleSidedAttributeName ) { return pxr::UsdGeomGprim( m_location->prim ).GetDoubleSidedAttr().HasAuthoredValue(); @@ -1170,12 +1151,10 @@ void USDScene::attributeNames( SceneInterface::NameList &attrs ) const attrs.push_back( g_kindAttributeName ); } -#if PXR_VERSION >= 2111 if( m_location->prim.HasAPI() ) { attrs.push_back( g_lightAttributeName ); } -#endif if( pxr::UsdGeomGprim( m_location->prim ).GetDoubleSidedAttr().HasAuthoredValue() ) { @@ -1265,12 +1244,10 @@ ConstObjectPtr USDScene::readAttribute( const SceneInterface::Name &name, double pxr::TfToken value; attr.Get( &value ); return new StringData( value.GetString() ); } -#if PXR_VERSION >= 2111 else if( name == g_lightAttributeName ) { return ShaderAlgo::readLight( pxr::UsdLuxLightAPI( m_location->prim ), m_root->timeCode( time ) ); } -#endif else if( name == g_kindAttributeName ) { pxr::TfToken kind; @@ -1367,7 +1344,6 @@ void USDScene::writeAttribute( const SceneInterface::Name &name, const Object *a } else if( const IECoreScene::ShaderNetwork *shaderNetwork = runTimeCast( attribute ) ) { -#if PXR_VERSION >= 2111 if( name == g_lightAttributeName ) { ShaderAlgo::writeLight( shaderNetwork, m_location->prim ); @@ -1377,10 +1353,6 @@ void USDScene::writeAttribute( const SceneInterface::Name &name, const Object *a const auto &[output, purpose] = materialOutputAndPurpose( name.string() ); m_materials[purpose][output] = shaderNetwork; } -#else - const auto &[output, purpose] = materialOutputAndPurpose( name.string() ); - m_materials[purpose][output] = shaderNetwork; -#endif } else if( name.string() == "gaffer:globals" ) { @@ -1750,13 +1722,11 @@ void USDScene::attributesHash( double time, IECore::MurmurHash &h ) const // Kind can not be animated so no need to update `mightBeTimeVarying`. } -#if PXR_VERSION >= 2111 if( m_location->prim.HasAPI() ) { mightBeTimeVarying = mightBeTimeVarying || ShaderAlgo::lightMightBeTimeVarying( pxr::UsdLuxLightAPI( m_location->prim ) ); haveAttributes = true; } -#endif auto doubleSidedAttr = pxr::UsdGeomGprim( m_location->prim ).GetDoubleSidedAttr(); if( doubleSidedAttr && doubleSidedAttr.HasAuthoredValue() )