Open vehsakul opened 10 months ago
I had this issue too, forcing backendType = WGPUBackendType_D3D12
rises the same error.
Same error when updating from v0.18.1.4 to v0.19.1.1. As mentioned above, it's happening with WGPUBackendType_D3D12
(WGPUBackendType_Vulkan
works fine).
Unfortunately I am unable to reproduce this behavior, does it fail if backendType
is set to WGPUBackendType_Undefined
?
WGPUBackendType_Undefined
works ok, and ends up choosing the Vulkan backend.
Using wgpuInstanceEnumerateAdapters
I have Vulkan, Dx12 and Gl backends. Passing .backendType =
WGPUBackendType_D3D12
, WGPUBackendType_OpenGL
and WGPUBackendType_WebGPU
(not sure what's expected for WebGPU, but I tried all values) will result in "No suitable adapter found".
This should be a minimal example that repros it:
int main(int argc, char **argv)
{
WGPUInstance instance = wgpuCreateInstance(nullptr);
assert(instance);
// Note: uncomment to print available adapters (requires `wgpuSetLogLevel(WGPULogLevel_Info)`).
// const WGPUInstanceEnumerateAdapterOptions options = { .backends = WGPUInstanceBackend_All };
// const size_t count = wgpuInstanceEnumerateAdapters(instance, &options, nullptr);
// assert(count > 0);
const WGPURequestAdapterOptions options { .backendType = WGPUBackendType_D3D12 }; // !!
WGPUAdapter adapter = nullptr;
wgpuInstanceRequestAdapter(
instance,
&options,
[](WGPURequestAdapterStatus status, WGPUAdapter adapter, char const *message, void *userdata) {
if (status == WGPURequestAdapterStatus_Success) {
*reinterpret_cast<WGPUAdapter *>(userdata) = adapter;
}
},
/* userdata */ static_cast<void *>(&adapter));
assert(adapter);
}
This is a bug upstream https://github.com/gfx-rs/wgpu/issues/5289
Workaround for now is provide the desired backend flag/s when creating the instance rather than when requesting the adapter.
WGPUInstanceExtras instanceExtras = { 0 };
instanceExtras.chain.sType = (WGPUSType)WGPUSType_InstanceExtras;
instanceExtras.backends = WGPUInstanceBackend_DX12;
WGPUInstanceDescriptor instanceDescriptor = { 0 };
instanceDescriptor.nextInChain = &instanceExtras.chain;
WGPUInstance instance = wgpuCreateInstance(&instanceDescriptor);
result:
surface_ was created by SDL2 library, it used to work using the last wgpu-native release from github