Add WGPUStringView string utilities (wgpu_string.h)#248
Merged
Conversation
added 2 commits
July 7, 2026 09:52
…ng_view & const char* - added unit tests for the WGPUStringViews utilities
MatzeOGH
commented
Jul 8, 2026
| } | ||
|
|
||
| // utility to create a webgpu string view from std::string, std::string_view, const char* | ||
| inline constexpr WGPUStringView wsv(std::string_view s) noexcept |
Contributor
Author
There was a problem hiding this comment.
The name of the method can be improved. If it is used in the code base, people understand it, but nobody will ever find it on its own.
to_wsv() or something
GeraldKimmersdorfer
approved these changes
Jul 9, 2026
GeraldKimmersdorfer
left a comment
Contributor
There was a problem hiding this comment.
I like this feature as it makes the construction of wgpu strings more compact. Even though mostly it solves issues we didnt have yet I can see positive implications with having this abstraction on hand. I assume you use stuff like the content equality in your code, because so far we didnt use such operators at all.
From my side a clear Go.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
webgpu/base/wgpu_string.h, a small header-only utility for working with Dawn'sWGPUStringView({ const char* data; size_t length; }). Today the codebase constructs these by hand, e.g.WGPUStringView { .data = label.c_str(), .length = WGPU_STRLEN }, and reads them back with rawstd::string_view(msg.data, msg.length). This centralizes that into one utility.