From 65c838ad64b51cd0efb0bc48a34121741dace8d7 Mon Sep 17 00:00:00 2001 From: Mark Tucker Date: Thu, 12 May 2022 11:34:57 -0400 Subject: [PATCH] Fix code generation for GLSL bindings to primvars. This type of binding was missing the definition of HdGetScalar_name to call HdGet_name. --- pxr/imaging/hdSt/codeGen.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pxr/imaging/hdSt/codeGen.cpp b/pxr/imaging/hdSt/codeGen.cpp index 2c9963e632..18d6454f7f 100644 --- a/pxr/imaging/hdSt/codeGen.cpp +++ b/pxr/imaging/hdSt/codeGen.cpp @@ -5579,6 +5579,17 @@ HdSt_CodeGen::_GenerateShaderParameters(bool bindlessTextureEnabled) << "\n}\n" << "#define HD_HAS_" << it->second.name << " 1\n"; + // Emit scalar accessors to support shading languages like MSL which + // do not support swizzle operators on scalar values. + if (_GetNumComponents(it->second.dataType) <= 4) { + accessors + << _GetFlatType(it->second.dataType) << " HdGetScalar_" + << it->second.name << "()" + << " { return HdGet_" << it->second.name << "()" + << _GetFlatTypeSwizzleString(it->second.dataType) + << "; }\n"; + } + if (it->second.name == it->second.inPrimvars[0]) { accessors << "#endif\n";