Skip to content

Commit

Permalink
Merge pull request #2807 from erikaharrison-adsk/adsk/bugfix/namecoll…
Browse files Browse the repository at this point in the history
…isionfix

Autodesk: Bugfix - Avoid name collision with MaterialX inputs and built-in uniforms

(Internal change: 2308795)
  • Loading branch information
pixar-oss committed Dec 15, 2023
2 parents 0d14d83 + 99c21fc commit 396c9b1
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 23 deletions.
70 changes: 50 additions & 20 deletions pxr/imaging/hdSt/codeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3462,12 +3462,16 @@ static void _EmitTextureAccessors(
// Forward declare texture scale and bias
if (hasTextureScaleAndBias) {
accessors
<< "#ifdef HD_HAS_" << name << "_" << HdStTokens->scale << "\n"
<< "FORWARD_DECL(vec4 HdGet_" << name << "_" << HdStTokens->scale
<< "#ifdef HD_HAS_" << name << "_"
<< HdStTokens->storm << "_" << HdStTokens->scale << "\n"
<< "FORWARD_DECL(vec4 HdGet_" << name << "_"
<< HdStTokens->storm << "_" << HdStTokens->scale
<< "());\n"
<< "#endif\n"
<< "#ifdef HD_HAS_" << name << "_" << HdStTokens->bias << "\n"
<< "FORWARD_DECL(vec4 HdGet_" << name << "_" << HdStTokens->bias
<< "#ifdef HD_HAS_" << name << "_" << HdStTokens->storm
<< "_" << HdStTokens->bias << "\n"
<< "FORWARD_DECL(vec4 HdGet_" << name << "_" << HdStTokens->storm
<< "_" << HdStTokens->bias
<< "());\n"
<< "#endif\n";
}
Expand Down Expand Up @@ -3624,11 +3628,15 @@ static void _EmitTextureAccessors(
}
}
accessors
<< "#ifdef HD_HAS_" << name << "_" << HdStTokens->scale << "\n"
<< " * HdGet_" << name << "_" << HdStTokens->scale << "()\n"
<< "#ifdef HD_HAS_" << name << "_" << HdStTokens->storm << "_"
<< HdStTokens->scale << "\n"
<< " * HdGet_" << name << "_" << HdStTokens->storm << "_"
<< HdStTokens->scale << "()\n"
<< "#endif\n"
<< "#ifdef HD_HAS_" << name << "_" << HdStTokens->bias << "\n"
<< " + HdGet_" << name << "_" << HdStTokens->bias << "()\n"
<< "#ifdef HD_HAS_" << name << "_" << HdStTokens->storm << "_"
<< HdStTokens->bias << "\n"
<< " + HdGet_" << name << "_" << HdStTokens->storm << "_"
<< HdStTokens->bias << "()\n"
<< "#endif\n"
<< ")" << swizzle << ");\n";
} else {
Expand Down Expand Up @@ -3684,12 +3692,16 @@ static void _EmitTextureAccessors(
<< name
<< HdSt_ResourceBindingSuffixTokens->fallback
<< fallbackSwizzle << ")\n"
<< "#ifdef HD_HAS_" << name << "_" << HdStTokens->scale << "\n"
<< " * HdGet_" << name << "_" << HdStTokens->scale
<< "#ifdef HD_HAS_" << name << "_"
<< HdStTokens->storm << "_" << HdStTokens->scale << "\n"
<< " * HdGet_" << name << "_"
<< HdStTokens->storm << "_" << HdStTokens->scale
<< "()" << swizzle << "\n"
<< "#endif\n"
<< "#ifdef HD_HAS_" << name << "_" << HdStTokens->bias << "\n"
<< " + HdGet_" << name << "_" << HdStTokens->bias
<< "#ifdef HD_HAS_" << name << "_"
<< HdStTokens->storm << "_" << HdStTokens->bias << "\n"
<< " + HdGet_" << name << "_"
<< HdStTokens->storm << "_" << HdStTokens->bias
<< "()" << swizzle << "\n"
<< "#endif\n"
<< ");\n"
Expand Down Expand Up @@ -5966,13 +5978,17 @@ HdSt_CodeGen::_GenerateShaderParameters(bool bindlessTextureEnabled)

accessors
<< "#ifdef HD_HAS_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->scale << "\n"
<< "vec4 HdGet_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->scale << "();\n"
<< "#endif\n"
<< "#ifdef HD_HAS_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->bias << "\n"
<< "vec4 HdGet_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->bias << "();\n"
<< "#endif\n";

Expand Down Expand Up @@ -6014,13 +6030,17 @@ HdSt_CodeGen::_GenerateShaderParameters(bool bindlessTextureEnabled)
<< HdSt_ResourceBindingSuffixTokens->fallback
<< fallbackSwizzle << ")\n"
<< "#ifdef HD_HAS_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->scale << "\n"
<< " * HdGet_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->scale << "()" << swizzle << "\n"
<< "#endif\n"
<< "#ifdef HD_HAS_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->bias << "\n"
<< " + HdGet_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->bias << "()" << swizzle << "\n"
<< "#endif\n"
<< " );\n }\n";
Expand All @@ -6029,13 +6049,17 @@ HdSt_CodeGen::_GenerateShaderParameters(bool bindlessTextureEnabled)
accessors
<< " return (ret\n"
<< "#ifdef HD_HAS_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->scale << "\n"
<< " * HdGet_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->scale << "()\n"
<< "#endif\n"
<< "#ifdef HD_HAS_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->bias << "\n"
<< " + HdGet_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->bias << "()\n"
<< "#endif\n"
<< " )" << swizzle << ";\n}\n";
Expand Down Expand Up @@ -6086,13 +6110,17 @@ HdSt_CodeGen::_GenerateShaderParameters(bool bindlessTextureEnabled)

accessors
<< "#ifdef HD_HAS_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->scale << "\n"
<< "FORWARD_DECL(vec4 HdGet_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->scale << "());\n"
<< "#endif\n"
<< "#ifdef HD_HAS_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->bias << "\n"
<< "FORWARD_DECL(vec4 HdGet_" << it->second.name << "_"
<< HdStTokens->storm << "_"
<< HdStTokens->bias << "());\n"
<< "#endif\n";

Expand Down Expand Up @@ -6136,29 +6164,31 @@ HdSt_CodeGen::_GenerateShaderParameters(bool bindlessTextureEnabled)
<< HdSt_ResourceBindingSuffixTokens->fallback
<< fallbackSwizzle << ")\n"
<< "#ifdef HD_HAS_" << it->second.name << "_"
<< HdStTokens->scale << "\n"
<< HdStTokens->storm << "_" << HdStTokens->scale << "\n"
<< " * HdGet_" << it->second.name << "_"
<< HdStTokens->scale << "()" << swizzle << "\n"
<< HdStTokens->storm << "_" << HdStTokens->scale << "()"
<< swizzle << "\n"
<< "#endif\n"
<< "#ifdef HD_HAS_" << it->second.name << "_"
<< HdStTokens->bias << "\n"
<< HdStTokens->storm << "_" << HdStTokens->bias << "\n"
<< " + HdGet_" << it->second.name << "_"
<< HdStTokens->bias << "()" << swizzle << "\n"
<< HdStTokens->storm << "_" << HdStTokens->bias << "()"
<< swizzle << "\n"
<< "#endif\n"
<< " );\n }\n";
}

accessors
<< " return (ret\n"
<< "#ifdef HD_HAS_" << it->second.name << "_"
<< HdStTokens->scale << "\n"
<< HdStTokens->storm << "_" << HdStTokens->scale << "\n"
<< " * HdGet_" << it->second.name << "_"
<< HdStTokens->scale << "()\n"
<< HdStTokens->storm << "_" << HdStTokens->scale << "()\n"
<< "#endif\n"
<< "#ifdef HD_HAS_" << it->second.name << "_"
<< HdStTokens->bias << "\n"
<< HdStTokens->storm << "_" << HdStTokens->bias << "\n"
<< " + HdGet_" << it->second.name << "_"
<< HdStTokens->bias << "()\n"
<< HdStTokens->storm << "_" << HdStTokens->bias << "()\n"
<< "#endif\n"
<< " )" << swizzle << ";\n}\n";

Expand Down
6 changes: 4 additions & 2 deletions pxr/imaging/hdSt/materialNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,8 @@ _MakeMaterialParamsForTexture(
// Handle texture scale and bias
HdSt_MaterialParam texScaleParam;
texScaleParam.paramType = HdSt_MaterialParam::ParamTypeFallback;
texScaleParam.name = TfToken(paramName.GetString() + "_" +
texScaleParam.name = TfToken(paramName.GetString() + "_" +
HdStTokens->storm.GetString() + "_" +
HdStTokens->scale.GetString());
texScaleParam.fallbackValue = VtValue(_ResolveParameter(node,
sdrNode,
Expand All @@ -840,7 +841,8 @@ _MakeMaterialParamsForTexture(

HdSt_MaterialParam texBiasParam;
texBiasParam.paramType = HdSt_MaterialParam::ParamTypeFallback;
texBiasParam.name = TfToken(paramName.GetString() + "_" +
texBiasParam.name = TfToken(paramName.GetString() + "_" +
HdStTokens->storm.GetString() + "_" +
HdStTokens->bias.GetString());
texBiasParam.fallbackValue = VtValue(_ResolveParameter(node,
sdrNode,
Expand Down
3 changes: 2 additions & 1 deletion pxr/imaging/hdSt/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ PXR_NAMESPACE_OPEN_SCOPE
(pointSizeScale) \
(screenSpaceWidths) \
(minScreenSpaceWidths) \
(shadowCompareTextures)
(shadowCompareTextures) \
(storm)

#define HDST_TEXTURE_TOKENS \
(wrapS) \
Expand Down

0 comments on commit 396c9b1

Please sign in to comment.