Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use string views in webgpu.h #23766

Closed
TLescoatTFX opened this issue Feb 26, 2025 · 1 comment
Closed

Use string views in webgpu.h #23766

TLescoatTFX opened this issue Feb 26, 2025 · 1 comment
Assignees
Labels

Comments

@TLescoatTFX
Copy link

Hello,

The official C header for WebGPU now use string views in-lieu of null-terminated strings (see webgpu-native/webgpu-headers#170 (comment) ). Emscripten still use null-terminated strings, while Dawn use WGPUStringView. Those 2 types are incompatible, which is a pain when targeting web/native webgpu through emscripten/dawn.

If you do not have the time to implement string views in Emscripten' webgpu.h, please let me know how to do it, I can submit a PR for that.

dawn/webgpu.h (excerpt)

typedef struct WGPUBindGroupDescriptor {
    WGPUChainedStruct* nextInChain;
    WGPUStringView label;
    WGPUBindGroupLayout layout;
    size_t entryCount;
    WGPUBindGroupEntry const * entries;
} WGPUBindGroupDescriptor WGPU_STRUCTURE_ATTRIBUTE;

emscripten/webgpu.h (excerpt)

typedef struct WGPUBindGroupDescriptor {
    WGPUChainedStruct const * nextInChain;
    WGPU_NULLABLE char const * label;
    WGPUBindGroupLayout layout;
    size_t entryCount;
    WGPUBindGroupEntry const * entries;
} WGPUBindGroupDescriptor WGPU_STRUCTURE_ATTRIBUTE;

Notice:

    WGPUStringView label;             // Dawn
    WGPU_NULLABLE char const * label; // Emscripten

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.1-git
clang version 20.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/emscripten/4.0.1/libexec/llvm/bin
@kainino0x
Copy link
Collaborator

There are actually many more changes than this for which Emscripten is behind the standard webgpu.h. We're not updating Emscripten for now; please see #23432. See "emdawnwebgpu" for the updated version which is maintained in Dawn. We'll probably have that as an easy-to-use downloadable package in the future.

@kainino0x kainino0x closed this as not planned Won't fix, can't repro, duplicate, stale Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants