Closed FuXiii closed 1 year ago
Hi! Some answers:
webgpu/webgpu.h
is part of Emscripten, in the system
folder (see here).nonportable-include-path
warning is from Clang, and I read about it years ago.--shell-file
).glue.h
and glue.cpp
are my code, used to hold other parts of the code together. Since this is written for Windows, Mac and the browser, it smooths out some of the features. Compare with the Mac and Windows sources.Hope that helps!
Thank you for your answer! o(〃'▽'〃)o
In the third item the documented here
link url is https://github.com/cwoffenden/hello-webgpu/issues/nonportable-include-path
it look like a invalid link. (`・ω・′)ゞ
Link fixed!
Thanks~(●'◡'●)ノ♥
Some question about compile hello-webgpu
base emscripten
:
Why must use #define KEEP_IN_MODULE extern "C" __attribute__((used, visibility("default")))
before _glue_main_()
?
Where I can find the documents about it?
#ifndef KEEP_IN_MODULE
#define KEEP_IN_MODULE extern "C" __attribute__((used, visibility("default")))
#endif
KEEP_IN_MODULE void _glue_main_() { __main__(0, nullptr); }
In glue.cpp
the _glue_main_()
will call __main__(int argc, char* argv[])
which defined in main.cpp
,but in JavaScript
code void glue_preint()
which defined in EM_JS
it will call the var entry
which is __glue_main_
.Why entry
equal to __glue_main_
instead of _glue_main_
(one less underline) ?
KEEP_IN_MODULE void _glue_main_() { __main__(0, nullptr); }
EM_JS(void, glue_preint, (), {
var entry = __glue_main_; // Why can't be: var entry = _glue_main_;
I try to find the JavaScript
code in browser, I found:
...
var __glue_main_, _main, _malloc, _free, stackSave, stackRestore, stackAlloc, dynCall_jiji;
WebAssembly.instantiate(Module['wasm'], imports).then(function(output) {
asm = output.instance.exports;
__glue_main_ = asm["_glue_main_"];
...
}
Is that means all exposed C/C++
function into WebAssembly
will add a underline in front of it?
ヾ(๑╹◡╹)ノ" Thanks~
The KEEP_IN_MODULE
macro is used because I want to call _glue_main_()
from JavaScript (once the WebGPU context has been asynchronously created). Without this, and depending on other compiler flags, it risks being either name mangled or removed from the exports.
And yes, in JS an extra _
is inserted.
Ok, Thanks~ ٩(๑❛ᴗ❛๑)۶
If I run hello-webgpu
in python -m http.server
server, it will work well. but if I copy hello-webgpu.html
, hello-webgpu.js
and hello-webgpu.wasm
into real http server and open the page in same browser it will show nothing and output No support for WebGPU
error message.
The page URL is this
It fails because WebGPU use needs serving from a secure context (HTTPS). This link works, for example:
Thank you very much!!! ~(●'◡'●)ノ♥
When I research
hello-webgpu
useEmscripten
, I had met some questions:Emscripten
to compilemain.cpp
(./src/main.cpp
) will includewebgpu.h
(./inc/webgpu.h
), andwebgpu.h
(./inc/webgpu.h
) will also includewebgpu/webgpu.h
. Where is thiswebgpu/webgpu.h
?CMAKE_CXX_FLAGS
? I can't found the description about-Wno-nonportable-include-path
in gcc doc-s WASM=1,-s USE_WEBGPU=1
inCMAKE_EXE_LINKER_FLAGS
shell.html
file? For what purpose? Where can I find the document?glue.h/glue.cpp
used for? Where can I find the document?WGPUDevice
? Inhttps://www.w3.org/TR/webgpu/
theWGPUDevice
was not found in the official documentation ofWebGPU
, butGPUDevice
could be found, but such asWGPUSurfaceDescriptorFromCanvasHTMLSelector
orGPUSurfaceDescriptorFromCanvasHTMLSelector
could not be found.Emscripten
?Thanks~(●'◡'●)ノ♥