Fix crash when cooking Android OpenGLES on Linux by replacing swscanf based parser with native FindNextHLSLDefinitionOfType

#jira UE-205727
#rnx
#rb dan.elksnitis, Dmitriy.Dyomin, Florin.Pascu

[CL 32299451 by matthew sorrels in ue5-main branch]
This commit is contained in:
matthew sorrels
2024-03-18 10:05:42 -04:00
parent 36efd22010
commit b1018568f8
3 changed files with 31 additions and 21 deletions

View File

@@ -360,6 +360,27 @@ const TCHAR* ParseHLSLSymbolName(const TCHAR* SearchString, FString& SymbolName)
return Result.GetData() + Result.Len();
}
FStringView FindNextHLSLDefinitionOfType(FStringView Typename, FStringView StartPos)
{
// handle both the case where identifier for declaration immediately precedes a ; and has whitespace separating the two
const TCHAR* NextWhitespace;
const TCHAR* NextNonWhitespace;
FStringView SymbolName;
NextWhitespace = FindNextWhitespace(StartPos.GetData());
if (NextWhitespace == StartPos.GetData())
{
NextNonWhitespace = FindNextNonWhitespace(NextWhitespace);
SymbolName = ParseHLSLSymbolName<TCHAR, FStringView>(NextNonWhitespace);
NextNonWhitespace = FindNextNonWhitespace(NextNonWhitespace + SymbolName.Len());
if (NextNonWhitespace && (*NextNonWhitespace == ';'))
{
return SymbolName;
}
}
return {};
}
FStringView UE::ShaderCompilerCommon::RemoveConstantBufferPrefix(FStringView InName)
{
return UE::String::RemoveFromStart(InName, FStringView(UE::ShaderCompilerCommon::kUniformBufferConstantBufferPrefix));