1212#include < MaterialXGenShader/Shader.h>
1313#include < MaterialXGenShader/ShaderGenerator.h>
1414#include < MaterialXGenShader/Syntax.h>
15+ #if defined(PXR_OPENGL_SUPPORT_ENABLED)
1516#include < MaterialXGenGlsl/Nodes/SurfaceNodeGlsl.h>
17+ #endif
18+ #if defined(PXR_METAL_SUPPORT_ENABLED)
1619#include < MaterialXGenMsl/Nodes/SurfaceNodeMsl.h>
20+ #endif
1721#include < MaterialXGenMsl/MslResourceBindingContext.h>
1822#include < MaterialXGenMsl/MslShaderGenerator.h>
1923
@@ -482,10 +486,14 @@ HdStMaterialXShaderGen<Base>::_EmitMxVertexDataDeclarations(
482486 const std::string &targetShadingLanguage = Base::getTarget ();
483487
484488 // add beginning ( or {
489+ #if defined(PXR_GL_SUPPORT_ENABLED)
485490 if (targetShadingLanguage == mx::GlslShaderGenerator::TARGET) {
486491 line += " (" ;
487492 }
488493 else if (targetShadingLanguage == mx::MslShaderGenerator::TARGET) {
494+ #elif defined(PXR_METAL_SUPPORT_ENABLED)
495+ if (targetShadingLanguage == mx::MslShaderGenerator::TARGET) {
496+ #endif
489497 line += " {" ;
490498 }
491499 else {
@@ -500,13 +508,16 @@ HdStMaterialXShaderGen<Base>::_EmitMxVertexDataDeclarations(
500508 }
501509
502510 // add ending ) or }
511+ #if defined(PXR_OPENGL_SUPPORT_ENABLED)
503512 if (targetShadingLanguage == mx::GlslShaderGenerator::TARGET) {
504513 line += " )" ;
505514 }
506515 else if (targetShadingLanguage == mx::MslShaderGenerator::TARGET) {
516+ #elif defined(PXR_METAL_SUPPORT_ENABLED)
517+ if (targetShadingLanguage == mx::MslShaderGenerator::TARGET) {
507518 line += " }" ;
508519 }
509-
520+ #endif
510521 emitLine (line, mxStage);
511522}
512523
@@ -776,17 +787,23 @@ HdStMaterialXShaderGen<Base>::_EmitDataStructsAndFunctionDefinitions(
776787 }
777788 if (shadowing) {
778789 mx::ShaderGenerator::emitLibraryInclude (
779- " pbrlib/" + mx::GlslShaderGenerator::TARGET
780- + " /lib/mx_shadow.glsl" , mxContext, mxStage);
790+ " pbrlib/"
791+ #if defined(PXR_OPENGL_SUPPORT_ENABLED)
792+ + mx::GlslShaderGenerator::TARGET + " /" +
793+ #endif
794+ " lib/mx_shadow.glsl" , mxContext, mxStage);
781795 }
782796
783797 // Emit directional albedo table code.
784798 if (mxContext.getOptions ().hwDirectionalAlbedoMethod ==
785799 mx::HwDirectionalAlbedoMethod::DIRECTIONAL_ALBEDO_TABLE ||
786800 mxContext.getOptions ().hwWriteAlbedoTable ) {
787801 mx::ShaderGenerator::emitLibraryInclude (
788- " pbrlib/" + mx::GlslShaderGenerator::TARGET
789- + " /lib/mx_table.glsl" , mxContext, mxStage);
802+ " pbrlib/"
803+ #if defined(PXR_OPENGL_SUPPORT_ENABLED)
804+ + mx::GlslShaderGenerator::TARGET + " /" +
805+ #endif
806+ " lib/mx_table.glsl" , mxContext, mxStage);
790807 Base::emitLineBreak (mxStage);
791808 }
792809
@@ -832,7 +849,7 @@ HdStMaterialXShaderGen<Base>::_EmitDataStructsAndFunctionDefinitions(
832849// ----------------------------------------------------------------------------
833850// HdSt MaterialX ShaderGen OpenGL GLSL
834851// ----------------------------------------------------------------------------
835-
852+ # if defined(PXR_OPENGL_SUPPORT_ENABLED)
836853namespace {
837854 // Create a customized version of the class mx::SurfaceNodeGlsl
838855 // to be able to notify the shader generator when we start/end
@@ -982,7 +999,9 @@ HdStMaterialXShaderGenGlsl::_EmitMxFunctions(
982999 _EmitDataStructsAndFunctionDefinitions (
9831000 mxGraph, mxContext, mxStage, &_tokenSubstitutions);
9841001}
1002+ #endif
9851003
1004+ #if defined(PXR_VULKAN_SUPPORT_ENABLED)
9861005// ----------------------------------------------------------------------------
9871006// HdSt MaterialX ShaderGen Vulkan GLSL
9881007// ----------------------------------------------------------------------------
@@ -1134,7 +1153,9 @@ HdStMaterialXShaderGenVkGlsl::_EmitMxFunctions(
11341153 _EmitDataStructsAndFunctionDefinitions (
11351154 mxGraph, mxContext, mxStage, &_tokenSubstitutions);
11361155}
1156+ #endif
11371157
1158+ #if defined(PXR_METAL_SUPPORT_ENABLED)
11381159// ----------------------------------------------------------------------------
11391160// HdSt MaterialX ShaderGen Metal
11401161// ----------------------------------------------------------------------------
@@ -1295,11 +1316,17 @@ HdStMaterialXShaderGenMsl::_EmitMxFunctions(
12951316 mx::ShaderStage& mxStage) const
12961317{
12971318 mx::ShaderGenerator::emitLibraryInclude (
1298- " pbrlib/" + mx::GlslShaderGenerator::TARGET
1299- + " /lib/mx_microfacet.glsl" , mxContext, mxStage);
1319+ " pbrlib/"
1320+ #if defined(PXR_OPENGL_SUPPORT_ENABLED)
1321+ + mx::GlslShaderGenerator::TARGET + " /" +
1322+ #endif
1323+ " lib/mx_microfacet.glsl" , mxContext, mxStage);
13001324 mx::ShaderGenerator::emitLibraryInclude (
1301- " stdlib/" + mx::MslShaderGenerator::TARGET
1302- + " /lib/mx_math.metal" , mxContext, mxStage);
1325+ " stdlib/"
1326+ #if defined(PXR_OPENGL_SUPPORT_ENABLED)
1327+ + mx::GlslShaderGenerator::TARGET + " /" +
1328+ #endif
1329+ " lib/mx_math.metal" , mxContext, mxStage);
13031330 _EmitConstantsUniformsAndTypeDefs (
13041331 mxContext, mxStage,_syntax->getConstantQualifier ());
13051332
@@ -1347,6 +1374,6 @@ HdStMaterialXShaderGenMsl::_EmitMxFunctions(
13471374 _EmitDataStructsAndFunctionDefinitions (
13481375 mxGraph, mxContext, mxStage, &_tokenSubstitutions);
13491376}
1350-
1377+ # endif
13511378
13521379PXR_NAMESPACE_CLOSE_SCOPE
0 commit comments