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>
diff --git a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp
index 3c34203..96bb4ba 100644
--- a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp
+++ b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp
@@ -372,11 +372,14 @@
// 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;