Make HLSL cache key guard comment ASSERT more specific

SPIRV-Cross still emits some comments, so for now, just check that
the specific guard comments Dawn uses are not contained in the HLSL
output.

Bug: dawn:549
Change-Id: Ia6d32befa5ef983e56494542d46e9c3592b6480a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/36300
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2020-12-29 22:22:22 +00:00 committed by Commit Bot service account
parent 0eb61724c8
commit 9a38e5b60d
1 changed files with 6 additions and 3 deletions

View File

@ -372,11 +372,14 @@ namespace dawn_native { namespace d3d12 {
// blob.
// These strings can be HLSL comments because Tint does not emit HLSL comments.
// TODO(dawn:549): Replace guards strings with something more secure.
ASSERT(hlslSource.find("//") == std::string::npos);
constexpr char kStartGuard[] = "// Start shader autogenerated by Dawn.";
constexpr char kEndGuard[] = "// End shader autogenerated by Dawn.";
ASSERT(hlslSource.find(kStartGuard) == std::string::npos);
ASSERT(hlslSource.find(kEndGuard) == std::string::npos);
stream << "// Start shader autogenerated by Dawn.";
stream << kStartGuard << "\n";
stream << hlslSource;
stream << "// End of shader autogenerated by Dawn.";
stream << "\n" << kEndGuard;
stream << compileFlags;