Open xrui94 opened 4 months ago
cc @kainino0x
Looks like CreateSurface() got broken in 3.1.52 when used in a pthread. It worked in 3.1.51.
HelloTriangle.js:240 TypeError: Cannot read properties of undefined (reading 'getContext')
at _wgpuInstanceCreateSurface (http://localhost:6931/HelloTriangle.js:10209:24)
at HelloTriangle.wasm.wgpu::Instance::CreateSurface(wgpu::SurfaceDescriptor const*) const (http://localhost:6931/HelloTriangle.wasm:wasm-function[5898]:0x38c609)
at invoke_viii (http://localhost:6931/HelloTriangle.js:11034:29)
at HelloTriangle.wasm.Context@Diyou::From(Window@Diyou const&, std::__2::function<void (Context@Diyou&&)>) (http://localhost:6931/HelloTriangle.wasm:wasm-function[386]:0xc832)
at invoke_vii (http://localhost:6931/HelloTriangle.js:11023:29)
at HelloTriangle.wasm.Renderer::CreateFrom(Window@Diyou&&) (http://localhost:6931/HelloTriangle.wasm:wasm-function[371]:0x8fa6)
at invoke_vi (http://localhost:6931/HelloTriangle.js:11012:29)
at HelloTriangle.wasm.main (http://localhost:6931/HelloTriangle.wasm:wasm-function[360]:0x781e)
at HelloTriangle.wasm.__main_void (http://localhost:6931/HelloTriangle.wasm:wasm-function[3569]:0x346864)
at HelloTriangle.wasm._main_thread (http://localhost:6931/HelloTriangle.wasm:wasm-function[3571]:0x3468fd)
While Emscripten WebGPU headers don't yet integrate OffscreenCanvas, this offscreen_canvas.c example (also a variant with pthreads and proxy-to-pthread) shows one approach of how this can be achieved in user projects in context of Wasm Workers or pthreads using a different API.
In OpenGL or WebGL, i can create a offscreen canvas app, the code just like:
so, i wonder how to create offscreen canvas app? I know there is some ways such as:
However, how to do it in thread by using offscreenCanvas and WebGPU( webgpu_cpp.h from emscripten )? There is an example?