Build: Add USD patch to fix issues with MaterialX EDF on Metal

Ref #122575, #118455

Pull Request: https://projects.blender.org/blender/blender/pulls/122725
This commit is contained in:
Brecht Van Lommel 2024-06-04 18:59:45 +02:00 committed by Brecht Van Lommel
parent 820edb920d
commit dd6b535521
2 changed files with 52 additions and 3 deletions

@ -119,9 +119,12 @@ ExternalProject_Add(external_usd
${PATCH_CMD} -p 1 -d
${BUILD_DIR}/usd/src/external_usd <
${PATCH_DIR}/usd.diff &&
${PATCH_CMD} -p 1 -d
${BUILD_DIR}/usd/src/external_usd <
${PATCH_DIR}/usd_core_profile.diff
${PATCH_CMD} -p 1 -d
${BUILD_DIR}/usd/src/external_usd <
${PATCH_DIR}/usd_core_profile.diff &&
${PATCH_CMD} -p 1 -d
${BUILD_DIR}/usd/src/external_usd <
${PATCH_DIR}/usd_metal_edf.diff
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${LIBDIR}/usd

@ -0,0 +1,46 @@
From 4f05a62018ee5134843f7cefed826585f13a509b Mon Sep 17 00:00:00 2001
From: Dhruv Govil <dgovil2@apple.com>
Date: Mon, 3 Jun 2024 15:31:34 -0700
Subject: [PATCH] Fix shader compile bug when using EDF in Storm
Fixes
https://github.com/PixarAnimationStudios/OpenUSD/issues/3105
Thanks to Lee Kerley for the fix
---
pxr/imaging/hdSt/materialXShaderGen.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/pxr/imaging/hdSt/materialXShaderGen.cpp b/pxr/imaging/hdSt/materialXShaderGen.cpp
index ca1806bf03..8b0e1a3a41 100644
--- a/pxr/imaging/hdSt/materialXShaderGen.cpp
+++ b/pxr/imaging/hdSt/materialXShaderGen.cpp
@@ -692,7 +692,6 @@ HdStMaterialXShaderGen<Base>::_EmitConstantsUniformsAndTypeDefs(
mxContext.getOptions().hwDirectionalAlbedoMethod)),
mxStage, false);
Base::emitLineBreak(mxStage);
- Base::emitTypeDefinitions(mxContext, mxStage);
// Add all constants and ensure that values are initialized
const mx::VariableBlock& constants = mxStage.getConstantBlock();
@@ -945,6 +944,10 @@ HdStMaterialXShaderGenGlsl::_EmitMxFunctions(
mx::ShaderGenerator::emitLibraryInclude(
"stdlib/" + mx::GlslShaderGenerator::TARGET
+ "/lib/mx_math.glsl", mxContext, mxStage);
+
+ // Add type definitions
+ emitTypeDefinitions(mxContext, mxStage);
+
_EmitConstantsUniformsAndTypeDefs(
mxContext, mxStage, _syntax->getConstantQualifier());
@@ -1106,6 +1109,9 @@ HdStMaterialXShaderGenMsl::_EmitGlslfxMetalShader(
addStageUniform(mx::HW::LIGHT_DATA, mx::Type::FLOAT,
"shadowOcclusion", mxStage);
+ // Add type definitions
+ emitTypeDefinitions(mxContext, mxStage);
+
// Add type definitions
emitConstantBufferDeclarations(mxContext, resourceBindingCtx, mxStage);