Ensure WGSL StringView knows length When ShaderModule passes a WGSL string it first converts to const char* and then StringView. This discards length information and requires strlen() to be used to figure out length again later. Don't discard the length information to avoid this. Bug: none Change-Id: I910a2680f3e373049f211f2a1f19c06a9e789a14 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/239656 Commit-Queue: Kyle Charbonneau <kylechar@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/dawn/native/ShaderModule.cpp b/src/dawn/native/ShaderModule.cpp index c255eed..cce91b8 100644 --- a/src/dawn/native/ShaderModule.cpp +++ b/src/dawn/native/ShaderModule.cpp
@@ -1651,7 +1651,7 @@ descriptor.nextInChain = &spirvDescriptor; break; case Type::Wgsl: - wgslDescriptor.code = mWgsl.c_str(); + wgslDescriptor.code = std::string_view(mWgsl); descriptor.nextInChain = &wgslDescriptor; break; default: