emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.84k stars 3.31k forks source link

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

Closed Please-just-dont closed 5 months ago

Please-just-dont commented 5 months 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 5 months 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 5 months 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 5 months ago

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