wgpuInstanceEnumerateAdapters will return 0 adapters when passed WGPUInstanceBackend_All
laurelkeys opened this issue · 1 comments
Take this snippet from examples/enumerate_adapters/main.c
:
wgpu-native/examples/enumerate_adapters/main.c
Lines 15 to 19 in 5b75378
The following is expected to work like it, but it currently returns adapter_count = 0
:
const WGPUInstanceEnumerateAdapterOptions options = { .backends = WGPUInstanceBackend_All };
const size_t adapter_count =
wgpuInstanceEnumerateAdapters(instance, &options, NULL);
WGPUAdapter *adapters = malloc(sizeof(WGPUAdapter) * adapter_count);
assert(adapters);
wgpuInstanceEnumerateAdapters(instance, &options, adapters);
On the other hand, passing .backends = (WGPUInstanceBackend_Vulkan | WGPUInstanceBackend_GL | WGPUInstanceBackend_Metal | WGPUInstanceBackend_DX12 | WGPUInstanceBackend_DX11 | WGPUInstanceBackend_BrowserWebGPU)
does work (i.e. it returns the same adapter_count
as the first snippet where NULL
is used.
The problem seems to be in src/lib.rs
not accounting for the fact that WGPUInstanceBackend_All = 0
(and that, on Rust's side, it should be mapped to wgt::Backends::all()
):
Lines 2720 to 2725 in 5b75378
Note: I didn't look further as I'm using the wgpu_native.dll
and .pdb
(v0.18.1.4) from C++ and haven't downloaded the code (e.g. to edit and build it), but please let me know if there's more information I could provide.
Btw, are there plans on updating wgpu.h
to use WGPU_NULLABLE
like webgpu.h
already does? This would be great for documenting Option<>
al parameters, e.g.:
// vvvvvvvvvvvvv
size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPU_NULLABLE WGPUInstanceEnumerateAdapterOptions const * options, WGPUAdapter * adapters);