Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAYA-129258 - MayaUsd: remove support for USD < v21.11 #3128

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ message(STATUS " Python_EXECUTABLE = ${Python_EXECUTABLE}")

include(cmake/jinja.cmake)

find_package(USD 0.20.05 REQUIRED)
find_package(USD 0.21.11 REQUIRED)
if (CMAKE_WANT_MATERIALX_BUILD)
# Requires at least USD 21.08 for hdMtlx module and USD must have been built with MaterialX:
if(NOT TARGET hdMtlx)
Expand Down
17 changes: 4 additions & 13 deletions cmake/compiler_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,10 @@ set(CMAKE_CXX_EXTENSIONS OFF)

function(mayaUsd_compile_config TARGET)
# required compiler feature
# Require C++14 if we're either building for Maya 2019 or later, or if we're building against
# USD 20.05 or later. Otherwise require C++11.
if ((MAYA_APP_VERSION VERSION_GREATER_EQUAL 2019) OR (PXR_VERSION VERSION_GREATER_EQUAL 2005))
target_compile_features(${TARGET}
PRIVATE
cxx_std_14
)
else()
target_compile_features(${TARGET}
PRIVATE
cxx_std_11
)
endif()
target_compile_features(${TARGET}
PRIVATE
cxx_std_14
)
if(IS_GNU OR IS_CLANG)
target_compile_options(${TARGET}
PRIVATE
Expand Down
39 changes: 10 additions & 29 deletions cmake/modules/FindUSD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,14 @@ get_filename_component(PXR_USD_LOCATION "${USD_CONFIG_FILE}" DIRECTORY)

include(${USD_CONFIG_FILE})

if(DEFINED PXR_VERSION)
# Starting in core USD 21.05, pxrConfig.cmake provides the various USD
# version numbers as CMake variables, in which case PXR_VERSION should have
# been defined, along with the major, minor, and patch version numbers, so
# there is no need to extract them from the pxr/pxr.h header file anymore.
# The only thing we need to do is assemble the USD_VERSION version string.
set(USD_VERSION ${PXR_MAJOR_VERSION}.${PXR_MINOR_VERSION}.${PXR_PATCH_VERSION})
elseif(USD_INCLUDE_DIR AND EXISTS "${USD_INCLUDE_DIR}/pxr/pxr.h")
foreach(_usd_comp MAJOR MINOR PATCH)
file(STRINGS
"${USD_INCLUDE_DIR}/pxr/pxr.h"
_usd_tmp
REGEX "#define PXR_${_usd_comp}_VERSION .*$")
string(REGEX MATCHALL "[0-9]+" USD_${_usd_comp}_VERSION ${_usd_tmp})
endforeach()
set(USD_VERSION ${USD_MAJOR_VERSION}.${USD_MINOR_VERSION}.${USD_PATCH_VERSION})
math(EXPR PXR_VERSION "${USD_MAJOR_VERSION} * 10000 + ${USD_MINOR_VERSION} * 100 + ${USD_PATCH_VERSION}")
if(NOT DEFINED PXR_VERSION)
message(FATAL_ERROR "Expected PXR_VERSION defined in pxrConfig.cmake")
endif()
# Starting in core USD 21.05, pxrConfig.cmake provides the various USD
# version numbers as CMake variables, in which case PXR_VERSION should have
# been defined, along with the major, minor, and patch version numbers.
# The only thing we need to do is assemble the USD_VERSION version string.
set(USD_VERSION ${PXR_MAJOR_VERSION}.${PXR_MINOR_VERSION}.${PXR_PATCH_VERSION})

# Set special Autodesk USD version. We use this to communicate whether or not
# there are extra patches on-top of the normal USD build.
Expand All @@ -81,22 +71,13 @@ if (USD_VERSION VERSION_LESS "0.23.02")
endif()
endif()

# Note that on Windows with USD <= 0.19.11, USD_LIB_PREFIX should be left at
# default (or set to empty string), even if PXR_LIB_PREFIX was specified when
# building core USD, due to a bug.

# On all other platforms / versions, it should match the PXR_LIB_PREFIX used
# USD_LIB_PREFIX should match the PXR_LIB_PREFIX used
# for building USD (and shouldn't need to be touched if PXR_LIB_PREFIX was not
# used / left at it's default value). Starting with USD 21.11, the default
# value for PXR_LIB_PREFIX was changed to include "usd_".

if (USD_VERSION VERSION_GREATER_EQUAL "0.21.11")
set(USD_LIB_PREFIX "${CMAKE_SHARED_LIBRARY_PREFIX}usd_"
CACHE STRING "Prefix of USD libraries; generally matches the PXR_LIB_PREFIX used when building core USD")
else()
set(USD_LIB_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}
CACHE STRING "Prefix of USD libraries; generally matches the PXR_LIB_PREFIX used when building core USD")
endif()
set(USD_LIB_PREFIX "${CMAKE_SHARED_LIBRARY_PREFIX}usd_"
CACHE STRING "Prefix of USD libraries; generally matches the PXR_LIB_PREFIX used when building core USD")

if (WIN32)
# ".lib" on Windows
Expand Down
8 changes: 4 additions & 4 deletions doc/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ Before building the project, consult the following table to ensure you use the r

#### 2. Download and Build Pixar USD

See Pixar's official github page for instructions on how to build USD: https://github.com/PixarAnimationStudios/USD . Pixar has recently removed support for building Maya USD libraries/plug-ins in their github repository and ```build_usd.py```. When building the maya-usd project, it is important the recommended ```Pixar USD``` commitID or tag from the table below are used:
See Pixar's official github page for instructions on how to build USD: https://github.com/PixarAnimationStudios/USD . Pixar has removed support for building Maya USD libraries/plug-ins in their github repository and ```build_usd.py```. When building the maya-usd project, it is important the recommended ```Pixar USD``` commitID or tag from the table below are used:

| | ![](images/pxr.png) |
|:------------: |:---------------: |
| CommitID/Tags | release: [v21.02](https://github.com/PixarAnimationStudios/USD/releases/tag/v21.02) or [v21.05](https://github.com/PixarAnimationStudios/USD/releases/tag/v21.05) or [v21.08](https://github.com/PixarAnimationStudios/USD/releases/tag/v21.08) or [v21.11](https://github.com/PixarAnimationStudios/USD/releases/tag/v21.11) or [v22.05b](https://github.com/PixarAnimationStudios/USD/releases/tag/v22.05b) or [v22.08](https://github.com/PixarAnimationStudios/USD/releases/tag/v22.08) or [v22.11](https://github.com/PixarAnimationStudios/USD/releases/tag/v22.11)<br> dev: [97d2ba3 (tag v23.02)](https://github.com/PixarAnimationStudios/USD/commit/97d2ba37cc8749b147694d0dd5f9e7127e1b6919) |
| | ![](images/pxr.png) | USD version used in Maya |
|:------------: |:---------------: |:------------------------:|
| CommitID/Tags | release: [v21.11](https://github.com/PixarAnimationStudios/USD/releases/tag/v21.11) or [v22.05b](https://github.com/PixarAnimationStudios/USD/releases/tag/v22.05b) or [v22.08](https://github.com/PixarAnimationStudios/USD/releases/tag/v22.08) or [v22.11](https://github.com/PixarAnimationStudios/USD/releases/tag/v22.11)<br> dev: [97d2ba3 (tag v23.02)](https://github.com/PixarAnimationStudios/USD/commit/97d2ba37cc8749b147694d0dd5f9e7127e1b6919) | Maya 2022 = v21.11<br>Maya 2023 = v21.11<br>Maya 2024 = v22.11 |

For additional information on building Pixar USD, see the ***Additional Build Instruction*** section below.

Expand Down
13 changes: 2 additions & 11 deletions lib/mayaUsd/fileio/jobs/readJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,12 +540,7 @@ void UsdMaya_ReadJob::_DoImportInstanceIt(
if (!primIt.IsPostVisit()) {
return;
}
const UsdPrim prototype =
#if PXR_VERSION < 2011
prim.GetMaster();
#else
prim.GetPrototype();
#endif
const UsdPrim prototype = prim.GetPrototype();
if (!prototype) {
return;
}
Expand Down Expand Up @@ -650,11 +645,7 @@ bool UsdMaya_ReadJob::_DoImport(UsdPrimRange& rootRange, const UsdPrim& usdRootP
UsdMayaPrimReaderContext readCtx(&mNewNodeRegistry);
readCtx.SetTimeSampleMultiplier(mTimeSampleMultiplier);

#if PXR_VERSION < 2011
auto prototypes = usdRootPrim.GetStage()->GetMasters();
#else
auto prototypes = usdRootPrim.GetStage()->GetPrototypes();
#endif
auto prototypes = usdRootPrim.GetStage()->GetPrototypes();
const int loopSize = prototypes.size();
MayaUsd::ProgressBarLoopScope prototypesLoop(loopSize);
for (const auto& prototype : prototypes) {
Expand Down
13 changes: 0 additions & 13 deletions lib/mayaUsd/fileio/shading/shadingModeUseRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,7 @@ class UseRegistryShadingModeImporter
// renderContext is not found. Therefore we need to test first that the
// render context output we are looking for really exists:
if (shadeMaterial.GetSurfaceOutput(renderContext)) {
#if PXR_VERSION > 2105
UsdShadeShader surfaceShader = shadeMaterial.ComputeSurfaceSource({ renderContext });
#else
UsdShadeShader surfaceShader = shadeMaterial.ComputeSurfaceSource(renderContext);
#endif
if (surfaceShader) {
const TfToken surfaceShaderPlugName = _context->GetSurfaceShaderPlugName();
if (!surfaceShaderPlugName.IsEmpty()) {
Expand All @@ -460,11 +456,7 @@ class UseRegistryShadingModeImporter
}

if (shadeMaterial.GetVolumeOutput(renderContext)) {
#if PXR_VERSION > 2105
UsdShadeShader volumeShader = shadeMaterial.ComputeVolumeSource({ renderContext });
#else
UsdShadeShader volumeShader = shadeMaterial.ComputeVolumeSource(renderContext);
#endif
if (volumeShader) {
const TfToken volumeShaderPlugName = _context->GetVolumeShaderPlugName();
if (!volumeShaderPlugName.IsEmpty()) {
Expand All @@ -474,13 +466,8 @@ class UseRegistryShadingModeImporter
}

if (shadeMaterial.GetDisplacementOutput(renderContext)) {
#if PXR_VERSION > 2105
UsdShadeShader displacementShader
= shadeMaterial.ComputeDisplacementSource({ renderContext });
#else
UsdShadeShader displacementShader
= shadeMaterial.ComputeDisplacementSource(renderContext);
#endif
if (displacementShader) {
const TfToken displacementShaderPlugName
= _context->GetDisplacementShaderPlugName();
Expand Down
46 changes: 7 additions & 39 deletions lib/mayaUsd/fileio/translators/translatorLight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@
#include <pxr/usd/usd/prim.h>
#include <pxr/usd/usd/stage.h>
#include <pxr/usd/usdLux/distantLight.h>
#if PXR_VERSION < 2111
#include <pxr/usd/usdLux/light.h>
#else
#include <pxr/usd/usdLux/lightAPI.h>
#endif
#include <pxr/usd/usdLux/rectLight.h>
#include <pxr/usd/usdLux/shadowAPI.h>
#include <pxr/usd/usdLux/shapingAPI.h>
Expand Down Expand Up @@ -85,12 +81,8 @@ TF_DEFINE_PRIVATE_TOKENS(

// Export the "common" light attributes from MFnLights to UsdLuxLightAPI
bool UsdMayaTranslatorLight::WriteLightAttrs(
const UsdTimeCode& usdTime,
#if PXR_VERSION < 2111
const UsdLuxLight& usdLight,
#else
const UsdLuxLightAPI& usdLight,
#endif
const UsdTimeCode& usdTime,
const UsdLuxLightAPI& usdLight,
MFnLight& mayaLight,
UsdUtilsSparseValueWriter* valueWriter)
{
Expand Down Expand Up @@ -148,11 +140,7 @@ bool UsdMayaTranslatorLight::WriteLightAttrs(
// accessors, as we need to support animations. Instead we're getting
// the Maya plugs from MFnDependencyNode
static bool _ReadLightAttrs(
#if PXR_VERSION < 2111
const UsdLuxLight& lightSchema,
#else
const UsdLuxLightAPI& lightSchema,
#endif
const UsdLuxLightAPI& lightSchema,
MFnDependencyNode& depFn,
const UsdMayaPrimReaderArgs& args,
UsdMayaPrimReaderContext& context)
Expand Down Expand Up @@ -229,11 +217,7 @@ bool UsdMayaTranslatorLight::WriteDirectionalLightAttrs(

// Import the specialized MFnDirectionalLight attributes
static bool _ReadDirectionalLight(
#if PXR_VERSION < 2111
const UsdLuxLight& lightSchema,
#else
const UsdLuxLightAPI& lightSchema,
#endif
const UsdLuxLightAPI& lightSchema,
MFnDependencyNode& depFn,
const UsdMayaPrimReaderArgs& args,
UsdMayaPrimReaderContext& context)
Expand Down Expand Up @@ -274,11 +258,7 @@ bool UsdMayaTranslatorLight::WritePointLightAttrs(

// Import the specialized MFnPointLight attributes
static bool _ReadPointLight(
#if PXR_VERSION < 2111
const UsdLuxLight& lightSchema,
#else
const UsdLuxLightAPI& lightSchema,
#endif
const UsdLuxLightAPI& lightSchema,
MFnDependencyNode& depFn,
const UsdMayaPrimReaderArgs& args,
UsdMayaPrimReaderContext& context)
Expand Down Expand Up @@ -346,11 +326,7 @@ bool UsdMayaTranslatorLight::WriteSpotLightAttrs(

// Import the specialized MFnSpotLight attributes
static bool _ReadSpotLight(
#if PXR_VERSION < 2111
const UsdLuxLight& lightSchema,
#else
const UsdLuxLightAPI& lightSchema,
#endif
const UsdLuxLightAPI& lightSchema,
MFnDependencyNode& depFn,
const UsdMayaPrimReaderArgs& args,
UsdMayaPrimReaderContext& context)
Expand Down Expand Up @@ -429,11 +405,7 @@ bool UsdMayaTranslatorLight::WriteAreaLightAttrs(

/// Read the parameters from UsdLuxRectLight into a Maya area light
static bool _ReadAreaLight(
#if PXR_VERSION < 2111
const UsdLuxLight& lightSchema,
#else
const UsdLuxLightAPI& lightSchema,
#endif
const UsdLuxLightAPI& lightSchema,
MFnDependencyNode& depFn,
const UsdMayaPrimReaderArgs& args,
UsdMayaPrimReaderContext& context)
Expand Down Expand Up @@ -462,11 +434,7 @@ bool UsdMayaTranslatorLight::Read(
if (!usdPrim) {
return false;
}
#if PXR_VERSION < 2111
const UsdLuxLight lightSchema(usdPrim);
#else
const UsdLuxLightAPI lightSchema(usdPrim);
#endif
if (!lightSchema) {
TF_RUNTIME_ERROR(
"Failed to read UsdLuxLightAPI prim for light %s", usdPrim.GetPath().GetText());
Expand Down
12 changes: 2 additions & 10 deletions lib/mayaUsd/fileio/translators/translatorLight.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@

#include <pxr/pxr.h>
#include <pxr/usd/usdLux/distantLight.h>
#if PXR_VERSION < 2111
#include <pxr/usd/usdLux/light.h>
#else
#include <pxr/usd/usdLux/lightAPI.h>
#endif
#include <pxr/usd/usdLux/rectLight.h>
#include <pxr/usd/usdLux/sphereLight.h>

Expand All @@ -48,12 +44,8 @@ struct UsdMayaTranslatorLight
/// Return true if all the parameters were exported properly.
MAYAUSD_CORE_PUBLIC
static bool WriteLightAttrs(
const UsdTimeCode& usdTime,
#if PXR_VERSION < 2111
const UsdLuxLight& usdLight,
#else
const UsdLuxLightAPI& usdLight,
#endif
const UsdTimeCode& usdTime,
const UsdLuxLightAPI& usdLight,
MFnLight& mayaLight,
UsdUtilsSparseValueWriter* valueWriter = nullptr);

Expand Down
Loading