[shaders] fixing stripped code header length calculation, and account for auto-appended null terminator

#rnx
#rb Christopher.Waters

[CL 32547715 by dan elksnitis in ue5-main branch]
This commit is contained in:
dan elksnitis
2024-03-27 12:44:40 -04:00
parent deace613c4
commit 3ffa257b2c
@@ -20,7 +20,7 @@ struct FPreprocessConstants
check(StrippedCodeHeaderBuilder.GetAllocatedSize() == 0);
StrippedCodeHeader = { StrippedCodeHeaderBuilder.GetData(), StrippedCodeHeaderBuilder.Len() };
StrippedCodeHeader = StrippedCodeHeaderBuilder.ToView();
}
static constexpr FShaderSource::FViewType DebugHashPrefix = SHADER_SOURCE_VIEWLITERAL("DebugHash_");
@@ -39,10 +39,12 @@ private:
static constexpr int32 HeaderLen =
DebugHashCommentStart.Len() +
DebugHashPrefix.Len() +
DebugHashCommentEnd.Len() +
2 * sizeof(FShaderCompilerInputHash::ByteArray) + // size of input hash converted to a hex string
LineDirectiveStart.Len() +
FilenameSentinel.Len() +
LineDirectiveEnd.Len();
LineDirectiveEnd.Len() +
1; // +1 for null terminator, even though we don't need it builder always ensures there's space for one
FShaderSource::TStringBuilder<HeaderLen> StrippedCodeHeaderBuilder;
};