Skip to content

Use string views in webgpu.h #23766

Closed as not planned
Closed as not planned
@TLescoatTFX

Description

@TLescoatTFX

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions