GLSL has strict identifier requirements. During codegen, we turn primvar (and other) names into GLSL identifiers. When the primvar name is not a legal GLSL identifier, we convert it into one using HdStGLConversions::GetGLSLIdentifier(). However, the TfTokens thus generated were short-lived, so on subsequent frames, primvars (&c.) with GL-illegal names would produce new TfTokens at new memory addresses, giving them different hash values. The hash value differences caused the program's overall hash value to change from frame to frame, triggering unnecessary recompilation.
To fix this, all TfTokens generated by GetGLSLIdentifier() will be instantiated as immortal, so that even if they go out of scope, later calls to GetGLSLIdentifier() for a given input name will produce TfTokens with the same hash value as those from earlier calls.
(Internal change:
2309306)
return identifier;
}
- return TfToken(result);
+ return TfToken(result, TfToken::Immortal);
}
PXR_NAMESPACE_CLOSE_SCOPE