Skip to content

Add WGPUStringView string utilities (wgpu_string.h)#248

Merged
adam-ce merged 3 commits into
AlpineMapsOrg:mainfrom
MatzeOGH:feature/wgpu_string
Jul 9, 2026
Merged

Add WGPUStringView string utilities (wgpu_string.h)#248
adam-ce merged 3 commits into
AlpineMapsOrg:mainfrom
MatzeOGH:feature/wgpu_string

Conversation

@MatzeOGH

@MatzeOGH MatzeOGH commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Adds webgpu/base/wgpu_string.h, a small header-only utility for working with Dawn's WGPUStringView ({ 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 raw std::string_view(msg.data, msg.length). This centralizes that into one utility.

Matthias Huerbe added 2 commits July 7, 2026 09:52
…ng_view & const char*

- added unit tests for the WGPUStringViews utilities
Comment thread webgpu/base/wgpu_string.h
}

// utility to create a webgpu string view from std::string, std::string_view, const char*
inline constexpr WGPUStringView wsv(std::string_view s) noexcept

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GeraldKimmersdorfer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@adam-ce adam-ce merged commit 65f705e into AlpineMapsOrg:main Jul 9, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants