From 9a38e5b60dccb9ca6f596adf91328aca9c17e62f Mon Sep 17 00:00:00 2001 From: Austin Eng <enga@chromium.org> Date: Tue, 29 Dec 2020 22:22:22 +0000 Subject: [PATCH] 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> --- src/dawn_native/d3d12/ShaderModuleD3D12.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp index 3c34203b5d..96bb4ba87d 100644 --- a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp +++ b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp @@ -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;