emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.36k stars 3.25k forks source link

Are we allowed to pass null as options to navigator_gpu_request_adapter_sync()? #22096

Closed Moeman1984 closed 2 weeks ago

Moeman1984 commented 2 weeks ago

Emscripten version 3.1.55

Getting an error thrown when passing nullptr to navigator_gpu_request_adapter_sync. The function signature for gpu_request_adapter_sync is:

// options: may be null to request an adapter without specific options. WGpuAdapter navigator_gpu_request_adapter_sync(const WGpuRequestAdapterOptions *options);

And I'm getting an error thrown in the browser saying:

Assertion failed: assert(options != 0) failed!

because in lib_webgpu.js at line 556:

navigator_gpu_request_adapter_sync: function(options) { return Asyncify.handleAsync(() => { {{{ wdebuglog('navigator_gpu_request_adapter_sync: options: ${options}'); }}} {{{ wassert('navigator["gpu"], "Your browser does not support WebGPU!"'); }}} {{{ wassert('options != 0'); }}} {{{ wassert('options % 4 == 0'); }}} // Must be aligned at uint32_t boundary

Is this intended?

kainino0x commented 2 weeks ago

navigator_gpu_request_adapter_sync is part of https://github.com/juj/wasm_webgpu (which designs its own C interface) not Emscripten's built-in bindings (which adhere to https://github.com/webgpu-native/webgpu-headers which is very different).

You probably want to file this bug on wasm_webgpu.

juj commented 2 weeks ago

Hmm I recall GitHub had a "Transfer Issue" mechanism at some point, to let authors migrate issues to other repos.. though I wonder if that has gone, couldn't find a button for that now.

In any case, @Moeman1984 , the intent has been that navigator_gpu_request_adapter_async and navigator_gpu_request_adapter_sync would require the options field. Updated that with annotation in above commit.

There are (perhaps slightly clumsily named) functions navigator_gpu_request_adapter_async_simple and navigator_gpu_request_adapter_sync_simple that allow creating an adapter without needing to pass an options object.

sbc100 commented 2 weeks ago

@juj, I think you can only transfer issues between repos in the same org.