Skip to content

Standard location of the webgpu.h header #460

@eliemichel

Description

@eliemichel

Has there been a position stated about where the webgpu.h should be expected wrt. include paths?

The reason I ask is with regards to the generation/specification of extension headers and in particular the way they should include webgpu.h, as well as questions that arise when sharing code without imposing a build systems (e.g., in Dear ImGui's wgpu backend).

Some elements I could find in practice:

  • Currently, our generator adds #include "webgpu.h" when generating extensions, which implies that either my_webgpu_extension.h sits in the very same directory as webgpu.h or this directory is in the include paths. But this has not been tested much and is probably still open to evolution?
  • Dawn places its generated header in webgpu/webgpu.h and tends to #include <webgpu/webgpu.h> in examples.
  • Same for emscripten
  • The question came up in wgpu-native, especially because its is the only implementation that already adopted the dual header scheme (i.e. a separate file for implem-specific extensions), and there was no strong opinion, but it settled for some convenience reason on using #include "webgpu.h" in wgpu.h and placing it in the very same directory as webgpu.h. Both are in a directory called "webgpu" as well.
  • After some thought about it in early its developments, I adopted #include <webgpu/webgpu.h> for my programming guide and the associated code because it felt compatible with most examples I could find (and I liked the webgpu/ prefix to regroup potential extensions like c++ wrapper, etc.).

Since all implementation indeed distribute webgpu.h in a directory called "webgpu", should we (a) explicitly state that the preferred way to include the WebGPU native header is through webgpu/webgpu.h and (b) have extension header use #include <webgpu/webgpu.h> in case they are distributed through a different directory?

For some reason my intuition tells me that (a) is a yes and (b) is a no, but feel free to prove me wrong :D

Some other examples:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions