66//
77#include " pxr/imaging/hdSt/materialXShaderGen.h"
88#include " pxr/imaging/hdSt/materialXFilter.h"
9+ #include " pxr/imaging/hdMtlx/combinedMtlxVersion.h"
910#include " pxr/base/tf/stringUtils.h"
1011
1112#include < MaterialXCore/Value.h>
@@ -263,15 +264,6 @@ HdStMaterialXShaderGen<Base>::_EmitMxSurfaceShader(
263264 // closure/shader nodes and need to be emitted first.
264265 Base::emitFunctionCalls (mxGraph, mxContext, mxStage,
265266 mx::ShaderNode::Classification::TEXTURE);
266-
267- #if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION == 38 && \
268- MATERIALX_BUILD_VERSION <= 4
269- // Emit function calls for all surface shader nodes.
270- // These will internally emit their closure function calls.
271- Base::emitFunctionCalls (mxGraph, mxContext, mxStage,
272- mx::ShaderNode::Classification::SHADER |
273- mx::ShaderNode::Classification::SURFACE);
274- #else
275267 // Emit function calls for "root" closure/shader nodes.
276268 // These will internally emit function calls for any dependent
277269 // closure nodes upstream.
@@ -289,7 +281,6 @@ HdStMaterialXShaderGen<Base>::_EmitMxSurfaceShader(
289281 }
290282 }
291283 }
292- #endif
293284 }
294285 else {
295286 // No surface shader graph so just generate all
@@ -303,7 +294,7 @@ HdStMaterialXShaderGen<Base>::_EmitMxSurfaceShader(
303294 if (outputConnection) {
304295
305296 std::string finalOutput = outputConnection->getVariable ();
306- #if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION <= 38
297+ #if MTLX_COMBINED_VERSION < 13900
307298 // channels feature removed in MaterialX 1.39
308299 const std::string& channels = outputSocket->getChannels ();
309300 if (!channels.empty ()) {
@@ -312,7 +303,6 @@ HdStMaterialXShaderGen<Base>::_EmitMxSurfaceShader(
312303 channels, outputSocket->getType ());
313304 }
314305#endif
315-
316306 if (mxGraph.hasClassification (
317307 mx::ShaderNode::Classification::SURFACE)) {
318308 if (mxContext.getOptions ().hwTransparency ) {
@@ -840,19 +830,6 @@ HdStMaterialXShaderGen<Base>::_EmitDataStructsAndFunctionDefinitions(
840830 mxContext, mxStage);
841831 }
842832
843- // Prior to MaterialX 1.38.5 the token substitutions need to
844- // include the full path to the .glsl files, so we prepend that
845- // here.
846- #if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION == 38
847- #if MATERIALX_BUILD_VERSION < 4
848- (*tokenSubstitutions)[mx::ShaderGenerator::T_FILE_TRANSFORM_UV].insert (
849- 0 , " stdlib/" + Base::TARGET + " /lib/" );
850- #elif MATERIALX_BUILD_VERSION == 4
851- (*tokenSubstitutions)[mx::ShaderGenerator::T_FILE_TRANSFORM_UV].insert (
852- 0 , " libraries/stdlib/" + Base::TARGET + " /lib/" );
853- #endif
854- #endif
855-
856833 // Add light sampling functions
857834 Base::emitLightFunctionDefinitions (mxGraph, mxContext, mxStage);
858835
@@ -895,9 +872,7 @@ namespace {
895872template <>
896873HdStMaterialXShaderGen<mx::GlslShaderGenerator>::HdStMaterialXShaderGen(
897874 HdSt_MxShaderGenInfo const & mxHdInfo)
898- #if (MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION <= 38) || \
899- (MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION <= 39 && \
900- MATERIALX_BUILD_VERSION <= 2 )
875+ #if MTLX_COMBINED_VERSION <= 13902
901876 : mx::GlslShaderGenerator(),
902877#else
903878 : mx::GlslShaderGenerator(mx::TypeSystem::create()),
@@ -1052,9 +1027,7 @@ namespace {
10521027template <>
10531028HdStMaterialXShaderGen<mx::VkShaderGenerator>::HdStMaterialXShaderGen(
10541029 HdSt_MxShaderGenInfo const & mxHdInfo)
1055- #if (MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION <= 38) || \
1056- (MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION <= 39 && \
1057- MATERIALX_BUILD_VERSION <= 2 )
1030+ #if MTLX_COMBINED_VERSION <= 13902
10581031 : mx::VkShaderGenerator(),
10591032#else
10601033 : mx::VkShaderGenerator(mx::TypeSystem::create()),
@@ -1208,9 +1181,7 @@ namespace {
12081181template <>
12091182HdStMaterialXShaderGen<mx::MslShaderGenerator>::HdStMaterialXShaderGen(
12101183 HdSt_MxShaderGenInfo const & mxHdInfo)
1211- #if (MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION <= 38) || \
1212- (MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION <= 39 && \
1213- MATERIALX_BUILD_VERSION <= 2 )
1184+ #if MTLX_COMBINED_VERSION <= 13902
12141185 : mx::MslShaderGenerator(),
12151186#else
12161187 : mx::MslShaderGenerator(mx::TypeSystem::create()),
@@ -1398,7 +1369,7 @@ HdStMaterialXShaderGenMsl::_EmitMxFunctions(
13981369bool
13991370HdStMaterialXHelpers::MxTypeIsNone (mx::TypeDesc typeDesc)
14001371{
1401- #if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION <= 38
1372+ #if MTLX_COMBINED_VERSION < 13900
14021373 return typeDesc == *mx::Type::NONE;
14031374#else
14041375 return typeDesc == mx::Type::NONE;
@@ -1408,7 +1379,7 @@ HdStMaterialXHelpers::MxTypeIsNone(mx::TypeDesc typeDesc)
14081379bool
14091380HdStMaterialXHelpers::MxTypeIsSurfaceShader (mx::TypeDesc typeDesc)
14101381{
1411- #if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION <= 38
1382+ #if MTLX_COMBINED_VERSION < 13900
14121383 return typeDesc == *mx::Type::SURFACESHADER;
14131384#else
14141385 return typeDesc == mx::Type::SURFACESHADER;
@@ -1418,7 +1389,7 @@ HdStMaterialXHelpers::MxTypeIsSurfaceShader(mx::TypeDesc typeDesc)
14181389bool
14191390HdStMaterialXHelpers::MxTypeDescIsFilename (const mx::TypeDesc typeDesc)
14201391{
1421- #if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION <= 38
1392+ #if MTLX_COMBINED_VERSION < 13900
14221393 return typeDesc == *mx::Type::FILENAME;
14231394#else
14241395 return typeDesc == mx::Type::FILENAME;
@@ -1428,7 +1399,7 @@ HdStMaterialXHelpers::MxTypeDescIsFilename(const mx::TypeDesc typeDesc)
14281399const mx::TypeDesc
14291400HdStMaterialXHelpers::GetMxTypeDesc (const mx::ShaderPort* port)
14301401{
1431- #if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION <= 38
1402+ #if MTLX_COMBINED_VERSION < 13900
14321403 return port->getType () ? *(port->getType ()) : *mx::Type::NONE;
14331404#else
14341405 return port->getType ();
@@ -1441,13 +1412,12 @@ HdStMaterialXHelpers::MxGetTypeString(
14411412 const mx::GenContext& mxContext,
14421413 const std::string& typeName)
14431414{
1444- #if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION <= 38
1415+ #if MTLX_COMBINED_VERSION < 13900
14451416 const mx::TypeDesc* mxType = mx::TypeDesc::get (typeName);
14461417 if (!mxType) {
14471418 return mx::Type::NONE->getName ();
14481419 }
1449- #elif MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION == 39 && \
1450- MATERIALX_BUILD_VERSION <=2
1420+ #elif MTLX_COMBINED_VERSION <= 13902
14511421 const mx::TypeDesc mxType = mx::TypeDesc::get (typeName);
14521422#else
14531423 const mx::TypeDesc mxType = mxContext.getTypeDesc (typeName);
@@ -1458,7 +1428,7 @@ HdStMaterialXHelpers::MxGetTypeString(
14581428const std::string&
14591429HdStMaterialXHelpers::GetVector2Name ()
14601430{
1461- #if MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION <= 38
1431+ #if MTLX_COMBINED_VERSION < 13900
14621432 return mx::Type::VECTOR2->getName ();
14631433#else
14641434 return mx::Type::VECTOR2.getName ();
0 commit comments