emscripten webgpu.h bindings: WGPU_WHOLE_SIZE global constant leads to linker errors

88 views
Skip to first unread message

Andre Weissflog

unread,
Feb 5, 2020, 10:57:54 AM2/5/20
to Dawn Graphics
Hi, I just stumbled over a little problem when using the new webgpu.h bindings in emscripten (provided by the Dawn team, that's why I'm posting here):

There's a globally visible symbol defined in the webgpu.h header:

const uint64_t WGPU_WHOLE_SIZE = 0xffffffffffffffffULL; // UINT64_MAX

If the header is now included in different compilation units, this leads to a linker error because the linker sees the same symbols multiple times:

wasm-ld: error: duplicate symbol: WGPU_WHOLE_SIZE
>>> defined in wgpu/CMakeFiles/clear-wgpu.dir/clear-wgpu.c.obj
>>> defined in wgpu/libwgpu_entry.a(wgpu_entry.c.obj)

Putting a "static" in front fixes the problem, however:

(1) WGPU_WHOLE_SIZE doesn't seem to be used anywhere in the header, so I wonder if it is necessary at all

(2) IMHO a traditional "#define WGPU_WHOLE_SIZE (0xffffffffffffffffULL)" would be better (since C doesn't have "proper" constants anyway)

Cheers!
-Floh.

Corentin Wallez

unread,
Feb 5, 2020, 11:29:01 AM2/5/20
to Andre Weissflog, Dawn Graphics
Thanks for the report, that's indeed a C++ism that shouldn't be in the C header. Put up fixes for Dawn and webgpu-headers.

WGPU_WHOLE_SIZE can be used in the WGPUBindGroupBinding::size field to signify that the whole buffer should be used.

Cheers,

Corentin

--
You received this message because you are subscribed to the Google Groups "Dawn Graphics" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dawn-graphic...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dawn-graphics/7a13f71d-3a79-4d92-9c87-8fa266e96b72%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages